@staff0rd/assist 0.1066.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/claude/advice/code-comments.md +1 -1
- package/claude/commands/strip-code-comments.md +2 -1
- package/dist/built-version +1 -1
- package/dist/commands/extension/extension/content.js +1 -1
- package/dist/commands/extension/extension/docs.js +1 -1
- package/dist/commands/extension/extension/updates.json +2 -2
- package/dist/commands/sessions/web/bundle.js +377 -377
- package/dist/index.js +661 -745
- package/package.json +1 -1
- package/claude/skills/review-ci/SKILL.md +0 -69
- package/claude/skills/review-ci/review-ci.yml +0 -55
- package/claude/skills/review-ci/scripts/check.mjs +0 -2
- package/claude/skills/review-ci/scripts/init.mjs +0 -34
- package/claude/skills/review-ci/scripts/review.mjs +0 -787
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.
|
|
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(
|
|
2422
|
+
function rowToItemSummary(row2) {
|
|
2423
2423
|
return {
|
|
2424
|
-
id:
|
|
2425
|
-
origin:
|
|
2426
|
-
type:
|
|
2427
|
-
name:
|
|
2428
|
-
status:
|
|
2429
|
-
starred:
|
|
2430
|
-
jiraKey:
|
|
2431
|
-
githubIssue:
|
|
2432
|
-
currentPhase:
|
|
2433
|
-
totalPhases: (
|
|
2434
|
-
usageTotal:
|
|
2435
|
-
tokensUp: Number(
|
|
2436
|
-
tokensDown: Number(
|
|
2437
|
-
activeMs: Number(
|
|
2438
|
-
peakContextPct: Number(
|
|
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 [
|
|
2577
|
-
if (!
|
|
2578
|
-
return
|
|
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
|
|
2671
|
-
const bucket = map.get(
|
|
2672
|
-
if (bucket) bucket.push(
|
|
2673
|
-
else map.set(
|
|
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
|
-
(
|
|
2771
|
-
tokensUp:
|
|
2772
|
-
tokensDown:
|
|
2773
|
-
activeMs:
|
|
2774
|
-
peakContextPct: Math.max(
|
|
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,
|
|
2836
|
-
if (
|
|
2837
|
-
if (
|
|
2838
|
-
if (
|
|
2839
|
-
if (
|
|
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(
|
|
2841
|
+
function baseItem(row2) {
|
|
2842
2842
|
const item = {
|
|
2843
|
-
id:
|
|
2844
|
-
type:
|
|
2845
|
-
name:
|
|
2846
|
-
acceptanceCriteria: JSON.parse(
|
|
2847
|
-
status:
|
|
2848
|
-
starred:
|
|
2849
|
-
origin:
|
|
2850
|
-
};
|
|
2851
|
-
assignOptionalColumns(item,
|
|
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(
|
|
2867
|
-
const item = baseItem(
|
|
2868
|
-
attachComments(item, rel,
|
|
2869
|
-
attachLinks(item, rel,
|
|
2870
|
-
attachPlan(item, rel,
|
|
2871
|
-
attachUsage(item, rel,
|
|
2872
|
-
attachSessions(item, rel,
|
|
2873
|
-
attachGitRefs(item, rel,
|
|
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((
|
|
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((
|
|
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((
|
|
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 [
|
|
3735
|
-
return
|
|
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 [
|
|
3788
|
-
if (!
|
|
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(
|
|
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 [
|
|
4041
|
-
if (
|
|
4042
|
-
await maybeQueueDocsRefresh(orm,
|
|
4043
|
-
return
|
|
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 [
|
|
4442
|
-
return
|
|
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((
|
|
4849
|
-
sha:
|
|
4850
|
-
...
|
|
4851
|
-
...
|
|
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 [
|
|
7700
|
-
if (!
|
|
7701
|
-
if (
|
|
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 [
|
|
9016
|
-
return
|
|
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((
|
|
9055
|
-
id: inboxMessageKey(
|
|
9056
|
-
source:
|
|
9057
|
-
sender:
|
|
9058
|
-
summary:
|
|
9059
|
-
link:
|
|
9060
|
-
receivedAt: (
|
|
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 [
|
|
10201
|
-
return
|
|
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,
|
|
10293
|
+
const [rows, total2] = await Promise.all([
|
|
10294
10294
|
listUsagePeaks(db, { ...range, window }),
|
|
10295
10295
|
countUsagePeaks(db, window)
|
|
10296
10296
|
]);
|
|
10297
|
-
return { rows, total:
|
|
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((
|
|
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 [
|
|
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(
|
|
10365
|
-
doneCount: Number(
|
|
10366
|
-
repoCount: Number(
|
|
10367
|
-
medianPhases: Number(
|
|
10368
|
-
medianActiveMs: Number(
|
|
10369
|
-
medianTokens: Number(
|
|
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(
|
|
10404
|
+
function toItemUsageSummary(row2) {
|
|
10405
10405
|
return {
|
|
10406
|
-
...
|
|
10407
|
-
phaseCount:
|
|
10408
|
-
recordedPhases: Number(
|
|
10409
|
-
tokensUp: Number(
|
|
10410
|
-
tokensDown: Number(
|
|
10411
|
-
activeMs: Number(
|
|
10412
|
-
peakContextPct: Number(
|
|
10413
|
-
lastPhaseAt:
|
|
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,
|
|
10484
|
-
runsByKind: Object.fromEntries(byKind.map((
|
|
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:
|
|
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:
|
|
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((
|
|
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 [
|
|
12729
|
-
return
|
|
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 [
|
|
12780
|
-
const outcome = update4(
|
|
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((
|
|
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((
|
|
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
|
|
15480
|
-
console.log(line(
|
|
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
|
|
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(`${
|
|
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((
|
|
18253
|
-
table:
|
|
18254
|
-
column:
|
|
18255
|
-
rawColumn:
|
|
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
|
|
18309
|
+
const total2 = incoming.reduce((sum3, n) => sum3 + n, 0);
|
|
18310
18310
|
console.error(
|
|
18311
18311
|
chalk54.green(
|
|
18312
|
-
`Imported backlog: ${
|
|
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 [
|
|
21354
|
-
const cnt =
|
|
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 [
|
|
21408
|
-
const phaseCount =
|
|
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 [
|
|
21464
|
-
if (!
|
|
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 [
|
|
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
|
|
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 [
|
|
22433
|
-
return
|
|
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;
|
|
@@ -22683,7 +22683,7 @@ function stripEnvPrefix(parts) {
|
|
|
22683
22683
|
|
|
22684
22684
|
// src/commands/cliHook/isGhGraphqlIssueMutation.ts
|
|
22685
22685
|
import { readFileSync as readFileSync30 } from "fs";
|
|
22686
|
-
var ISSUE_MUTATION = /\bmutation\b[\s\S]*(?:issue|comment|label|assign|reaction|milestone)/i;
|
|
22686
|
+
var ISSUE_MUTATION = /\bmutation\b[\s\S]*(?:issue|comment|review|label|assign|reaction|milestone)/i;
|
|
22687
22687
|
var FILE_REFERENCE = /(?:=@|--input[\s=]+)["']?([^\s"';&|)]+)/g;
|
|
22688
22688
|
function isGhGraphqlIssueMutation(command) {
|
|
22689
22689
|
if (!command.includes("graphql")) return false;
|
|
@@ -22700,20 +22700,29 @@ function readOrEmpty(path109) {
|
|
|
22700
22700
|
}
|
|
22701
22701
|
}
|
|
22702
22702
|
|
|
22703
|
-
// src/commands/cliHook/
|
|
22703
|
+
// src/commands/cliHook/isGhRestWrite.ts
|
|
22704
22704
|
var WRITE_METHODS = /* @__PURE__ */ new Set(["POST", "PATCH", "PUT", "DELETE"]);
|
|
22705
22705
|
var METHOD = /(?:-X|--method)[\s=]*["']?([A-Za-z]+)/g;
|
|
22706
22706
|
var BODY_FLAG = /\s(?:-[fF]|--field|--raw-field|--input)/;
|
|
22707
|
+
function isGhRestWrite(command, endpoint) {
|
|
22708
|
+
if (!/gh\s+api/.test(command) || !endpoint.test(command)) return false;
|
|
22709
|
+
const methods = [...command.matchAll(METHOD)].map((m) => m[1].toUpperCase());
|
|
22710
|
+
if (methods.length > 0) return methods.some((m) => WRITE_METHODS.has(m));
|
|
22711
|
+
return BODY_FLAG.test(command);
|
|
22712
|
+
}
|
|
22713
|
+
|
|
22714
|
+
// src/commands/cliHook/isGhIssueApiWrite.ts
|
|
22707
22715
|
var ISSUE_ENDPOINT = /repos\/[^/\s"'`]+\/[^/\s"'`]+\/issues(?:$|[/?\s"'`)])/;
|
|
22708
22716
|
function isGhIssueApiWrite(command) {
|
|
22709
22717
|
if (!/gh\s+api/.test(command)) return false;
|
|
22710
|
-
if (
|
|
22718
|
+
if (isGhRestWrite(command, ISSUE_ENDPOINT)) return true;
|
|
22711
22719
|
return isGhGraphqlIssueMutation(command);
|
|
22712
22720
|
}
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
22721
|
+
|
|
22722
|
+
// src/commands/cliHook/isGhPullReviewApiWrite.ts
|
|
22723
|
+
var PULL_REVIEW_ENDPOINT = /repos\/[^/\s"'`]+\/[^/\s"'`]+\/pulls\/(?:\d+\/)?(?:comments|reviews)(?:$|[/?\s"'`)])/;
|
|
22724
|
+
function isGhPullReviewApiWrite(command) {
|
|
22725
|
+
return isGhRestWrite(command, PULL_REVIEW_ENDPOINT);
|
|
22717
22726
|
}
|
|
22718
22727
|
|
|
22719
22728
|
// src/commands/cliHook/builtinDenyRules.ts
|
|
@@ -22738,6 +22747,10 @@ var PATTERN_DENIES = [
|
|
|
22738
22747
|
pattern: "gh issue comment",
|
|
22739
22748
|
message: "Do not run 'gh issue comment' directly. Use 'assist github issue comment <number> --body <body> [-R <owner>/<repo>]' instead \u2014 it validates the body before delegating to gh, and gates the comment on the user's approval itself. Run 'assist github issue comment --help' and follow its guidance to compose the body; it is authoritative on how approval is handled in this environment."
|
|
22740
22749
|
},
|
|
22750
|
+
{
|
|
22751
|
+
pattern: "gh pr comment",
|
|
22752
|
+
message: "Do not run 'gh pr comment' directly \u2014 it posts to the PR without the approval pane. Use 'assist github issue comment <number> --body <body> [-R <owner>/<repo>]' instead (PR numbers are issue numbers) \u2014 it validates the body before delegating to gh, and gates the comment on the user's approval itself. To reply in a review thread, use 'assist prs reply <comment-id> <body>'. Run the command's --help and follow its guidance; it is authoritative on how approval is handled in this environment."
|
|
22753
|
+
},
|
|
22741
22754
|
{
|
|
22742
22755
|
pattern: "git commit",
|
|
22743
22756
|
message: `Do not run 'git commit' directly. Use 'assist commit "<message>"' instead.`
|
|
@@ -22752,6 +22765,9 @@ var GH_ISSUE_API_MESSAGE = "Do not write to GitHub issues with 'gh api' (REST is
|
|
|
22752
22765
|
var BRANCH_CREATION_MESSAGE = "Do not create branches with raw git. Use the /branch command, or 'assist branch <slug> [--jira <KEY>]' \u2014 it branches off the fresh remote default and enforces the team naming convention.";
|
|
22753
22766
|
var CLOSE_WITH_COMMENT_MESSAGE = "Do not post a comment through 'gh issue close', 'gh issue reopen' or 'gh pr close' with --comment/-c \u2014 it goes to GitHub without the approval pane. Post the comment first with 'assist github issue comment <number> --body <body> [-R <owner>/<repo>]', which validates it and gates it on the user's approval, then run the same close/reopen without --comment.";
|
|
22754
22767
|
var CLOSE_WITH_COMMENT_REGEX = /gh (?:issue (?:close|reopen)|pr close)[^;&|]*? (?:--comment|-c)/;
|
|
22768
|
+
var PR_REVIEW_MESSAGE = "Do not run 'gh pr review' with a body or a verdict (--comment, --approve, --request-changes) \u2014 it posts to the PR without the approval pane. To reply on the PR conversation, use 'assist github issue comment <number> --body <body> [-R <owner>/<repo>]' (PR numbers are issue numbers); to reply in a review thread, use 'assist prs reply <comment-id> <body>'; to add a line comment to the pending review, use 'assist prs comment <path> <line> <body>'. Each gates the text on the user's approval. Leave approving or requesting changes to the user.";
|
|
22769
|
+
var PR_REVIEW_REGEX = /gh pr review[^;&|]*? (?:-[bcaFr]\b|--(?:body|body-file|comment|approve|request-changes)\b)/;
|
|
22770
|
+
var GH_PULL_REVIEW_API_MESSAGE = "Do not write to pull request comments or reviews with 'gh api' \u2014 it bypasses the content validation and the approval pane. Use 'assist github issue comment <number> --body <body>' for a PR conversation comment (PR numbers are issue numbers), 'assist prs reply <comment-id> <body>' to reply in a review thread, or 'assist prs comment <path> <line> <body>' to add a line comment to the pending review. Each gates the text on the user's approval before anything reaches GitHub.";
|
|
22755
22771
|
var BRANCH_CREATION_REGEXES = [
|
|
22756
22772
|
/git (?:checkout|co) -[bB]/,
|
|
22757
22773
|
/git switch (?:-[cC]|--create)/,
|
|
@@ -22771,9 +22787,17 @@ var builtinDenyRules = [
|
|
|
22771
22787
|
message: CLOSE_WITH_COMMENT_MESSAGE,
|
|
22772
22788
|
matches: (text20) => CLOSE_WITH_COMMENT_REGEX.test(text20)
|
|
22773
22789
|
},
|
|
22790
|
+
{
|
|
22791
|
+
message: PR_REVIEW_MESSAGE,
|
|
22792
|
+
matches: (text20) => PR_REVIEW_REGEX.test(text20)
|
|
22793
|
+
},
|
|
22774
22794
|
{
|
|
22775
22795
|
message: GH_ISSUE_API_MESSAGE,
|
|
22776
22796
|
matches: isGhIssueApiWrite
|
|
22797
|
+
},
|
|
22798
|
+
{
|
|
22799
|
+
message: GH_PULL_REVIEW_API_MESSAGE,
|
|
22800
|
+
matches: isGhPullReviewApiWrite
|
|
22777
22801
|
}
|
|
22778
22802
|
];
|
|
22779
22803
|
|
|
@@ -25599,10 +25623,10 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
25599
25623
|
const color = exceedsThreshold ? chalk130.red : chalk130.white;
|
|
25600
25624
|
console.log(`${color(file)} \u2192 ${chalk130.cyan(lines2)} lines`);
|
|
25601
25625
|
}
|
|
25602
|
-
const
|
|
25626
|
+
const total2 = results.reduce((sum3, r) => sum3 + r.lines, 0);
|
|
25603
25627
|
console.log(
|
|
25604
25628
|
chalk130.dim(`
|
|
25605
|
-
Total: ${
|
|
25629
|
+
Total: ${total2} lines across ${files.length} files`)
|
|
25606
25630
|
);
|
|
25607
25631
|
if (hasViolation) {
|
|
25608
25632
|
process.exit(1);
|
|
@@ -25999,8 +26023,8 @@ function matching(filter) {
|
|
|
25999
26023
|
const needle = filter.toLowerCase();
|
|
26000
26024
|
return (leaf) => leaf.key.toLowerCase().includes(needle);
|
|
26001
26025
|
}
|
|
26002
|
-
function headline(shown,
|
|
26003
|
-
return filter ? chalk140.bold(`${shown} of ${
|
|
26026
|
+
function headline(shown, total2, filter) {
|
|
26027
|
+
return filter ? chalk140.bold(`${shown} of ${total2} config keys matching "${filter}"`) : chalk140.bold(`${total2} config keys`);
|
|
26004
26028
|
}
|
|
26005
26029
|
function formatLeaf(leaf, help) {
|
|
26006
26030
|
const meta = [typeText(leaf), `default: ${formatConfigDefault(leaf)}`];
|
|
@@ -26237,15 +26261,15 @@ function registerConfig(program) {
|
|
|
26237
26261
|
import chalk148 from "chalk";
|
|
26238
26262
|
|
|
26239
26263
|
// src/commands/browser/formatInspectMatches.ts
|
|
26240
|
-
function formatInspectMatches({ matches, total:
|
|
26241
|
-
if (
|
|
26264
|
+
function formatInspectMatches({ matches, total: total2 }, query) {
|
|
26265
|
+
if (total2 === 0) return [`no elements match ${query}`];
|
|
26242
26266
|
const lines2 = matches.flatMap((match, index3) => [
|
|
26243
|
-
`[${index3 + 1}/${
|
|
26267
|
+
`[${index3 + 1}/${total2}] ${match.width}\xD7${match.height} ${JSON.stringify(match.text)}`,
|
|
26244
26268
|
...match.chain.map((step3) => ` ${step3}`)
|
|
26245
26269
|
]);
|
|
26246
|
-
if (
|
|
26270
|
+
if (total2 > matches.length)
|
|
26247
26271
|
lines2.push(
|
|
26248
|
-
`showing the first ${matches.length} of ${
|
|
26272
|
+
`showing the first ${matches.length} of ${total2} matches; narrow the query to see the rest`
|
|
26249
26273
|
);
|
|
26250
26274
|
return lines2;
|
|
26251
26275
|
}
|
|
@@ -26769,8 +26793,8 @@ async function findRetiredTables(exec3) {
|
|
|
26769
26793
|
[RETIRED_TABLES]
|
|
26770
26794
|
);
|
|
26771
26795
|
const found = [];
|
|
26772
|
-
for (const
|
|
26773
|
-
const name = String(
|
|
26796
|
+
for (const row2 of present) {
|
|
26797
|
+
const name = String(row2.table_name);
|
|
26774
26798
|
const [count10] = await exec3.query(
|
|
26775
26799
|
`SELECT count(*)::int AS rows FROM "${name}"`
|
|
26776
26800
|
);
|
|
@@ -27508,9 +27532,9 @@ function colorStatus(status2) {
|
|
|
27508
27532
|
if (status2 === "outdated") return chalk165.yellow(status2);
|
|
27509
27533
|
return chalk165.green(status2);
|
|
27510
27534
|
}
|
|
27511
|
-
function formatRow(
|
|
27512
|
-
const week = (
|
|
27513
|
-
return `${
|
|
27535
|
+
function formatRow(row2, nameWidth) {
|
|
27536
|
+
const week = (row2.lastWeek ?? "-").padEnd(9);
|
|
27537
|
+
return `${row2.name.padEnd(nameWidth)} ${row2.lastPush} ${week} ${colorStatus(row2.status)}`;
|
|
27514
27538
|
}
|
|
27515
27539
|
function printReposTable(rows) {
|
|
27516
27540
|
const nameWidth = Math.max(4, ...rows.map((r) => r.name.length));
|
|
@@ -27522,8 +27546,8 @@ function printReposTable(rows) {
|
|
|
27522
27546
|
].join(" ");
|
|
27523
27547
|
console.log(chalk165.dim(header));
|
|
27524
27548
|
console.log(chalk165.dim("-".repeat(header.length)));
|
|
27525
|
-
for (const
|
|
27526
|
-
console.log(formatRow(
|
|
27549
|
+
for (const row2 of rows) {
|
|
27550
|
+
console.log(formatRow(row2, nameWidth));
|
|
27527
27551
|
}
|
|
27528
27552
|
}
|
|
27529
27553
|
|
|
@@ -29126,9 +29150,14 @@ function extractRustCommentTexts(text20) {
|
|
|
29126
29150
|
}
|
|
29127
29151
|
|
|
29128
29152
|
// src/commands/editHook/extractYamlComments.ts
|
|
29153
|
+
var SHA_PINNED_USES = /^\s*(?:-\s+)?uses:\s*\S+@[0-9a-f]{40}\s+$/i;
|
|
29129
29154
|
function blankNonNewline2(text20) {
|
|
29130
29155
|
return text20.replace(/[^\n]/g, " ");
|
|
29131
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
|
+
}
|
|
29132
29161
|
function extractYamlComments(text20) {
|
|
29133
29162
|
const work = text20.replace(
|
|
29134
29163
|
/"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'/g,
|
|
@@ -29136,6 +29165,8 @@ function extractYamlComments(text20) {
|
|
|
29136
29165
|
);
|
|
29137
29166
|
const comments3 = [];
|
|
29138
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;
|
|
29139
29170
|
comments3.push(match[1]);
|
|
29140
29171
|
}
|
|
29141
29172
|
return comments3.map((comment3) => comment3.replace(/\s+/g, " ").trim()).filter((comment3) => comment3.length > 0);
|
|
@@ -29387,13 +29418,13 @@ import chalk182 from "chalk";
|
|
|
29387
29418
|
function printCountTable(labelHeader, rows) {
|
|
29388
29419
|
const labelWidth = Math.max(
|
|
29389
29420
|
labelHeader.length,
|
|
29390
|
-
...rows.map((
|
|
29421
|
+
...rows.map((row2) => row2.label.length)
|
|
29391
29422
|
);
|
|
29392
29423
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
29393
29424
|
console.log(chalk182.dim(header));
|
|
29394
29425
|
console.log(chalk182.dim("-".repeat(header.length)));
|
|
29395
|
-
for (const
|
|
29396
|
-
console.log(`${
|
|
29426
|
+
for (const row2 of rows) {
|
|
29427
|
+
console.log(`${row2.label.padEnd(labelWidth)} ${row2.count}`);
|
|
29397
29428
|
}
|
|
29398
29429
|
}
|
|
29399
29430
|
|
|
@@ -29723,7 +29754,7 @@ function buildFixStructurePlan(issues, options2) {
|
|
|
29723
29754
|
tooDeep,
|
|
29724
29755
|
typeChangeCount: entries.filter((entry) => entry.typeChange).length,
|
|
29725
29756
|
labelRemovalCount: entries.reduce(
|
|
29726
|
-
(
|
|
29757
|
+
(total2, entry) => total2 + entry.labelRemovals.length,
|
|
29727
29758
|
0
|
|
29728
29759
|
)
|
|
29729
29760
|
};
|
|
@@ -30132,8 +30163,8 @@ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([".mp4", ".webm", ".mov"]);
|
|
|
30132
30163
|
function cell(text20) {
|
|
30133
30164
|
return text20.replaceAll("|", String.raw`\|`);
|
|
30134
30165
|
}
|
|
30135
|
-
function row(
|
|
30136
|
-
return `| ${
|
|
30166
|
+
function row(cells) {
|
|
30167
|
+
return `| ${cells.join(" | ")} |`;
|
|
30137
30168
|
}
|
|
30138
30169
|
function imageTable(images) {
|
|
30139
30170
|
if (images.length === 0) return [];
|
|
@@ -30410,17 +30441,6 @@ function resolveIssueMilestone(target, wanted) {
|
|
|
30410
30441
|
|
|
30411
30442
|
// src/commands/prs/shared.ts
|
|
30412
30443
|
import { execSync as execSync42 } from "child_process";
|
|
30413
|
-
|
|
30414
|
-
// src/commands/prs/pinCurrentPr.ts
|
|
30415
|
-
var pinnedPr;
|
|
30416
|
-
function getPinnedPr() {
|
|
30417
|
-
return pinnedPr;
|
|
30418
|
-
}
|
|
30419
|
-
function currentPrSelector(currentBranch7) {
|
|
30420
|
-
return pinnedPr === void 0 ? currentBranch7() : String(pinnedPr);
|
|
30421
|
-
}
|
|
30422
|
-
|
|
30423
|
-
// src/commands/prs/shared.ts
|
|
30424
30444
|
function isGhNotInstalled(error) {
|
|
30425
30445
|
if (error instanceof Error) {
|
|
30426
30446
|
const msg = error.message.toLowerCase();
|
|
@@ -30445,7 +30465,7 @@ function viewCurrentPr(fields) {
|
|
|
30445
30465
|
const { org, repo } = getRepoInfo();
|
|
30446
30466
|
return JSON.parse(
|
|
30447
30467
|
execSync42(
|
|
30448
|
-
`gh pr view ${
|
|
30468
|
+
`gh pr view ${getCurrentBranch2()} --json ${fields} -R ${org}/${repo}`,
|
|
30449
30469
|
{
|
|
30450
30470
|
encoding: "utf8"
|
|
30451
30471
|
}
|
|
@@ -31442,14 +31462,14 @@ async function scanUnopenedThreads(threadIds, scanThreads, onEvent = () => {
|
|
|
31442
31462
|
// src/commands/inbox/scanInboxWithCoverage.ts
|
|
31443
31463
|
async function scanInboxWithCoverage(since, listener) {
|
|
31444
31464
|
const runs = [];
|
|
31445
|
-
const
|
|
31465
|
+
const total2 = () => runs.reduce(addScanUsage, emptyScanUsage());
|
|
31446
31466
|
const run4 = (pass) => {
|
|
31447
31467
|
const slot = runs.push(emptyScanUsage()) - 1;
|
|
31448
31468
|
return runInboxScanClaude(pass, {
|
|
31449
31469
|
...listener,
|
|
31450
31470
|
onUsage: (usage) => {
|
|
31451
31471
|
runs[slot] = usage;
|
|
31452
|
-
listener.onUsage?.(
|
|
31472
|
+
listener.onUsage?.(total2());
|
|
31453
31473
|
}
|
|
31454
31474
|
});
|
|
31455
31475
|
};
|
|
@@ -31466,7 +31486,7 @@ async function scanInboxWithCoverage(since, listener) {
|
|
|
31466
31486
|
}),
|
|
31467
31487
|
listener.onEvent
|
|
31468
31488
|
);
|
|
31469
|
-
return { messages: [...main.messages, ...followUp], usage:
|
|
31489
|
+
return { messages: [...main.messages, ...followUp], usage: total2() };
|
|
31470
31490
|
}
|
|
31471
31491
|
|
|
31472
31492
|
// src/shared/db/finishJobRun.ts
|
|
@@ -31477,8 +31497,8 @@ async function finishJobRun(db, id, result) {
|
|
|
31477
31497
|
|
|
31478
31498
|
// src/shared/db/startJobRun.ts
|
|
31479
31499
|
async function startJobRun(db, run4) {
|
|
31480
|
-
const [
|
|
31481
|
-
return
|
|
31500
|
+
const [row2] = await db.insert(jobRuns).values({ ...run4, status: "running" }).returning({ id: jobRuns.id });
|
|
31501
|
+
return row2.id;
|
|
31482
31502
|
}
|
|
31483
31503
|
|
|
31484
31504
|
// src/commands/inbox/withInboxScanJob.ts
|
|
@@ -34250,12 +34270,12 @@ function printPromptsTable(rows) {
|
|
|
34250
34270
|
].join(" ");
|
|
34251
34271
|
console.log(chalk205.dim(header));
|
|
34252
34272
|
console.log(chalk205.dim("-".repeat(header.length)));
|
|
34253
|
-
for (const
|
|
34254
|
-
const count10 = String(
|
|
34255
|
-
const tool =
|
|
34256
|
-
const command = truncate2(
|
|
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);
|
|
34257
34277
|
console.log(
|
|
34258
|
-
`${chalk205.yellow(count10)} ${tool} ${command} ${chalk205.dim(
|
|
34278
|
+
`${chalk205.yellow(count10)} ${tool} ${command} ${chalk205.dim(row2.repos)}`
|
|
34259
34279
|
);
|
|
34260
34280
|
}
|
|
34261
34281
|
}
|
|
@@ -34327,17 +34347,17 @@ function getPageSlice(pullRequests, page) {
|
|
|
34327
34347
|
const start2 = page * PAGE_SIZE2;
|
|
34328
34348
|
return pullRequests.slice(start2, start2 + PAGE_SIZE2);
|
|
34329
34349
|
}
|
|
34330
|
-
function pageHeader(page, totalPages,
|
|
34350
|
+
function pageHeader(page, totalPages, total2) {
|
|
34331
34351
|
return `
|
|
34332
|
-
Page ${page + 1} of ${totalPages} (${
|
|
34352
|
+
Page ${page + 1} of ${totalPages} (${total2} total)
|
|
34333
34353
|
`;
|
|
34334
34354
|
}
|
|
34335
34355
|
function displayPage(pullRequests, totalPages, page) {
|
|
34336
34356
|
console.log(pageHeader(page, totalPages, pullRequests.length));
|
|
34337
34357
|
for (const pr of getPageSlice(pullRequests, page)) printPr(pr);
|
|
34338
34358
|
}
|
|
34339
|
-
function hasNextPage(page,
|
|
34340
|
-
return page <
|
|
34359
|
+
function hasNextPage(page, total2) {
|
|
34360
|
+
return page < total2 - 1;
|
|
34341
34361
|
}
|
|
34342
34362
|
var NEXT_CHOICE = { name: "Next page", value: "next" };
|
|
34343
34363
|
var PREV_CHOICE = { name: "Previous page", value: "prev" };
|
|
@@ -34636,7 +34656,7 @@ function findPrForBranch(repo, branch2) {
|
|
|
34636
34656
|
return Number.parseInt(stdout.trim(), 10);
|
|
34637
34657
|
}
|
|
34638
34658
|
function currentAzureDevopsPr(repo) {
|
|
34639
|
-
const prId =
|
|
34659
|
+
const prId = findPrForBranch(repo, getCurrentBranch2());
|
|
34640
34660
|
if (Number.isNaN(prId)) {
|
|
34641
34661
|
console.error("Error: No pull request found for the current branch.");
|
|
34642
34662
|
process.exit(1);
|
|
@@ -36545,11 +36565,11 @@ function parseReadBudget(value) {
|
|
|
36545
36565
|
`Invalid budget "${value}". Use a duration like 45s, 1m30s or 2m.`
|
|
36546
36566
|
);
|
|
36547
36567
|
}
|
|
36548
|
-
const
|
|
36549
|
-
if (
|
|
36568
|
+
const total2 = Number(minutes ?? 0) * 60 + Number(seconds ?? 0);
|
|
36569
|
+
if (total2 === 0) {
|
|
36550
36570
|
throw new Error(`Invalid budget "${value}". Value must be at least 1s.`);
|
|
36551
36571
|
}
|
|
36552
|
-
return
|
|
36572
|
+
return total2;
|
|
36553
36573
|
}
|
|
36554
36574
|
|
|
36555
36575
|
// src/commands/readTime/resolveReadTimeTarget.ts
|
|
@@ -36681,12 +36701,12 @@ import chalk215 from "chalk";
|
|
|
36681
36701
|
|
|
36682
36702
|
// src/shared/createConnectionAuth.ts
|
|
36683
36703
|
import chalk210 from "chalk";
|
|
36684
|
-
function listConnections(connections,
|
|
36704
|
+
function listConnections(connections, format2) {
|
|
36685
36705
|
if (connections.length === 0) {
|
|
36686
36706
|
console.log("No connections configured.");
|
|
36687
36707
|
} else {
|
|
36688
36708
|
for (const c of connections) {
|
|
36689
|
-
console.log(
|
|
36709
|
+
console.log(format2(c));
|
|
36690
36710
|
}
|
|
36691
36711
|
}
|
|
36692
36712
|
}
|
|
@@ -40806,7 +40826,7 @@ function basename24(path109) {
|
|
|
40806
40826
|
return path109.slice(path109.lastIndexOf("/") + 1);
|
|
40807
40827
|
}
|
|
40808
40828
|
function sum(nodes, key) {
|
|
40809
|
-
return nodes.reduce((
|
|
40829
|
+
return nodes.reduce((total2, node) => total2 + node[key], 0);
|
|
40810
40830
|
}
|
|
40811
40831
|
function byName(a, b) {
|
|
40812
40832
|
return a.name.localeCompare(b.name);
|
|
@@ -40850,7 +40870,7 @@ function buildHighLevelTree(files) {
|
|
|
40850
40870
|
|
|
40851
40871
|
// src/commands/review/highLevel/buildHighLevelStructure.ts
|
|
40852
40872
|
function sum2(files, key) {
|
|
40853
|
-
return files.reduce((
|
|
40873
|
+
return files.reduce((total2, file) => total2 + file[key], 0);
|
|
40854
40874
|
}
|
|
40855
40875
|
function countOf(files, status2) {
|
|
40856
40876
|
return files.filter((file) => file.status === status2).length;
|
|
@@ -41014,7 +41034,7 @@ var EVIDENCE_PATTERNS = [
|
|
|
41014
41034
|
];
|
|
41015
41035
|
function countEvidence(body) {
|
|
41016
41036
|
return EVIDENCE_PATTERNS.reduce(
|
|
41017
|
-
(
|
|
41037
|
+
(total2, pattern2) => total2 + (body.match(pattern2)?.length ?? 0),
|
|
41018
41038
|
0
|
|
41019
41039
|
);
|
|
41020
41040
|
}
|
|
@@ -41582,12 +41602,12 @@ function visitCase(call, context) {
|
|
|
41582
41602
|
if (!context.changed) return [toCase(call, context)];
|
|
41583
41603
|
const lines2 = changedLines(call, context.changed);
|
|
41584
41604
|
if (lines2.length === 0) return [];
|
|
41585
|
-
const
|
|
41605
|
+
const total2 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
|
|
41586
41606
|
return [
|
|
41587
41607
|
toCase(
|
|
41588
41608
|
call,
|
|
41589
41609
|
context,
|
|
41590
|
-
lines2.length ===
|
|
41610
|
+
lines2.length === total2 ? { change: "added" } : { change: "modified", changedLines: lines2 }
|
|
41591
41611
|
)
|
|
41592
41612
|
];
|
|
41593
41613
|
}
|
|
@@ -42364,455 +42384,6 @@ async function runHighLevelReview(number, options2 = {}) {
|
|
|
42364
42384
|
// src/commands/review/reviewPr.ts
|
|
42365
42385
|
import { basename as basename26 } from "path";
|
|
42366
42386
|
|
|
42367
|
-
// src/commands/review/ci/writeJobSummary.ts
|
|
42368
|
-
import { appendFileSync as appendFileSync3, readFileSync as readFileSync57 } from "fs";
|
|
42369
|
-
|
|
42370
|
-
// src/commands/review/carriedUnanchoredFindings.ts
|
|
42371
|
-
function carriedUnanchoredFindings(unanchored) {
|
|
42372
|
-
return unanchored.filter((finding) => finding.source !== "already-raised");
|
|
42373
|
-
}
|
|
42374
|
-
|
|
42375
|
-
// src/commands/review/parseFindings.ts
|
|
42376
|
-
var SEVERITIES = ["blocker", "major", "minor", "nit"];
|
|
42377
|
-
var SOURCES = [
|
|
42378
|
-
"confirmed",
|
|
42379
|
-
"disputed",
|
|
42380
|
-
"claude-only",
|
|
42381
|
-
"codex-only",
|
|
42382
|
-
"already-raised"
|
|
42383
|
-
];
|
|
42384
|
-
function isSeverity(value) {
|
|
42385
|
-
return SEVERITIES.includes(value);
|
|
42386
|
-
}
|
|
42387
|
-
function isSource(value) {
|
|
42388
|
-
return SOURCES.includes(value);
|
|
42389
|
-
}
|
|
42390
|
-
function extractField(block, field) {
|
|
42391
|
-
const re = new RegExp(`^-\\s+${field}:\\s*(.*)$`, "im");
|
|
42392
|
-
const match = block.match(re);
|
|
42393
|
-
return match ? match[1].trim() : "";
|
|
42394
|
-
}
|
|
42395
|
-
function stripBackticks(value) {
|
|
42396
|
-
return value.replace(/^`+|`+$/g, "").trim();
|
|
42397
|
-
}
|
|
42398
|
-
function parseFindingBlock(block) {
|
|
42399
|
-
const newlineIndex = block.indexOf("\n");
|
|
42400
|
-
const title = newlineIndex === -1 ? block.trim() : block.slice(0, newlineIndex).trim();
|
|
42401
|
-
const body = newlineIndex === -1 ? "" : block.slice(newlineIndex + 1);
|
|
42402
|
-
const severityRaw = extractField(body, "Severity").toLowerCase();
|
|
42403
|
-
const sourceRaw = extractField(body, "Source").toLowerCase();
|
|
42404
|
-
return {
|
|
42405
|
-
title,
|
|
42406
|
-
severity: isSeverity(severityRaw) ? severityRaw : null,
|
|
42407
|
-
source: isSource(sourceRaw) ? sourceRaw : null,
|
|
42408
|
-
location: stripBackticks(extractField(body, "Location")),
|
|
42409
|
-
impact: extractField(body, "Impact"),
|
|
42410
|
-
recommendation: extractField(body, "Recommendation")
|
|
42411
|
-
};
|
|
42412
|
-
}
|
|
42413
|
-
function parseFindings(markdown) {
|
|
42414
|
-
return markdown.split(/^###\s+Finding:\s*/m).slice(1).map(parseFindingBlock);
|
|
42415
|
-
}
|
|
42416
|
-
|
|
42417
|
-
// src/commands/review/summariseSynthesis.ts
|
|
42418
|
-
var SEVERITIES2 = ["blocker", "major", "minor", "nit"];
|
|
42419
|
-
function isSeverity2(value) {
|
|
42420
|
-
return SEVERITIES2.includes(value);
|
|
42421
|
-
}
|
|
42422
|
-
function extractSummary(markdown) {
|
|
42423
|
-
const match = markdown.match(
|
|
42424
|
-
/^##\s+Summary\s*\n([\s\S]*?)(?=\n##\s|\n###\s|$)/m
|
|
42425
|
-
);
|
|
42426
|
-
if (!match) return "";
|
|
42427
|
-
return match[1].trim();
|
|
42428
|
-
}
|
|
42429
|
-
function countBySeverity(markdown) {
|
|
42430
|
-
const totals = { blocker: 0, major: 0, minor: 0, nit: 0 };
|
|
42431
|
-
const regex = /^-\s+Severity:\s*([a-zA-Z]+)/gm;
|
|
42432
|
-
for (const match of markdown.matchAll(regex)) {
|
|
42433
|
-
const severity = match[1].toLowerCase();
|
|
42434
|
-
if (isSeverity2(severity)) totals[severity]++;
|
|
42435
|
-
}
|
|
42436
|
-
return totals;
|
|
42437
|
-
}
|
|
42438
|
-
function summariseSynthesis(markdown) {
|
|
42439
|
-
const totals = countBySeverity(markdown);
|
|
42440
|
-
const findingCount = totals.blocker + totals.major + totals.minor + totals.nit;
|
|
42441
|
-
return { summary: extractSummary(markdown), totals, findingCount };
|
|
42442
|
-
}
|
|
42443
|
-
function formatSynthesisSummary(summary) {
|
|
42444
|
-
const lines2 = [];
|
|
42445
|
-
const { totals, findingCount } = summary;
|
|
42446
|
-
lines2.push(
|
|
42447
|
-
`Findings: ${findingCount} (blocker ${totals.blocker}, major ${totals.major}, minor ${totals.minor}, nit ${totals.nit})`
|
|
42448
|
-
);
|
|
42449
|
-
if (summary.summary) lines2.push("", summary.summary);
|
|
42450
|
-
return lines2.join("\n");
|
|
42451
|
-
}
|
|
42452
|
-
|
|
42453
|
-
// src/commands/review/buildReviewSummary.ts
|
|
42454
|
-
var UNANCHOR_REASONS = {
|
|
42455
|
-
"out-of-diff": "its line falls outside the PR diff",
|
|
42456
|
-
unlocated: "it has no parseable file:line",
|
|
42457
|
-
"comment-rejected": "GitHub rejected its line comment"
|
|
42458
|
-
};
|
|
42459
|
-
function formatFindingLine(finding) {
|
|
42460
|
-
const severity = finding.severity ?? "finding";
|
|
42461
|
-
return `- **${severity}: ${finding.title}**`;
|
|
42462
|
-
}
|
|
42463
|
-
function formatLocation(finding) {
|
|
42464
|
-
const location = finding.location.trim();
|
|
42465
|
-
if (!location || location.toLowerCase() === "n/a") return "no location";
|
|
42466
|
-
return `\`${location}\``;
|
|
42467
|
-
}
|
|
42468
|
-
function formatUnanchoredFinding(finding) {
|
|
42469
|
-
const lines2 = [
|
|
42470
|
-
`${formatFindingLine(finding)} \u2014 ${formatLocation(finding)}`,
|
|
42471
|
-
` - Not anchored: ${UNANCHOR_REASONS[finding.reason]}`
|
|
42472
|
-
];
|
|
42473
|
-
if (finding.impact) lines2.push(` - Impact: ${finding.impact}`);
|
|
42474
|
-
if (finding.recommendation)
|
|
42475
|
-
lines2.push(` - Recommendation: ${finding.recommendation}`);
|
|
42476
|
-
return lines2;
|
|
42477
|
-
}
|
|
42478
|
-
function buildReviewSummary(markdown, unanchored = []) {
|
|
42479
|
-
const summary = summariseSynthesis(markdown);
|
|
42480
|
-
const findings2 = parseFindings(markdown);
|
|
42481
|
-
const lines2 = ["## Code review summary", "", formatSynthesisSummary(summary)];
|
|
42482
|
-
if (findings2.length > 0) {
|
|
42483
|
-
lines2.push("", "### Findings", "");
|
|
42484
|
-
for (const finding of findings2) lines2.push(formatFindingLine(finding));
|
|
42485
|
-
}
|
|
42486
|
-
const carried = carriedUnanchoredFindings(unanchored);
|
|
42487
|
-
if (carried.length > 0) {
|
|
42488
|
-
lines2.push(
|
|
42489
|
-
"",
|
|
42490
|
-
"### Findings not anchored to the diff",
|
|
42491
|
-
"",
|
|
42492
|
-
"No line comment could be attached to these, so the detail is here instead.",
|
|
42493
|
-
""
|
|
42494
|
-
);
|
|
42495
|
-
for (const finding of carried)
|
|
42496
|
-
lines2.push(...formatUnanchoredFinding(finding));
|
|
42497
|
-
}
|
|
42498
|
-
return lines2.join("\n");
|
|
42499
|
-
}
|
|
42500
|
-
|
|
42501
|
-
// src/commands/review/partitionFindings.ts
|
|
42502
|
-
function isValidLine(n) {
|
|
42503
|
-
return Number.isInteger(n) && n >= 1;
|
|
42504
|
-
}
|
|
42505
|
-
function toLineBound(finding) {
|
|
42506
|
-
if (!finding.location || finding.location.toLowerCase() === "n/a") {
|
|
42507
|
-
return null;
|
|
42508
|
-
}
|
|
42509
|
-
const match = finding.location.match(/^(.+):(\d+)(?:-(\d+))?$/);
|
|
42510
|
-
if (!match) return null;
|
|
42511
|
-
const startLine = Number.parseInt(match[2], 10);
|
|
42512
|
-
const endLine = match[3] ? Number.parseInt(match[3], 10) : startLine;
|
|
42513
|
-
if (!isValidLine(startLine) || !isValidLine(endLine)) return null;
|
|
42514
|
-
if (endLine < startLine) return null;
|
|
42515
|
-
const base = { ...finding, file: match[1], line: endLine };
|
|
42516
|
-
return startLine === endLine ? base : { ...base, startLine };
|
|
42517
|
-
}
|
|
42518
|
-
function partitionFindings(findings2) {
|
|
42519
|
-
const lineBound = [];
|
|
42520
|
-
const unlocated = [];
|
|
42521
|
-
const alreadyRaised = [];
|
|
42522
|
-
for (const finding of findings2) {
|
|
42523
|
-
if (finding.source === "already-raised") {
|
|
42524
|
-
alreadyRaised.push(finding);
|
|
42525
|
-
continue;
|
|
42526
|
-
}
|
|
42527
|
-
const bound = toLineBound(finding);
|
|
42528
|
-
if (bound) lineBound.push(bound);
|
|
42529
|
-
else unlocated.push(finding);
|
|
42530
|
-
}
|
|
42531
|
-
return { lineBound, unlocated, alreadyRaised };
|
|
42532
|
-
}
|
|
42533
|
-
|
|
42534
|
-
// src/commands/review/buildDiffLineIndex.ts
|
|
42535
|
-
var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
|
|
42536
|
-
var HUNK_HEADER3 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
|
|
42537
|
-
function buildDiffLineIndex(diff3) {
|
|
42538
|
-
const index3 = /* @__PURE__ */ new Map();
|
|
42539
|
-
let currentFile = null;
|
|
42540
|
-
let newLine = 0;
|
|
42541
|
-
for (const line of diff3.split("\n")) {
|
|
42542
|
-
const fileMatch = line.match(FILE_HEADER);
|
|
42543
|
-
if (fileMatch) {
|
|
42544
|
-
currentFile = fileMatch[1] === "/dev/null" ? null : fileMatch[1];
|
|
42545
|
-
continue;
|
|
42546
|
-
}
|
|
42547
|
-
const hunkMatch = line.match(HUNK_HEADER3);
|
|
42548
|
-
if (hunkMatch) {
|
|
42549
|
-
newLine = Number(hunkMatch[1]);
|
|
42550
|
-
continue;
|
|
42551
|
-
}
|
|
42552
|
-
if (currentFile === null) continue;
|
|
42553
|
-
if (line.startsWith("-")) continue;
|
|
42554
|
-
if (line.startsWith("+") || line.startsWith(" ")) {
|
|
42555
|
-
let set = index3.get(currentFile);
|
|
42556
|
-
if (!set) {
|
|
42557
|
-
set = /* @__PURE__ */ new Set();
|
|
42558
|
-
index3.set(currentFile, set);
|
|
42559
|
-
}
|
|
42560
|
-
set.add(newLine);
|
|
42561
|
-
newLine++;
|
|
42562
|
-
}
|
|
42563
|
-
}
|
|
42564
|
-
return index3;
|
|
42565
|
-
}
|
|
42566
|
-
|
|
42567
|
-
// src/commands/review/fetchPrDiff.ts
|
|
42568
|
-
import { execSync as execSync58 } from "child_process";
|
|
42569
|
-
function fetchPrDiff(prNumber, baseSha, headSha) {
|
|
42570
|
-
const { org, repo } = getRepoInfo();
|
|
42571
|
-
try {
|
|
42572
|
-
return execSync58(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
|
|
42573
|
-
encoding: "utf8",
|
|
42574
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
42575
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
42576
|
-
});
|
|
42577
|
-
} catch (error) {
|
|
42578
|
-
if (!isDiffTooLarge(error)) throw error;
|
|
42579
|
-
return fetchDiffViaGit(baseSha, headSha);
|
|
42580
|
-
}
|
|
42581
|
-
}
|
|
42582
|
-
function isDiffTooLarge(error) {
|
|
42583
|
-
return error instanceof Error && (error.message.includes("too_large") || error.message.includes("maximum number of files"));
|
|
42584
|
-
}
|
|
42585
|
-
function fetchDiffViaGit(baseSha, headSha) {
|
|
42586
|
-
try {
|
|
42587
|
-
execSync58(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
|
|
42588
|
-
} catch {
|
|
42589
|
-
}
|
|
42590
|
-
return execSync58(`git diff ${baseSha}...${headSha}`, {
|
|
42591
|
-
encoding: "utf8",
|
|
42592
|
-
maxBuffer: 256 * 1024 * 1024
|
|
42593
|
-
});
|
|
42594
|
-
}
|
|
42595
|
-
|
|
42596
|
-
// src/commands/review/partitionFindingsByDiff.ts
|
|
42597
|
-
function isWithinDiff(finding, index3) {
|
|
42598
|
-
const lines2 = index3.get(finding.file);
|
|
42599
|
-
if (!lines2) return false;
|
|
42600
|
-
if (!lines2.has(finding.line)) return false;
|
|
42601
|
-
if (finding.startLine !== void 0 && !lines2.has(finding.startLine)) {
|
|
42602
|
-
return false;
|
|
42603
|
-
}
|
|
42604
|
-
return true;
|
|
42605
|
-
}
|
|
42606
|
-
function partitionFindingsByDiff(findings2, index3) {
|
|
42607
|
-
const inDiff = [];
|
|
42608
|
-
const outOfDiff = [];
|
|
42609
|
-
for (const finding of findings2) {
|
|
42610
|
-
if (isWithinDiff(finding, index3)) inDiff.push(finding);
|
|
42611
|
-
else outOfDiff.push(finding);
|
|
42612
|
-
}
|
|
42613
|
-
return { inDiff, outOfDiff };
|
|
42614
|
-
}
|
|
42615
|
-
|
|
42616
|
-
// src/commands/review/warnOutOfDiff.ts
|
|
42617
|
-
import chalk261 from "chalk";
|
|
42618
|
-
function warnOutOfDiff(outOfDiff) {
|
|
42619
|
-
if (outOfDiff.length === 0) return;
|
|
42620
|
-
console.warn(
|
|
42621
|
-
chalk261.yellow(
|
|
42622
|
-
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
42623
|
-
)
|
|
42624
|
-
);
|
|
42625
|
-
for (const finding of outOfDiff) {
|
|
42626
|
-
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
42627
|
-
console.warn(
|
|
42628
|
-
` ${chalk261.yellow("\xB7")} ${finding.title} ${chalk261.dim(
|
|
42629
|
-
`(${finding.file}:${range})`
|
|
42630
|
-
)}`
|
|
42631
|
-
);
|
|
42632
|
-
}
|
|
42633
|
-
}
|
|
42634
|
-
|
|
42635
|
-
// src/commands/review/selectInDiffFindings.ts
|
|
42636
|
-
function selectInDiffFindings(lineBound, prDiff) {
|
|
42637
|
-
const diff3 = fetchPrDiff(prDiff.prNumber, prDiff.baseSha, prDiff.headSha);
|
|
42638
|
-
const { inDiff, outOfDiff } = partitionFindingsByDiff(
|
|
42639
|
-
lineBound,
|
|
42640
|
-
buildDiffLineIndex(diff3)
|
|
42641
|
-
);
|
|
42642
|
-
warnOutOfDiff(outOfDiff);
|
|
42643
|
-
return {
|
|
42644
|
-
inDiff,
|
|
42645
|
-
unanchored: outOfDiff.map(
|
|
42646
|
-
(finding) => ({
|
|
42647
|
-
...finding,
|
|
42648
|
-
reason: "out-of-diff"
|
|
42649
|
-
})
|
|
42650
|
-
)
|
|
42651
|
-
};
|
|
42652
|
-
}
|
|
42653
|
-
|
|
42654
|
-
// src/commands/review/warnUnlocated.ts
|
|
42655
|
-
import chalk262 from "chalk";
|
|
42656
|
-
function warnUnlocated(unlocated) {
|
|
42657
|
-
if (unlocated.length === 0) return;
|
|
42658
|
-
console.warn(
|
|
42659
|
-
chalk262.yellow(
|
|
42660
|
-
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
42661
|
-
)
|
|
42662
|
-
);
|
|
42663
|
-
for (const finding of unlocated) {
|
|
42664
|
-
const where = finding.location || chalk262.dim("missing");
|
|
42665
|
-
console.warn(
|
|
42666
|
-
` ${chalk262.yellow("\xB7")} ${finding.title} ${chalk262.dim(`(${where})`)}`
|
|
42667
|
-
);
|
|
42668
|
-
}
|
|
42669
|
-
}
|
|
42670
|
-
|
|
42671
|
-
// src/commands/review/selectPostableFindings.ts
|
|
42672
|
-
function selectPostableFindings(markdown, prInfo) {
|
|
42673
|
-
const findings2 = parseFindings(markdown);
|
|
42674
|
-
if (findings2.length === 0) {
|
|
42675
|
-
console.log("Synthesis contains no findings; nothing to post.");
|
|
42676
|
-
return { inDiff: [], unanchored: [] };
|
|
42677
|
-
}
|
|
42678
|
-
const { lineBound, unlocated, alreadyRaised } = partitionFindings(findings2);
|
|
42679
|
-
warnUnlocated(unlocated);
|
|
42680
|
-
if (alreadyRaised.length > 0) {
|
|
42681
|
-
console.log(
|
|
42682
|
-
`Skipped ${alreadyRaised.length} finding(s) already raised by prior comments.`
|
|
42683
|
-
);
|
|
42684
|
-
}
|
|
42685
|
-
const carriedUnlocated = unlocated.map(
|
|
42686
|
-
(finding) => ({
|
|
42687
|
-
...finding,
|
|
42688
|
-
reason: "unlocated"
|
|
42689
|
-
})
|
|
42690
|
-
);
|
|
42691
|
-
if (lineBound.length === 0) {
|
|
42692
|
-
console.log("No line-bound findings to comment on.");
|
|
42693
|
-
return { inDiff: [], unanchored: carriedUnlocated };
|
|
42694
|
-
}
|
|
42695
|
-
const { inDiff, unanchored } = selectInDiffFindings(lineBound, prInfo);
|
|
42696
|
-
if (inDiff.length === 0)
|
|
42697
|
-
console.log(
|
|
42698
|
-
"No findings fall within the PR diff; no line comments to post."
|
|
42699
|
-
);
|
|
42700
|
-
return { inDiff, unanchored: [...carriedUnlocated, ...unanchored] };
|
|
42701
|
-
}
|
|
42702
|
-
|
|
42703
|
-
// src/commands/review/ci/buildTokenUsageTable.ts
|
|
42704
|
-
var SLOT_LABELS = ["Reviewer 1", "Reviewer 2", "Synthesis"];
|
|
42705
|
-
var DASH = "\u2014";
|
|
42706
|
-
function format(value) {
|
|
42707
|
-
return value === void 0 ? DASH : value.toLocaleString("en-US");
|
|
42708
|
-
}
|
|
42709
|
-
function cells(usage) {
|
|
42710
|
-
if (!usage) return [DASH, DASH, DASH, DASH];
|
|
42711
|
-
return [
|
|
42712
|
-
format(usage.input),
|
|
42713
|
-
format(usage.output),
|
|
42714
|
-
format(usage.cacheRead),
|
|
42715
|
-
format(usage.cacheWrite)
|
|
42716
|
-
];
|
|
42717
|
-
}
|
|
42718
|
-
function sumOf(reported, pick3) {
|
|
42719
|
-
const values = reported.map(pick3).filter((v) => v !== void 0);
|
|
42720
|
-
return values.length === 0 ? void 0 : values.reduce((a, b) => a + b, 0);
|
|
42721
|
-
}
|
|
42722
|
-
function total2(usages) {
|
|
42723
|
-
const reported = usages.filter((u) => u !== void 0);
|
|
42724
|
-
return [
|
|
42725
|
-
format(sumOf(reported, (u) => u.input)),
|
|
42726
|
-
format(sumOf(reported, (u) => u.output)),
|
|
42727
|
-
format(sumOf(reported, (u) => u.cacheRead)),
|
|
42728
|
-
format(sumOf(reported, (u) => u.cacheWrite))
|
|
42729
|
-
];
|
|
42730
|
-
}
|
|
42731
|
-
function row2(label, values) {
|
|
42732
|
-
return `| ${label} | ${values.join(" | ")} |`;
|
|
42733
|
-
}
|
|
42734
|
-
function buildTokenUsageTable(usages) {
|
|
42735
|
-
return [
|
|
42736
|
-
"## Token usage",
|
|
42737
|
-
"",
|
|
42738
|
-
"| Slot | Input | Output | Cache read | Cache write |",
|
|
42739
|
-
"| --- | ---: | ---: | ---: | ---: |",
|
|
42740
|
-
...usages.map(
|
|
42741
|
-
(usage, i) => row2(SLOT_LABELS[i] ?? `Slot ${i + 1}`, cells(usage))
|
|
42742
|
-
),
|
|
42743
|
-
row2("**Total**", total2(usages))
|
|
42744
|
-
].join("\n");
|
|
42745
|
-
}
|
|
42746
|
-
|
|
42747
|
-
// src/commands/review/ci/writeJobSummary.ts
|
|
42748
|
-
function writeJobSummary(synthesisPath, prInfo, summaryPath, slots) {
|
|
42749
|
-
if (!summaryPath) return;
|
|
42750
|
-
const markdown = readFileSync57(synthesisPath, "utf8");
|
|
42751
|
-
const { unanchored } = selectPostableFindings(markdown, prInfo);
|
|
42752
|
-
const usageTable = buildTokenUsageTable(slots.map((slot) => slot.usage));
|
|
42753
|
-
appendFileSync3(
|
|
42754
|
-
summaryPath,
|
|
42755
|
-
`${buildReviewSummary(markdown, unanchored)}
|
|
42756
|
-
|
|
42757
|
-
${usageTable}
|
|
42758
|
-
`
|
|
42759
|
-
);
|
|
42760
|
-
}
|
|
42761
|
-
|
|
42762
|
-
// src/commands/review/appendCiFooter.ts
|
|
42763
|
-
function appendCiFooter(body, ciFooter) {
|
|
42764
|
-
return ciFooter ? `${body}
|
|
42765
|
-
|
|
42766
|
-
${ciFooter}` : body;
|
|
42767
|
-
}
|
|
42768
|
-
|
|
42769
|
-
// src/commands/review/runReviewSubmission.ts
|
|
42770
|
-
function runReviewSubmission(mutation, body) {
|
|
42771
|
-
try {
|
|
42772
|
-
const prId = getCurrentPrNodeId();
|
|
42773
|
-
runGhGraphql(mutation, { prId, body });
|
|
42774
|
-
console.log("Submitted review.");
|
|
42775
|
-
return true;
|
|
42776
|
-
} catch (error) {
|
|
42777
|
-
if (isGhNotInstalled(error)) {
|
|
42778
|
-
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
42779
|
-
return false;
|
|
42780
|
-
}
|
|
42781
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
42782
|
-
console.error(`Failed to submit review: ${message3}`);
|
|
42783
|
-
return false;
|
|
42784
|
-
}
|
|
42785
|
-
}
|
|
42786
|
-
|
|
42787
|
-
// src/commands/review/submitBodyOnlyReview.ts
|
|
42788
|
-
var MUTATION6 = `mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
|
|
42789
|
-
function submitBodyOnlyReview(body) {
|
|
42790
|
-
return runReviewSubmission(MUTATION6, body);
|
|
42791
|
-
}
|
|
42792
|
-
|
|
42793
|
-
// src/commands/review/submitFailedReview.ts
|
|
42794
|
-
function describeFailures(failures) {
|
|
42795
|
-
if (failures.length === 0) return "The review did not complete.";
|
|
42796
|
-
const steps = failures.map((f) => f.name.replace("-", " ")).join(" and ");
|
|
42797
|
-
return `The review did not complete: ${steps} failed.`;
|
|
42798
|
-
}
|
|
42799
|
-
function submitFailedReview(failures, ciFooter, runUrl) {
|
|
42800
|
-
const lines2 = [
|
|
42801
|
-
"## Code review failed",
|
|
42802
|
-
"",
|
|
42803
|
-
`${describeFailures(failures)} No findings were posted.`
|
|
42804
|
-
];
|
|
42805
|
-
if (runUrl) lines2.push("", `See the [workflow run](${runUrl}) for details.`);
|
|
42806
|
-
submitBodyOnlyReview(appendCiFooter(lines2.join("\n"), ciFooter));
|
|
42807
|
-
}
|
|
42808
|
-
|
|
42809
|
-
// src/commands/review/exitFailedCiReview.ts
|
|
42810
|
-
function exitFailedCiReview(failures, ci) {
|
|
42811
|
-
console.error("Review failed; no findings were posted.");
|
|
42812
|
-
submitFailedReview(failures, ci.footer, ci.runUrl);
|
|
42813
|
-
process.exit(1);
|
|
42814
|
-
}
|
|
42815
|
-
|
|
42816
42387
|
// src/commands/review/cachedReviewerResult.ts
|
|
42817
42388
|
import { statSync as statSync12 } from "fs";
|
|
42818
42389
|
function cachedReviewerResult(name, outputPath) {
|
|
@@ -42862,10 +42433,10 @@ function renderEntry(entry, frame) {
|
|
|
42862
42433
|
}
|
|
42863
42434
|
|
|
42864
42435
|
// src/commands/review/startReviewLog.ts
|
|
42865
|
-
import { format
|
|
42436
|
+
import { format } from "util";
|
|
42866
42437
|
|
|
42867
42438
|
// src/commands/review/createReviewLogSink.ts
|
|
42868
|
-
import { appendFileSync as
|
|
42439
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync30 } from "fs";
|
|
42869
42440
|
import { join as join93 } from "path";
|
|
42870
42441
|
var LOG_FILE = "review.log";
|
|
42871
42442
|
function createReviewLogSink() {
|
|
@@ -42878,7 +42449,7 @@ function createReviewLogSink() {
|
|
|
42878
42449
|
buffered.push(stripped);
|
|
42879
42450
|
return;
|
|
42880
42451
|
}
|
|
42881
|
-
|
|
42452
|
+
appendFileSync3(logPath2, `${stripped}
|
|
42882
42453
|
`);
|
|
42883
42454
|
},
|
|
42884
42455
|
attach(reviewDir) {
|
|
@@ -42891,7 +42462,7 @@ function createReviewLogSink() {
|
|
|
42891
42462
|
...buffered
|
|
42892
42463
|
];
|
|
42893
42464
|
buffered = [];
|
|
42894
|
-
|
|
42465
|
+
appendFileSync3(logPath2, `${lines2.join("\n")}
|
|
42895
42466
|
`);
|
|
42896
42467
|
}
|
|
42897
42468
|
};
|
|
@@ -42910,7 +42481,7 @@ function patch(method) {
|
|
|
42910
42481
|
const original = console[method].bind(console);
|
|
42911
42482
|
console[method] = (...args) => {
|
|
42912
42483
|
original(...args);
|
|
42913
|
-
appendReviewLog(
|
|
42484
|
+
appendReviewLog(format(...args));
|
|
42914
42485
|
};
|
|
42915
42486
|
}
|
|
42916
42487
|
function startReviewLog() {
|
|
@@ -43607,12 +43178,12 @@ function parseCodexEvent(line) {
|
|
|
43607
43178
|
}
|
|
43608
43179
|
|
|
43609
43180
|
// src/commands/review/createCodexLineHandler.ts
|
|
43610
|
-
function addUsage(
|
|
43611
|
-
if (!
|
|
43181
|
+
function addUsage(total2, turn) {
|
|
43182
|
+
if (!total2) return turn;
|
|
43612
43183
|
return {
|
|
43613
|
-
input:
|
|
43614
|
-
output:
|
|
43615
|
-
cacheRead:
|
|
43184
|
+
input: total2.input + turn.input,
|
|
43185
|
+
output: total2.output + turn.output,
|
|
43186
|
+
cacheRead: total2.cacheRead + turn.cacheRead
|
|
43616
43187
|
};
|
|
43617
43188
|
}
|
|
43618
43189
|
function createCodexLineHandler(name, spinner, model) {
|
|
@@ -43754,7 +43325,138 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
43754
43325
|
import { existsSync as existsSync73, unlinkSync as unlinkSync18 } from "fs";
|
|
43755
43326
|
|
|
43756
43327
|
// src/commands/review/synthesise.ts
|
|
43757
|
-
import { readFileSync as
|
|
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
|
+
}
|
|
43758
43460
|
|
|
43759
43461
|
// src/commands/review/buildSynthesisStdin.ts
|
|
43760
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.
|
|
@@ -43823,7 +43525,7 @@ Files:
|
|
|
43823
43525
|
|
|
43824
43526
|
// src/commands/review/synthesise.ts
|
|
43825
43527
|
function printSummary2(synthesisPath) {
|
|
43826
|
-
const markdown =
|
|
43528
|
+
const markdown = readFileSync57(synthesisPath, "utf8");
|
|
43827
43529
|
console.log("");
|
|
43828
43530
|
console.log(buildReviewSummary(markdown));
|
|
43829
43531
|
console.log("");
|
|
@@ -43977,8 +43679,8 @@ async function runReviewPipeline(paths, options2) {
|
|
|
43977
43679
|
}
|
|
43978
43680
|
|
|
43979
43681
|
// src/commands/review/annotateDiffWithLineNumbers.ts
|
|
43980
|
-
var
|
|
43981
|
-
var
|
|
43682
|
+
var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
|
|
43683
|
+
var HUNK_HEADER3 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
|
|
43982
43684
|
var GUTTER_WIDTH = 6;
|
|
43983
43685
|
function gutter(lineNumber) {
|
|
43984
43686
|
const label = lineNumber === null ? "" : String(lineNumber);
|
|
@@ -43988,11 +43690,11 @@ function annotateDiffWithLineNumbers(diff3) {
|
|
|
43988
43690
|
let inFile = false;
|
|
43989
43691
|
let newLine = 0;
|
|
43990
43692
|
return diff3.split("\n").map((line) => {
|
|
43991
|
-
if (
|
|
43693
|
+
if (FILE_HEADER.test(line)) {
|
|
43992
43694
|
inFile = true;
|
|
43993
43695
|
return gutter(null) + line;
|
|
43994
43696
|
}
|
|
43995
|
-
const hunkMatch = line.match(
|
|
43697
|
+
const hunkMatch = line.match(HUNK_HEADER3);
|
|
43996
43698
|
if (hunkMatch) {
|
|
43997
43699
|
newLine = Number(hunkMatch[1]);
|
|
43998
43700
|
return gutter(null) + line;
|
|
@@ -44109,9 +43811,9 @@ function buildReviewPaths(repoRoot2, key) {
|
|
|
44109
43811
|
}
|
|
44110
43812
|
|
|
44111
43813
|
// src/commands/review/fetchExistingComments.ts
|
|
44112
|
-
import { execSync as
|
|
43814
|
+
import { execSync as execSync58 } from "child_process";
|
|
44113
43815
|
function fetchRawComments(org, repo, prNumber) {
|
|
44114
|
-
const out =
|
|
43816
|
+
const out = execSync58(
|
|
44115
43817
|
`gh api --paginate repos/${org}/${repo}/pulls/${prNumber}/comments`,
|
|
44116
43818
|
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
|
|
44117
43819
|
);
|
|
@@ -44174,6 +43876,35 @@ function logPriorComments(count10) {
|
|
|
44174
43876
|
// src/commands/review/gatherContext.ts
|
|
44175
43877
|
import { execSync as execSync61 } from "child_process";
|
|
44176
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
|
+
|
|
44177
43908
|
// src/commands/review/fetchPrDiffInfo.ts
|
|
44178
43909
|
import { execSync as execSync60 } from "child_process";
|
|
44179
43910
|
function getCurrentBranch3() {
|
|
@@ -44189,11 +43920,6 @@ function runGh2(command) {
|
|
|
44189
43920
|
});
|
|
44190
43921
|
}
|
|
44191
43922
|
function fetchRawPr(org, repo, branch2) {
|
|
44192
|
-
const pinned = getPinnedPr();
|
|
44193
|
-
if (pinned !== void 0)
|
|
44194
|
-
return JSON.parse(
|
|
44195
|
-
runGh2(`gh pr view ${pinned} --json ${FIELDS3} -R ${org}/${repo}`)
|
|
44196
|
-
);
|
|
44197
43923
|
const parsed = JSON.parse(
|
|
44198
43924
|
runGh2(
|
|
44199
43925
|
`gh pr list --state open --head ${branch2} --json ${FIELDS3} -R ${org}/${repo}`
|
|
@@ -44268,7 +43994,7 @@ function gatherChangedContext() {
|
|
|
44268
43994
|
}
|
|
44269
43995
|
|
|
44270
43996
|
// src/commands/review/postReviewToPr.ts
|
|
44271
|
-
import { readFileSync as
|
|
43997
|
+
import { readFileSync as readFileSync58 } from "fs";
|
|
44272
43998
|
|
|
44273
43999
|
// src/commands/review/chainAddressComments.ts
|
|
44274
44000
|
function chainAddressComments(prNumber, announce) {
|
|
@@ -44328,6 +44054,13 @@ async function postFindings(findings2) {
|
|
|
44328
44054
|
return { posted, failed: failed3 };
|
|
44329
44055
|
}
|
|
44330
44056
|
|
|
44057
|
+
// src/commands/review/appendCiFooter.ts
|
|
44058
|
+
function appendCiFooter(body, ciFooter) {
|
|
44059
|
+
return ciFooter ? `${body}
|
|
44060
|
+
|
|
44061
|
+
${ciFooter}` : body;
|
|
44062
|
+
}
|
|
44063
|
+
|
|
44331
44064
|
// src/commands/review/buildReviewBody.ts
|
|
44332
44065
|
function buildReviewBody(markdown, unanchored, ciFooter) {
|
|
44333
44066
|
return appendCiFooter(
|
|
@@ -44336,6 +44069,30 @@ function buildReviewBody(markdown, unanchored, ciFooter) {
|
|
|
44336
44069
|
);
|
|
44337
44070
|
}
|
|
44338
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
|
+
|
|
44339
44096
|
// src/commands/review/submitPendingReview.ts
|
|
44340
44097
|
var MUTATION7 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
|
|
44341
44098
|
function submitPendingReview(body) {
|
|
@@ -44397,6 +44154,179 @@ async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
|
|
|
44397
44154
|
return { posted, submitted: false };
|
|
44398
44155
|
}
|
|
44399
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
|
+
|
|
44400
44330
|
// src/commands/review/stillOnReviewedPr.ts
|
|
44401
44331
|
function currentPrNumber() {
|
|
44402
44332
|
try {
|
|
@@ -44450,7 +44380,7 @@ async function confirmPost(prNumber, work, options2) {
|
|
|
44450
44380
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
44451
44381
|
}
|
|
44452
44382
|
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
44453
|
-
const markdown =
|
|
44383
|
+
const markdown = readFileSync58(synthesisPath, "utf8");
|
|
44454
44384
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
44455
44385
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
44456
44386
|
if (inDiff.length === 0 && carried.length === 0)
|
|
@@ -44596,8 +44526,7 @@ function runPostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
44596
44526
|
prompt: options2.prompt ?? true,
|
|
44597
44527
|
submit: options2.submit ?? false,
|
|
44598
44528
|
addressComments: options2.addressComments ?? false,
|
|
44599
|
-
announce: options2.announce ?? false
|
|
44600
|
-
ciFooter: options2.ci?.footer
|
|
44529
|
+
announce: options2.announce ?? false
|
|
44601
44530
|
});
|
|
44602
44531
|
}
|
|
44603
44532
|
|
|
@@ -44608,22 +44537,9 @@ async function reviewPr(repoRoot2, options2) {
|
|
|
44608
44537
|
attachReviewLog(paths.reviewDir);
|
|
44609
44538
|
const outcome = await runReviewPipeline(paths, {
|
|
44610
44539
|
verbose: options2.verbose ?? false,
|
|
44611
|
-
|
|
44612
|
-
|
|
44613
|
-
|
|
44614
|
-
});
|
|
44615
|
-
const synthesisOk = outcome.ok;
|
|
44616
|
-
if (!synthesisOk && options2.ci)
|
|
44617
|
-
exitFailedCiReview(outcome.failures, options2.ci);
|
|
44618
|
-
if (synthesisOk && options2.ci)
|
|
44619
|
-
writeJobSummary(
|
|
44620
|
-
paths.synthesisPath,
|
|
44621
|
-
context,
|
|
44622
|
-
options2.ci.summaryPath,
|
|
44623
|
-
outcome.slots
|
|
44624
|
-
);
|
|
44625
|
-
if (synthesisOk)
|
|
44626
|
-
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);
|
|
44627
44543
|
console.log(`Done. Review folder: ${paths.reviewDir}`);
|
|
44628
44544
|
}
|
|
44629
44545
|
|
|
@@ -44814,11 +44730,11 @@ import path88 from "path";
|
|
|
44814
44730
|
import chalk263 from "chalk";
|
|
44815
44731
|
|
|
44816
44732
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
44817
|
-
import { existsSync as existsSync75, readFileSync as
|
|
44733
|
+
import { existsSync as existsSync75, readFileSync as readFileSync60, writeFileSync as writeFileSync45 } from "fs";
|
|
44818
44734
|
import path87 from "path";
|
|
44819
44735
|
|
|
44820
44736
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
44821
|
-
import { readFileSync as
|
|
44737
|
+
import { readFileSync as readFileSync59 } from "fs";
|
|
44822
44738
|
import path86 from "path";
|
|
44823
44739
|
|
|
44824
44740
|
// src/commands/rules/findClaudeFiles.ts
|
|
@@ -44842,7 +44758,7 @@ function findClaudeFiles(dir) {
|
|
|
44842
44758
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
44843
44759
|
function scopedRuleDirectories(root2) {
|
|
44844
44760
|
return findClaudeFiles(root2).filter(
|
|
44845
|
-
(file) => path86.dirname(file) !== root2 && parseRulesSection(
|
|
44761
|
+
(file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync59(file, "utf8")).length > 0
|
|
44846
44762
|
).map(
|
|
44847
44763
|
(file) => `${path86.relative(root2, path86.dirname(file)).split(path86.sep).join("/")}/`
|
|
44848
44764
|
).sort();
|
|
@@ -44884,7 +44800,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
44884
44800
|
function updateScopedRulesIndex(root2) {
|
|
44885
44801
|
const directories = scopedRuleDirectories(root2);
|
|
44886
44802
|
const rootFile = path87.join(root2, "CLAUDE.md");
|
|
44887
|
-
const before = existsSync75(rootFile) ?
|
|
44803
|
+
const before = existsSync75(rootFile) ? readFileSync60(rootFile, "utf8") : "";
|
|
44888
44804
|
const after = upsertScopedRulesPointer(before, directories);
|
|
44889
44805
|
if (after !== before) writeFileSync45(rootFile, after);
|
|
44890
44806
|
return directories;
|
|
@@ -44937,7 +44853,7 @@ function listRules(target, options2 = {}) {
|
|
|
44937
44853
|
}
|
|
44938
44854
|
|
|
44939
44855
|
// src/commands/rules/addRule.ts
|
|
44940
|
-
import { existsSync as existsSync77, readFileSync as
|
|
44856
|
+
import { existsSync as existsSync77, readFileSync as readFileSync62, writeFileSync as writeFileSync46 } from "fs";
|
|
44941
44857
|
import path91 from "path";
|
|
44942
44858
|
import chalk265 from "chalk";
|
|
44943
44859
|
|
|
@@ -44962,11 +44878,11 @@ function insertRuleBullet(content, rule) {
|
|
|
44962
44878
|
}
|
|
44963
44879
|
|
|
44964
44880
|
// src/commands/rules/nextRuleCode.ts
|
|
44965
|
-
import { readFileSync as
|
|
44881
|
+
import { readFileSync as readFileSync61 } from "fs";
|
|
44966
44882
|
var CODE_PREFIX = "R";
|
|
44967
44883
|
function nextRuleCode(root2) {
|
|
44968
44884
|
const numbers = findClaudeFiles(root2).flatMap(
|
|
44969
|
-
(file) => parseRulesSection(
|
|
44885
|
+
(file) => parseRulesSection(readFileSync61(file, "utf8")).map(
|
|
44970
44886
|
(rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
|
|
44971
44887
|
)
|
|
44972
44888
|
);
|
|
@@ -44993,7 +44909,7 @@ function resolveRuleScope(target) {
|
|
|
44993
44909
|
|
|
44994
44910
|
// src/commands/rules/addRule.ts
|
|
44995
44911
|
function read3(file) {
|
|
44996
|
-
return existsSync77(file) ?
|
|
44912
|
+
return existsSync77(file) ? readFileSync62(file, "utf8") : "";
|
|
44997
44913
|
}
|
|
44998
44914
|
function addRule(text20, options2) {
|
|
44999
44915
|
const rule = text20.trim();
|
|
@@ -45223,12 +45139,12 @@ function mapDataToEvents(data) {
|
|
|
45223
45139
|
const levelIdx = col("Level");
|
|
45224
45140
|
const exIdx = col("Exception");
|
|
45225
45141
|
const msgIdx = col("Message");
|
|
45226
|
-
return data.Rows.map((
|
|
45227
|
-
Timestamp: ticksToIso(
|
|
45228
|
-
Level: String(
|
|
45229
|
-
Exception:
|
|
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,
|
|
45230
45146
|
Properties: [],
|
|
45231
|
-
MessageTemplateTokens: [{ Text: String(
|
|
45147
|
+
MessageTemplateTokens: [{ Text: String(row2[msgIdx] ?? "") }]
|
|
45232
45148
|
}));
|
|
45233
45149
|
}
|
|
45234
45150
|
|
|
@@ -45516,7 +45432,7 @@ function findShownSessionFiles(body, writtenPaths, locations) {
|
|
|
45516
45432
|
}
|
|
45517
45433
|
|
|
45518
45434
|
// src/commands/show/sessionWrittenPaths.ts
|
|
45519
|
-
import { readFileSync as
|
|
45435
|
+
import { readFileSync as readFileSync63 } from "fs";
|
|
45520
45436
|
|
|
45521
45437
|
// src/commands/sessions/shared/asRecord.ts
|
|
45522
45438
|
function asRecord(value) {
|
|
@@ -45544,7 +45460,7 @@ function writtenFilePaths(entry) {
|
|
|
45544
45460
|
function sessionWrittenPaths(transcriptPath2) {
|
|
45545
45461
|
let text20;
|
|
45546
45462
|
try {
|
|
45547
|
-
text20 =
|
|
45463
|
+
text20 = readFileSync63(transcriptPath2, "utf8");
|
|
45548
45464
|
} catch {
|
|
45549
45465
|
return [];
|
|
45550
45466
|
}
|
|
@@ -45663,12 +45579,12 @@ import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync48 } from "fs";
|
|
|
45663
45579
|
import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync47 } from "fs";
|
|
45664
45580
|
|
|
45665
45581
|
// src/commands/slack/readSlackParts.ts
|
|
45666
|
-
import { readFileSync as
|
|
45582
|
+
import { readFileSync as readFileSync64 } from "fs";
|
|
45667
45583
|
function readSlackParts(files) {
|
|
45668
45584
|
return files.map((file) => {
|
|
45669
45585
|
let contents;
|
|
45670
45586
|
try {
|
|
45671
|
-
contents =
|
|
45587
|
+
contents = readFileSync64(file, "utf8");
|
|
45672
45588
|
} catch {
|
|
45673
45589
|
console.error(`Error: Part file not found: ${file}`);
|
|
45674
45590
|
process.exit(1);
|
|
@@ -45888,8 +45804,8 @@ function printTable(rows) {
|
|
|
45888
45804
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
45889
45805
|
console.log(chalk276.dim(header));
|
|
45890
45806
|
console.log(chalk276.dim("-".repeat(header.length)));
|
|
45891
|
-
for (const
|
|
45892
|
-
const line = columns.map((c, i) => formatCell(
|
|
45807
|
+
for (const row2 of rows) {
|
|
45808
|
+
const line = columns.map((c, i) => formatCell(row2[c]).padEnd(widths[i])).join(" ");
|
|
45893
45809
|
console.log(line);
|
|
45894
45810
|
}
|
|
45895
45811
|
console.log(chalk276.dim(`
|
|
@@ -46328,13 +46244,13 @@ function syncCodexHooks(sourcePath) {
|
|
|
46328
46244
|
// src/commands/sync/syncCodex.ts
|
|
46329
46245
|
function syncCodex(claudeDir, options2) {
|
|
46330
46246
|
if (!isHarnessAvailable("codex")) return;
|
|
46331
|
-
const { total:
|
|
46247
|
+
const { total: total2, names } = installHarnessCommands(
|
|
46332
46248
|
claudeDir,
|
|
46333
46249
|
harnesses.codex,
|
|
46334
46250
|
commandToSkill
|
|
46335
46251
|
);
|
|
46336
46252
|
syncCodexHooks(path98.join(claudeDir, "..", "codex", "config.toml"));
|
|
46337
|
-
console.log(`Synced ${
|
|
46253
|
+
console.log(`Synced ${total2} skill(s) to ~/.codex/skills`);
|
|
46338
46254
|
if (!options2?.prune) return;
|
|
46339
46255
|
const force = options2.force ?? false;
|
|
46340
46256
|
reportPrune(
|
|
@@ -46782,9 +46698,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
46782
46698
|
}
|
|
46783
46699
|
|
|
46784
46700
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
46785
|
-
import { readFileSync as
|
|
46701
|
+
import { readFileSync as readFileSync69 } from "fs";
|
|
46786
46702
|
function readCleanedCues(inputPath) {
|
|
46787
|
-
return deduplicateCues(parseVtt(
|
|
46703
|
+
return deduplicateCues(parseVtt(readFileSync69(inputPath, "utf8")));
|
|
46788
46704
|
}
|
|
46789
46705
|
|
|
46790
46706
|
// src/commands/transcript/clean.ts
|
|
@@ -46792,21 +46708,21 @@ var FORMATS = ["md", "vtt"];
|
|
|
46792
46708
|
function isCleanFormat(value) {
|
|
46793
46709
|
return FORMATS.includes(value);
|
|
46794
46710
|
}
|
|
46795
|
-
function serialise(cues,
|
|
46796
|
-
return
|
|
46711
|
+
function serialise(cues, format2, timestamps) {
|
|
46712
|
+
return format2 === "vtt" ? formatVtt(cues) : formatChatLog(cuesToChatMessages(cues), { timestamps });
|
|
46797
46713
|
}
|
|
46798
46714
|
function clean(file, options2 = {}) {
|
|
46799
|
-
const
|
|
46800
|
-
if (!isCleanFormat(
|
|
46715
|
+
const format2 = options2.format ?? "md";
|
|
46716
|
+
if (!isCleanFormat(format2)) {
|
|
46801
46717
|
console.error(
|
|
46802
|
-
`Error: --format must be one of: ${FORMATS.join(", ")} (got: ${
|
|
46718
|
+
`Error: --format must be one of: ${FORMATS.join(", ")} (got: ${format2})`
|
|
46803
46719
|
);
|
|
46804
46720
|
process.exit(1);
|
|
46805
46721
|
}
|
|
46806
46722
|
const timestamps = options2.timestamps ?? false;
|
|
46807
|
-
if (timestamps &&
|
|
46723
|
+
if (timestamps && format2 !== "md") {
|
|
46808
46724
|
console.error(
|
|
46809
|
-
`Error: --timestamps applies only to --format md (got: ${
|
|
46725
|
+
`Error: --timestamps applies only to --format md (got: ${format2})`
|
|
46810
46726
|
);
|
|
46811
46727
|
process.exit(1);
|
|
46812
46728
|
}
|
|
@@ -46819,7 +46735,7 @@ function clean(file, options2 = {}) {
|
|
|
46819
46735
|
console.error(`Error: no cues found in: ${file}`);
|
|
46820
46736
|
process.exit(1);
|
|
46821
46737
|
}
|
|
46822
|
-
console.log(serialise(cues,
|
|
46738
|
+
console.log(serialise(cues, format2, timestamps));
|
|
46823
46739
|
}
|
|
46824
46740
|
|
|
46825
46741
|
// src/commands/transcript/shared.ts
|
|
@@ -47564,7 +47480,7 @@ function configKeys2() {
|
|
|
47564
47480
|
}
|
|
47565
47481
|
|
|
47566
47482
|
// src/commands/verify/forbiddenStrings.ts
|
|
47567
|
-
import { existsSync as existsSync86, readFileSync as
|
|
47483
|
+
import { existsSync as existsSync86, readFileSync as readFileSync70 } from "fs";
|
|
47568
47484
|
|
|
47569
47485
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
47570
47486
|
import { minimatch as minimatch10 } from "minimatch";
|
|
@@ -47611,7 +47527,7 @@ function forbiddenStrings() {
|
|
|
47611
47527
|
}
|
|
47612
47528
|
let parsed;
|
|
47613
47529
|
try {
|
|
47614
|
-
parsed = JSON.parse(
|
|
47530
|
+
parsed = JSON.parse(readFileSync70(file, "utf8"));
|
|
47615
47531
|
} catch (error) {
|
|
47616
47532
|
console.log(`Could not parse ${file}: ${error.message}`);
|
|
47617
47533
|
process.exit(1);
|
|
@@ -47683,7 +47599,7 @@ Total: ${lines2.length} hardcoded color(s)`);
|
|
|
47683
47599
|
}
|
|
47684
47600
|
|
|
47685
47601
|
// src/commands/verify/migrations.ts
|
|
47686
|
-
import { readFileSync as
|
|
47602
|
+
import { readFileSync as readFileSync71 } from "fs";
|
|
47687
47603
|
import path105 from "path";
|
|
47688
47604
|
|
|
47689
47605
|
// src/commands/verify/migrations/checkAppendOnly.ts
|
|
@@ -47848,7 +47764,7 @@ function migrations2() {
|
|
|
47848
47764
|
if (ref) {
|
|
47849
47765
|
const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
|
|
47850
47766
|
const current2 = new Map(
|
|
47851
|
-
files.map((file) => [file,
|
|
47767
|
+
files.map((file) => [file, readFileSync71(path105.join(dir, file), "utf8")])
|
|
47852
47768
|
);
|
|
47853
47769
|
for (const finding of checkAppendOnly(baseline, current2)) {
|
|
47854
47770
|
problems.push(
|
|
@@ -48806,7 +48722,7 @@ function registerWatch(program) {
|
|
|
48806
48722
|
|
|
48807
48723
|
// src/commands/roam/postRoamActivity.ts
|
|
48808
48724
|
import { execFileSync as execFileSync31 } from "child_process";
|
|
48809
|
-
import { readdirSync as readdirSync26, readFileSync as
|
|
48725
|
+
import { readdirSync as readdirSync26, readFileSync as readFileSync72, statSync as statSync14 } from "fs";
|
|
48810
48726
|
import { join as join109 } from "path";
|
|
48811
48727
|
function findPortFile(roamDir) {
|
|
48812
48728
|
let entries;
|
|
@@ -48837,7 +48753,7 @@ function postRoamActivity(app, event) {
|
|
|
48837
48753
|
if (!portFile) return;
|
|
48838
48754
|
let port;
|
|
48839
48755
|
try {
|
|
48840
|
-
port =
|
|
48756
|
+
port = readFileSync72(portFile, "utf8").trim();
|
|
48841
48757
|
} catch {
|
|
48842
48758
|
return;
|
|
48843
48759
|
}
|
|
@@ -49458,11 +49374,11 @@ function applyLine(result, pending, line) {
|
|
|
49458
49374
|
}
|
|
49459
49375
|
|
|
49460
49376
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
49461
|
-
import { readFileSync as
|
|
49377
|
+
import { readFileSync as readFileSync73 } from "fs";
|
|
49462
49378
|
function readDaemonPidFile() {
|
|
49463
49379
|
try {
|
|
49464
49380
|
const pid = Number.parseInt(
|
|
49465
|
-
|
|
49381
|
+
readFileSync73(daemonPaths.pid, "utf8").trim(),
|
|
49466
49382
|
10
|
|
49467
49383
|
);
|
|
49468
49384
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -49681,8 +49597,8 @@ function createActivityThrottle(onActivity) {
|
|
|
49681
49597
|
import { eq as eq57 } from "drizzle-orm";
|
|
49682
49598
|
var INBOX_LAST_RUN_KEY = "inbox.lastRun";
|
|
49683
49599
|
async function readInboxLastRun(orm) {
|
|
49684
|
-
const [
|
|
49685
|
-
return
|
|
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;
|
|
49686
49602
|
}
|
|
49687
49603
|
|
|
49688
49604
|
// src/commands/sessions/daemon/inbox/loadScanRun.ts
|
|
@@ -50305,7 +50221,7 @@ function sendResizeSnapshot(s, send) {
|
|
|
50305
50221
|
}
|
|
50306
50222
|
|
|
50307
50223
|
// src/commands/sessions/daemon/viewerSize.ts
|
|
50308
|
-
import { readFileSync as
|
|
50224
|
+
import { readFileSync as readFileSync74, writeFileSync as writeFileSync59 } from "fs";
|
|
50309
50225
|
var DEFAULT_SIZE = { cols: 120, rows: 30 };
|
|
50310
50226
|
var remembered;
|
|
50311
50227
|
function rememberViewerSize(cols, rows) {
|
|
@@ -50327,7 +50243,7 @@ function viewerSize() {
|
|
|
50327
50243
|
function readSavedSize() {
|
|
50328
50244
|
try {
|
|
50329
50245
|
const { cols, rows } = JSON.parse(
|
|
50330
|
-
|
|
50246
|
+
readFileSync74(daemonPaths.viewerSize, "utf8")
|
|
50331
50247
|
);
|
|
50332
50248
|
if (typeof cols === "number" && typeof rows === "number" && cols > 0)
|
|
50333
50249
|
return { cols, rows };
|
|
@@ -51205,14 +51121,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
|
|
|
51205
51121
|
}
|
|
51206
51122
|
|
|
51207
51123
|
// src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
|
|
51208
|
-
import { readFileSync as
|
|
51124
|
+
import { readFileSync as readFileSync75, writeFileSync as writeFileSync61 } from "fs";
|
|
51209
51125
|
var KEEP_TAIL = 256 * 1024;
|
|
51210
51126
|
var MAX_LOG_SIZE = 4 * 1024 * 1024;
|
|
51211
51127
|
function trimWatcherLog(cwd) {
|
|
51212
51128
|
const path109 = watcherLogPath(cwd);
|
|
51213
51129
|
let log2;
|
|
51214
51130
|
try {
|
|
51215
|
-
log2 =
|
|
51131
|
+
log2 = readFileSync75(path109, "utf8");
|
|
51216
51132
|
} catch {
|
|
51217
51133
|
return;
|
|
51218
51134
|
}
|
|
@@ -51222,13 +51138,13 @@ function trimWatcherLog(cwd) {
|
|
|
51222
51138
|
}
|
|
51223
51139
|
|
|
51224
51140
|
// src/commands/sessions/daemon/worktree/appendWatcherLog.ts
|
|
51225
|
-
import { appendFileSync as
|
|
51141
|
+
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "fs";
|
|
51226
51142
|
import { dirname as dirname50 } from "path";
|
|
51227
51143
|
function appendWatcherLog(cwd, data) {
|
|
51228
51144
|
try {
|
|
51229
51145
|
const path109 = watcherLogPath(cwd);
|
|
51230
51146
|
mkdirSync41(dirname50(path109), { recursive: true });
|
|
51231
|
-
|
|
51147
|
+
appendFileSync4(path109, data);
|
|
51232
51148
|
} catch {
|
|
51233
51149
|
}
|
|
51234
51150
|
}
|
|
@@ -52035,7 +51951,7 @@ function pidList(pids) {
|
|
|
52035
51951
|
}
|
|
52036
51952
|
|
|
52037
51953
|
// src/commands/sessions/daemon/worktree/readOccupant.ts
|
|
52038
|
-
import { readFileSync as
|
|
51954
|
+
import { readFileSync as readFileSync76 } from "fs";
|
|
52039
51955
|
var VSCODE_PATHS = [
|
|
52040
51956
|
"/.vscode-server/",
|
|
52041
51957
|
"/.vscode-server-insiders/",
|
|
@@ -52070,7 +51986,7 @@ function parentPid(stat5) {
|
|
|
52070
51986
|
}
|
|
52071
51987
|
function readProc(procRoot, pid, file) {
|
|
52072
51988
|
try {
|
|
52073
|
-
return
|
|
51989
|
+
return readFileSync76(`${procRoot}/${pid}/${file}`, "utf8");
|
|
52074
51990
|
} catch {
|
|
52075
51991
|
return void 0;
|
|
52076
51992
|
}
|
|
@@ -52924,10 +52840,10 @@ function applyReviewPause(session, activity2) {
|
|
|
52924
52840
|
// src/shared/db/getPhaseActiveMs.ts
|
|
52925
52841
|
import { and as and26, eq as eq58 } from "drizzle-orm";
|
|
52926
52842
|
async function getPhaseActiveMs(db, itemId2, phaseIdx) {
|
|
52927
|
-
const [
|
|
52843
|
+
const [row2] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
|
|
52928
52844
|
and26(eq58(phaseUsage.itemId, itemId2), eq58(phaseUsage.phaseIdx, phaseIdx))
|
|
52929
52845
|
);
|
|
52930
|
-
return
|
|
52846
|
+
return row2?.activeMs ?? 0;
|
|
52931
52847
|
}
|
|
52932
52848
|
|
|
52933
52849
|
// src/commands/sessions/daemon/loadPhaseActiveMs.ts
|
|
@@ -58277,7 +58193,7 @@ function handleConnection(socket, manager) {
|
|
|
58277
58193
|
import { unlinkSync as unlinkSync21, writeFileSync as writeFileSync63 } from "fs";
|
|
58278
58194
|
|
|
58279
58195
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
58280
|
-
import { readFileSync as
|
|
58196
|
+
import { readFileSync as readFileSync77 } from "fs";
|
|
58281
58197
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
58282
58198
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
58283
58199
|
const timer = setInterval(() => {
|
|
@@ -58288,7 +58204,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
58288
58204
|
}
|
|
58289
58205
|
function ownsPidFile() {
|
|
58290
58206
|
try {
|
|
58291
|
-
return
|
|
58207
|
+
return readFileSync77(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
58292
58208
|
} catch {
|
|
58293
58209
|
return false;
|
|
58294
58210
|
}
|