@staff0rd/assist 0.1061.0 → 0.1062.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/built-version +1 -1
- package/dist/commands/sessions/web/bundle.js +438 -438
- package/dist/index.js +82 -43
- package/package.json +1 -1
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.1062.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -41344,9 +41344,21 @@ function gatherHighLevelSubject(prNumber, force, slicing) {
|
|
|
41344
41344
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
41345
41345
|
import { randomUUID as randomUUID24 } from "crypto";
|
|
41346
41346
|
|
|
41347
|
+
// src/commands/review/highLevel/isHighLevelSliceCheck.ts
|
|
41348
|
+
var SLICE_CHECKS = /* @__PURE__ */ new Set([
|
|
41349
|
+
"structure-sensible",
|
|
41350
|
+
"tests-worth-having",
|
|
41351
|
+
"critical-diffs-correct"
|
|
41352
|
+
]);
|
|
41353
|
+
function isHighLevelSliceCheck(id) {
|
|
41354
|
+
return SLICE_CHECKS.has(id);
|
|
41355
|
+
}
|
|
41356
|
+
|
|
41347
41357
|
// src/commands/review/highLevel/highLevelProgress.ts
|
|
41348
|
-
function toItem2(check2, decision) {
|
|
41349
|
-
const ticked = decision.checklist?.find(
|
|
41358
|
+
function toItem2(check2, decision, slice) {
|
|
41359
|
+
const ticked = decision.checklist?.find(
|
|
41360
|
+
(entry) => entry.id === check2.id && entry.slice === slice?.number
|
|
41361
|
+
);
|
|
41350
41362
|
const comment3 = ticked?.comment?.trim();
|
|
41351
41363
|
return {
|
|
41352
41364
|
id: check2.id,
|
|
@@ -41355,13 +41367,21 @@ function toItem2(check2, decision) {
|
|
|
41355
41367
|
status: check2.status,
|
|
41356
41368
|
reason: check2.reason,
|
|
41357
41369
|
ticked: ticked?.ticked ?? check2.status === "pass",
|
|
41358
|
-
...comment3 ? { comment: comment3 } : {}
|
|
41370
|
+
...comment3 ? { comment: comment3 } : {},
|
|
41371
|
+
...slice ? { slice: slice.number, sliceTitle: slice.title } : {}
|
|
41359
41372
|
};
|
|
41360
41373
|
}
|
|
41361
|
-
function
|
|
41374
|
+
function itemsOf(check2, decision, slices) {
|
|
41375
|
+
if (!slices || !isHighLevelSliceCheck(check2.id))
|
|
41376
|
+
return [toItem2(check2, decision)];
|
|
41377
|
+
return slices.map(
|
|
41378
|
+
(slice, index3) => toItem2(check2, decision, { number: index3 + 1, title: slice.title })
|
|
41379
|
+
);
|
|
41380
|
+
}
|
|
41381
|
+
function highLevelProgress(checks2, decision, slices) {
|
|
41362
41382
|
const reviewComments2 = decision.reviewComments ?? [];
|
|
41363
41383
|
return {
|
|
41364
|
-
items: checks2.
|
|
41384
|
+
items: checks2.flatMap((check2) => itemsOf(check2, decision, slices)),
|
|
41365
41385
|
...reviewComments2.length > 0 ? { reviewComments: reviewComments2 } : {}
|
|
41366
41386
|
};
|
|
41367
41387
|
}
|
|
@@ -41375,7 +41395,7 @@ function buildHighLevelDraft(subject, decision) {
|
|
|
41375
41395
|
headRef,
|
|
41376
41396
|
headSha,
|
|
41377
41397
|
savedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
41378
|
-
...highLevelProgress(checks2, decision)
|
|
41398
|
+
...highLevelProgress(checks2, decision, subject.slices)
|
|
41379
41399
|
};
|
|
41380
41400
|
}
|
|
41381
41401
|
|
|
@@ -41400,7 +41420,7 @@ function buildHighLevelRecord(subject, decision) {
|
|
|
41400
41420
|
headSha,
|
|
41401
41421
|
verdict: VERDICTS[highLevelReviewEvent(decision)],
|
|
41402
41422
|
reviewedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
41403
|
-
...highLevelProgress(checks2, decision)
|
|
41423
|
+
...highLevelProgress(checks2, decision, subject.slices)
|
|
41404
41424
|
};
|
|
41405
41425
|
}
|
|
41406
41426
|
|
|
@@ -41498,10 +41518,29 @@ function formatItem(item) {
|
|
|
41498
41518
|
const comment3 = item.comment.replace(/\n/g, "\n ");
|
|
41499
41519
|
return `- ${statusMarkers[item.status]} **${item.title}** \u2014 ${comment3}`;
|
|
41500
41520
|
}
|
|
41521
|
+
function findings(items2) {
|
|
41522
|
+
const lines2 = items2.map(formatItem).filter((line) => line !== void 0);
|
|
41523
|
+
return lines2.length > 0 ? lines2.join("\n") : void 0;
|
|
41524
|
+
}
|
|
41525
|
+
function sliceSections(items2) {
|
|
41526
|
+
const bySlice = /* @__PURE__ */ new Map();
|
|
41527
|
+
for (const item of items2)
|
|
41528
|
+
if (item.slice !== void 0)
|
|
41529
|
+
bySlice.set(item.slice, [...bySlice.get(item.slice) ?? [], item]);
|
|
41530
|
+
return [...bySlice].flatMap(([number, sliceItems]) => {
|
|
41531
|
+
const lines2 = findings(sliceItems);
|
|
41532
|
+
if (!lines2) return [];
|
|
41533
|
+
const title = sliceItems[0]?.sliceTitle;
|
|
41534
|
+
return [`**Slice ${number}${title ? `: ${title}` : ""}**
|
|
41535
|
+
|
|
41536
|
+
${lines2}`];
|
|
41537
|
+
});
|
|
41538
|
+
}
|
|
41501
41539
|
function formatHighLevelReviewBody(items2, reviewComments2 = []) {
|
|
41502
41540
|
const sections = [];
|
|
41503
|
-
const
|
|
41504
|
-
if (
|
|
41541
|
+
const prWide = findings(items2.filter((item) => item.slice === void 0));
|
|
41542
|
+
if (prWide) sections.push(prWide);
|
|
41543
|
+
sections.push(...sliceSections(items2));
|
|
41505
41544
|
if (reviewComments2.length > 0)
|
|
41506
41545
|
sections.push(
|
|
41507
41546
|
`**Comments**
|
|
@@ -41979,11 +42018,11 @@ function formatUnanchoredFinding(finding) {
|
|
|
41979
42018
|
}
|
|
41980
42019
|
function buildReviewSummary(markdown, unanchored = []) {
|
|
41981
42020
|
const summary = summariseSynthesis(markdown);
|
|
41982
|
-
const
|
|
42021
|
+
const findings2 = parseFindings(markdown);
|
|
41983
42022
|
const lines2 = ["## Code review summary", "", formatSynthesisSummary(summary)];
|
|
41984
|
-
if (
|
|
42023
|
+
if (findings2.length > 0) {
|
|
41985
42024
|
lines2.push("", "### Findings", "");
|
|
41986
|
-
for (const finding of
|
|
42025
|
+
for (const finding of findings2) lines2.push(formatFindingLine(finding));
|
|
41987
42026
|
}
|
|
41988
42027
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
41989
42028
|
if (carried.length > 0) {
|
|
@@ -42017,11 +42056,11 @@ function toLineBound(finding) {
|
|
|
42017
42056
|
const base = { ...finding, file: match[1], line: endLine };
|
|
42018
42057
|
return startLine === endLine ? base : { ...base, startLine };
|
|
42019
42058
|
}
|
|
42020
|
-
function partitionFindings(
|
|
42059
|
+
function partitionFindings(findings2) {
|
|
42021
42060
|
const lineBound = [];
|
|
42022
42061
|
const unlocated = [];
|
|
42023
42062
|
const alreadyRaised = [];
|
|
42024
|
-
for (const finding of
|
|
42063
|
+
for (const finding of findings2) {
|
|
42025
42064
|
if (finding.source === "already-raised") {
|
|
42026
42065
|
alreadyRaised.push(finding);
|
|
42027
42066
|
continue;
|
|
@@ -42105,10 +42144,10 @@ function isWithinDiff(finding, index3) {
|
|
|
42105
42144
|
}
|
|
42106
42145
|
return true;
|
|
42107
42146
|
}
|
|
42108
|
-
function partitionFindingsByDiff(
|
|
42147
|
+
function partitionFindingsByDiff(findings2, index3) {
|
|
42109
42148
|
const inDiff = [];
|
|
42110
42149
|
const outOfDiff = [];
|
|
42111
|
-
for (const finding of
|
|
42150
|
+
for (const finding of findings2) {
|
|
42112
42151
|
if (isWithinDiff(finding, index3)) inDiff.push(finding);
|
|
42113
42152
|
else outOfDiff.push(finding);
|
|
42114
42153
|
}
|
|
@@ -42172,12 +42211,12 @@ function warnUnlocated(unlocated) {
|
|
|
42172
42211
|
|
|
42173
42212
|
// src/commands/review/selectPostableFindings.ts
|
|
42174
42213
|
function selectPostableFindings(markdown, prInfo) {
|
|
42175
|
-
const
|
|
42176
|
-
if (
|
|
42214
|
+
const findings2 = parseFindings(markdown);
|
|
42215
|
+
if (findings2.length === 0) {
|
|
42177
42216
|
console.log("Synthesis contains no findings; nothing to post.");
|
|
42178
42217
|
return { inDiff: [], unanchored: [] };
|
|
42179
42218
|
}
|
|
42180
|
-
const { lineBound, unlocated, alreadyRaised } = partitionFindings(
|
|
42219
|
+
const { lineBound, unlocated, alreadyRaised } = partitionFindings(findings2);
|
|
42181
42220
|
warnUnlocated(unlocated);
|
|
42182
42221
|
if (alreadyRaised.length > 0) {
|
|
42183
42222
|
console.log(
|
|
@@ -43808,10 +43847,10 @@ function buildCommentBody(finding) {
|
|
|
43808
43847
|
lines2.push("", `Recommendation: ${finding.recommendation}`);
|
|
43809
43848
|
return sanitiseReviewerNames(lines2.join("\n"));
|
|
43810
43849
|
}
|
|
43811
|
-
async function postFindings(
|
|
43850
|
+
async function postFindings(findings2) {
|
|
43812
43851
|
let posted = 0;
|
|
43813
43852
|
const failed3 = [];
|
|
43814
|
-
for (const finding of
|
|
43853
|
+
for (const finding of findings2) {
|
|
43815
43854
|
const body = buildCommentBody(finding);
|
|
43816
43855
|
try {
|
|
43817
43856
|
await comment2(finding.file, finding.line, body, {
|
|
@@ -46863,15 +46902,15 @@ function toSingleLine(text20) {
|
|
|
46863
46902
|
return text20.replace(/\s+/g, " ").trim();
|
|
46864
46903
|
}
|
|
46865
46904
|
function collectSourceFindings(file, lines2, project) {
|
|
46866
|
-
const
|
|
46905
|
+
const findings2 = [];
|
|
46867
46906
|
const sourceFile = project.addSourceFileAtPath(file);
|
|
46868
46907
|
for (const { pos, text: text20 } of collectComments(sourceFile)) {
|
|
46869
46908
|
const { line } = sourceFile.getLineAndColumnAtPos(pos);
|
|
46870
46909
|
if (!lines2.has(line)) continue;
|
|
46871
46910
|
if (isCommentExempt(text20)) continue;
|
|
46872
|
-
|
|
46911
|
+
findings2.push({ file, line, text: toSingleLine(text20) });
|
|
46873
46912
|
}
|
|
46874
|
-
return
|
|
46913
|
+
return findings2;
|
|
46875
46914
|
}
|
|
46876
46915
|
|
|
46877
46916
|
// src/commands/verify/blockCodeComments/collectYamlComments.ts
|
|
@@ -46888,13 +46927,13 @@ function collectYamlComments(content) {
|
|
|
46888
46927
|
|
|
46889
46928
|
// src/commands/verify/blockCodeComments/toFindings.ts
|
|
46890
46929
|
function toFindings(file, lines2, raw, exempt) {
|
|
46891
|
-
const
|
|
46930
|
+
const findings2 = [];
|
|
46892
46931
|
for (const { line, text: text20 } of raw) {
|
|
46893
46932
|
if (!lines2.has(line)) continue;
|
|
46894
46933
|
if (exempt && isCommentExempt(text20)) continue;
|
|
46895
|
-
|
|
46934
|
+
findings2.push({ file, line, text: text20.replace(/\s+/g, " ").trim() });
|
|
46896
46935
|
}
|
|
46897
|
-
return
|
|
46936
|
+
return findings2;
|
|
46898
46937
|
}
|
|
46899
46938
|
|
|
46900
46939
|
// src/commands/verify/blockCodeComments/collectFileComments.ts
|
|
@@ -46992,29 +47031,29 @@ function findComments(options2) {
|
|
|
46992
47031
|
skipAddingFilesFromTsConfig: true,
|
|
46993
47032
|
compilerOptions: { allowJs: true }
|
|
46994
47033
|
});
|
|
46995
|
-
const
|
|
47034
|
+
const findings2 = [];
|
|
46996
47035
|
for (const [file, lines2] of addedLines) {
|
|
46997
47036
|
if (!shouldScan(file, options2.ignoreGlobs)) continue;
|
|
46998
|
-
|
|
47037
|
+
findings2.push(...collectFileComments(file, lines2, project));
|
|
46999
47038
|
}
|
|
47000
|
-
|
|
47001
|
-
return
|
|
47039
|
+
findings2.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
|
|
47040
|
+
return findings2;
|
|
47002
47041
|
}
|
|
47003
47042
|
|
|
47004
47043
|
// src/commands/verify/blockCodeComments.ts
|
|
47005
47044
|
function blockCodeComments() {
|
|
47006
47045
|
const ignoreGlobs = loadConfig().blockCodeComments?.ignore ?? [];
|
|
47007
|
-
const
|
|
47008
|
-
if (
|
|
47046
|
+
const findings2 = findComments({ ignoreGlobs });
|
|
47047
|
+
if (findings2.length === 0) {
|
|
47009
47048
|
console.log("No comments on changed lines.");
|
|
47010
47049
|
process.exit(0);
|
|
47011
47050
|
}
|
|
47012
47051
|
console.log("Comments on changed lines:\n");
|
|
47013
|
-
for (const { file, line, text: text20 } of
|
|
47052
|
+
for (const { file, line, text: text20 } of findings2) {
|
|
47014
47053
|
console.log(`${file}:${line} \u2192 ${text20}`);
|
|
47015
47054
|
}
|
|
47016
47055
|
console.log(`
|
|
47017
|
-
Total: ${
|
|
47056
|
+
Total: ${findings2.length} comment(s)`);
|
|
47018
47057
|
console.log(
|
|
47019
47058
|
"\nEvery comment on a changed line fails this gate, whether you added or edited it. Remove them and let the code document itself."
|
|
47020
47059
|
);
|
|
@@ -47190,13 +47229,13 @@ import path105 from "path";
|
|
|
47190
47229
|
|
|
47191
47230
|
// src/commands/verify/migrations/checkAppendOnly.ts
|
|
47192
47231
|
function checkAppendOnly(baseline, current) {
|
|
47193
|
-
const
|
|
47232
|
+
const findings2 = [];
|
|
47194
47233
|
for (const [file, content] of baseline) {
|
|
47195
47234
|
const now = current.get(file);
|
|
47196
|
-
if (now === void 0)
|
|
47197
|
-
else if (now !== content)
|
|
47235
|
+
if (now === void 0) findings2.push({ file, kind: "removed" });
|
|
47236
|
+
else if (now !== content) findings2.push({ file, kind: "modified" });
|
|
47198
47237
|
}
|
|
47199
|
-
return
|
|
47238
|
+
return findings2;
|
|
47200
47239
|
}
|
|
47201
47240
|
|
|
47202
47241
|
// src/commands/verify/migrations/checkDestructive.ts
|
|
@@ -47208,16 +47247,16 @@ var DESTRUCTIVE_PATTERNS = [
|
|
|
47208
47247
|
];
|
|
47209
47248
|
var MARKER = /--\s*destructive-ok\b/i;
|
|
47210
47249
|
function checkDestructive(migrations3) {
|
|
47211
|
-
const
|
|
47250
|
+
const findings2 = [];
|
|
47212
47251
|
for (const migration of migrations3) {
|
|
47213
47252
|
const statements = DESTRUCTIVE_PATTERNS.filter(
|
|
47214
47253
|
(pattern2) => pattern2.regex.test(migration.sql)
|
|
47215
47254
|
).map((pattern2) => pattern2.label);
|
|
47216
47255
|
if (statements.length === 0) continue;
|
|
47217
47256
|
if (MARKER.test(migration.sql)) continue;
|
|
47218
|
-
|
|
47257
|
+
findings2.push({ id: migration.id, name: migration.name, statements });
|
|
47219
47258
|
}
|
|
47220
|
-
return
|
|
47259
|
+
return findings2;
|
|
47221
47260
|
}
|
|
47222
47261
|
|
|
47223
47262
|
// src/commands/verify/migrations/checkSequential.ts
|