@staff0rd/assist 0.842.0 → 0.844.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.844.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -2153,19 +2153,19 @@ function printMeasureTable(records, totalMs) {
|
|
|
2153
2153
|
const nameWidth = Math.max(
|
|
2154
2154
|
"Command".length,
|
|
2155
2155
|
"TOTAL".length,
|
|
2156
|
-
...rows.map((
|
|
2156
|
+
...rows.map((row3) => row3.name.length)
|
|
2157
2157
|
);
|
|
2158
2158
|
const durationWidth = Math.max(
|
|
2159
2159
|
"Duration".length,
|
|
2160
2160
|
formatDuration(totalMs).length,
|
|
2161
|
-
...rows.map((
|
|
2161
|
+
...rows.map((row3) => row3.duration.length)
|
|
2162
2162
|
);
|
|
2163
2163
|
const line = (status2, name, duration) => ` ${status2.padEnd(6)} ${name.padEnd(nameWidth)} ${duration.padStart(durationWidth)}`;
|
|
2164
2164
|
const separator = ` ${" ".repeat(6)} ${"\u2500".repeat(nameWidth)} ${"\u2500".repeat(durationWidth)}`;
|
|
2165
2165
|
console.log();
|
|
2166
2166
|
console.log(line("Status", "Command", "Duration"));
|
|
2167
|
-
for (const
|
|
2168
|
-
console.log(line(
|
|
2167
|
+
for (const row3 of rows) {
|
|
2168
|
+
console.log(line(row3.status, row3.name, row3.duration));
|
|
2169
2169
|
}
|
|
2170
2170
|
console.log(separator);
|
|
2171
2171
|
console.log(line("", "TOTAL", formatDuration(totalMs)));
|
|
@@ -2864,17 +2864,17 @@ async function activity(options2) {
|
|
|
2864
2864
|
console.log("Not enough data points to chart.");
|
|
2865
2865
|
return;
|
|
2866
2866
|
}
|
|
2867
|
-
const
|
|
2867
|
+
const total2 = data.reduce((sum3, d) => sum3 + d.count, 0);
|
|
2868
2868
|
const activeDays = data.filter((d) => d.count > 0).length;
|
|
2869
|
-
console.log(`${
|
|
2869
|
+
console.log(`${total2} commits across ${activeDays} active days.`);
|
|
2870
2870
|
const weekly = /* @__PURE__ */ new Map();
|
|
2871
|
-
for (const { date, count:
|
|
2871
|
+
for (const { date, count: count9 } of data) {
|
|
2872
2872
|
const d = new Date(date);
|
|
2873
2873
|
d.setDate(d.getDate() - d.getDay());
|
|
2874
2874
|
const weekStart = d.toISOString().slice(0, 10);
|
|
2875
|
-
weekly.set(weekStart, (weekly.get(weekStart) ?? 0) +
|
|
2875
|
+
weekly.set(weekStart, (weekly.get(weekStart) ?? 0) + count9);
|
|
2876
2876
|
}
|
|
2877
|
-
const weeklyData = [...weekly.entries()].map(([date,
|
|
2877
|
+
const weeklyData = [...weekly.entries()].map(([date, count9]) => ({ date, count: count9 })).sort((a, b) => a.date.localeCompare(b.date));
|
|
2878
2878
|
const until = data[data.length - 1].date;
|
|
2879
2879
|
renderLineChart({
|
|
2880
2880
|
title: "Commit Activity",
|
|
@@ -4171,7 +4171,7 @@ async function readAppliedIds(exec3) {
|
|
|
4171
4171
|
const rows = await exec3.query(
|
|
4172
4172
|
`SELECT id FROM ${APPLIED_MIGRATIONS_TABLE} ORDER BY id`
|
|
4173
4173
|
);
|
|
4174
|
-
return new Set(rows.map((
|
|
4174
|
+
return new Set(rows.map((row3) => Number(row3.id)));
|
|
4175
4175
|
}
|
|
4176
4176
|
async function applyMigrations(exec3) {
|
|
4177
4177
|
await exec3.exec(CREATE_APPLIED_MIGRATIONS);
|
|
@@ -4212,7 +4212,7 @@ async function readAppliedIds2(exec3) {
|
|
|
4212
4212
|
const rows = await exec3.query(
|
|
4213
4213
|
`SELECT id FROM ${APPLIED_MIGRATIONS_TABLE} ORDER BY id`
|
|
4214
4214
|
);
|
|
4215
|
-
return rows.map((
|
|
4215
|
+
return rows.map((row3) => Number(row3.id));
|
|
4216
4216
|
}
|
|
4217
4217
|
async function getMigrationStatus(exec3) {
|
|
4218
4218
|
return compareMigrations(await readAppliedIds2(exec3));
|
|
@@ -5116,9 +5116,9 @@ function itemColumns(item, origin) {
|
|
|
5116
5116
|
|
|
5117
5117
|
// src/commands/backlog/insertItem.ts
|
|
5118
5118
|
async function insertItem(db, item, origin) {
|
|
5119
|
-
const [
|
|
5120
|
-
if (!
|
|
5121
|
-
return
|
|
5119
|
+
const [row3] = await db.insert(items).values(itemColumns(item, origin)).returning({ id: items.id });
|
|
5120
|
+
if (!row3) throw new Error("Failed to insert backlog item");
|
|
5121
|
+
return row3.id;
|
|
5122
5122
|
}
|
|
5123
5123
|
|
|
5124
5124
|
// src/commands/backlog/insertPlan.ts
|
|
@@ -5223,10 +5223,10 @@ import { asc as asc3, eq as eq3 } from "drizzle-orm";
|
|
|
5223
5223
|
// src/commands/backlog/groupByItem.ts
|
|
5224
5224
|
function groupByItem(rows) {
|
|
5225
5225
|
const map = /* @__PURE__ */ new Map();
|
|
5226
|
-
for (const
|
|
5227
|
-
const bucket = map.get(
|
|
5228
|
-
if (bucket) bucket.push(
|
|
5229
|
-
else map.set(
|
|
5226
|
+
for (const row3 of rows) {
|
|
5227
|
+
const bucket = map.get(row3.itemId);
|
|
5228
|
+
if (bucket) bucket.push(row3);
|
|
5229
|
+
else map.set(row3.itemId, [row3]);
|
|
5230
5230
|
}
|
|
5231
5231
|
return map;
|
|
5232
5232
|
}
|
|
@@ -5342,11 +5342,11 @@ function attachSubtasks(item, rel, id) {
|
|
|
5342
5342
|
// src/commands/backlog/sumPhaseUsage.ts
|
|
5343
5343
|
function sumPhaseUsage(usage) {
|
|
5344
5344
|
return usage.reduce(
|
|
5345
|
-
(
|
|
5346
|
-
tokensUp:
|
|
5347
|
-
tokensDown:
|
|
5348
|
-
activeMs:
|
|
5349
|
-
peakContextPct: Math.max(
|
|
5345
|
+
(total2, u) => ({
|
|
5346
|
+
tokensUp: total2.tokensUp + u.tokensUp,
|
|
5347
|
+
tokensDown: total2.tokensDown + u.tokensDown,
|
|
5348
|
+
activeMs: total2.activeMs + u.activeMs,
|
|
5349
|
+
peakContextPct: Math.max(total2.peakContextPct, u.peakContextPct)
|
|
5350
5350
|
}),
|
|
5351
5351
|
{ tokensUp: 0, tokensDown: 0, activeMs: 0, peakContextPct: 0 }
|
|
5352
5352
|
);
|
|
@@ -5407,23 +5407,23 @@ function rowToComment(c) {
|
|
|
5407
5407
|
function rowToLink(l) {
|
|
5408
5408
|
return { type: l.type, targetId: l.targetId };
|
|
5409
5409
|
}
|
|
5410
|
-
function assignOptionalColumns(item,
|
|
5411
|
-
if (
|
|
5412
|
-
if (
|
|
5413
|
-
if (
|
|
5414
|
-
if (
|
|
5410
|
+
function assignOptionalColumns(item, row3) {
|
|
5411
|
+
if (row3.description != null) item.description = row3.description;
|
|
5412
|
+
if (row3.currentPhase != null) item.currentPhase = row3.currentPhase;
|
|
5413
|
+
if (row3.jiraKey != null) item.jiraKey = row3.jiraKey;
|
|
5414
|
+
if (row3.githubIssue != null) item.githubIssue = row3.githubIssue;
|
|
5415
5415
|
}
|
|
5416
|
-
function baseItem(
|
|
5416
|
+
function baseItem(row3) {
|
|
5417
5417
|
const item = {
|
|
5418
|
-
id:
|
|
5419
|
-
type:
|
|
5420
|
-
name:
|
|
5421
|
-
acceptanceCriteria: JSON.parse(
|
|
5422
|
-
status:
|
|
5423
|
-
starred:
|
|
5424
|
-
origin:
|
|
5425
|
-
};
|
|
5426
|
-
assignOptionalColumns(item,
|
|
5418
|
+
id: row3.id,
|
|
5419
|
+
type: row3.type,
|
|
5420
|
+
name: row3.name,
|
|
5421
|
+
acceptanceCriteria: JSON.parse(row3.acceptanceCriteria),
|
|
5422
|
+
status: row3.status,
|
|
5423
|
+
starred: row3.starred,
|
|
5424
|
+
origin: row3.origin
|
|
5425
|
+
};
|
|
5426
|
+
assignOptionalColumns(item, row3);
|
|
5427
5427
|
return item;
|
|
5428
5428
|
}
|
|
5429
5429
|
function attachComments(item, rel, id) {
|
|
@@ -5438,15 +5438,15 @@ function attachPlan(item, rel, id) {
|
|
|
5438
5438
|
const phases = rel.phases.get(id) ?? [];
|
|
5439
5439
|
if (phases.length > 0) item.plan = buildPlan(phases, rel.tasks.get(id) ?? []);
|
|
5440
5440
|
}
|
|
5441
|
-
function rowToItem(
|
|
5442
|
-
const item = baseItem(
|
|
5443
|
-
attachComments(item, rel,
|
|
5444
|
-
attachSubtasks(item, rel,
|
|
5445
|
-
attachLinks(item, rel,
|
|
5446
|
-
attachPlan(item, rel,
|
|
5447
|
-
attachUsage(item, rel,
|
|
5448
|
-
attachSessions(item, rel,
|
|
5449
|
-
attachGitRefs(item, rel,
|
|
5441
|
+
function rowToItem(row3, rel) {
|
|
5442
|
+
const item = baseItem(row3);
|
|
5443
|
+
attachComments(item, rel, row3.id);
|
|
5444
|
+
attachSubtasks(item, rel, row3.id);
|
|
5445
|
+
attachLinks(item, rel, row3.id);
|
|
5446
|
+
attachPlan(item, rel, row3.id);
|
|
5447
|
+
attachUsage(item, rel, row3.id);
|
|
5448
|
+
attachSessions(item, rel, row3.id);
|
|
5449
|
+
attachGitRefs(item, rel, row3.id);
|
|
5450
5450
|
return item;
|
|
5451
5451
|
}
|
|
5452
5452
|
|
|
@@ -5459,7 +5459,7 @@ async function loadAllItems(orm, origin) {
|
|
|
5459
5459
|
rows.map((r) => r.id),
|
|
5460
5460
|
{ includeComments: false, includeTasks: false, includeSubtasks: false }
|
|
5461
5461
|
);
|
|
5462
|
-
return rows.map((
|
|
5462
|
+
return rows.map((row3) => rowToItem(row3, rel));
|
|
5463
5463
|
}
|
|
5464
5464
|
|
|
5465
5465
|
// src/commands/backlog/parseBacklogJsonl.ts
|
|
@@ -5614,8 +5614,8 @@ async function ensureMigrated(orm, dir, origin) {
|
|
|
5614
5614
|
// src/commands/backlog/deleteItem.ts
|
|
5615
5615
|
import { eq as eq4 } from "drizzle-orm";
|
|
5616
5616
|
async function deleteItem(orm, id) {
|
|
5617
|
-
const [
|
|
5618
|
-
return
|
|
5617
|
+
const [row3] = await orm.delete(items).where(eq4(items.id, id)).returning({ name: items.name });
|
|
5618
|
+
return row3?.name;
|
|
5619
5619
|
}
|
|
5620
5620
|
|
|
5621
5621
|
// src/commands/backlog/findBacklogUp.ts
|
|
@@ -5640,13 +5640,13 @@ function findBacklogUp(startDir) {
|
|
|
5640
5640
|
// src/commands/backlog/loadItem.ts
|
|
5641
5641
|
import { eq as eq5 } from "drizzle-orm";
|
|
5642
5642
|
async function loadItem(orm, id) {
|
|
5643
|
-
const [
|
|
5644
|
-
if (!
|
|
5643
|
+
const [row3] = await orm.select().from(items).where(eq5(items.id, id));
|
|
5644
|
+
if (!row3) return void 0;
|
|
5645
5645
|
const rel = await loadRelations(orm, [id], {
|
|
5646
5646
|
includeUsage: true,
|
|
5647
5647
|
includeGitRefs: true
|
|
5648
5648
|
});
|
|
5649
|
-
return rowToItem(
|
|
5649
|
+
return rowToItem(row3, rel);
|
|
5650
5650
|
}
|
|
5651
5651
|
|
|
5652
5652
|
// src/commands/backlog/saveAllItems.ts
|
|
@@ -5706,8 +5706,8 @@ async function updateCurrentPhase(orm, id, phase) {
|
|
|
5706
5706
|
// src/commands/backlog/updateStatus.ts
|
|
5707
5707
|
import { eq as eq10 } from "drizzle-orm";
|
|
5708
5708
|
async function updateStatus(orm, id, status2) {
|
|
5709
|
-
const [
|
|
5710
|
-
return
|
|
5709
|
+
const [row3] = await orm.update(items).set({ status: status2 }).where(eq10(items.id, id)).returning({ name: items.name });
|
|
5710
|
+
return row3?.name;
|
|
5711
5711
|
}
|
|
5712
5712
|
|
|
5713
5713
|
// src/commands/backlog/shared.ts
|
|
@@ -6238,9 +6238,9 @@ import chalk43 from "chalk";
|
|
|
6238
6238
|
// src/commands/backlog/deleteComment.ts
|
|
6239
6239
|
import { and as and4, eq as eq14 } from "drizzle-orm";
|
|
6240
6240
|
async function deleteComment(orm, itemId2, commentId) {
|
|
6241
|
-
const [
|
|
6242
|
-
if (!
|
|
6243
|
-
if (
|
|
6241
|
+
const [row3] = await orm.select({ type: comments.type }).from(comments).where(and4(eq14(comments.id, commentId), eq14(comments.itemId, itemId2)));
|
|
6242
|
+
if (!row3) return "not-found";
|
|
6243
|
+
if (row3.type === "summary") return "is-summary";
|
|
6244
6244
|
await orm.delete(comments).where(and4(eq14(comments.id, commentId), eq14(comments.itemId, itemId2)));
|
|
6245
6245
|
return "deleted";
|
|
6246
6246
|
}
|
|
@@ -6421,10 +6421,10 @@ var IDENTITY_SQL = `
|
|
|
6421
6421
|
`;
|
|
6422
6422
|
async function introspectIdentityColumns(client) {
|
|
6423
6423
|
const { rows } = await client.query(IDENTITY_SQL);
|
|
6424
|
-
return rows.map((
|
|
6425
|
-
table:
|
|
6426
|
-
column:
|
|
6427
|
-
rawColumn:
|
|
6424
|
+
return rows.map((row3) => ({
|
|
6425
|
+
table: row3.table,
|
|
6426
|
+
column: row3.column,
|
|
6427
|
+
rawColumn: row3.raw_column
|
|
6428
6428
|
}));
|
|
6429
6429
|
}
|
|
6430
6430
|
function resyncIdentitySql(col) {
|
|
@@ -6478,10 +6478,10 @@ async function importBacklog(file, options2 = {}) {
|
|
|
6478
6478
|
return;
|
|
6479
6479
|
}
|
|
6480
6480
|
await restore(client, parsed);
|
|
6481
|
-
const
|
|
6481
|
+
const total2 = incoming.reduce((sum3, n) => sum3 + n, 0);
|
|
6482
6482
|
console.error(
|
|
6483
6483
|
chalk45.green(
|
|
6484
|
-
`Imported backlog: ${
|
|
6484
|
+
`Imported backlog: ${total2} rows restored across ${tables.length} tables.`
|
|
6485
6485
|
)
|
|
6486
6486
|
);
|
|
6487
6487
|
});
|
|
@@ -6700,8 +6700,8 @@ import chalk49 from "chalk";
|
|
|
6700
6700
|
import chalk48 from "chalk";
|
|
6701
6701
|
import { count, eq as eq17 } from "drizzle-orm";
|
|
6702
6702
|
async function resolveInsertPosition(orm, itemId2, position) {
|
|
6703
|
-
const [
|
|
6704
|
-
const phaseCount =
|
|
6703
|
+
const [row3] = await orm.select({ cnt: count() }).from(planPhases).where(eq17(planPhases.itemId, itemId2));
|
|
6704
|
+
const phaseCount = row3?.cnt ?? 0;
|
|
6705
6705
|
if (position === void 0) return phaseCount;
|
|
6706
6706
|
const pos = Number.parseInt(position, 10);
|
|
6707
6707
|
if (pos < 1 || pos > phaseCount + 1) {
|
|
@@ -9743,24 +9743,24 @@ function phaseUsageTotals(orm) {
|
|
|
9743
9743
|
}
|
|
9744
9744
|
|
|
9745
9745
|
// src/commands/backlog/rowToItemSummary.ts
|
|
9746
|
-
function rowToItemSummary(
|
|
9746
|
+
function rowToItemSummary(row3) {
|
|
9747
9747
|
return {
|
|
9748
|
-
id:
|
|
9749
|
-
origin:
|
|
9750
|
-
type:
|
|
9751
|
-
name:
|
|
9752
|
-
status:
|
|
9753
|
-
starred:
|
|
9754
|
-
jiraKey:
|
|
9755
|
-
githubIssue:
|
|
9756
|
-
currentPhase:
|
|
9757
|
-
totalPhases: (
|
|
9758
|
-
incompleteSubtasks:
|
|
9759
|
-
usageTotal:
|
|
9760
|
-
tokensUp: Number(
|
|
9761
|
-
tokensDown: Number(
|
|
9762
|
-
activeMs: Number(
|
|
9763
|
-
peakContextPct: Number(
|
|
9748
|
+
id: row3.id,
|
|
9749
|
+
origin: row3.origin,
|
|
9750
|
+
type: row3.type,
|
|
9751
|
+
name: row3.name,
|
|
9752
|
+
status: row3.status,
|
|
9753
|
+
starred: row3.starred,
|
|
9754
|
+
jiraKey: row3.jiraKey ?? void 0,
|
|
9755
|
+
githubIssue: row3.githubIssue ?? void 0,
|
|
9756
|
+
currentPhase: row3.currentPhase ?? void 0,
|
|
9757
|
+
totalPhases: (row3.planPhaseCount || 1) + 1,
|
|
9758
|
+
incompleteSubtasks: row3.incompleteSubtasks ?? 0,
|
|
9759
|
+
usageTotal: row3.tokensUp == null ? void 0 : {
|
|
9760
|
+
tokensUp: Number(row3.tokensUp),
|
|
9761
|
+
tokensDown: Number(row3.tokensDown),
|
|
9762
|
+
activeMs: Number(row3.activeMs),
|
|
9763
|
+
peakContextPct: Number(row3.peakContextPct ?? 0)
|
|
9764
9764
|
}
|
|
9765
9765
|
};
|
|
9766
9766
|
}
|
|
@@ -10150,8 +10150,8 @@ import chalk84 from "chalk";
|
|
|
10150
10150
|
// src/commands/backlog/updateStarred.ts
|
|
10151
10151
|
import { eq as eq24 } from "drizzle-orm";
|
|
10152
10152
|
async function updateStarred(orm, id, starred) {
|
|
10153
|
-
const [
|
|
10154
|
-
return
|
|
10153
|
+
const [row3] = await orm.update(items).set({ starred }).where(eq24(items.id, id)).returning({ name: items.name });
|
|
10154
|
+
return row3?.name;
|
|
10155
10155
|
}
|
|
10156
10156
|
|
|
10157
10157
|
// src/commands/backlog/setStarred.ts
|
|
@@ -10313,8 +10313,8 @@ async function updateSubtask(orm, itemId2, idx, fields) {
|
|
|
10313
10313
|
if (fields.title !== void 0) set.title = fields.title;
|
|
10314
10314
|
if (fields.description !== void 0) set.description = fields.description;
|
|
10315
10315
|
if (fields.status !== void 0) set.status = fields.status;
|
|
10316
|
-
const [
|
|
10317
|
-
return
|
|
10316
|
+
const [row3] = await orm.update(itemSubtasks).set(set).where(and9(eq26(itemSubtasks.itemId, itemId2), eq26(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
10317
|
+
return row3?.title;
|
|
10318
10318
|
}
|
|
10319
10319
|
|
|
10320
10320
|
// src/commands/backlog/validSubtaskStatuses.ts
|
|
@@ -10370,8 +10370,8 @@ import chalk93 from "chalk";
|
|
|
10370
10370
|
// src/commands/backlog/deleteSubtask.ts
|
|
10371
10371
|
import { and as and10, asc as asc6, eq as eq27 } from "drizzle-orm";
|
|
10372
10372
|
async function deleteSubtask(orm, itemId2, idx) {
|
|
10373
|
-
const [
|
|
10374
|
-
if (!
|
|
10373
|
+
const [row3] = await orm.delete(itemSubtasks).where(and10(eq27(itemSubtasks.itemId, itemId2), eq27(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
10374
|
+
if (!row3) return void 0;
|
|
10375
10375
|
const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(eq27(itemSubtasks.itemId, itemId2)).orderBy(asc6(itemSubtasks.idx));
|
|
10376
10376
|
for (let i = 0; i < remaining.length; i++) {
|
|
10377
10377
|
const oldIdx = remaining[i].idx;
|
|
@@ -10380,7 +10380,7 @@ async function deleteSubtask(orm, itemId2, idx) {
|
|
|
10380
10380
|
and10(eq27(itemSubtasks.itemId, itemId2), eq27(itemSubtasks.idx, oldIdx))
|
|
10381
10381
|
);
|
|
10382
10382
|
}
|
|
10383
|
-
return
|
|
10383
|
+
return row3.title;
|
|
10384
10384
|
}
|
|
10385
10385
|
|
|
10386
10386
|
// src/commands/backlog/removeSubtask.ts
|
|
@@ -10402,8 +10402,8 @@ import chalk94 from "chalk";
|
|
|
10402
10402
|
// src/commands/backlog/updateSubtaskStatus.ts
|
|
10403
10403
|
import { and as and11, eq as eq28 } from "drizzle-orm";
|
|
10404
10404
|
async function updateSubtaskStatus(orm, itemId2, idx, status2) {
|
|
10405
|
-
const [
|
|
10406
|
-
return
|
|
10405
|
+
const [row3] = await orm.update(itemSubtasks).set({ status: status2 }).where(and11(eq28(itemSubtasks.itemId, itemId2), eq28(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
10406
|
+
return row3?.title;
|
|
10407
10407
|
}
|
|
10408
10408
|
|
|
10409
10409
|
// src/commands/backlog/subtaskStatus.ts
|
|
@@ -10480,8 +10480,8 @@ async function adjustCurrentPhase(db, item, removedIdx) {
|
|
|
10480
10480
|
return;
|
|
10481
10481
|
}
|
|
10482
10482
|
if (removedIdx !== currentIdx) return;
|
|
10483
|
-
const [
|
|
10484
|
-
const cnt =
|
|
10483
|
+
const [row3] = await db.select({ cnt: count3() }).from(planPhases).where(eq29(planPhases.itemId, item.id));
|
|
10484
|
+
const cnt = row3?.cnt ?? 0;
|
|
10485
10485
|
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq29(items.id, item.id));
|
|
10486
10486
|
}
|
|
10487
10487
|
|
|
@@ -10534,8 +10534,8 @@ async function movePhase(id, from, to) {
|
|
|
10534
10534
|
if (!found) return;
|
|
10535
10535
|
const { orm, item } = found;
|
|
10536
10536
|
const itemId2 = item.id;
|
|
10537
|
-
const [
|
|
10538
|
-
const phaseCount =
|
|
10537
|
+
const [row3] = await orm.select({ cnt: count4() }).from(planPhases).where(eq31(planPhases.itemId, itemId2));
|
|
10538
|
+
const phaseCount = row3?.cnt ?? 0;
|
|
10539
10539
|
const fromIdx = toIndex(from, phaseCount);
|
|
10540
10540
|
if (fromIdx === void 0) return;
|
|
10541
10541
|
const toIdx = toIndex(to, phaseCount);
|
|
@@ -10590,8 +10590,8 @@ async function findPhase(id, phase) {
|
|
|
10590
10590
|
const { orm, item } = found;
|
|
10591
10591
|
const itemId2 = item.id;
|
|
10592
10592
|
const phaseIdx = Number.parseInt(phase, 10) - 1;
|
|
10593
|
-
const [
|
|
10594
|
-
if (!
|
|
10593
|
+
const [row3] = await orm.select({ cnt: count5() }).from(planPhases).where(and15(eq33(planPhases.itemId, itemId2), eq33(planPhases.idx, phaseIdx)));
|
|
10594
|
+
if (!row3 || row3.cnt === 0) {
|
|
10595
10595
|
console.log(
|
|
10596
10596
|
chalk96.red(
|
|
10597
10597
|
`Phase ${phaseIdx + 1} not found on item ${formatItemId(itemId2)}.`
|
|
@@ -12302,10 +12302,10 @@ async function listCommitRefs(db, itemId2) {
|
|
|
12302
12302
|
title: itemGitRefs.title,
|
|
12303
12303
|
url: itemGitRefs.url
|
|
12304
12304
|
}).from(itemGitRefs).where(and17(eq38(itemGitRefs.itemId, itemId2), eq38(itemGitRefs.kind, "commit"))).orderBy(asc10(itemGitRefs.createdAt), asc10(itemGitRefs.ref));
|
|
12305
|
-
return rows.map((
|
|
12306
|
-
sha:
|
|
12307
|
-
...
|
|
12308
|
-
...
|
|
12305
|
+
return rows.map((row3) => ({
|
|
12306
|
+
sha: row3.ref,
|
|
12307
|
+
...row3.title ? { title: row3.title } : {},
|
|
12308
|
+
...row3.url ? { url: row3.url } : {}
|
|
12309
12309
|
}));
|
|
12310
12310
|
}
|
|
12311
12311
|
|
|
@@ -15507,8 +15507,8 @@ function listScopedRules(req, res) {
|
|
|
15507
15507
|
// src/shared/db/countUsagePeaks.ts
|
|
15508
15508
|
import { count as count6, eq as eq39 } from "drizzle-orm";
|
|
15509
15509
|
async function countUsagePeaks(db, window) {
|
|
15510
|
-
const [
|
|
15511
|
-
return
|
|
15510
|
+
const [row3] = await db.select({ value: count6() }).from(usagePeaks).where(window ? eq39(usagePeaks.window, window) : void 0);
|
|
15511
|
+
return row3?.value ?? 0;
|
|
15512
15512
|
}
|
|
15513
15513
|
|
|
15514
15514
|
// src/shared/db/listUsagePeaks.ts
|
|
@@ -15587,20 +15587,20 @@ function listUsageHistory(req, res) {
|
|
|
15587
15587
|
return respondPagedRows(req, res, async (range, params) => {
|
|
15588
15588
|
const window = parseWindow(params.get("window"));
|
|
15589
15589
|
const db = await getDb();
|
|
15590
|
-
const [rows,
|
|
15590
|
+
const [rows, total2] = await Promise.all([
|
|
15591
15591
|
listUsagePeaks(db, { ...range, window }),
|
|
15592
15592
|
countUsagePeaks(db, window)
|
|
15593
15593
|
]);
|
|
15594
|
-
return { rows, total };
|
|
15594
|
+
return { rows, total: total2 };
|
|
15595
15595
|
});
|
|
15596
15596
|
}
|
|
15597
15597
|
|
|
15598
15598
|
// src/shared/db/countItemUsageByOrigin.ts
|
|
15599
15599
|
import { asc as asc11, desc as desc4, eq as eq41, sql as sql19 } from "drizzle-orm";
|
|
15600
15600
|
async function countItemUsageByOrigin(db) {
|
|
15601
|
-
const
|
|
15602
|
-
const rows = await db.select({ origin: items.origin, count:
|
|
15603
|
-
return rows.map((
|
|
15601
|
+
const count9 = sql19`count(distinct ${phaseUsage.itemId})::int`;
|
|
15602
|
+
const rows = await db.select({ origin: items.origin, count: count9 }).from(items).innerJoin(phaseUsage, eq41(phaseUsage.itemId, items.id)).groupBy(items.origin).orderBy(desc4(count9), asc11(items.origin));
|
|
15603
|
+
return rows.map((row3) => ({ origin: row3.origin, count: Number(row3.count) }));
|
|
15604
15604
|
}
|
|
15605
15605
|
|
|
15606
15606
|
// src/shared/db/itemUsageWhere.ts
|
|
@@ -15647,7 +15647,7 @@ function median(value) {
|
|
|
15647
15647
|
async function itemUsageStats(db, options2) {
|
|
15648
15648
|
const totals = phaseUsageTotals(db);
|
|
15649
15649
|
const planned = planPhaseCounts(db);
|
|
15650
|
-
const [
|
|
15650
|
+
const [row3] = await db.select({
|
|
15651
15651
|
itemCount: sql20`count(*)::int`,
|
|
15652
15652
|
doneCount: sql20`count(*) filter (where ${items.status} = 'done')::int`,
|
|
15653
15653
|
repoCount: sql20`count(distinct ${items.origin})::int`,
|
|
@@ -15658,12 +15658,12 @@ async function itemUsageStats(db, options2) {
|
|
|
15658
15658
|
medianTokens: median(sql20`${totals.tokensUp} + ${totals.tokensDown}`)
|
|
15659
15659
|
}).from(items).innerJoin(totals, eq43(totals.itemId, items.id)).leftJoin(planned, eq43(planned.itemId, items.id)).where(itemUsageWhere(options2));
|
|
15660
15660
|
return {
|
|
15661
|
-
itemCount: Number(
|
|
15662
|
-
doneCount: Number(
|
|
15663
|
-
repoCount: Number(
|
|
15664
|
-
medianPhases: Number(
|
|
15665
|
-
medianActiveMs: Number(
|
|
15666
|
-
medianTokens: Number(
|
|
15661
|
+
itemCount: Number(row3?.itemCount ?? 0),
|
|
15662
|
+
doneCount: Number(row3?.doneCount ?? 0),
|
|
15663
|
+
repoCount: Number(row3?.repoCount ?? 0),
|
|
15664
|
+
medianPhases: Number(row3?.medianPhases ?? 0),
|
|
15665
|
+
medianActiveMs: Number(row3?.medianActiveMs ?? 0),
|
|
15666
|
+
medianTokens: Number(row3?.medianTokens ?? 0)
|
|
15667
15667
|
};
|
|
15668
15668
|
}
|
|
15669
15669
|
|
|
@@ -15698,16 +15698,16 @@ function lastPhaseActivity(db) {
|
|
|
15698
15698
|
}
|
|
15699
15699
|
|
|
15700
15700
|
// src/shared/db/toItemUsageSummary.ts
|
|
15701
|
-
function toItemUsageSummary(
|
|
15701
|
+
function toItemUsageSummary(row3) {
|
|
15702
15702
|
return {
|
|
15703
|
-
...
|
|
15704
|
-
phaseCount:
|
|
15705
|
-
recordedPhases: Number(
|
|
15706
|
-
tokensUp: Number(
|
|
15707
|
-
tokensDown: Number(
|
|
15708
|
-
activeMs: Number(
|
|
15709
|
-
peakContextPct: Number(
|
|
15710
|
-
lastPhaseAt:
|
|
15703
|
+
...row3,
|
|
15704
|
+
phaseCount: row3.phaseCount ?? 0,
|
|
15705
|
+
recordedPhases: Number(row3.recordedPhases),
|
|
15706
|
+
tokensUp: Number(row3.tokensUp),
|
|
15707
|
+
tokensDown: Number(row3.tokensDown),
|
|
15708
|
+
activeMs: Number(row3.activeMs),
|
|
15709
|
+
peakContextPct: Number(row3.peakContextPct),
|
|
15710
|
+
lastPhaseAt: row3.lastPhaseAt ?? null
|
|
15711
15711
|
};
|
|
15712
15712
|
}
|
|
15713
15713
|
|
|
@@ -16312,8 +16312,8 @@ async function commitsBehind(cwd, repo, base, shas) {
|
|
|
16312
16312
|
]);
|
|
16313
16313
|
const ref = response.data?.repository?.ref;
|
|
16314
16314
|
for (const [index2, sha] of shas.entries()) {
|
|
16315
|
-
const
|
|
16316
|
-
behind.set(sha, typeof
|
|
16315
|
+
const count9 = ref?.[`c${index2}`]?.behindBy;
|
|
16316
|
+
behind.set(sha, typeof count9 === "number" ? count9 : null);
|
|
16317
16317
|
}
|
|
16318
16318
|
} catch {
|
|
16319
16319
|
return behind;
|
|
@@ -16430,9 +16430,9 @@ function deploymentsQuery(environments) {
|
|
|
16430
16430
|
function headCommit2(node) {
|
|
16431
16431
|
return node?.oid ? releaseCommit(node.oid, node) : null;
|
|
16432
16432
|
}
|
|
16433
|
-
function environmentNodes(repository,
|
|
16433
|
+
function environmentNodes(repository, count9) {
|
|
16434
16434
|
return Array.from(
|
|
16435
|
-
{ length:
|
|
16435
|
+
{ length: count9 },
|
|
16436
16436
|
(_, index2) => repository[deploymentsAlias(index2)]?.nodes ?? []
|
|
16437
16437
|
).flat();
|
|
16438
16438
|
}
|
|
@@ -17621,7 +17621,7 @@ function globalOnlyRepoKeyError(key, verb) {
|
|
|
17621
17621
|
// src/shared/db/listRepoConfigs.ts
|
|
17622
17622
|
async function listRepoConfigs(orm) {
|
|
17623
17623
|
const rows = await orm.select().from(repoConfigs);
|
|
17624
|
-
return Object.fromEntries(rows.map((
|
|
17624
|
+
return Object.fromEntries(rows.map((row3) => [row3.repoKey, row3.config]));
|
|
17625
17625
|
}
|
|
17626
17626
|
|
|
17627
17627
|
// src/shared/resolveNamedRepoWriteLabel.ts
|
|
@@ -21763,7 +21763,7 @@ function calculateHalstead(node) {
|
|
|
21763
21763
|
// src/commands/complexity/shared/countSloc.ts
|
|
21764
21764
|
function countSloc(content) {
|
|
21765
21765
|
let inMultiLineComment = false;
|
|
21766
|
-
let
|
|
21766
|
+
let count9 = 0;
|
|
21767
21767
|
for (const line of content.split("\n")) {
|
|
21768
21768
|
const trimmed = line.trim();
|
|
21769
21769
|
if (inMultiLineComment) {
|
|
@@ -21771,7 +21771,7 @@ function countSloc(content) {
|
|
|
21771
21771
|
inMultiLineComment = false;
|
|
21772
21772
|
const afterComment = trimmed.substring(trimmed.indexOf("*/") + 2);
|
|
21773
21773
|
if (afterComment.trim().length > 0) {
|
|
21774
|
-
|
|
21774
|
+
count9++;
|
|
21775
21775
|
}
|
|
21776
21776
|
}
|
|
21777
21777
|
continue;
|
|
@@ -21783,7 +21783,7 @@ function countSloc(content) {
|
|
|
21783
21783
|
if (trimmed.includes("*/")) {
|
|
21784
21784
|
const afterComment = trimmed.substring(trimmed.indexOf("*/") + 2);
|
|
21785
21785
|
if (afterComment.trim().length > 0) {
|
|
21786
|
-
|
|
21786
|
+
count9++;
|
|
21787
21787
|
}
|
|
21788
21788
|
} else {
|
|
21789
21789
|
inMultiLineComment = true;
|
|
@@ -21791,10 +21791,10 @@ function countSloc(content) {
|
|
|
21791
21791
|
continue;
|
|
21792
21792
|
}
|
|
21793
21793
|
if (trimmed.length > 0) {
|
|
21794
|
-
|
|
21794
|
+
count9++;
|
|
21795
21795
|
}
|
|
21796
21796
|
}
|
|
21797
|
-
return
|
|
21797
|
+
return count9;
|
|
21798
21798
|
}
|
|
21799
21799
|
|
|
21800
21800
|
// src/commands/complexity/shared.ts
|
|
@@ -22124,10 +22124,10 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
22124
22124
|
const color = exceedsThreshold ? chalk131.red : chalk131.white;
|
|
22125
22125
|
console.log(`${color(file)} \u2192 ${chalk131.cyan(lines2)} lines`);
|
|
22126
22126
|
}
|
|
22127
|
-
const
|
|
22127
|
+
const total2 = results.reduce((sum3, r) => sum3 + r.lines, 0);
|
|
22128
22128
|
console.log(
|
|
22129
22129
|
chalk131.dim(`
|
|
22130
|
-
Total: ${
|
|
22130
|
+
Total: ${total2} lines across ${files.length} files`)
|
|
22131
22131
|
);
|
|
22132
22132
|
if (hasViolation) {
|
|
22133
22133
|
process.exit(1);
|
|
@@ -22405,8 +22405,8 @@ function matching(filter) {
|
|
|
22405
22405
|
const needle = filter.toLowerCase();
|
|
22406
22406
|
return (leaf) => leaf.key.toLowerCase().includes(needle);
|
|
22407
22407
|
}
|
|
22408
|
-
function headline(shown,
|
|
22409
|
-
return filter ? chalk138.bold(`${shown} of ${
|
|
22408
|
+
function headline(shown, total2, filter) {
|
|
22409
|
+
return filter ? chalk138.bold(`${shown} of ${total2} config keys matching "${filter}"`) : chalk138.bold(`${total2} config keys`);
|
|
22410
22410
|
}
|
|
22411
22411
|
function formatLeaf(leaf, help) {
|
|
22412
22412
|
const meta = [typeText(leaf), `default: ${formatConfigDefault(leaf)}`];
|
|
@@ -22820,12 +22820,12 @@ async function findRetiredTables(exec3) {
|
|
|
22820
22820
|
[RETIRED_TABLES]
|
|
22821
22821
|
);
|
|
22822
22822
|
const found = [];
|
|
22823
|
-
for (const
|
|
22824
|
-
const name = String(
|
|
22825
|
-
const [
|
|
22823
|
+
for (const row3 of present) {
|
|
22824
|
+
const name = String(row3.table_name);
|
|
22825
|
+
const [count9] = await exec3.query(
|
|
22826
22826
|
`SELECT count(*)::int AS rows FROM "${name}"`
|
|
22827
22827
|
);
|
|
22828
|
-
found.push({ name, rows: Number(
|
|
22828
|
+
found.push({ name, rows: Number(count9.rows) });
|
|
22829
22829
|
}
|
|
22830
22830
|
return found;
|
|
22831
22831
|
}
|
|
@@ -23469,9 +23469,9 @@ function colorStatus(status2) {
|
|
|
23469
23469
|
if (status2 === "outdated") return chalk154.yellow(status2);
|
|
23470
23470
|
return chalk154.green(status2);
|
|
23471
23471
|
}
|
|
23472
|
-
function formatRow(
|
|
23473
|
-
const devlog = (
|
|
23474
|
-
return `${
|
|
23472
|
+
function formatRow(row3, nameWidth) {
|
|
23473
|
+
const devlog = (row3.lastDevlog ?? "-").padEnd(11);
|
|
23474
|
+
return `${row3.name.padEnd(nameWidth)} ${row3.lastPush} ${devlog} ${colorStatus(row3.status)}`;
|
|
23475
23475
|
}
|
|
23476
23476
|
function printReposTable(rows) {
|
|
23477
23477
|
const nameWidth = Math.max(4, ...rows.map((r) => r.name.length));
|
|
@@ -23483,8 +23483,8 @@ function printReposTable(rows) {
|
|
|
23483
23483
|
].join(" ");
|
|
23484
23484
|
console.log(chalk154.dim(header));
|
|
23485
23485
|
console.log(chalk154.dim("-".repeat(header.length)));
|
|
23486
|
-
for (const
|
|
23487
|
-
console.log(formatRow(
|
|
23486
|
+
for (const row3 of rows) {
|
|
23487
|
+
console.log(formatRow(row3, nameWidth));
|
|
23488
23488
|
}
|
|
23489
23489
|
}
|
|
23490
23490
|
|
|
@@ -25066,13 +25066,13 @@ import chalk167 from "chalk";
|
|
|
25066
25066
|
function printCountTable(labelHeader, rows) {
|
|
25067
25067
|
const labelWidth = Math.max(
|
|
25068
25068
|
labelHeader.length,
|
|
25069
|
-
...rows.map((
|
|
25069
|
+
...rows.map((row3) => row3.label.length)
|
|
25070
25070
|
);
|
|
25071
25071
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
25072
25072
|
console.log(chalk167.dim(header));
|
|
25073
25073
|
console.log(chalk167.dim("-".repeat(header.length)));
|
|
25074
|
-
for (const
|
|
25075
|
-
console.log(`${
|
|
25074
|
+
for (const row3 of rows) {
|
|
25075
|
+
console.log(`${row3.label.padEnd(labelWidth)} ${row3.count}`);
|
|
25076
25076
|
}
|
|
25077
25077
|
}
|
|
25078
25078
|
|
|
@@ -25411,7 +25411,7 @@ function buildFixStructurePlan(issues, options2) {
|
|
|
25411
25411
|
tooDeep,
|
|
25412
25412
|
typeChangeCount: entries.filter((entry) => entry.typeChange).length,
|
|
25413
25413
|
labelRemovalCount: entries.reduce(
|
|
25414
|
-
(
|
|
25414
|
+
(total2, entry) => total2 + entry.labelRemovals.length,
|
|
25415
25415
|
0
|
|
25416
25416
|
)
|
|
25417
25417
|
};
|
|
@@ -25533,8 +25533,8 @@ function annotate(entry) {
|
|
|
25533
25533
|
}
|
|
25534
25534
|
return notes;
|
|
25535
25535
|
}
|
|
25536
|
-
function formatCount(
|
|
25537
|
-
return `${
|
|
25536
|
+
function formatCount(count9, noun) {
|
|
25537
|
+
return `${count9} ${noun}${count9 === 1 ? "" : "s"}`;
|
|
25538
25538
|
}
|
|
25539
25539
|
function printFixStructurePlan(plan2, chain2, apply) {
|
|
25540
25540
|
writeLineNow(chalk171.dim(`chain: ${chain2.join(" > ")}`));
|
|
@@ -25819,8 +25819,8 @@ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([".mp4", ".webm", ".mov"]);
|
|
|
25819
25819
|
function cell(text18) {
|
|
25820
25820
|
return text18.replaceAll("|", String.raw`\|`);
|
|
25821
25821
|
}
|
|
25822
|
-
function row(
|
|
25823
|
-
return `| ${
|
|
25822
|
+
function row(cells2) {
|
|
25823
|
+
return `| ${cells2.join(" | ")} |`;
|
|
25824
25824
|
}
|
|
25825
25825
|
function imageTable(images) {
|
|
25826
25826
|
if (images.length === 0) return [];
|
|
@@ -28777,14 +28777,14 @@ async function netcap(options2) {
|
|
|
28777
28777
|
const filter = options2.filter ?? "";
|
|
28778
28778
|
await mkdir6(dirname34(outPath), { recursive: true });
|
|
28779
28779
|
const extensionPath = await prepareExtensionForLoad(port, filter);
|
|
28780
|
-
let
|
|
28780
|
+
let count9 = 0;
|
|
28781
28781
|
const handler = createNetcapHandler({
|
|
28782
28782
|
outPath,
|
|
28783
28783
|
onPing: () => console.log(chalk183.dim("ping from extension")),
|
|
28784
28784
|
onCapture: (entry) => {
|
|
28785
|
-
|
|
28785
|
+
count9 += 1;
|
|
28786
28786
|
console.log(
|
|
28787
|
-
chalk183.green(`captured #${
|
|
28787
|
+
chalk183.green(`captured #${count9}`),
|
|
28788
28788
|
chalk183.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
28789
28789
|
);
|
|
28790
28790
|
}
|
|
@@ -28805,7 +28805,7 @@ async function netcap(options2) {
|
|
|
28805
28805
|
console.log(
|
|
28806
28806
|
chalk183.bold(
|
|
28807
28807
|
`
|
|
28808
|
-
netcap stopped \u2014 captured ${
|
|
28808
|
+
netcap stopped \u2014 captured ${count9} ${count9 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
28809
28809
|
)
|
|
28810
28810
|
);
|
|
28811
28811
|
process.exit(0);
|
|
@@ -29378,12 +29378,12 @@ function printPromptsTable(rows) {
|
|
|
29378
29378
|
].join(" ");
|
|
29379
29379
|
console.log(chalk186.dim(header));
|
|
29380
29380
|
console.log(chalk186.dim("-".repeat(header.length)));
|
|
29381
|
-
for (const
|
|
29382
|
-
const
|
|
29383
|
-
const tool =
|
|
29384
|
-
const command = truncate(
|
|
29381
|
+
for (const row3 of rows) {
|
|
29382
|
+
const count9 = String(row3.count).padStart(countWidth);
|
|
29383
|
+
const tool = row3.tool.padEnd(toolWidth);
|
|
29384
|
+
const command = truncate(row3.command, 60).padEnd(commandWidth);
|
|
29385
29385
|
console.log(
|
|
29386
|
-
`${chalk186.yellow(
|
|
29386
|
+
`${chalk186.yellow(count9)} ${tool} ${command} ${chalk186.dim(row3.repos)}`
|
|
29387
29387
|
);
|
|
29388
29388
|
}
|
|
29389
29389
|
}
|
|
@@ -29452,17 +29452,17 @@ function getPageSlice(pullRequests, page) {
|
|
|
29452
29452
|
const start2 = page * PAGE_SIZE2;
|
|
29453
29453
|
return pullRequests.slice(start2, start2 + PAGE_SIZE2);
|
|
29454
29454
|
}
|
|
29455
|
-
function pageHeader(page, totalPages,
|
|
29455
|
+
function pageHeader(page, totalPages, total2) {
|
|
29456
29456
|
return `
|
|
29457
|
-
Page ${page + 1} of ${totalPages} (${
|
|
29457
|
+
Page ${page + 1} of ${totalPages} (${total2} total)
|
|
29458
29458
|
`;
|
|
29459
29459
|
}
|
|
29460
29460
|
function displayPage(pullRequests, totalPages, page) {
|
|
29461
29461
|
console.log(pageHeader(page, totalPages, pullRequests.length));
|
|
29462
29462
|
for (const pr of getPageSlice(pullRequests, page)) printPr(pr);
|
|
29463
29463
|
}
|
|
29464
|
-
function hasNextPage(page,
|
|
29465
|
-
return page <
|
|
29464
|
+
function hasNextPage(page, total2) {
|
|
29465
|
+
return page < total2 - 1;
|
|
29466
29466
|
}
|
|
29467
29467
|
var NEXT_CHOICE = { name: "Next page", value: "next" };
|
|
29468
29468
|
var PREV_CHOICE = { name: "Previous page", value: "prev" };
|
|
@@ -29493,8 +29493,8 @@ async function promptNavigation(currentPage, totalPages) {
|
|
|
29493
29493
|
});
|
|
29494
29494
|
return parseAction(action);
|
|
29495
29495
|
}
|
|
29496
|
-
function computeTotalPages(
|
|
29497
|
-
return Math.ceil(
|
|
29496
|
+
function computeTotalPages(count9) {
|
|
29497
|
+
return Math.ceil(count9 / PAGE_SIZE2);
|
|
29498
29498
|
}
|
|
29499
29499
|
async function navigateAndDisplay(pullRequests, totalPages, currentPage) {
|
|
29500
29500
|
const delta = await promptNavigation(currentPage, totalPages);
|
|
@@ -29985,9 +29985,9 @@ function renderResolvedIndex(threads, style) {
|
|
|
29985
29985
|
for (const thread of threads) {
|
|
29986
29986
|
const first = thread.comments[0];
|
|
29987
29987
|
if (!first) continue;
|
|
29988
|
-
const
|
|
29988
|
+
const count9 = thread.comments.length > 1 ? ` (${thread.comments.length} comments)` : "";
|
|
29989
29989
|
lines2.push(
|
|
29990
|
-
` ${style.bold(threadLocation(first))} ${first.user}: ${firstLine(first.body)}${
|
|
29990
|
+
` ${style.bold(threadLocation(first))} ${first.user}: ${firstLine(first.body)}${count9}`
|
|
29991
29991
|
);
|
|
29992
29992
|
}
|
|
29993
29993
|
lines2.push("");
|
|
@@ -31261,12 +31261,12 @@ function printPrStatus(pr) {
|
|
|
31261
31261
|
// src/commands/prs/status/printPrsStatus.ts
|
|
31262
31262
|
function printPrsStatus(report) {
|
|
31263
31263
|
for (const repo of report.repos) {
|
|
31264
|
-
const
|
|
31265
|
-
console.log(`${chalk190.bold(repo.repo)} ${chalk190.dim(`(${
|
|
31264
|
+
const count9 = repo.pullRequests.length;
|
|
31265
|
+
console.log(`${chalk190.bold(repo.repo)} ${chalk190.dim(`(${count9} open)`)}`);
|
|
31266
31266
|
for (const pr of repo.pullRequests) {
|
|
31267
31267
|
printPrStatus(pr);
|
|
31268
31268
|
}
|
|
31269
|
-
if (
|
|
31269
|
+
if (count9 === 0) console.log(chalk190.dim(" no open pull requests"));
|
|
31270
31270
|
console.log();
|
|
31271
31271
|
}
|
|
31272
31272
|
if (report.errors.length === 0) return;
|
|
@@ -31359,11 +31359,11 @@ function parseReadBudget(value) {
|
|
|
31359
31359
|
`Invalid budget "${value}". Use a duration like 45s, 1m30s or 2m.`
|
|
31360
31360
|
);
|
|
31361
31361
|
}
|
|
31362
|
-
const
|
|
31363
|
-
if (
|
|
31362
|
+
const total2 = Number(minutes ?? 0) * 60 + Number(seconds ?? 0);
|
|
31363
|
+
if (total2 === 0) {
|
|
31364
31364
|
throw new Error(`Invalid budget "${value}". Value must be at least 1s.`);
|
|
31365
31365
|
}
|
|
31366
|
-
return
|
|
31366
|
+
return total2;
|
|
31367
31367
|
}
|
|
31368
31368
|
|
|
31369
31369
|
// src/commands/readTime/resolveReadTimeTarget.ts
|
|
@@ -31495,12 +31495,12 @@ import chalk196 from "chalk";
|
|
|
31495
31495
|
|
|
31496
31496
|
// src/shared/createConnectionAuth.ts
|
|
31497
31497
|
import chalk191 from "chalk";
|
|
31498
|
-
function listConnections(connections,
|
|
31498
|
+
function listConnections(connections, format3) {
|
|
31499
31499
|
if (connections.length === 0) {
|
|
31500
31500
|
console.log("No connections configured.");
|
|
31501
31501
|
} else {
|
|
31502
31502
|
for (const c of connections) {
|
|
31503
|
-
console.log(
|
|
31503
|
+
console.log(format3(c));
|
|
31504
31504
|
}
|
|
31505
31505
|
}
|
|
31506
31506
|
}
|
|
@@ -33183,16 +33183,16 @@ import {
|
|
|
33183
33183
|
} from "ts-morph";
|
|
33184
33184
|
var suppressionPattern = /^\s*(\/\/|\/\*)\s*oxlint-disable\b/;
|
|
33185
33185
|
function countLeadingSuppressions(sourceFile) {
|
|
33186
|
-
let
|
|
33186
|
+
let count9 = 0;
|
|
33187
33187
|
for (const stmt of sourceFile.getStatementsWithComments()) {
|
|
33188
33188
|
const kind = stmt.getKind();
|
|
33189
33189
|
if ((kind === SyntaxKind2.SingleLineCommentTrivia || kind === SyntaxKind2.MultiLineCommentTrivia) && suppressionPattern.test(stmt.getText())) {
|
|
33190
|
-
|
|
33190
|
+
count9++;
|
|
33191
33191
|
} else {
|
|
33192
33192
|
break;
|
|
33193
33193
|
}
|
|
33194
33194
|
}
|
|
33195
|
-
return
|
|
33195
|
+
return count9;
|
|
33196
33196
|
}
|
|
33197
33197
|
function addImportPreservingSuppressions(sourceFile, structure) {
|
|
33198
33198
|
if (sourceFile.getImportDeclarations().length > 0) {
|
|
@@ -35329,7 +35329,7 @@ function summariseRepoTree(cwd = process.cwd()) {
|
|
|
35329
35329
|
return [...directories.entries()].map(([directory, extensions]) => ({
|
|
35330
35330
|
directory,
|
|
35331
35331
|
extensions: [...extensions.entries()].sort((a, b) => b[1] - a[1]),
|
|
35332
|
-
total: [...extensions.values()].reduce((sum3,
|
|
35332
|
+
total: [...extensions.values()].reduce((sum3, count9) => sum3 + count9, 0)
|
|
35333
35333
|
})).sort((a, b) => b.total - a.total || a.directory.localeCompare(b.directory)).slice(0, MAX_DIRECTORIES).map(
|
|
35334
35334
|
(entry) => `${entry.directory} \u2014 ${entry.total} files: ${formatExtensions(entry.extensions)}`
|
|
35335
35335
|
).join("\n");
|
|
@@ -35357,7 +35357,7 @@ function countByDirectory(files) {
|
|
|
35357
35357
|
return directories;
|
|
35358
35358
|
}
|
|
35359
35359
|
function formatExtensions(extensions) {
|
|
35360
|
-
return extensions.slice(0, MAX_EXTENSIONS_PER_DIRECTORY).map(([extension2,
|
|
35360
|
+
return extensions.slice(0, MAX_EXTENSIONS_PER_DIRECTORY).map(([extension2, count9]) => `${extension2}(${count9})`).join(", ");
|
|
35361
35361
|
}
|
|
35362
35362
|
|
|
35363
35363
|
// src/commands/review/highLevel/proposeHighLevelGlobs.ts
|
|
@@ -35482,7 +35482,7 @@ function basename24(path109) {
|
|
|
35482
35482
|
return path109.slice(path109.lastIndexOf("/") + 1);
|
|
35483
35483
|
}
|
|
35484
35484
|
function sum(nodes, key) {
|
|
35485
|
-
return nodes.reduce((
|
|
35485
|
+
return nodes.reduce((total2, node) => total2 + node[key], 0);
|
|
35486
35486
|
}
|
|
35487
35487
|
function byName(a, b) {
|
|
35488
35488
|
return a.name.localeCompare(b.name);
|
|
@@ -35526,7 +35526,7 @@ function buildHighLevelTree(files) {
|
|
|
35526
35526
|
|
|
35527
35527
|
// src/commands/review/highLevel/buildHighLevelStructure.ts
|
|
35528
35528
|
function sum2(files, key) {
|
|
35529
|
-
return files.reduce((
|
|
35529
|
+
return files.reduce((total2, file) => total2 + file[key], 0);
|
|
35530
35530
|
}
|
|
35531
35531
|
function countOf(files, status2) {
|
|
35532
35532
|
return files.filter((file) => file.status === status2).length;
|
|
@@ -35674,10 +35674,10 @@ function dedentedSource(call) {
|
|
|
35674
35674
|
// src/commands/review/highLevel/visitCase.ts
|
|
35675
35675
|
function visitCase(call, context) {
|
|
35676
35676
|
if (!context.changed) return [toCase(call, context, void 0)];
|
|
35677
|
-
const
|
|
35678
|
-
if (
|
|
35677
|
+
const count9 = changedLines(call, context.changed);
|
|
35678
|
+
if (count9 === 0) return [];
|
|
35679
35679
|
const lines2 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
|
|
35680
|
-
return [toCase(call, context,
|
|
35680
|
+
return [toCase(call, context, count9 === lines2 ? "added" : "modified")];
|
|
35681
35681
|
}
|
|
35682
35682
|
function toCase(call, context, change) {
|
|
35683
35683
|
const line = call.getStartLineNumber();
|
|
@@ -35691,10 +35691,10 @@ function toCase(call, context, change) {
|
|
|
35691
35691
|
};
|
|
35692
35692
|
}
|
|
35693
35693
|
function changedLines(call, changed) {
|
|
35694
|
-
let
|
|
35694
|
+
let count9 = 0;
|
|
35695
35695
|
for (let line = call.getStartLineNumber(); line <= call.getEndLineNumber(); line++)
|
|
35696
|
-
if (changed.has(line))
|
|
35697
|
-
return
|
|
35696
|
+
if (changed.has(line)) count9++;
|
|
35697
|
+
return count9;
|
|
35698
35698
|
}
|
|
35699
35699
|
|
|
35700
35700
|
// src/commands/review/highLevel/extractTestHierarchy.ts
|
|
@@ -35835,12 +35835,12 @@ var EVIDENCE_PATTERNS = [
|
|
|
35835
35835
|
];
|
|
35836
35836
|
function countEvidence(body) {
|
|
35837
35837
|
return EVIDENCE_PATTERNS.reduce(
|
|
35838
|
-
(
|
|
35838
|
+
(total2, pattern2) => total2 + (body.match(pattern2)?.length ?? 0),
|
|
35839
35839
|
0
|
|
35840
35840
|
);
|
|
35841
35841
|
}
|
|
35842
|
-
function plural(
|
|
35843
|
-
return `${
|
|
35842
|
+
function plural(count9, noun) {
|
|
35843
|
+
return `${count9} ${noun}${count9 === 1 ? "" : "s"}`;
|
|
35844
35844
|
}
|
|
35845
35845
|
function checkUiEvidence(body, changedFiles2, uiPaths) {
|
|
35846
35846
|
if (uiPaths.length === 0)
|
|
@@ -36739,74 +36739,70 @@ function selectPostableFindings(markdown, prInfo) {
|
|
|
36739
36739
|
return { inDiff, unanchored: [...carriedUnlocated, ...unanchored] };
|
|
36740
36740
|
}
|
|
36741
36741
|
|
|
36742
|
+
// src/commands/review/ci/buildTokenUsageTable.ts
|
|
36743
|
+
var SLOT_LABELS = ["Reviewer 1", "Reviewer 2", "Synthesis"];
|
|
36744
|
+
var DASH = "\u2014";
|
|
36745
|
+
function format(value) {
|
|
36746
|
+
return value === void 0 ? DASH : value.toLocaleString("en-US");
|
|
36747
|
+
}
|
|
36748
|
+
function cells(usage) {
|
|
36749
|
+
if (!usage) return [DASH, DASH, DASH, DASH];
|
|
36750
|
+
return [
|
|
36751
|
+
format(usage.input),
|
|
36752
|
+
format(usage.output),
|
|
36753
|
+
format(usage.cacheRead),
|
|
36754
|
+
format(usage.cacheWrite)
|
|
36755
|
+
];
|
|
36756
|
+
}
|
|
36757
|
+
function sumOf(reported, pick) {
|
|
36758
|
+
const values = reported.map(pick).filter((v) => v !== void 0);
|
|
36759
|
+
return values.length === 0 ? void 0 : values.reduce((a, b) => a + b, 0);
|
|
36760
|
+
}
|
|
36761
|
+
function total(usages) {
|
|
36762
|
+
const reported = usages.filter((u) => u !== void 0);
|
|
36763
|
+
return [
|
|
36764
|
+
format(sumOf(reported, (u) => u.input)),
|
|
36765
|
+
format(sumOf(reported, (u) => u.output)),
|
|
36766
|
+
format(sumOf(reported, (u) => u.cacheRead)),
|
|
36767
|
+
format(sumOf(reported, (u) => u.cacheWrite))
|
|
36768
|
+
];
|
|
36769
|
+
}
|
|
36770
|
+
function row2(label2, values) {
|
|
36771
|
+
return `| ${label2} | ${values.join(" | ")} |`;
|
|
36772
|
+
}
|
|
36773
|
+
function buildTokenUsageTable(usages) {
|
|
36774
|
+
return [
|
|
36775
|
+
"## Token usage",
|
|
36776
|
+
"",
|
|
36777
|
+
"| Slot | Input | Output | Cache read | Cache write |",
|
|
36778
|
+
"| --- | ---: | ---: | ---: | ---: |",
|
|
36779
|
+
...usages.map(
|
|
36780
|
+
(usage, i) => row2(SLOT_LABELS[i] ?? `Slot ${i + 1}`, cells(usage))
|
|
36781
|
+
),
|
|
36782
|
+
row2("**Total**", total(usages))
|
|
36783
|
+
].join("\n");
|
|
36784
|
+
}
|
|
36785
|
+
|
|
36742
36786
|
// src/commands/review/ci/writeJobSummary.ts
|
|
36743
|
-
function writeJobSummary(synthesisPath, prInfo, summaryPath) {
|
|
36787
|
+
function writeJobSummary(synthesisPath, prInfo, summaryPath, slots) {
|
|
36744
36788
|
if (!summaryPath) return;
|
|
36745
36789
|
const markdown = readFileSync51(synthesisPath, "utf8");
|
|
36746
36790
|
const { unanchored } = selectPostableFindings(markdown, prInfo);
|
|
36747
|
-
|
|
36748
|
-
|
|
36749
|
-
|
|
36791
|
+
const usageTable = buildTokenUsageTable(slots.map((slot) => slot.usage));
|
|
36792
|
+
appendFileSync2(
|
|
36793
|
+
summaryPath,
|
|
36794
|
+
`${buildReviewSummary(markdown, unanchored)}
|
|
36750
36795
|
|
|
36751
|
-
|
|
36752
|
-
|
|
36753
|
-
|
|
36754
|
-
// src/commands/review/chainAddressComments.ts
|
|
36755
|
-
function chainAddressComments(prNumber, announce) {
|
|
36756
|
-
const args = ["review-pr-comments", String(prNumber)];
|
|
36757
|
-
if (announce) args.push("--announce");
|
|
36758
|
-
return startChainedSession(
|
|
36759
|
-
`an Address Comments session for PR #${prNumber}`,
|
|
36760
|
-
() => requestAssistSession(args, process.cwd(), { inPlace: true })
|
|
36796
|
+
${usageTable}
|
|
36797
|
+
`
|
|
36761
36798
|
);
|
|
36762
36799
|
}
|
|
36763
36800
|
|
|
36764
|
-
// src/commands/review/
|
|
36765
|
-
|
|
36766
|
-
|
|
36767
|
-
if (options2.addressComments && raisedComments) {
|
|
36768
|
-
await chainAddressComments(prNumber, options2.announce);
|
|
36769
|
-
return;
|
|
36770
|
-
}
|
|
36771
|
-
if (options2.announce) await announcePr(prNumber);
|
|
36772
|
-
}
|
|
36773
|
-
|
|
36774
|
-
// src/commands/review/sanitiseReviewerNames.ts
|
|
36775
|
-
var REVIEWER_LABEL = "the reviewer";
|
|
36776
|
-
function sanitiseReviewerNames(value) {
|
|
36777
|
-
return value.replace(/\bclaude\b/gi, REVIEWER_LABEL).replace(/\bopus\b/gi, REVIEWER_LABEL);
|
|
36778
|
-
}
|
|
36801
|
+
// src/commands/review/appendCiFooter.ts
|
|
36802
|
+
function appendCiFooter(body, ciFooter) {
|
|
36803
|
+
return ciFooter ? `${body}
|
|
36779
36804
|
|
|
36780
|
-
|
|
36781
|
-
function buildCommentBody(finding) {
|
|
36782
|
-
const lines2 = [];
|
|
36783
|
-
const severityLabel = finding.severity ?? "finding";
|
|
36784
|
-
lines2.push(`**${severityLabel}: ${finding.title}**`);
|
|
36785
|
-
if (finding.impact) lines2.push("", `Impact: ${finding.impact}`);
|
|
36786
|
-
if (finding.recommendation)
|
|
36787
|
-
lines2.push("", `Recommendation: ${finding.recommendation}`);
|
|
36788
|
-
return sanitiseReviewerNames(lines2.join("\n"));
|
|
36789
|
-
}
|
|
36790
|
-
async function postFindings(findings) {
|
|
36791
|
-
let posted = 0;
|
|
36792
|
-
let failed3 = 0;
|
|
36793
|
-
for (const finding of findings) {
|
|
36794
|
-
const body = buildCommentBody(finding);
|
|
36795
|
-
try {
|
|
36796
|
-
await comment2(finding.file, finding.line, body, {
|
|
36797
|
-
startLine: finding.startLine,
|
|
36798
|
-
skipPreview: true
|
|
36799
|
-
});
|
|
36800
|
-
posted++;
|
|
36801
|
-
} catch (error) {
|
|
36802
|
-
failed3++;
|
|
36803
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
36804
|
-
console.error(
|
|
36805
|
-
`Failed to post comment on ${finding.file}:${finding.line}: ${message3}`
|
|
36806
|
-
);
|
|
36807
|
-
}
|
|
36808
|
-
}
|
|
36809
|
-
return { posted, failed: failed3 };
|
|
36805
|
+
${ciFooter}` : body;
|
|
36810
36806
|
}
|
|
36811
36807
|
|
|
36812
36808
|
// src/commands/review/runReviewSubmission.ts
|
|
@@ -36831,243 +36827,27 @@ function submitBodyOnlyReview(body) {
|
|
|
36831
36827
|
runReviewSubmission(MUTATION6, body);
|
|
36832
36828
|
}
|
|
36833
36829
|
|
|
36834
|
-
// src/commands/review/
|
|
36835
|
-
|
|
36836
|
-
|
|
36837
|
-
|
|
36838
|
-
}
|
|
36839
|
-
|
|
36840
|
-
// src/commands/review/appendCiFooter.ts
|
|
36841
|
-
function appendCiFooter(body, ciFooter) {
|
|
36842
|
-
return ciFooter ? `${body}
|
|
36843
|
-
|
|
36844
|
-
${ciFooter}` : body;
|
|
36845
|
-
}
|
|
36846
|
-
|
|
36847
|
-
// src/commands/review/buildReviewBody.ts
|
|
36848
|
-
function buildReviewBody(markdown, unanchored, ciFooter) {
|
|
36849
|
-
return appendCiFooter(
|
|
36850
|
-
sanitiseReviewerNames(buildReviewSummary(markdown, unanchored)),
|
|
36851
|
-
ciFooter
|
|
36852
|
-
);
|
|
36853
|
-
}
|
|
36854
|
-
|
|
36855
|
-
// src/commands/review/postAndMaybeSubmit.ts
|
|
36856
|
-
function submitReview(body, posted) {
|
|
36857
|
-
if (posted > 0) submitPendingReview(body);
|
|
36858
|
-
else submitBodyOnlyReview(body);
|
|
36859
|
-
}
|
|
36860
|
-
async function decideSubmit(options2) {
|
|
36861
|
-
if (!options2.prompt) return options2.submit;
|
|
36862
|
-
await setSessionStatus("waiting");
|
|
36863
|
-
try {
|
|
36864
|
-
return await promptConfirm("Submit the pending review?", options2.submit);
|
|
36865
|
-
} finally {
|
|
36866
|
-
await setSessionStatus("running");
|
|
36867
|
-
}
|
|
36868
|
-
}
|
|
36869
|
-
async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
|
|
36870
|
-
const result = await postFindings(lineBound);
|
|
36871
|
-
const failedSuffix = result.failed > 0 ? `, ${result.failed} failed` : "";
|
|
36872
|
-
console.log(`Posted ${result.posted} comment(s)${failedSuffix}.`);
|
|
36873
|
-
const carried = carriedUnanchoredFindings(unanchored);
|
|
36874
|
-
if (result.posted === 0 && carried.length === 0 && !options2.ciFooter)
|
|
36875
|
-
return { posted: 0, submitted: false };
|
|
36876
|
-
const shouldSubmit = await decideSubmit(options2);
|
|
36877
|
-
if (shouldSubmit) {
|
|
36878
|
-
submitReview(
|
|
36879
|
-
buildReviewBody(markdown, unanchored, options2.ciFooter),
|
|
36880
|
-
result.posted
|
|
36881
|
-
);
|
|
36882
|
-
return { posted: result.posted, submitted: true };
|
|
36883
|
-
}
|
|
36884
|
-
console.log("Leaving the review unsubmitted.");
|
|
36885
|
-
return { posted: result.posted, submitted: false };
|
|
36886
|
-
}
|
|
36887
|
-
|
|
36888
|
-
// src/commands/review/stillOnReviewedPr.ts
|
|
36889
|
-
function currentPrNumber() {
|
|
36890
|
-
try {
|
|
36891
|
-
return findCurrentPrNumber();
|
|
36892
|
-
} catch (error) {
|
|
36893
|
-
console.error(
|
|
36894
|
-
`Error: could not confirm which PR this tree is on: ${error instanceof Error ? error.message : String(error)}`
|
|
36895
|
-
);
|
|
36896
|
-
return null;
|
|
36897
|
-
}
|
|
36898
|
-
}
|
|
36899
|
-
function stillOnReviewedPr(prNumber) {
|
|
36900
|
-
const current = currentPrNumber();
|
|
36901
|
-
if (current === prNumber) return true;
|
|
36902
|
-
console.error(
|
|
36903
|
-
`Error: this tree is now on ${current === null ? "a branch with no open PR" : `PR #${current}`}, not the reviewed PR #${prNumber}; skipping the post and any chained sessions.`
|
|
36904
|
-
);
|
|
36905
|
-
return false;
|
|
36906
|
-
}
|
|
36907
|
-
|
|
36908
|
-
// src/commands/review/submitNoFindingsReview.ts
|
|
36909
|
-
function submitNoFindingsReview(markdown, ciFooter) {
|
|
36910
|
-
const body = sanitiseReviewerNames(
|
|
36911
|
-
`${buildReviewSummary(markdown)}
|
|
36912
|
-
|
|
36913
|
-
No findings were raised.`
|
|
36914
|
-
);
|
|
36915
|
-
submitBodyOnlyReview(appendCiFooter(body, ciFooter));
|
|
36916
|
-
}
|
|
36917
|
-
|
|
36918
|
-
// src/commands/review/describeWork.ts
|
|
36919
|
-
function describeWork(comments3, carried) {
|
|
36920
|
-
const parts = [];
|
|
36921
|
-
if (comments3 > 0) parts.push(`${comments3} line comment(s)`);
|
|
36922
|
-
if (carried > 0) parts.push(`${carried} finding(s) in the review body`);
|
|
36923
|
-
return parts.join(" and ");
|
|
36924
|
-
}
|
|
36925
|
-
|
|
36926
|
-
// src/commands/review/postReviewToPr.ts
|
|
36927
|
-
var NOTHING_POSTED = { posted: 0, submitted: false };
|
|
36928
|
-
async function confirmPost(prNumber, work, options2) {
|
|
36929
|
-
if (!options2.prompt) return true;
|
|
36930
|
-
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
36931
|
-
}
|
|
36932
|
-
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
36933
|
-
const markdown = readFileSync52(synthesisPath, "utf8");
|
|
36934
|
-
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
36935
|
-
const carried = carriedUnanchoredFindings(unanchored);
|
|
36936
|
-
if (inDiff.length === 0 && carried.length === 0) {
|
|
36937
|
-
if (!options2.ciFooter) return NOTHING_POSTED;
|
|
36938
|
-
submitNoFindingsReview(markdown, options2.ciFooter);
|
|
36939
|
-
return { posted: 0, submitted: true };
|
|
36940
|
-
}
|
|
36941
|
-
const work = describeWork(inDiff.length, carried.length);
|
|
36942
|
-
console.log(`Found PR #${prInfo.prNumber} with ${work} to post.`);
|
|
36943
|
-
const confirmed = await confirmPost(prInfo.prNumber, work, options2);
|
|
36944
|
-
if (!confirmed) {
|
|
36945
|
-
console.log("Skipped posting.");
|
|
36946
|
-
return NOTHING_POSTED;
|
|
36947
|
-
}
|
|
36948
|
-
return postAndMaybeSubmit(inDiff, unanchored, markdown, options2);
|
|
36949
|
-
}
|
|
36950
|
-
async function postReviewToPr(synthesisPath, prInfo, options2) {
|
|
36951
|
-
if (!stillOnReviewedPr(prInfo.prNumber)) return;
|
|
36952
|
-
const outcome = await postFindingsToPr(prInfo, synthesisPath, options2);
|
|
36953
|
-
await chainAfterReview(prInfo.prNumber, outcome, options2);
|
|
36954
|
-
}
|
|
36955
|
-
|
|
36956
|
-
// src/commands/review/runApplySession.ts
|
|
36957
|
-
function buildApplyPrompt(synthesisPath) {
|
|
36958
|
-
return `You are helping the user apply fixes for a code review with each finding decided one at a time.
|
|
36959
|
-
|
|
36960
|
-
Read ${synthesisPath}. It contains a list of findings under the \`## Findings\` heading. Each finding is a block in this exact format:
|
|
36961
|
-
|
|
36962
|
-
### Finding: <short title>
|
|
36963
|
-
- Severity: blocker | major | minor | nit
|
|
36964
|
-
- Source: confirmed | disputed | claude-only | codex-only | already-raised
|
|
36965
|
-
- Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
|
|
36966
|
-
- Impact: one sentence on what could go wrong
|
|
36967
|
-
- Recommendation: one or two sentences with a concrete change
|
|
36968
|
-
|
|
36969
|
-
For every finding whose Source is NOT \`already-raised\`, walk through it with the user one at a time:
|
|
36970
|
-
1. Read the referenced file/lines (use the Location field) and any nearby code needed to understand the impact.
|
|
36971
|
-
2. Present a short assessment (one or two sentences) of whether the finding is real and what the right fix is.
|
|
36972
|
-
3. Ask the user: apply or skip?
|
|
36973
|
-
- On 'apply': edit the relevant file(s) in place to fix the issue, then remove that finding's entire \`### Finding:\` block from ${synthesisPath} (including any blank line that separated it from the next block).
|
|
36974
|
-
- On 'skip': leave the finding block in ${synthesisPath} unchanged and move on.
|
|
36975
|
-
|
|
36976
|
-
Skip findings whose Source is \`already-raised\` entirely \u2014 do not present them and do not remove them from ${synthesisPath}.
|
|
36977
|
-
|
|
36978
|
-
Important constraints:
|
|
36979
|
-
- Do not stage, commit, or push any changes. Leave all code edits unstaged in the working tree.
|
|
36980
|
-
- Do not post anything to a PR.
|
|
36981
|
-
- Only modify ${synthesisPath} by removing the blocks for findings the user chose to apply. Do not edit the wording of any remaining finding block.
|
|
36982
|
-
- When every non-already-raised finding has been decided, briefly summarise what was applied vs skipped and exit.`;
|
|
36983
|
-
}
|
|
36984
|
-
async function runApplySession(synthesisPath) {
|
|
36985
|
-
const { done: done2 } = spawnClaude(buildApplyPrompt(synthesisPath), {
|
|
36986
|
-
allowEdits: true
|
|
36987
|
-
});
|
|
36988
|
-
await done2;
|
|
36989
|
-
}
|
|
36990
|
-
|
|
36991
|
-
// src/commands/review/runBacklogSession.ts
|
|
36992
|
-
function buildBacklogPrompt(synthesisPath) {
|
|
36993
|
-
return `/bug add each finding in ${synthesisPath} as a phase
|
|
36994
|
-
|
|
36995
|
-
Read ${synthesisPath}. It contains a list of findings under the \`## Findings\` heading, each in a \`### Finding:\` block with Severity, Source, Location, Impact, and Recommendation fields.
|
|
36996
|
-
|
|
36997
|
-
File ONE bug backlog item covering the review findings:
|
|
36998
|
-
- Include EVERY finding in the file as a phase on that single item \u2014 including findings whose Source is \`already-raised\`.
|
|
36999
|
-
- Each phase should be named after its finding's title and its tasks should capture the finding's Location, Impact, and Recommendation.
|
|
37000
|
-
- File the item with \`assist backlog propose\`, then apply the whole plan with a single \`assist backlog update-plan <id> --json -\` call whose payload lists every finding as a phase. Do not run \`assist backlog add-phase\` per finding \u2014 the plan lands in one preview, or not at all.
|
|
37001
|
-
|
|
37002
|
-
Important constraints:
|
|
37003
|
-
- Do not edit ${synthesisPath} \u2014 leave it untouched.
|
|
37004
|
-
- Do not post anything to a PR.
|
|
37005
|
-
- Do not stage, commit, or push any changes.`;
|
|
37006
|
-
}
|
|
37007
|
-
async function runBacklogSession(synthesisPath) {
|
|
37008
|
-
const { done: done2 } = spawnClaude(buildBacklogPrompt(synthesisPath), {
|
|
37009
|
-
allowEdits: true
|
|
37010
|
-
});
|
|
37011
|
-
await done2;
|
|
37012
|
-
}
|
|
37013
|
-
|
|
37014
|
-
// src/commands/review/runRefineSession.ts
|
|
37015
|
-
function buildRefinePrompt(synthesisPath) {
|
|
37016
|
-
return `You are refining a code review synthesis with the user.
|
|
37017
|
-
|
|
37018
|
-
Read ${synthesisPath} and walk the user through each finding one at a time. Before asking the user what to do with a finding, do some investigation so you can give an informed opinion:
|
|
37019
|
-
- Read the referenced file/lines (use the Location field) to confirm the issue is real and current.
|
|
37020
|
-
- Check nearby code, callers, or related files when the impact depends on context.
|
|
37021
|
-
- Form a view on whether the finding is applicable, whether the stated severity is right, and whether the recommendation actually fixes the problem.
|
|
37022
|
-
|
|
37023
|
-
Then present your assessment briefly (one or two sentences) and ask the user whether to keep it as-is, edit it (e.g. adjust severity, sharpen the recommendation), or drop it. After all existing findings are reviewed, ask whether to add any new findings.
|
|
37024
|
-
|
|
37025
|
-
Edit ${synthesisPath} in place so the resulting file is the user's final list:
|
|
37026
|
-
- To drop a finding, remove its entire \`### Finding:\` block.
|
|
37027
|
-
- To edit a finding, modify only the fields the user wants changed.
|
|
37028
|
-
- To add a new finding, append a block in the exact format below under the \`## Findings\` heading.
|
|
37029
|
-
|
|
37030
|
-
Each finding block must use this exact format so it parses correctly:
|
|
37031
|
-
|
|
37032
|
-
### Finding: <short title>
|
|
37033
|
-
- Severity: blocker | major | minor | nit
|
|
37034
|
-
- Source: confirmed | disputed | claude-only | codex-only | already-raised
|
|
37035
|
-
- Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
|
|
37036
|
-
- Impact: one sentence on what could go wrong
|
|
37037
|
-
- Recommendation: one or two sentences with a concrete change
|
|
37038
|
-
|
|
37039
|
-
User-supplied findings should use Source: \`confirmed\`. Use Location \`n/a\` only when the finding is not tied to a specific line.
|
|
37040
|
-
|
|
37041
|
-
Do not post anything to a PR; only edit ${synthesisPath}. When the user is done, exit.`;
|
|
36830
|
+
// src/commands/review/submitFailedReview.ts
|
|
36831
|
+
function describeFailures(failures) {
|
|
36832
|
+
if (failures.length === 0) return "The review did not complete.";
|
|
36833
|
+
const steps = failures.map((f) => f.name.replace("-", " ")).join(" and ");
|
|
36834
|
+
return `The review did not complete: ${steps} failed.`;
|
|
37042
36835
|
}
|
|
37043
|
-
|
|
37044
|
-
const
|
|
37045
|
-
|
|
37046
|
-
|
|
37047
|
-
|
|
36836
|
+
function submitFailedReview(failures, ciFooter, runUrl) {
|
|
36837
|
+
const lines2 = [
|
|
36838
|
+
"## Code review failed",
|
|
36839
|
+
"",
|
|
36840
|
+
`${describeFailures(failures)} No findings were posted.`
|
|
36841
|
+
];
|
|
36842
|
+
if (runUrl) lines2.push("", `See the [workflow run](${runUrl}) for details.`);
|
|
36843
|
+
submitBodyOnlyReview(appendCiFooter(lines2.join("\n"), ciFooter));
|
|
37048
36844
|
}
|
|
37049
36845
|
|
|
37050
|
-
// src/commands/review/
|
|
37051
|
-
function
|
|
37052
|
-
|
|
37053
|
-
|
|
37054
|
-
|
|
37055
|
-
return null;
|
|
37056
|
-
}
|
|
37057
|
-
async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
37058
|
-
const session = nonPostingSession(options2);
|
|
37059
|
-
if (!session) {
|
|
37060
|
-
await postReviewToPr(synthesisPath, prInfo, {
|
|
37061
|
-
prompt: options2.prompt,
|
|
37062
|
-
submit: options2.submit,
|
|
37063
|
-
addressComments: options2.addressComments,
|
|
37064
|
-
announce: options2.announce,
|
|
37065
|
-
ciFooter: options2.ciFooter
|
|
37066
|
-
});
|
|
37067
|
-
return;
|
|
37068
|
-
}
|
|
37069
|
-
await session(synthesisPath);
|
|
37070
|
-
if (options2.announce) await announcePr(prInfo.prNumber);
|
|
36846
|
+
// src/commands/review/exitFailedCiReview.ts
|
|
36847
|
+
function exitFailedCiReview(failures, ci) {
|
|
36848
|
+
console.error("Review failed; no findings were posted.");
|
|
36849
|
+
submitFailedReview(failures, ci.footer, ci.runUrl);
|
|
36850
|
+
process.exit(1);
|
|
37071
36851
|
}
|
|
37072
36852
|
|
|
37073
36853
|
// src/commands/review/cachedReviewerResult.ts
|
|
@@ -37119,7 +36899,7 @@ function renderEntry(entry, frame) {
|
|
|
37119
36899
|
}
|
|
37120
36900
|
|
|
37121
36901
|
// src/commands/review/startReviewLog.ts
|
|
37122
|
-
import { format } from "util";
|
|
36902
|
+
import { format as format2 } from "util";
|
|
37123
36903
|
|
|
37124
36904
|
// src/commands/review/createReviewLogSink.ts
|
|
37125
36905
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync24 } from "fs";
|
|
@@ -37167,7 +36947,7 @@ function patch(method) {
|
|
|
37167
36947
|
const original = console[method].bind(console);
|
|
37168
36948
|
console[method] = (...args) => {
|
|
37169
36949
|
original(...args);
|
|
37170
|
-
appendReviewLog(
|
|
36950
|
+
appendReviewLog(format2(...args));
|
|
37171
36951
|
};
|
|
37172
36952
|
}
|
|
37173
36953
|
function startReviewLog() {
|
|
@@ -37294,69 +37074,6 @@ function skippedCodexResult(outputPath) {
|
|
|
37294
37074
|
return { name: "codex", outputPath, exitCode: 0, stderr: "" };
|
|
37295
37075
|
}
|
|
37296
37076
|
|
|
37297
|
-
// src/commands/review/reviewerLabel.ts
|
|
37298
|
-
function reviewerLabel(name, model) {
|
|
37299
|
-
return model ? `${name} (${model})` : name;
|
|
37300
|
-
}
|
|
37301
|
-
|
|
37302
|
-
// src/commands/review/formatReviewerFailure.ts
|
|
37303
|
-
var FAST_FAIL_MS = 1e3;
|
|
37304
|
-
var STDOUT_TAIL_LINES = 20;
|
|
37305
|
-
function indent2(text18) {
|
|
37306
|
-
return text18.split(/\r?\n/).map((line) => ` ${line}`);
|
|
37307
|
-
}
|
|
37308
|
-
function tailLines(text18, maxLines) {
|
|
37309
|
-
const lines2 = text18.split(/\r?\n/);
|
|
37310
|
-
return lines2.length <= maxLines ? text18 : lines2.slice(-maxLines).join("\n");
|
|
37311
|
-
}
|
|
37312
|
-
function isFastFail(input) {
|
|
37313
|
-
return input.exitCode !== 0 && input.elapsedMs !== void 0 && input.elapsedMs < FAST_FAIL_MS;
|
|
37314
|
-
}
|
|
37315
|
-
function fastFailHint(command) {
|
|
37316
|
-
return [
|
|
37317
|
-
`${command} exited almost immediately \u2014 it likely failed to start.`,
|
|
37318
|
-
`Common causes: not installed on PATH, not authenticated, or misconfigured.`,
|
|
37319
|
-
`Try \`${command} --version\` to confirm install, then \`${command} login\` if authentication may be missing.`
|
|
37320
|
-
];
|
|
37321
|
-
}
|
|
37322
|
-
function outputDetail(input) {
|
|
37323
|
-
const stderr = input.stderr.trim();
|
|
37324
|
-
if (stderr) return ["stderr:", ...indent2(stderr)];
|
|
37325
|
-
const stdout = (input.stdout ?? "").trim();
|
|
37326
|
-
if (stdout) {
|
|
37327
|
-
return [
|
|
37328
|
-
`stdout (no stderr was captured \u2014 showing last ${STDOUT_TAIL_LINES} lines):`,
|
|
37329
|
-
...indent2(tailLines(stdout, STDOUT_TAIL_LINES))
|
|
37330
|
-
];
|
|
37331
|
-
}
|
|
37332
|
-
return [
|
|
37333
|
-
"No stderr or stdout was captured. Check the review folder for partial output, or rerun with --verbose for full streaming output."
|
|
37334
|
-
];
|
|
37335
|
-
}
|
|
37336
|
-
function formatReviewerFailure(input) {
|
|
37337
|
-
const command = input.command ?? input.name;
|
|
37338
|
-
const seconds = Math.round((input.elapsedMs ?? 0) / 1e3);
|
|
37339
|
-
const headerLine = `${reviewerLabel(command, input.model)} CLI exited with code ${input.exitCode} after ${seconds}s`;
|
|
37340
|
-
const detailLines = [];
|
|
37341
|
-
if (isFastFail(input)) detailLines.push(...fastFailHint(command));
|
|
37342
|
-
detailLines.push(...outputDetail(input));
|
|
37343
|
-
return { headerLine, detailLines };
|
|
37344
|
-
}
|
|
37345
|
-
function printReviewerFailure(input) {
|
|
37346
|
-
if (input.exitCode === 0) return;
|
|
37347
|
-
const diagnostic = formatReviewerFailure(input);
|
|
37348
|
-
console.error(`[${input.name}] ${diagnostic.headerLine}`);
|
|
37349
|
-
for (const line of diagnostic.detailLines) console.error(line);
|
|
37350
|
-
}
|
|
37351
|
-
|
|
37352
|
-
// src/commands/review/printReviewerFailures.ts
|
|
37353
|
-
function printReviewerFailures(results) {
|
|
37354
|
-
for (const r of results) printReviewerFailure(r);
|
|
37355
|
-
}
|
|
37356
|
-
|
|
37357
|
-
// src/commands/review/runAndSynthesise.ts
|
|
37358
|
-
import { existsSync as existsSync68, unlinkSync as unlinkSync19 } from "fs";
|
|
37359
|
-
|
|
37360
37077
|
// src/commands/review/buildReviewerStdin.ts
|
|
37361
37078
|
var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in the request file whose absolute path is given below.
|
|
37362
37079
|
|
|
@@ -37442,6 +37159,11 @@ The review request is at: ${requestPath}
|
|
|
37442
37159
|
`;
|
|
37443
37160
|
}
|
|
37444
37161
|
|
|
37162
|
+
// src/commands/review/reviewerLabel.ts
|
|
37163
|
+
function reviewerLabel(name, model) {
|
|
37164
|
+
return model ? `${name} (${model})` : name;
|
|
37165
|
+
}
|
|
37166
|
+
|
|
37445
37167
|
// src/commands/review/buildCodexModelArgs.ts
|
|
37446
37168
|
function buildCodexModelArgs() {
|
|
37447
37169
|
return buildLitellmCodexArgs(loadConfig().review?.codexModel);
|
|
@@ -37450,50 +37172,6 @@ function buildCodexModelArgs() {
|
|
|
37450
37172
|
// src/commands/review/runClaudeReviewer.ts
|
|
37451
37173
|
import { writeFileSync as writeFileSync41 } from "fs";
|
|
37452
37174
|
|
|
37453
|
-
// src/commands/review/finaliseReviewerSpinner.ts
|
|
37454
|
-
var SUMMARY_MAX_LEN = 80;
|
|
37455
|
-
function summariseStderr(stderr) {
|
|
37456
|
-
const firstLine3 = stderr.split(/\r?\n/).find((l) => l.trim().length > 0);
|
|
37457
|
-
if (!firstLine3) return "";
|
|
37458
|
-
const trimmed = firstLine3.trim();
|
|
37459
|
-
return trimmed.length > SUMMARY_MAX_LEN ? `${trimmed.slice(0, SUMMARY_MAX_LEN - 1)}\u2026` : trimmed;
|
|
37460
|
-
}
|
|
37461
|
-
function finaliseReviewerSpinner(spinner, outcome) {
|
|
37462
|
-
const label2 = reviewerLabel(outcome.name, outcome.model);
|
|
37463
|
-
const elapsed = Math.round(outcome.elapsedMs / 1e3);
|
|
37464
|
-
if (outcome.exitCode === 0) {
|
|
37465
|
-
spinner.succeed(`${label2} \u2014 done in ${elapsed}s`);
|
|
37466
|
-
return;
|
|
37467
|
-
}
|
|
37468
|
-
const summary = summariseStderr(outcome.stderr ?? "");
|
|
37469
|
-
const suffix = summary ? `: ${summary}` : "";
|
|
37470
|
-
spinner.fail(
|
|
37471
|
-
`${label2} \u2014 failed in ${elapsed}s (exit ${outcome.exitCode})${suffix}`
|
|
37472
|
-
);
|
|
37473
|
-
}
|
|
37474
|
-
|
|
37475
|
-
// src/commands/review/finaliseReviewerRun.ts
|
|
37476
|
-
function finaliseReviewerRun(spec, spinner, result) {
|
|
37477
|
-
if (spinner)
|
|
37478
|
-
finaliseReviewerSpinner(spinner, {
|
|
37479
|
-
name: spec.name,
|
|
37480
|
-
model: spec.model,
|
|
37481
|
-
exitCode: result.exitCode,
|
|
37482
|
-
elapsedMs: result.elapsedMs,
|
|
37483
|
-
stderr: result.stderr
|
|
37484
|
-
});
|
|
37485
|
-
return {
|
|
37486
|
-
name: spec.name,
|
|
37487
|
-
command: spec.command,
|
|
37488
|
-
model: spec.model,
|
|
37489
|
-
outputPath: spec.outputPath,
|
|
37490
|
-
exitCode: result.exitCode,
|
|
37491
|
-
stderr: result.stderr,
|
|
37492
|
-
stdout: result.stdout,
|
|
37493
|
-
elapsedMs: result.elapsedMs
|
|
37494
|
-
};
|
|
37495
|
-
}
|
|
37496
|
-
|
|
37497
37175
|
// src/commands/review/formatToolSummary.ts
|
|
37498
37176
|
function truncate2(value, max = 80) {
|
|
37499
37177
|
const collapsed = value.replace(/\s+/g, " ").trim();
|
|
@@ -37530,6 +37208,21 @@ function simplifyShellCommand(command) {
|
|
|
37530
37208
|
return truncate2(inner);
|
|
37531
37209
|
}
|
|
37532
37210
|
|
|
37211
|
+
// src/commands/review/parseClaudeUsage.ts
|
|
37212
|
+
function count8(value) {
|
|
37213
|
+
return typeof value === "number" ? value : 0;
|
|
37214
|
+
}
|
|
37215
|
+
function parseClaudeUsage(usage) {
|
|
37216
|
+
if (typeof usage !== "object" || usage === null) return void 0;
|
|
37217
|
+
const raw = usage;
|
|
37218
|
+
return {
|
|
37219
|
+
input: count8(raw.input_tokens),
|
|
37220
|
+
output: count8(raw.output_tokens),
|
|
37221
|
+
cacheRead: count8(raw.cache_read_input_tokens),
|
|
37222
|
+
cacheWrite: count8(raw.cache_creation_input_tokens)
|
|
37223
|
+
};
|
|
37224
|
+
}
|
|
37225
|
+
|
|
37533
37226
|
// src/commands/review/parseClaudeEvent.ts
|
|
37534
37227
|
function isAssistantEvent(value) {
|
|
37535
37228
|
return typeof value === "object" && value !== null && value.type === "assistant";
|
|
@@ -37560,7 +37253,8 @@ function parseClaudeEvent(line) {
|
|
|
37560
37253
|
if (toolUses.length > 0) return { kind: "tool_uses", toolUses };
|
|
37561
37254
|
}
|
|
37562
37255
|
if (isResultEvent(event) && typeof event.result === "string") {
|
|
37563
|
-
|
|
37256
|
+
const usage = parseClaudeUsage(event.usage);
|
|
37257
|
+
return usage ? { kind: "final", text: event.result, usage } : { kind: "final", text: event.result };
|
|
37564
37258
|
}
|
|
37565
37259
|
return { kind: "ignore" };
|
|
37566
37260
|
}
|
|
@@ -37582,6 +37276,68 @@ function reportReviewerToolUse(name, use, spinner, model) {
|
|
|
37582
37276
|
console.log(`[${label2}] ${use.tool}${suffix}`);
|
|
37583
37277
|
}
|
|
37584
37278
|
|
|
37279
|
+
// src/commands/review/createClaudeLineHandler.ts
|
|
37280
|
+
function createClaudeLineHandler(name, spinner, model) {
|
|
37281
|
+
const state = { finalText: "" };
|
|
37282
|
+
const onLine = (line) => {
|
|
37283
|
+
const event = parseClaudeEvent(line);
|
|
37284
|
+
if (event.kind === "tool_uses") {
|
|
37285
|
+
for (const use of event.toolUses)
|
|
37286
|
+
reportReviewerToolUse(name, use, spinner, model);
|
|
37287
|
+
return;
|
|
37288
|
+
}
|
|
37289
|
+
if (event.kind === "final") {
|
|
37290
|
+
state.finalText = event.text;
|
|
37291
|
+
state.usage = event.usage;
|
|
37292
|
+
}
|
|
37293
|
+
};
|
|
37294
|
+
return { state, onLine };
|
|
37295
|
+
}
|
|
37296
|
+
|
|
37297
|
+
// src/commands/review/finaliseReviewerSpinner.ts
|
|
37298
|
+
var SUMMARY_MAX_LEN = 80;
|
|
37299
|
+
function summariseStderr(stderr) {
|
|
37300
|
+
const firstLine3 = stderr.split(/\r?\n/).find((l) => l.trim().length > 0);
|
|
37301
|
+
if (!firstLine3) return "";
|
|
37302
|
+
const trimmed = firstLine3.trim();
|
|
37303
|
+
return trimmed.length > SUMMARY_MAX_LEN ? `${trimmed.slice(0, SUMMARY_MAX_LEN - 1)}\u2026` : trimmed;
|
|
37304
|
+
}
|
|
37305
|
+
function finaliseReviewerSpinner(spinner, outcome) {
|
|
37306
|
+
const label2 = reviewerLabel(outcome.name, outcome.model);
|
|
37307
|
+
const elapsed = Math.round(outcome.elapsedMs / 1e3);
|
|
37308
|
+
if (outcome.exitCode === 0) {
|
|
37309
|
+
spinner.succeed(`${label2} \u2014 done in ${elapsed}s`);
|
|
37310
|
+
return;
|
|
37311
|
+
}
|
|
37312
|
+
const summary = summariseStderr(outcome.stderr ?? "");
|
|
37313
|
+
const suffix = summary ? `: ${summary}` : "";
|
|
37314
|
+
spinner.fail(
|
|
37315
|
+
`${label2} \u2014 failed in ${elapsed}s (exit ${outcome.exitCode})${suffix}`
|
|
37316
|
+
);
|
|
37317
|
+
}
|
|
37318
|
+
|
|
37319
|
+
// src/commands/review/finaliseReviewerRun.ts
|
|
37320
|
+
function finaliseReviewerRun(spec, spinner, result) {
|
|
37321
|
+
if (spinner)
|
|
37322
|
+
finaliseReviewerSpinner(spinner, {
|
|
37323
|
+
name: spec.name,
|
|
37324
|
+
model: spec.model,
|
|
37325
|
+
exitCode: result.exitCode,
|
|
37326
|
+
elapsedMs: result.elapsedMs,
|
|
37327
|
+
stderr: result.stderr
|
|
37328
|
+
});
|
|
37329
|
+
return {
|
|
37330
|
+
name: spec.name,
|
|
37331
|
+
command: spec.command,
|
|
37332
|
+
model: spec.model,
|
|
37333
|
+
outputPath: spec.outputPath,
|
|
37334
|
+
exitCode: result.exitCode,
|
|
37335
|
+
stderr: result.stderr,
|
|
37336
|
+
stdout: result.stdout,
|
|
37337
|
+
elapsedMs: result.elapsedMs
|
|
37338
|
+
};
|
|
37339
|
+
}
|
|
37340
|
+
|
|
37585
37341
|
// src/commands/review/runStreamingChild.ts
|
|
37586
37342
|
import { spawn as spawn8 } from "child_process";
|
|
37587
37343
|
|
|
@@ -37628,6 +37384,56 @@ function attachStdoutTail(child, maxBytes = 8192) {
|
|
|
37628
37384
|
return state;
|
|
37629
37385
|
}
|
|
37630
37386
|
|
|
37387
|
+
// src/commands/review/formatReviewerFailure.ts
|
|
37388
|
+
var FAST_FAIL_MS = 1e3;
|
|
37389
|
+
var STDOUT_TAIL_LINES = 20;
|
|
37390
|
+
function indent2(text18) {
|
|
37391
|
+
return text18.split(/\r?\n/).map((line) => ` ${line}`);
|
|
37392
|
+
}
|
|
37393
|
+
function tailLines(text18, maxLines) {
|
|
37394
|
+
const lines2 = text18.split(/\r?\n/);
|
|
37395
|
+
return lines2.length <= maxLines ? text18 : lines2.slice(-maxLines).join("\n");
|
|
37396
|
+
}
|
|
37397
|
+
function isFastFail(input) {
|
|
37398
|
+
return input.exitCode !== 0 && input.elapsedMs !== void 0 && input.elapsedMs < FAST_FAIL_MS;
|
|
37399
|
+
}
|
|
37400
|
+
function fastFailHint(command) {
|
|
37401
|
+
return [
|
|
37402
|
+
`${command} exited almost immediately \u2014 it likely failed to start.`,
|
|
37403
|
+
`Common causes: not installed on PATH, not authenticated, or misconfigured.`,
|
|
37404
|
+
`Try \`${command} --version\` to confirm install, then \`${command} login\` if authentication may be missing.`
|
|
37405
|
+
];
|
|
37406
|
+
}
|
|
37407
|
+
function outputDetail(input) {
|
|
37408
|
+
const stderr = input.stderr.trim();
|
|
37409
|
+
if (stderr) return ["stderr:", ...indent2(stderr)];
|
|
37410
|
+
const stdout = (input.stdout ?? "").trim();
|
|
37411
|
+
if (stdout) {
|
|
37412
|
+
return [
|
|
37413
|
+
`stdout (no stderr was captured \u2014 showing last ${STDOUT_TAIL_LINES} lines):`,
|
|
37414
|
+
...indent2(tailLines(stdout, STDOUT_TAIL_LINES))
|
|
37415
|
+
];
|
|
37416
|
+
}
|
|
37417
|
+
return [
|
|
37418
|
+
"No stderr or stdout was captured. Check the review folder for partial output, or rerun with --verbose for full streaming output."
|
|
37419
|
+
];
|
|
37420
|
+
}
|
|
37421
|
+
function formatReviewerFailure(input) {
|
|
37422
|
+
const command = input.command ?? input.name;
|
|
37423
|
+
const seconds = Math.round((input.elapsedMs ?? 0) / 1e3);
|
|
37424
|
+
const headerLine = `${reviewerLabel(command, input.model)} CLI exited with code ${input.exitCode} after ${seconds}s`;
|
|
37425
|
+
const detailLines = [];
|
|
37426
|
+
if (isFastFail(input)) detailLines.push(...fastFailHint(command));
|
|
37427
|
+
detailLines.push(...outputDetail(input));
|
|
37428
|
+
return { headerLine, detailLines };
|
|
37429
|
+
}
|
|
37430
|
+
function printReviewerFailure(input) {
|
|
37431
|
+
if (input.exitCode === 0) return;
|
|
37432
|
+
const diagnostic = formatReviewerFailure(input);
|
|
37433
|
+
console.error(`[${input.name}] ${diagnostic.headerLine}`);
|
|
37434
|
+
for (const line of diagnostic.detailLines) console.error(line);
|
|
37435
|
+
}
|
|
37436
|
+
|
|
37631
37437
|
// src/commands/review/logChildClose.ts
|
|
37632
37438
|
function logChildClose(args) {
|
|
37633
37439
|
const elapsedSeconds = Math.round(args.elapsedMs / 1e3);
|
|
@@ -37768,9 +37574,13 @@ function runStreamingChild(spec) {
|
|
|
37768
37574
|
|
|
37769
37575
|
// src/commands/review/runClaudeReviewer.ts
|
|
37770
37576
|
async function runClaudeReviewer(spec) {
|
|
37771
|
-
let finalText = "";
|
|
37772
37577
|
const { spinner, override } = spec;
|
|
37773
37578
|
const command = "claude";
|
|
37579
|
+
const { state, onLine } = createClaudeLineHandler(
|
|
37580
|
+
spec.name,
|
|
37581
|
+
spinner,
|
|
37582
|
+
override?.model
|
|
37583
|
+
);
|
|
37774
37584
|
const result = await runStreamingChild({
|
|
37775
37585
|
name: spec.name,
|
|
37776
37586
|
command,
|
|
@@ -37787,23 +37597,16 @@ async function runClaudeReviewer(spec) {
|
|
|
37787
37597
|
stdin: spec.stdin,
|
|
37788
37598
|
quiet: Boolean(spinner),
|
|
37789
37599
|
...override ? { env: override.env } : {},
|
|
37790
|
-
onLine
|
|
37791
|
-
const event = parseClaudeEvent(line);
|
|
37792
|
-
if (event.kind === "tool_uses") {
|
|
37793
|
-
for (const use of event.toolUses)
|
|
37794
|
-
reportReviewerToolUse(spec.name, use, spinner, override?.model);
|
|
37795
|
-
return;
|
|
37796
|
-
}
|
|
37797
|
-
if (event.kind === "final") finalText = event.text;
|
|
37798
|
-
}
|
|
37600
|
+
onLine
|
|
37799
37601
|
});
|
|
37800
|
-
if (result.exitCode === 0 && finalText)
|
|
37801
|
-
writeFileSync41(spec.outputPath, finalText);
|
|
37802
|
-
|
|
37602
|
+
if (result.exitCode === 0 && state.finalText)
|
|
37603
|
+
writeFileSync41(spec.outputPath, state.finalText);
|
|
37604
|
+
const finalised = finaliseReviewerRun(
|
|
37803
37605
|
{ ...spec, command, model: override?.model },
|
|
37804
37606
|
spinner,
|
|
37805
37607
|
result
|
|
37806
37608
|
);
|
|
37609
|
+
return state.usage ? { ...finalised, usage: state.usage } : finalised;
|
|
37807
37610
|
}
|
|
37808
37611
|
|
|
37809
37612
|
// src/commands/review/runCodexReviewer.ts
|
|
@@ -37951,8 +37754,11 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
37951
37754
|
return { results, anyFresh };
|
|
37952
37755
|
}
|
|
37953
37756
|
|
|
37757
|
+
// src/commands/review/synthesiseAfterReviewers.ts
|
|
37758
|
+
import { existsSync as existsSync68, unlinkSync as unlinkSync19 } from "fs";
|
|
37759
|
+
|
|
37954
37760
|
// src/commands/review/synthesise.ts
|
|
37955
|
-
import { readFileSync as
|
|
37761
|
+
import { readFileSync as readFileSync52 } from "fs";
|
|
37956
37762
|
|
|
37957
37763
|
// src/commands/review/buildSynthesisStdin.ts
|
|
37958
37764
|
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.
|
|
@@ -38021,7 +37827,7 @@ Files:
|
|
|
38021
37827
|
|
|
38022
37828
|
// src/commands/review/synthesise.ts
|
|
38023
37829
|
function printSummary2(synthesisPath) {
|
|
38024
|
-
const markdown =
|
|
37830
|
+
const markdown = readFileSync52(synthesisPath, "utf8");
|
|
38025
37831
|
console.log("");
|
|
38026
37832
|
console.log(buildReviewSummary(markdown));
|
|
38027
37833
|
console.log("");
|
|
@@ -38053,6 +37859,24 @@ async function synthesise(paths, options2) {
|
|
|
38053
37859
|
return result;
|
|
38054
37860
|
}
|
|
38055
37861
|
|
|
37862
|
+
// src/commands/review/synthesiseAfterReviewers.ts
|
|
37863
|
+
async function synthesiseAfterReviewers(input) {
|
|
37864
|
+
const { paths, failures } = input;
|
|
37865
|
+
if (input.anyFresh && existsSync68(paths.synthesisPath)) {
|
|
37866
|
+
unlinkSync19(paths.synthesisPath);
|
|
37867
|
+
}
|
|
37868
|
+
const synthesisResult = await synthesise(paths, {
|
|
37869
|
+
multi: input.multi,
|
|
37870
|
+
slot: input.slot
|
|
37871
|
+
});
|
|
37872
|
+
if (synthesisResult.exitCode !== 0) failures.push(synthesisResult);
|
|
37873
|
+
return {
|
|
37874
|
+
ok: synthesisResult.exitCode === 0,
|
|
37875
|
+
failures,
|
|
37876
|
+
slots: [...input.results, synthesisResult]
|
|
37877
|
+
};
|
|
37878
|
+
}
|
|
37879
|
+
|
|
38056
37880
|
// src/commands/review/skipReason.ts
|
|
38057
37881
|
function skipReason(results, failures, strict) {
|
|
38058
37882
|
if (failures.length === results.length)
|
|
@@ -38084,17 +37908,16 @@ async function runAndSynthesise(args) {
|
|
|
38084
37908
|
const reason4 = skipReason(results, failures, args.strict);
|
|
38085
37909
|
if (reason4) {
|
|
38086
37910
|
console.error(reason4);
|
|
38087
|
-
return { ok: false, failures };
|
|
37911
|
+
return { ok: false, failures, slots: results };
|
|
38088
37912
|
}
|
|
38089
|
-
|
|
38090
|
-
|
|
38091
|
-
|
|
38092
|
-
|
|
37913
|
+
return synthesiseAfterReviewers({
|
|
37914
|
+
paths,
|
|
37915
|
+
results,
|
|
37916
|
+
failures,
|
|
37917
|
+
anyFresh,
|
|
38093
37918
|
multi,
|
|
38094
37919
|
slot: args.models.synthesis
|
|
38095
37920
|
});
|
|
38096
|
-
if (synthesisResult.exitCode !== 0) failures.push(synthesisResult);
|
|
38097
|
-
return { ok: synthesisResult.exitCode === 0, failures };
|
|
38098
37921
|
}
|
|
38099
37922
|
|
|
38100
37923
|
// src/commands/review/useSpinnerUi.ts
|
|
@@ -38103,6 +37926,18 @@ function useSpinnerUi(verbose) {
|
|
|
38103
37926
|
return Boolean(process.stdout.isTTY);
|
|
38104
37927
|
}
|
|
38105
37928
|
|
|
37929
|
+
// src/commands/review/printReviewerFailures.ts
|
|
37930
|
+
function printReviewerFailures(results) {
|
|
37931
|
+
for (const r of results) printReviewerFailure(r);
|
|
37932
|
+
}
|
|
37933
|
+
|
|
37934
|
+
// src/commands/review/reportFailures.ts
|
|
37935
|
+
function reportFailures(failures, usingSpinner) {
|
|
37936
|
+
if (failures.length === 0) return;
|
|
37937
|
+
if (!usingSpinner) return;
|
|
37938
|
+
printReviewerFailures(failures);
|
|
37939
|
+
}
|
|
37940
|
+
|
|
38106
37941
|
// src/commands/review/runReviewPipeline.ts
|
|
38107
37942
|
function createUi(spinnerUi) {
|
|
38108
37943
|
const startedAt = Date.now();
|
|
@@ -38117,11 +37952,6 @@ function finishUi(ui, ok) {
|
|
|
38117
37952
|
if (ok) ui.elapsed.succeed(label2);
|
|
38118
37953
|
else ui.elapsed.fail(label2);
|
|
38119
37954
|
}
|
|
38120
|
-
function reportFailures(failures, usingSpinner) {
|
|
38121
|
-
if (failures.length === 0) return;
|
|
38122
|
-
if (!usingSpinner) return;
|
|
38123
|
-
printReviewerFailures(failures);
|
|
38124
|
-
}
|
|
38125
37955
|
async function runReviewPipeline(paths, options2) {
|
|
38126
37956
|
const cachedClaude = cachedReviewerResult("claude", paths.claudePath);
|
|
38127
37957
|
const codexPlan = await planCodexReviewer(
|
|
@@ -38140,7 +37970,7 @@ async function runReviewPipeline(paths, options2) {
|
|
|
38140
37970
|
});
|
|
38141
37971
|
finishUi(ui, outcome.ok);
|
|
38142
37972
|
reportFailures(outcome.failures, ui.multi !== void 0);
|
|
38143
|
-
return outcome
|
|
37973
|
+
return outcome;
|
|
38144
37974
|
} catch (error) {
|
|
38145
37975
|
ui.multi?.failRemaining();
|
|
38146
37976
|
throw error;
|
|
@@ -38337,9 +38167,9 @@ function setupReviewDir(repoRoot2, context, force) {
|
|
|
38337
38167
|
console.log(`Review folder: ${paths.reviewDir}`);
|
|
38338
38168
|
return paths;
|
|
38339
38169
|
}
|
|
38340
|
-
function logPriorComments(
|
|
38341
|
-
if (
|
|
38342
|
-
console.log(`Including ${
|
|
38170
|
+
function logPriorComments(count9) {
|
|
38171
|
+
if (count9 === 0) return;
|
|
38172
|
+
console.log(`Including ${count9} prior review comment(s) in request.md.`);
|
|
38343
38173
|
}
|
|
38344
38174
|
|
|
38345
38175
|
// src/commands/review/gatherContext.ts
|
|
@@ -38438,7 +38268,300 @@ function gatherChangedContext() {
|
|
|
38438
38268
|
process.exit(1);
|
|
38439
38269
|
}
|
|
38440
38270
|
|
|
38441
|
-
// src/commands/review/
|
|
38271
|
+
// src/commands/review/postReviewToPr.ts
|
|
38272
|
+
import { readFileSync as readFileSync53 } from "fs";
|
|
38273
|
+
|
|
38274
|
+
// src/commands/review/chainAddressComments.ts
|
|
38275
|
+
function chainAddressComments(prNumber, announce) {
|
|
38276
|
+
const args = ["review-pr-comments", String(prNumber)];
|
|
38277
|
+
if (announce) args.push("--announce");
|
|
38278
|
+
return startChainedSession(
|
|
38279
|
+
`an Address Comments session for PR #${prNumber}`,
|
|
38280
|
+
() => requestAssistSession(args, process.cwd(), { inPlace: true })
|
|
38281
|
+
);
|
|
38282
|
+
}
|
|
38283
|
+
|
|
38284
|
+
// src/commands/review/chainAfterReview.ts
|
|
38285
|
+
async function chainAfterReview(prNumber, outcome, options2) {
|
|
38286
|
+
const raisedComments = outcome.posted > 0 && outcome.submitted;
|
|
38287
|
+
if (options2.addressComments && raisedComments) {
|
|
38288
|
+
await chainAddressComments(prNumber, options2.announce);
|
|
38289
|
+
return;
|
|
38290
|
+
}
|
|
38291
|
+
if (options2.announce) await announcePr(prNumber);
|
|
38292
|
+
}
|
|
38293
|
+
|
|
38294
|
+
// src/commands/review/sanitiseReviewerNames.ts
|
|
38295
|
+
var REVIEWER_LABEL = "the reviewer";
|
|
38296
|
+
function sanitiseReviewerNames(value) {
|
|
38297
|
+
return value.replace(/\bclaude\b/gi, REVIEWER_LABEL).replace(/\bopus\b/gi, REVIEWER_LABEL);
|
|
38298
|
+
}
|
|
38299
|
+
|
|
38300
|
+
// src/commands/review/postFindings.ts
|
|
38301
|
+
function buildCommentBody(finding) {
|
|
38302
|
+
const lines2 = [];
|
|
38303
|
+
const severityLabel = finding.severity ?? "finding";
|
|
38304
|
+
lines2.push(`**${severityLabel}: ${finding.title}**`);
|
|
38305
|
+
if (finding.impact) lines2.push("", `Impact: ${finding.impact}`);
|
|
38306
|
+
if (finding.recommendation)
|
|
38307
|
+
lines2.push("", `Recommendation: ${finding.recommendation}`);
|
|
38308
|
+
return sanitiseReviewerNames(lines2.join("\n"));
|
|
38309
|
+
}
|
|
38310
|
+
async function postFindings(findings) {
|
|
38311
|
+
let posted = 0;
|
|
38312
|
+
let failed3 = 0;
|
|
38313
|
+
for (const finding of findings) {
|
|
38314
|
+
const body = buildCommentBody(finding);
|
|
38315
|
+
try {
|
|
38316
|
+
await comment2(finding.file, finding.line, body, {
|
|
38317
|
+
startLine: finding.startLine,
|
|
38318
|
+
skipPreview: true
|
|
38319
|
+
});
|
|
38320
|
+
posted++;
|
|
38321
|
+
} catch (error) {
|
|
38322
|
+
failed3++;
|
|
38323
|
+
const message3 = error instanceof Error ? error.message : String(error);
|
|
38324
|
+
console.error(
|
|
38325
|
+
`Failed to post comment on ${finding.file}:${finding.line}: ${message3}`
|
|
38326
|
+
);
|
|
38327
|
+
}
|
|
38328
|
+
}
|
|
38329
|
+
return { posted, failed: failed3 };
|
|
38330
|
+
}
|
|
38331
|
+
|
|
38332
|
+
// src/commands/review/submitPendingReview.ts
|
|
38333
|
+
var MUTATION7 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
|
|
38334
|
+
function submitPendingReview(body) {
|
|
38335
|
+
runReviewSubmission(MUTATION7, body);
|
|
38336
|
+
}
|
|
38337
|
+
|
|
38338
|
+
// src/commands/review/buildReviewBody.ts
|
|
38339
|
+
function buildReviewBody(markdown, unanchored, ciFooter) {
|
|
38340
|
+
return appendCiFooter(
|
|
38341
|
+
sanitiseReviewerNames(buildReviewSummary(markdown, unanchored)),
|
|
38342
|
+
ciFooter
|
|
38343
|
+
);
|
|
38344
|
+
}
|
|
38345
|
+
|
|
38346
|
+
// src/commands/review/postAndMaybeSubmit.ts
|
|
38347
|
+
function submitReview(body, posted) {
|
|
38348
|
+
if (posted > 0) submitPendingReview(body);
|
|
38349
|
+
else submitBodyOnlyReview(body);
|
|
38350
|
+
}
|
|
38351
|
+
async function decideSubmit(options2) {
|
|
38352
|
+
if (!options2.prompt) return options2.submit;
|
|
38353
|
+
await setSessionStatus("waiting");
|
|
38354
|
+
try {
|
|
38355
|
+
return await promptConfirm("Submit the pending review?", options2.submit);
|
|
38356
|
+
} finally {
|
|
38357
|
+
await setSessionStatus("running");
|
|
38358
|
+
}
|
|
38359
|
+
}
|
|
38360
|
+
async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
|
|
38361
|
+
const result = await postFindings(lineBound);
|
|
38362
|
+
const failedSuffix = result.failed > 0 ? `, ${result.failed} failed` : "";
|
|
38363
|
+
console.log(`Posted ${result.posted} comment(s)${failedSuffix}.`);
|
|
38364
|
+
const carried = carriedUnanchoredFindings(unanchored);
|
|
38365
|
+
if (result.posted === 0 && carried.length === 0 && !options2.ciFooter)
|
|
38366
|
+
return { posted: 0, submitted: false };
|
|
38367
|
+
const shouldSubmit = await decideSubmit(options2);
|
|
38368
|
+
if (shouldSubmit) {
|
|
38369
|
+
submitReview(
|
|
38370
|
+
buildReviewBody(markdown, unanchored, options2.ciFooter),
|
|
38371
|
+
result.posted
|
|
38372
|
+
);
|
|
38373
|
+
return { posted: result.posted, submitted: true };
|
|
38374
|
+
}
|
|
38375
|
+
console.log("Leaving the review unsubmitted.");
|
|
38376
|
+
return { posted: result.posted, submitted: false };
|
|
38377
|
+
}
|
|
38378
|
+
|
|
38379
|
+
// src/commands/review/stillOnReviewedPr.ts
|
|
38380
|
+
function currentPrNumber() {
|
|
38381
|
+
try {
|
|
38382
|
+
return findCurrentPrNumber();
|
|
38383
|
+
} catch (error) {
|
|
38384
|
+
console.error(
|
|
38385
|
+
`Error: could not confirm which PR this tree is on: ${error instanceof Error ? error.message : String(error)}`
|
|
38386
|
+
);
|
|
38387
|
+
return null;
|
|
38388
|
+
}
|
|
38389
|
+
}
|
|
38390
|
+
function stillOnReviewedPr(prNumber) {
|
|
38391
|
+
const current = currentPrNumber();
|
|
38392
|
+
if (current === prNumber) return true;
|
|
38393
|
+
console.error(
|
|
38394
|
+
`Error: this tree is now on ${current === null ? "a branch with no open PR" : `PR #${current}`}, not the reviewed PR #${prNumber}; skipping the post and any chained sessions.`
|
|
38395
|
+
);
|
|
38396
|
+
return false;
|
|
38397
|
+
}
|
|
38398
|
+
|
|
38399
|
+
// src/commands/review/submitNoFindingsReview.ts
|
|
38400
|
+
function submitNoFindingsReview(markdown, ciFooter) {
|
|
38401
|
+
const body = sanitiseReviewerNames(
|
|
38402
|
+
`${buildReviewSummary(markdown)}
|
|
38403
|
+
|
|
38404
|
+
No findings were raised.`
|
|
38405
|
+
);
|
|
38406
|
+
submitBodyOnlyReview(appendCiFooter(body, ciFooter));
|
|
38407
|
+
}
|
|
38408
|
+
|
|
38409
|
+
// src/commands/review/describeWork.ts
|
|
38410
|
+
function describeWork(comments3, carried) {
|
|
38411
|
+
const parts = [];
|
|
38412
|
+
if (comments3 > 0) parts.push(`${comments3} line comment(s)`);
|
|
38413
|
+
if (carried > 0) parts.push(`${carried} finding(s) in the review body`);
|
|
38414
|
+
return parts.join(" and ");
|
|
38415
|
+
}
|
|
38416
|
+
|
|
38417
|
+
// src/commands/review/postReviewToPr.ts
|
|
38418
|
+
var NOTHING_POSTED = { posted: 0, submitted: false };
|
|
38419
|
+
async function confirmPost(prNumber, work, options2) {
|
|
38420
|
+
if (!options2.prompt) return true;
|
|
38421
|
+
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
38422
|
+
}
|
|
38423
|
+
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
38424
|
+
const markdown = readFileSync53(synthesisPath, "utf8");
|
|
38425
|
+
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
38426
|
+
const carried = carriedUnanchoredFindings(unanchored);
|
|
38427
|
+
if (inDiff.length === 0 && carried.length === 0) {
|
|
38428
|
+
if (!options2.ciFooter) return NOTHING_POSTED;
|
|
38429
|
+
submitNoFindingsReview(markdown, options2.ciFooter);
|
|
38430
|
+
return { posted: 0, submitted: true };
|
|
38431
|
+
}
|
|
38432
|
+
const work = describeWork(inDiff.length, carried.length);
|
|
38433
|
+
console.log(`Found PR #${prInfo.prNumber} with ${work} to post.`);
|
|
38434
|
+
const confirmed = await confirmPost(prInfo.prNumber, work, options2);
|
|
38435
|
+
if (!confirmed) {
|
|
38436
|
+
console.log("Skipped posting.");
|
|
38437
|
+
return NOTHING_POSTED;
|
|
38438
|
+
}
|
|
38439
|
+
return postAndMaybeSubmit(inDiff, unanchored, markdown, options2);
|
|
38440
|
+
}
|
|
38441
|
+
async function postReviewToPr(synthesisPath, prInfo, options2) {
|
|
38442
|
+
if (!stillOnReviewedPr(prInfo.prNumber)) return;
|
|
38443
|
+
const outcome = await postFindingsToPr(prInfo, synthesisPath, options2);
|
|
38444
|
+
await chainAfterReview(prInfo.prNumber, outcome, options2);
|
|
38445
|
+
}
|
|
38446
|
+
|
|
38447
|
+
// src/commands/review/runApplySession.ts
|
|
38448
|
+
function buildApplyPrompt(synthesisPath) {
|
|
38449
|
+
return `You are helping the user apply fixes for a code review with each finding decided one at a time.
|
|
38450
|
+
|
|
38451
|
+
Read ${synthesisPath}. It contains a list of findings under the \`## Findings\` heading. Each finding is a block in this exact format:
|
|
38452
|
+
|
|
38453
|
+
### Finding: <short title>
|
|
38454
|
+
- Severity: blocker | major | minor | nit
|
|
38455
|
+
- Source: confirmed | disputed | claude-only | codex-only | already-raised
|
|
38456
|
+
- Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
|
|
38457
|
+
- Impact: one sentence on what could go wrong
|
|
38458
|
+
- Recommendation: one or two sentences with a concrete change
|
|
38459
|
+
|
|
38460
|
+
For every finding whose Source is NOT \`already-raised\`, walk through it with the user one at a time:
|
|
38461
|
+
1. Read the referenced file/lines (use the Location field) and any nearby code needed to understand the impact.
|
|
38462
|
+
2. Present a short assessment (one or two sentences) of whether the finding is real and what the right fix is.
|
|
38463
|
+
3. Ask the user: apply or skip?
|
|
38464
|
+
- On 'apply': edit the relevant file(s) in place to fix the issue, then remove that finding's entire \`### Finding:\` block from ${synthesisPath} (including any blank line that separated it from the next block).
|
|
38465
|
+
- On 'skip': leave the finding block in ${synthesisPath} unchanged and move on.
|
|
38466
|
+
|
|
38467
|
+
Skip findings whose Source is \`already-raised\` entirely \u2014 do not present them and do not remove them from ${synthesisPath}.
|
|
38468
|
+
|
|
38469
|
+
Important constraints:
|
|
38470
|
+
- Do not stage, commit, or push any changes. Leave all code edits unstaged in the working tree.
|
|
38471
|
+
- Do not post anything to a PR.
|
|
38472
|
+
- Only modify ${synthesisPath} by removing the blocks for findings the user chose to apply. Do not edit the wording of any remaining finding block.
|
|
38473
|
+
- When every non-already-raised finding has been decided, briefly summarise what was applied vs skipped and exit.`;
|
|
38474
|
+
}
|
|
38475
|
+
async function runApplySession(synthesisPath) {
|
|
38476
|
+
const { done: done2 } = spawnClaude(buildApplyPrompt(synthesisPath), {
|
|
38477
|
+
allowEdits: true
|
|
38478
|
+
});
|
|
38479
|
+
await done2;
|
|
38480
|
+
}
|
|
38481
|
+
|
|
38482
|
+
// src/commands/review/runBacklogSession.ts
|
|
38483
|
+
function buildBacklogPrompt(synthesisPath) {
|
|
38484
|
+
return `/bug add each finding in ${synthesisPath} as a phase
|
|
38485
|
+
|
|
38486
|
+
Read ${synthesisPath}. It contains a list of findings under the \`## Findings\` heading, each in a \`### Finding:\` block with Severity, Source, Location, Impact, and Recommendation fields.
|
|
38487
|
+
|
|
38488
|
+
File ONE bug backlog item covering the review findings:
|
|
38489
|
+
- Include EVERY finding in the file as a phase on that single item \u2014 including findings whose Source is \`already-raised\`.
|
|
38490
|
+
- Each phase should be named after its finding's title and its tasks should capture the finding's Location, Impact, and Recommendation.
|
|
38491
|
+
- File the item with \`assist backlog propose\`, then apply the whole plan with a single \`assist backlog update-plan <id> --json -\` call whose payload lists every finding as a phase. Do not run \`assist backlog add-phase\` per finding \u2014 the plan lands in one preview, or not at all.
|
|
38492
|
+
|
|
38493
|
+
Important constraints:
|
|
38494
|
+
- Do not edit ${synthesisPath} \u2014 leave it untouched.
|
|
38495
|
+
- Do not post anything to a PR.
|
|
38496
|
+
- Do not stage, commit, or push any changes.`;
|
|
38497
|
+
}
|
|
38498
|
+
async function runBacklogSession(synthesisPath) {
|
|
38499
|
+
const { done: done2 } = spawnClaude(buildBacklogPrompt(synthesisPath), {
|
|
38500
|
+
allowEdits: true
|
|
38501
|
+
});
|
|
38502
|
+
await done2;
|
|
38503
|
+
}
|
|
38504
|
+
|
|
38505
|
+
// src/commands/review/runRefineSession.ts
|
|
38506
|
+
function buildRefinePrompt(synthesisPath) {
|
|
38507
|
+
return `You are refining a code review synthesis with the user.
|
|
38508
|
+
|
|
38509
|
+
Read ${synthesisPath} and walk the user through each finding one at a time. Before asking the user what to do with a finding, do some investigation so you can give an informed opinion:
|
|
38510
|
+
- Read the referenced file/lines (use the Location field) to confirm the issue is real and current.
|
|
38511
|
+
- Check nearby code, callers, or related files when the impact depends on context.
|
|
38512
|
+
- Form a view on whether the finding is applicable, whether the stated severity is right, and whether the recommendation actually fixes the problem.
|
|
38513
|
+
|
|
38514
|
+
Then present your assessment briefly (one or two sentences) and ask the user whether to keep it as-is, edit it (e.g. adjust severity, sharpen the recommendation), or drop it. After all existing findings are reviewed, ask whether to add any new findings.
|
|
38515
|
+
|
|
38516
|
+
Edit ${synthesisPath} in place so the resulting file is the user's final list:
|
|
38517
|
+
- To drop a finding, remove its entire \`### Finding:\` block.
|
|
38518
|
+
- To edit a finding, modify only the fields the user wants changed.
|
|
38519
|
+
- To add a new finding, append a block in the exact format below under the \`## Findings\` heading.
|
|
38520
|
+
|
|
38521
|
+
Each finding block must use this exact format so it parses correctly:
|
|
38522
|
+
|
|
38523
|
+
### Finding: <short title>
|
|
38524
|
+
- Severity: blocker | major | minor | nit
|
|
38525
|
+
- Source: confirmed | disputed | claude-only | codex-only | already-raised
|
|
38526
|
+
- Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
|
|
38527
|
+
- Impact: one sentence on what could go wrong
|
|
38528
|
+
- Recommendation: one or two sentences with a concrete change
|
|
38529
|
+
|
|
38530
|
+
User-supplied findings should use Source: \`confirmed\`. Use Location \`n/a\` only when the finding is not tied to a specific line.
|
|
38531
|
+
|
|
38532
|
+
Do not post anything to a PR; only edit ${synthesisPath}. When the user is done, exit.`;
|
|
38533
|
+
}
|
|
38534
|
+
async function runRefineSession(synthesisPath) {
|
|
38535
|
+
const { done: done2 } = spawnClaude(buildRefinePrompt(synthesisPath), {
|
|
38536
|
+
allowEdits: true
|
|
38537
|
+
});
|
|
38538
|
+
await done2;
|
|
38539
|
+
}
|
|
38540
|
+
|
|
38541
|
+
// src/commands/review/handlePostSynthesis.ts
|
|
38542
|
+
function nonPostingSession(options2) {
|
|
38543
|
+
if (options2.backlog) return runBacklogSession;
|
|
38544
|
+
if (options2.apply) return runApplySession;
|
|
38545
|
+
if (options2.refine) return runRefineSession;
|
|
38546
|
+
return null;
|
|
38547
|
+
}
|
|
38548
|
+
async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
38549
|
+
const session = nonPostingSession(options2);
|
|
38550
|
+
if (!session) {
|
|
38551
|
+
await postReviewToPr(synthesisPath, prInfo, {
|
|
38552
|
+
prompt: options2.prompt,
|
|
38553
|
+
submit: options2.submit,
|
|
38554
|
+
addressComments: options2.addressComments,
|
|
38555
|
+
announce: options2.announce,
|
|
38556
|
+
ciFooter: options2.ciFooter
|
|
38557
|
+
});
|
|
38558
|
+
return;
|
|
38559
|
+
}
|
|
38560
|
+
await session(synthesisPath);
|
|
38561
|
+
if (options2.announce) await announcePr(prInfo.prNumber);
|
|
38562
|
+
}
|
|
38563
|
+
|
|
38564
|
+
// src/commands/review/runPostSynthesis.ts
|
|
38442
38565
|
function runPostSynthesis(synthesisPath, prInfo, options2) {
|
|
38443
38566
|
return handlePostSynthesis(synthesisPath, prInfo, {
|
|
38444
38567
|
refine: options2.refine ?? false,
|
|
@@ -38451,21 +38574,27 @@ function runPostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
38451
38574
|
ciFooter: options2.ci?.footer
|
|
38452
38575
|
});
|
|
38453
38576
|
}
|
|
38577
|
+
|
|
38578
|
+
// src/commands/review/reviewPr.ts
|
|
38454
38579
|
async function reviewPr(repoRoot2, options2) {
|
|
38455
38580
|
const context = gatherChangedContext();
|
|
38456
38581
|
const paths = setupReviewDir(repoRoot2, context, options2.force ?? false);
|
|
38457
38582
|
attachReviewLog(paths.reviewDir);
|
|
38458
|
-
const
|
|
38583
|
+
const outcome = await runReviewPipeline(paths, {
|
|
38459
38584
|
verbose: options2.verbose ?? false,
|
|
38460
38585
|
models: options2.ci?.models,
|
|
38461
38586
|
strict: options2.ci !== void 0
|
|
38462
38587
|
});
|
|
38463
|
-
|
|
38464
|
-
|
|
38465
|
-
|
|
38466
|
-
}
|
|
38588
|
+
const synthesisOk = outcome.ok;
|
|
38589
|
+
if (!synthesisOk && options2.ci)
|
|
38590
|
+
exitFailedCiReview(outcome.failures, options2.ci);
|
|
38467
38591
|
if (synthesisOk && options2.ci)
|
|
38468
|
-
writeJobSummary(
|
|
38592
|
+
writeJobSummary(
|
|
38593
|
+
paths.synthesisPath,
|
|
38594
|
+
context,
|
|
38595
|
+
options2.ci.summaryPath,
|
|
38596
|
+
outcome.slots
|
|
38597
|
+
);
|
|
38469
38598
|
if (synthesisOk)
|
|
38470
38599
|
await runPostSynthesis(paths.synthesisPath, context, options2);
|
|
38471
38600
|
console.log(`Done. Review folder: ${paths.reviewDir}`);
|
|
@@ -38957,16 +39086,16 @@ function filterToSql(filter) {
|
|
|
38957
39086
|
}
|
|
38958
39087
|
|
|
38959
39088
|
// src/commands/seq/fetchSeqData.ts
|
|
38960
|
-
function buildDataParams(filter,
|
|
39089
|
+
function buildDataParams(filter, count9, from, to) {
|
|
38961
39090
|
const sqlFilter = filterToSql(filter);
|
|
38962
|
-
const sql29 = `select @Timestamp, @Level, @Exception, @Message from stream where ${sqlFilter} order by @Timestamp desc limit ${
|
|
39091
|
+
const sql29 = `select @Timestamp, @Level, @Exception, @Message from stream where ${sqlFilter} order by @Timestamp desc limit ${count9}`;
|
|
38963
39092
|
const params = new URLSearchParams({ q: sql29 });
|
|
38964
39093
|
if (from) params.set("rangeStartUtc", from);
|
|
38965
39094
|
if (to) params.set("rangeEndUtc", to);
|
|
38966
39095
|
return params;
|
|
38967
39096
|
}
|
|
38968
|
-
async function fetchSeqData(conn, filter,
|
|
38969
|
-
const params = buildDataParams(filter,
|
|
39097
|
+
async function fetchSeqData(conn, filter, count9, from, to) {
|
|
39098
|
+
const params = buildDataParams(filter, count9, from, to);
|
|
38970
39099
|
const response = await fetchSeq(conn, "/api/data", params);
|
|
38971
39100
|
const data = await response.json();
|
|
38972
39101
|
return mapDataToEvents(data);
|
|
@@ -38988,12 +39117,12 @@ function mapDataToEvents(data) {
|
|
|
38988
39117
|
const levelIdx = col("Level");
|
|
38989
39118
|
const exIdx = col("Exception");
|
|
38990
39119
|
const msgIdx = col("Message");
|
|
38991
|
-
return data.Rows.map((
|
|
38992
|
-
Timestamp: ticksToIso(
|
|
38993
|
-
Level: String(
|
|
38994
|
-
Exception:
|
|
39120
|
+
return data.Rows.map((row3) => ({
|
|
39121
|
+
Timestamp: ticksToIso(row3[tsIdx]),
|
|
39122
|
+
Level: String(row3[levelIdx] ?? ""),
|
|
39123
|
+
Exception: row3[exIdx] != null ? String(row3[exIdx]) : void 0,
|
|
38995
39124
|
Properties: [],
|
|
38996
|
-
MessageTemplateTokens: [{ Text: String(
|
|
39125
|
+
MessageTemplateTokens: [{ Text: String(row3[msgIdx] ?? "") }]
|
|
38997
39126
|
}));
|
|
38998
39127
|
}
|
|
38999
39128
|
|
|
@@ -39133,12 +39262,12 @@ function resolveConnection2(name) {
|
|
|
39133
39262
|
async function seqQuery(filter, options2) {
|
|
39134
39263
|
rejectTimestampFilter(filter);
|
|
39135
39264
|
const conn = resolveConnection2(options2.connection);
|
|
39136
|
-
const
|
|
39265
|
+
const count9 = Number.parseInt(options2.count ?? "1000", 10);
|
|
39137
39266
|
const from = options2.from ? parseRelativeTime(options2.from) : void 0;
|
|
39138
39267
|
const to = options2.to ? parseRelativeTime(options2.to) : void 0;
|
|
39139
|
-
const events = from || to ? await fetchSeqData(conn, filter,
|
|
39268
|
+
const events = from || to ? await fetchSeqData(conn, filter, count9, from, to) : await fetchSeqEvents(
|
|
39140
39269
|
conn,
|
|
39141
|
-
new URLSearchParams({ filter, count: String(
|
|
39270
|
+
new URLSearchParams({ filter, count: String(count9) })
|
|
39142
39271
|
);
|
|
39143
39272
|
if (events.length === 0) {
|
|
39144
39273
|
console.log(chalk251.yellow("No events found."));
|
|
@@ -39154,10 +39283,10 @@ async function seqQuery(filter, options2) {
|
|
|
39154
39283
|
}
|
|
39155
39284
|
console.log(chalk251.dim(`
|
|
39156
39285
|
${events.length} events`));
|
|
39157
|
-
if (events.length >=
|
|
39286
|
+
if (events.length >= count9) {
|
|
39158
39287
|
console.log(
|
|
39159
39288
|
chalk251.yellow(
|
|
39160
|
-
`Results limited to ${
|
|
39289
|
+
`Results limited to ${count9}. Use --count to retrieve more.`
|
|
39161
39290
|
)
|
|
39162
39291
|
);
|
|
39163
39292
|
}
|
|
@@ -39534,8 +39663,8 @@ function printTable(rows) {
|
|
|
39534
39663
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
39535
39664
|
console.log(chalk255.dim(header));
|
|
39536
39665
|
console.log(chalk255.dim("-".repeat(header.length)));
|
|
39537
|
-
for (const
|
|
39538
|
-
const line = columns.map((c, i) => formatCell(
|
|
39666
|
+
for (const row3 of rows) {
|
|
39667
|
+
const line = columns.map((c, i) => formatCell(row3[c]).padEnd(widths[i])).join(" ");
|
|
39539
39668
|
console.log(line);
|
|
39540
39669
|
}
|
|
39541
39670
|
console.log(chalk255.dim(`
|
|
@@ -39919,13 +40048,13 @@ description: ${quoteYaml(description)}
|
|
|
39919
40048
|
}
|
|
39920
40049
|
function syncCodex(claudeDir, options2) {
|
|
39921
40050
|
if (!isHarnessAvailable("codex")) return;
|
|
39922
|
-
const { total, names } = installHarnessCommands(
|
|
40051
|
+
const { total: total2, names } = installHarnessCommands(
|
|
39923
40052
|
claudeDir,
|
|
39924
40053
|
harnesses.codex,
|
|
39925
40054
|
commandToSkill
|
|
39926
40055
|
);
|
|
39927
40056
|
syncCodexHooks(path95.join(claudeDir, "..", "codex", "config.toml"));
|
|
39928
|
-
console.log(`Synced ${
|
|
40057
|
+
console.log(`Synced ${total2} skill(s) to ~/.codex/skills`);
|
|
39929
40058
|
if (!options2?.prune) return;
|
|
39930
40059
|
const force = options2.force ?? false;
|
|
39931
40060
|
reportPrune(
|
|
@@ -40436,21 +40565,21 @@ var FORMATS = ["md", "vtt"];
|
|
|
40436
40565
|
function isCleanFormat(value) {
|
|
40437
40566
|
return FORMATS.includes(value);
|
|
40438
40567
|
}
|
|
40439
|
-
function serialise(cues,
|
|
40440
|
-
return
|
|
40568
|
+
function serialise(cues, format3, timestamps) {
|
|
40569
|
+
return format3 === "vtt" ? formatVtt(cues) : formatChatLog(cuesToChatMessages(cues), { timestamps });
|
|
40441
40570
|
}
|
|
40442
40571
|
function clean(file, options2 = {}) {
|
|
40443
|
-
const
|
|
40444
|
-
if (!isCleanFormat(
|
|
40572
|
+
const format3 = options2.format ?? "md";
|
|
40573
|
+
if (!isCleanFormat(format3)) {
|
|
40445
40574
|
console.error(
|
|
40446
|
-
`Error: --format must be one of: ${FORMATS.join(", ")} (got: ${
|
|
40575
|
+
`Error: --format must be one of: ${FORMATS.join(", ")} (got: ${format3})`
|
|
40447
40576
|
);
|
|
40448
40577
|
process.exit(1);
|
|
40449
40578
|
}
|
|
40450
40579
|
const timestamps = options2.timestamps ?? false;
|
|
40451
|
-
if (timestamps &&
|
|
40580
|
+
if (timestamps && format3 !== "md") {
|
|
40452
40581
|
console.error(
|
|
40453
|
-
`Error: --timestamps applies only to --format md (got: ${
|
|
40582
|
+
`Error: --timestamps applies only to --format md (got: ${format3})`
|
|
40454
40583
|
);
|
|
40455
40584
|
process.exit(1);
|
|
40456
40585
|
}
|
|
@@ -40463,7 +40592,7 @@ function clean(file, options2 = {}) {
|
|
|
40463
40592
|
console.error(`Error: no cues found in: ${file}`);
|
|
40464
40593
|
process.exit(1);
|
|
40465
40594
|
}
|
|
40466
|
-
console.log(serialise(cues,
|
|
40595
|
+
console.log(serialise(cues, format3, timestamps));
|
|
40467
40596
|
}
|
|
40468
40597
|
|
|
40469
40598
|
// src/commands/transcript/shared.ts
|
|
@@ -40924,10 +41053,10 @@ function closesBlock(trimmed, from) {
|
|
|
40924
41053
|
}
|
|
40925
41054
|
function csharpHeaderLineCount(content) {
|
|
40926
41055
|
const lines2 = content.split("\n");
|
|
40927
|
-
let
|
|
41056
|
+
let count9 = 0;
|
|
40928
41057
|
let inBlock = false;
|
|
40929
|
-
while (
|
|
40930
|
-
const trimmed = lines2[
|
|
41058
|
+
while (count9 < lines2.length) {
|
|
41059
|
+
const trimmed = lines2[count9].trim();
|
|
40931
41060
|
if (inBlock) {
|
|
40932
41061
|
inBlock = !closesBlock(trimmed, 0);
|
|
40933
41062
|
} else if (trimmed.startsWith("/*")) {
|
|
@@ -40935,9 +41064,9 @@ function csharpHeaderLineCount(content) {
|
|
|
40935
41064
|
} else if (trimmed !== "" && !trimmed.startsWith("//")) {
|
|
40936
41065
|
break;
|
|
40937
41066
|
}
|
|
40938
|
-
|
|
41067
|
+
count9++;
|
|
40939
41068
|
}
|
|
40940
|
-
return
|
|
41069
|
+
return count9;
|
|
40941
41070
|
}
|
|
40942
41071
|
|
|
40943
41072
|
// src/commands/verify/blockCodeComments/collectCsharpComments.ts
|
|
@@ -41710,9 +41839,9 @@ async function watchLoop() {
|
|
|
41710
41839
|
}
|
|
41711
41840
|
|
|
41712
41841
|
// src/commands/watch/readRecentCommits.ts
|
|
41713
|
-
function readRecentCommits(
|
|
41842
|
+
function readRecentCommits(count9 = 10, cwd) {
|
|
41714
41843
|
const output = runGit3(
|
|
41715
|
-
["log", `-${
|
|
41844
|
+
["log", `-${count9}`, "--pretty=format:%H%x09%h%x09%ar%x09%s"],
|
|
41716
41845
|
cwd
|
|
41717
41846
|
);
|
|
41718
41847
|
if (!output) return [];
|
|
@@ -42180,10 +42309,10 @@ function consumeSimulatedDivergence(cwd) {
|
|
|
42180
42309
|
}
|
|
42181
42310
|
|
|
42182
42311
|
// src/commands/watch/detectMovement.ts
|
|
42183
|
-
function detectMovement(from, to,
|
|
42312
|
+
function detectMovement(from, to, count9) {
|
|
42184
42313
|
if (from === to) return void 0;
|
|
42185
|
-
if (!Number.isFinite(
|
|
42186
|
-
return { from, to, count:
|
|
42314
|
+
if (!Number.isFinite(count9) || count9 <= 0) return void 0;
|
|
42315
|
+
return { from, to, count: count9 };
|
|
42187
42316
|
}
|
|
42188
42317
|
|
|
42189
42318
|
// src/commands/watch/readMovement.ts
|
|
@@ -42191,8 +42320,8 @@ function readMovement(cwd) {
|
|
|
42191
42320
|
try {
|
|
42192
42321
|
const from = runGit3(["rev-parse", "@"], cwd);
|
|
42193
42322
|
const to = runGit3(["rev-parse", "@{u}"], cwd);
|
|
42194
|
-
const
|
|
42195
|
-
return detectMovement(from, to,
|
|
42323
|
+
const count9 = Number(runGit3(["rev-list", "--count", "@..@{u}"], cwd));
|
|
42324
|
+
return detectMovement(from, to, count9);
|
|
42196
42325
|
} catch {
|
|
42197
42326
|
return void 0;
|
|
42198
42327
|
}
|
|
@@ -43116,9 +43245,9 @@ async function drainDaemon(options2 = {}) {
|
|
|
43116
43245
|
return;
|
|
43117
43246
|
}
|
|
43118
43247
|
}
|
|
43119
|
-
const
|
|
43248
|
+
const count9 = await requestDrain(socket, lines2);
|
|
43120
43249
|
socket.destroy();
|
|
43121
|
-
console.log(`Drained ${
|
|
43250
|
+
console.log(`Drained ${count9} session(s)`);
|
|
43122
43251
|
}
|
|
43123
43252
|
function reportLive(live) {
|
|
43124
43253
|
console.log(`${live.length} live session(s) would be closed:`);
|
|
@@ -43183,11 +43312,11 @@ function pollRepoConfigCache(intervalMs = POLL_MS) {
|
|
|
43183
43312
|
inFlight2 = true;
|
|
43184
43313
|
try {
|
|
43185
43314
|
const before = JSON.stringify(readRepoConfigCache());
|
|
43186
|
-
const
|
|
43315
|
+
const count9 = await refreshRepoConfigCache();
|
|
43187
43316
|
if (failing) daemonLog("repo config cache poll recovered");
|
|
43188
43317
|
failing = false;
|
|
43189
43318
|
if (JSON.stringify(readRepoConfigCache()) !== before)
|
|
43190
|
-
daemonLog(`repo config cache updated (${
|
|
43319
|
+
daemonLog(`repo config cache updated (${count9} repos)`);
|
|
43191
43320
|
} catch (error) {
|
|
43192
43321
|
if (!failing)
|
|
43193
43322
|
daemonLog(
|
|
@@ -43206,8 +43335,8 @@ function pollRepoConfigCache(intervalMs = POLL_MS) {
|
|
|
43206
43335
|
// src/commands/sessions/daemon/refreshRepoConfigCacheOnStart.ts
|
|
43207
43336
|
async function refreshRepoConfigCacheOnStart() {
|
|
43208
43337
|
try {
|
|
43209
|
-
const
|
|
43210
|
-
daemonLog(`repo config cache refreshed (${
|
|
43338
|
+
const count9 = await refreshRepoConfigCache();
|
|
43339
|
+
daemonLog(`repo config cache refreshed (${count9} repos)`);
|
|
43211
43340
|
} catch (error) {
|
|
43212
43341
|
daemonLog(
|
|
43213
43342
|
`repo config cache refresh failed; keeping the last snapshot: ${String(error)}`
|
|
@@ -45499,10 +45628,10 @@ function applyReviewPause(session, activity2) {
|
|
|
45499
45628
|
// src/shared/db/getPhaseActiveMs.ts
|
|
45500
45629
|
import { and as and20, eq as eq46 } from "drizzle-orm";
|
|
45501
45630
|
async function getPhaseActiveMs(db, itemId2, phaseIdx) {
|
|
45502
|
-
const [
|
|
45631
|
+
const [row3] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
|
|
45503
45632
|
and20(eq46(phaseUsage.itemId, itemId2), eq46(phaseUsage.phaseIdx, phaseIdx))
|
|
45504
45633
|
);
|
|
45505
|
-
return
|
|
45634
|
+
return row3?.activeMs ?? 0;
|
|
45506
45635
|
}
|
|
45507
45636
|
|
|
45508
45637
|
// src/commands/sessions/daemon/loadPhaseActiveMs.ts
|
|
@@ -50360,10 +50489,10 @@ async function requestSessionOutput(target) {
|
|
|
50360
50489
|
}
|
|
50361
50490
|
|
|
50362
50491
|
// src/commands/sessions/lastLines.ts
|
|
50363
|
-
function lastLines(scrollback,
|
|
50492
|
+
function lastLines(scrollback, count9) {
|
|
50364
50493
|
const lines2 = stripAnsi(scrollback).split(/\r?\n/);
|
|
50365
50494
|
if (lines2.at(-1) === "") lines2.pop();
|
|
50366
|
-
return lines2.slice(-
|
|
50495
|
+
return lines2.slice(-count9);
|
|
50367
50496
|
}
|
|
50368
50497
|
|
|
50369
50498
|
// src/commands/sessions/sessionOutput.ts
|
|
@@ -50383,14 +50512,14 @@ function resolveTarget3(sessionId, server) {
|
|
|
50383
50512
|
return { sessionId };
|
|
50384
50513
|
}
|
|
50385
50514
|
async function sessionOutput(sessionId, options2) {
|
|
50386
|
-
const
|
|
50387
|
-
if (!Number.isInteger(
|
|
50515
|
+
const count9 = Number.parseInt(options2.lines, 10);
|
|
50516
|
+
if (!Number.isInteger(count9) || count9 < 1)
|
|
50388
50517
|
return fail7(`-n must be a positive integer, got ${options2.lines}`);
|
|
50389
50518
|
const target = resolveTarget3(sessionId, options2.server);
|
|
50390
50519
|
if (typeof target === "string") return fail7(target);
|
|
50391
50520
|
try {
|
|
50392
50521
|
const scrollback = await requestSessionOutput(target);
|
|
50393
|
-
for (const line of lastLines(scrollback,
|
|
50522
|
+
for (const line of lastLines(scrollback, count9)) console.log(line);
|
|
50394
50523
|
} catch (error) {
|
|
50395
50524
|
fail7(error instanceof Error ? error.message : String(error));
|
|
50396
50525
|
}
|