revdeck 0.18.0 → 0.19.1
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/CHANGELOG.md +52 -0
- package/README.md +25 -6
- package/README.ru.md +27 -5
- package/dist/cli.js +488 -39
- package/dist/cli.js.map +4 -4
- package/dist/daemon.js +581 -101
- package/dist/daemon.js.map +4 -4
- package/dist/mcp.js +277 -19
- package/dist/mcp.js.map +4 -4
- package/dist/ui/assets/index-BPQZSbvp.js +21 -0
- package/dist/ui/index.html +1 -1
- package/docs/architecture.md +8 -0
- package/docs/capabilities.md +13 -6
- package/docs/configuration.md +26 -1
- package/docs/integrations.md +1 -0
- package/docs/protocol.md +7 -4
- package/docs/ru/architecture.md +9 -0
- package/docs/ru/capabilities.md +13 -4
- package/docs/ru/configuration.md +25 -1
- package/docs/ru/integrations.md +1 -0
- package/docs/ru/protocol.md +7 -4
- package/docs/ru/threat-model.md +3 -0
- package/docs/threat-model.md +3 -0
- package/package.json +1 -1
- package/skills/revdeck/en/Feedback.md +3 -1
- package/skills/revdeck/en/Review.md +6 -1
- package/skills/revdeck/en/SKILL.md +12 -1
- package/skills/revdeck/ru/Feedback.md +3 -1
- package/skills/revdeck/ru/Review.md +5 -1
- package/skills/revdeck/ru/SKILL.md +11 -1
- package/dist/ui/assets/index-D3hJTLAL.js +0 -21
package/dist/daemon.js
CHANGED
|
@@ -15,12 +15,22 @@ var __export = (target, all) => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
// src/core/redact.ts
|
|
18
|
-
function
|
|
18
|
+
function sanitize(value) {
|
|
19
19
|
let text2 = String(value ?? "").replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, " ");
|
|
20
20
|
for (const [pattern, replacement] of TOKEN_PATTERNS) {
|
|
21
21
|
text2 = text2.replace(pattern, replacement);
|
|
22
22
|
}
|
|
23
|
-
return text2
|
|
23
|
+
return text2;
|
|
24
|
+
}
|
|
25
|
+
function redact(value) {
|
|
26
|
+
return sanitize(value).slice(0, 4e3);
|
|
27
|
+
}
|
|
28
|
+
function redactClip(value, limit = 2e4, tail = 6e3) {
|
|
29
|
+
const text2 = sanitize(value);
|
|
30
|
+
if (text2.length <= limit) return text2;
|
|
31
|
+
return `${text2.slice(0, Math.max(0, limit - tail))}
|
|
32
|
+
\u2026 [truncated] \u2026
|
|
33
|
+
${text2.slice(-tail)}`;
|
|
24
34
|
}
|
|
25
35
|
function redactLine(value, max = 300) {
|
|
26
36
|
return redact(value).replace(/\s+/g, " ").trim().slice(0, max);
|
|
@@ -226,11 +236,23 @@ var init_exec = __esm({
|
|
|
226
236
|
shell: false
|
|
227
237
|
},
|
|
228
238
|
(error, stdout, stderr) => {
|
|
229
|
-
const
|
|
230
|
-
const
|
|
239
|
+
const rawCode = error?.code;
|
|
240
|
+
const signal = error?.signal;
|
|
241
|
+
const spawnFailure = Boolean(error) && typeof rawCode !== "number";
|
|
242
|
+
const code = typeof rawCode === "number" ? rawCode : error ? 1 : 0;
|
|
231
243
|
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
232
244
|
const reason = (stderr || stdout || error.message).trim();
|
|
233
|
-
reject(
|
|
245
|
+
reject(
|
|
246
|
+
Object.assign(new Error(reason.slice(0, 4e3)), {
|
|
247
|
+
command,
|
|
248
|
+
code,
|
|
249
|
+
rawCode,
|
|
250
|
+
signal,
|
|
251
|
+
spawnFailure,
|
|
252
|
+
stderr,
|
|
253
|
+
stdout
|
|
254
|
+
})
|
|
255
|
+
);
|
|
234
256
|
return;
|
|
235
257
|
}
|
|
236
258
|
resolve({ stdout, stderr, code });
|
|
@@ -416,6 +438,20 @@ function diffStats(files) {
|
|
|
416
438
|
}
|
|
417
439
|
return { files: files.length, additions, deletions };
|
|
418
440
|
}
|
|
441
|
+
function countFileLines(file) {
|
|
442
|
+
let additions = 0;
|
|
443
|
+
let deletions = 0;
|
|
444
|
+
for (const hunk of file.hunks) {
|
|
445
|
+
for (const line of hunk.lines) {
|
|
446
|
+
if (line.kind === "+") additions++;
|
|
447
|
+
else if (line.kind === "-") deletions++;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return { additions, deletions };
|
|
451
|
+
}
|
|
452
|
+
function diffFileSizes(files) {
|
|
453
|
+
return files.map((file) => ({ path: file.path, status: file.status, ...countFileLines(file) }));
|
|
454
|
+
}
|
|
419
455
|
function changedPaths(files) {
|
|
420
456
|
return files.map((file) => file.path);
|
|
421
457
|
}
|
|
@@ -558,7 +594,7 @@ __export(gitlab_exports, {
|
|
|
558
594
|
isAuthError: () => isAuthError
|
|
559
595
|
});
|
|
560
596
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
561
|
-
function gitlabMergeInfo(mr, baseSha,
|
|
597
|
+
function gitlabMergeInfo(mr, baseSha, headSha2) {
|
|
562
598
|
const targetBranch = String(mr.target_branch ?? "");
|
|
563
599
|
const detail = [mr.detailed_merge_status, mr.merge_status].filter(Boolean).join(" \xB7 ");
|
|
564
600
|
let state;
|
|
@@ -579,7 +615,7 @@ function gitlabMergeInfo(mr, baseSha, headSha) {
|
|
|
579
615
|
detail: detail || "not reported",
|
|
580
616
|
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
581
617
|
...baseSha ? { baseSha } : {},
|
|
582
|
-
...
|
|
618
|
+
...headSha2 ? { headSha: headSha2 } : {}
|
|
583
619
|
};
|
|
584
620
|
}
|
|
585
621
|
function isAuthError(error) {
|
|
@@ -1500,7 +1536,7 @@ async function writeFileAtomic(file, data, mode = 384, dirMode = 448) {
|
|
|
1500
1536
|
init_redact();
|
|
1501
1537
|
|
|
1502
1538
|
// src/version.ts
|
|
1503
|
-
var VERSION = "0.
|
|
1539
|
+
var VERSION = "0.19.1";
|
|
1504
1540
|
var PROTOCOL_VERSION = 2;
|
|
1505
1541
|
|
|
1506
1542
|
// src/daemon/main.ts
|
|
@@ -1804,6 +1840,20 @@ var Store = class {
|
|
|
1804
1840
|
used_at TEXT,
|
|
1805
1841
|
created_at TEXT NOT NULL
|
|
1806
1842
|
);
|
|
1843
|
+
CREATE TABLE IF NOT EXISTS check_runs (
|
|
1844
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1845
|
+
review_id TEXT NOT NULL REFERENCES reviews(id) ON DELETE CASCADE,
|
|
1846
|
+
check_id TEXT NOT NULL,
|
|
1847
|
+
name TEXT NOT NULL,
|
|
1848
|
+
argv_json TEXT NOT NULL,
|
|
1849
|
+
status TEXT NOT NULL,
|
|
1850
|
+
exit_code INTEGER,
|
|
1851
|
+
output TEXT NOT NULL,
|
|
1852
|
+
commit_sha TEXT NOT NULL,
|
|
1853
|
+
started_at TEXT NOT NULL,
|
|
1854
|
+
duration_ms INTEGER NOT NULL
|
|
1855
|
+
);
|
|
1856
|
+
CREATE INDEX IF NOT EXISTS check_runs_review ON check_runs(review_id, started_at);
|
|
1807
1857
|
CREATE TABLE IF NOT EXISTS audit (
|
|
1808
1858
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1809
1859
|
at TEXT NOT NULL,
|
|
@@ -2577,6 +2627,54 @@ var Store = class {
|
|
|
2577
2627
|
draft.updatedAt
|
|
2578
2628
|
);
|
|
2579
2629
|
}
|
|
2630
|
+
// --- checks ---
|
|
2631
|
+
saveCheckRuns(id, runs) {
|
|
2632
|
+
const insert = this.db.prepare(
|
|
2633
|
+
`INSERT INTO check_runs (review_id, check_id, name, argv_json, status, exit_code, output, commit_sha, started_at, duration_ms)
|
|
2634
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
2635
|
+
);
|
|
2636
|
+
this.transaction(() => {
|
|
2637
|
+
for (const run2 of runs) {
|
|
2638
|
+
insert.run(
|
|
2639
|
+
id,
|
|
2640
|
+
run2.checkId,
|
|
2641
|
+
run2.name,
|
|
2642
|
+
JSON.stringify(run2.argv),
|
|
2643
|
+
run2.status,
|
|
2644
|
+
run2.exitCode ?? null,
|
|
2645
|
+
run2.output,
|
|
2646
|
+
run2.commitSha,
|
|
2647
|
+
run2.startedAt,
|
|
2648
|
+
run2.durationMs
|
|
2649
|
+
);
|
|
2650
|
+
}
|
|
2651
|
+
});
|
|
2652
|
+
}
|
|
2653
|
+
/** Последний запуск по каждой проверке: история хранится, но контексту нужен актуальный. */
|
|
2654
|
+
latestCheckRuns(id) {
|
|
2655
|
+
const rows2 = this.db.prepare("SELECT * FROM check_runs WHERE review_id = ? ORDER BY started_at DESC, id DESC").all(id);
|
|
2656
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2657
|
+
const runs = [];
|
|
2658
|
+
for (const row of rows2) {
|
|
2659
|
+
const checkId = text(row, "check_id");
|
|
2660
|
+
if (seen.has(checkId)) continue;
|
|
2661
|
+
seen.add(checkId);
|
|
2662
|
+
const exitCode = row.exit_code;
|
|
2663
|
+
runs.push({
|
|
2664
|
+
reviewId: id,
|
|
2665
|
+
checkId,
|
|
2666
|
+
name: text(row, "name"),
|
|
2667
|
+
argv: json(row, "argv_json", []),
|
|
2668
|
+
status: text(row, "status"),
|
|
2669
|
+
exitCode: exitCode === null || exitCode === void 0 ? null : Number(exitCode),
|
|
2670
|
+
output: text(row, "output"),
|
|
2671
|
+
commitSha: text(row, "commit_sha"),
|
|
2672
|
+
startedAt: text(row, "started_at"),
|
|
2673
|
+
durationMs: Number(row.duration_ms)
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
return runs;
|
|
2677
|
+
}
|
|
2580
2678
|
// --- notes ---
|
|
2581
2679
|
listNotes(id) {
|
|
2582
2680
|
const rows2 = this.db.prepare("SELECT * FROM notes WHERE review_id = ? ORDER BY created_at").all(id);
|
|
@@ -2702,6 +2800,25 @@ var Store = class {
|
|
|
2702
2800
|
JSON.stringify(input.payload ?? null)
|
|
2703
2801
|
);
|
|
2704
2802
|
}
|
|
2803
|
+
eventFromRow(row) {
|
|
2804
|
+
return {
|
|
2805
|
+
id: Number(row.id),
|
|
2806
|
+
at: text(row, "at"),
|
|
2807
|
+
reviewId: row.review_id ? String(row.review_id) : null,
|
|
2808
|
+
actor: text(row, "actor"),
|
|
2809
|
+
type: text(row, "type"),
|
|
2810
|
+
...row.finding_id ? { findingId: String(row.finding_id) } : {},
|
|
2811
|
+
...row.thread_id ? { threadId: String(row.thread_id) } : {},
|
|
2812
|
+
...row.rule_ref ? { ruleRef: String(row.rule_ref) } : {},
|
|
2813
|
+
...row.commit_sha ? { commitSha: String(row.commit_sha) } : {},
|
|
2814
|
+
payload: json(row, "payload_json", null)
|
|
2815
|
+
};
|
|
2816
|
+
}
|
|
2817
|
+
/** Последние события в хронологическом порядке: паспорту ревью нужен свежий хвост. */
|
|
2818
|
+
recentEvents(reviewId2, limit = 200) {
|
|
2819
|
+
const rows2 = this.db.prepare("SELECT * FROM review_events WHERE review_id = ? ORDER BY id DESC LIMIT ?").all(reviewId2, limit);
|
|
2820
|
+
return rows2.reverse().map((row) => this.eventFromRow(row));
|
|
2821
|
+
}
|
|
2705
2822
|
listEvents(reviewId2, from, to, limit = 5e3) {
|
|
2706
2823
|
const clauses = ["review_id = ?"];
|
|
2707
2824
|
const params = [reviewId2];
|
|
@@ -2715,18 +2832,7 @@ var Store = class {
|
|
|
2715
2832
|
}
|
|
2716
2833
|
params.push(limit);
|
|
2717
2834
|
const rows2 = this.db.prepare(`SELECT * FROM review_events WHERE ${clauses.join(" AND ")} ORDER BY id ASC LIMIT ?`).all(...params);
|
|
2718
|
-
return rows2.map((row) => (
|
|
2719
|
-
id: Number(row.id),
|
|
2720
|
-
at: text(row, "at"),
|
|
2721
|
-
reviewId: row.review_id ? String(row.review_id) : null,
|
|
2722
|
-
actor: text(row, "actor"),
|
|
2723
|
-
type: text(row, "type"),
|
|
2724
|
-
...row.finding_id ? { findingId: String(row.finding_id) } : {},
|
|
2725
|
-
...row.thread_id ? { threadId: String(row.thread_id) } : {},
|
|
2726
|
-
...row.rule_ref ? { ruleRef: String(row.rule_ref) } : {},
|
|
2727
|
-
...row.commit_sha ? { commitSha: String(row.commit_sha) } : {},
|
|
2728
|
-
payload: json(row, "payload_json", null)
|
|
2729
|
-
}));
|
|
2835
|
+
return rows2.map((row) => this.eventFromRow(row));
|
|
2730
2836
|
}
|
|
2731
2837
|
// --- audit ---
|
|
2732
2838
|
audit(reviewId2, action, detail) {
|
|
@@ -2757,7 +2863,7 @@ var Store = class {
|
|
|
2757
2863
|
init_redact();
|
|
2758
2864
|
init_errors();
|
|
2759
2865
|
import { EventEmitter } from "node:events";
|
|
2760
|
-
import { createHash as
|
|
2866
|
+
import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
|
|
2761
2867
|
import { mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
2762
2868
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
2763
2869
|
import path8 from "node:path";
|
|
@@ -2845,7 +2951,8 @@ var REVIEW_ROLE_IDS = [
|
|
|
2845
2951
|
"observability",
|
|
2846
2952
|
"build",
|
|
2847
2953
|
"privacy",
|
|
2848
|
-
"general"
|
|
2954
|
+
"general",
|
|
2955
|
+
"verifier"
|
|
2849
2956
|
];
|
|
2850
2957
|
var DEFAULT_REVIEW_ROLES = ["correctness", "architecture", "tests"];
|
|
2851
2958
|
var REVIEW_ROLES = {
|
|
@@ -2924,6 +3031,18 @@ var REVIEW_ROLES = {
|
|
|
2924
3031
|
title: { ru: "\u041F\u0440\u0438\u0432\u0430\u0442\u043D\u043E\u0441\u0442\u044C", en: "Privacy" },
|
|
2925
3032
|
focus: { ru: "PII, \u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0441\u043E\u043D\u0430\u043B\u044C\u043D\u044B\u0445 \u0434\u0430\u043D\u043D\u044B\u0445, \u043B\u043E\u0433\u0438 \u0438 \u0443\u0442\u0435\u0447\u043A\u0438", en: "PII, personal data storage, logs and leaks" }
|
|
2926
3033
|
},
|
|
3034
|
+
verifier: {
|
|
3035
|
+
criteria: ["7", "12"],
|
|
3036
|
+
title: { ru: "\u0412\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440", en: "Verifier" },
|
|
3037
|
+
focus: {
|
|
3038
|
+
ru: "\u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C \u0438\u043B\u0438 \u043E\u043F\u0440\u043E\u0432\u0435\u0440\u0433\u043D\u0443\u0442\u044C \u043A\u0430\u0436\u0434\u043E\u0433\u043E \u043A\u0430\u043D\u0434\u0438\u0434\u0430\u0442\u0430 \u043F\u043E \u0441\u0442\u0440\u043E\u043A\u0435 \u0438 \u043F\u0440\u0430\u0432\u0438\u043B\u0443",
|
|
3039
|
+
en: "confirm or refute every candidate against the line and the rule"
|
|
3040
|
+
},
|
|
3041
|
+
instructions: {
|
|
3042
|
+
ru: "\u0422\u044B \u043D\u0435 \u0438\u0449\u0435\u0448\u044C \u043D\u043E\u0432\u044B\u0435 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F. \u041D\u0430 \u0432\u0445\u043E\u0434 \u0442\u0435\u0431\u0435 \u0434\u0430\u044E\u0442 JSON \u043A\u0430\u043D\u0434\u0438\u0434\u0430\u0442\u043E\u0432 \u043E\u0442 \u043B\u0438\u0434-\u0430\u0433\u0435\u043D\u0442\u0430. \u0414\u043B\u044F \u043A\u0430\u0436\u0434\u043E\u0433\u043E \u0432\u0435\u0440\u043D\u0438 verdict: confirmed | refuted | needs-evidence, \u043E\u0434\u043D\u0443 \u0441\u0442\u0440\u043E\u043A\u0443 \u043F\u0440\u0438\u0447\u0438\u043D\u044B \u0438 \u0446\u0438\u0442\u0430\u0442\u0443 \u2014 \u0441\u0442\u0440\u043E\u043A\u0443 \u0438\u0437 \u0444\u0430\u0439\u043B\u0430 \u0438\u043B\u0438 \u0440\u0430\u0437\u0434\u0435\u043B \u043F\u0440\u0430\u0432\u0438\u043B\u0430. refuted \u0441\u0442\u0430\u0432\u044C, \u0435\u0441\u043B\u0438 \u0441\u0442\u0440\u043E\u043A\u0438 \u043D\u0435\u0442, \u0441\u0446\u0435\u043D\u0430\u0440\u0438\u0439 \u043D\u0435 \u0432\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0438\u0442\u0441\u044F, \u043F\u0440\u0430\u0432\u0438\u043B\u043E \u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C\u043E \u0438\u043B\u0438 \u0443\u0440\u043E\u0432\u0435\u043D\u044C \u0437\u0430\u0432\u044B\u0448\u0435\u043D. \u041D\u043E\u0432\u044B\u0435 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043D\u0435 \u0434\u043E\u0431\u0430\u0432\u043B\u044F\u0439; \u0441\u043E\u043C\u043D\u0435\u043D\u0438\u0435 \u043E\u0444\u043E\u0440\u043C\u043B\u044F\u0439 \u043A\u0430\u043A needs-evidence.",
|
|
3043
|
+
en: "You do not search for new findings. The lead agent gives you a JSON array of candidates. For each one return a verdict: confirmed | refuted | needs-evidence, a one-line reason, and a citation \u2014 the file line or the rule section. Use refuted when the line does not exist, the scenario does not reproduce, the rule does not apply, or the level is inflated. Do not add new findings; record doubt as needs-evidence."
|
|
3044
|
+
}
|
|
3045
|
+
},
|
|
2927
3046
|
general: {
|
|
2928
3047
|
criteria: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
|
|
2929
3048
|
title: { ru: "\u041E\u0431\u0449\u0435\u0435 \u0440\u0435\u0432\u044C\u044E", en: "General review" },
|
|
@@ -2942,7 +3061,7 @@ function resolveReviewRole(id, language, custom = {}) {
|
|
|
2942
3061
|
title: role2.title[language],
|
|
2943
3062
|
description: role2.focus[language],
|
|
2944
3063
|
criteria: role2.criteria,
|
|
2945
|
-
instructions: ""
|
|
3064
|
+
instructions: role2.instructions?.[language] ?? ""
|
|
2946
3065
|
};
|
|
2947
3066
|
}
|
|
2948
3067
|
const role = custom[id];
|
|
@@ -3272,6 +3391,14 @@ async function currentBranch(root) {
|
|
|
3272
3391
|
return "";
|
|
3273
3392
|
}
|
|
3274
3393
|
}
|
|
3394
|
+
async function headSha(root) {
|
|
3395
|
+
try {
|
|
3396
|
+
const { stdout } = await run("git", ["rev-parse", "HEAD"], { cwd: root, timeoutMs: 1e4 });
|
|
3397
|
+
return stdout.trim();
|
|
3398
|
+
} catch {
|
|
3399
|
+
return "";
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3275
3402
|
|
|
3276
3403
|
// src/core/rules.ts
|
|
3277
3404
|
import path6 from "node:path";
|
|
@@ -3515,6 +3642,163 @@ function computeGroups(diff, custom = []) {
|
|
|
3515
3642
|
return [...groups.values()].sort((left, right) => right.additions + right.deletions - (left.additions + left.deletions) || left.title.localeCompare(right.title));
|
|
3516
3643
|
}
|
|
3517
3644
|
|
|
3645
|
+
// src/core/risk.ts
|
|
3646
|
+
var SENSITIVE_PATHS = [
|
|
3647
|
+
{ pattern: /(^|\/)(migrations?|database|db|schema)(\/|\.|$)/i, reason: "database-or-migration" },
|
|
3648
|
+
{ pattern: /(^|\/)(auth|security|crypto|permissions?|payments?|billing)(\/|\.|$)/i, reason: "security-sensitive" },
|
|
3649
|
+
{ pattern: /(^|\/)\.github\/workflows\//i, reason: "ci-workflow" },
|
|
3650
|
+
{ pattern: /(^|\/)\.(gitlab-ci|circleci|buildkite)(\/|\.|$)/i, reason: "ci-workflow" },
|
|
3651
|
+
{ pattern: /(^|\/)(Jenkinsfile|azure-pipelines[^/]*|bitbucket-pipelines[^/]*)$/i, reason: "ci-workflow" },
|
|
3652
|
+
{ pattern: /(^|\/)(Dockerfile|docker-compose[^/]*)$/i, reason: "container" },
|
|
3653
|
+
{ pattern: /(^|\/)(package-lock\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock|go\.sum|composer\.lock|Gemfile\.lock|poetry\.lock|uv\.lock)$/i, reason: "dependency-lock" },
|
|
3654
|
+
{ pattern: /(^|\/)(openapi|swagger|proto)(\/|\.|$)/i, reason: "public-contract" }
|
|
3655
|
+
];
|
|
3656
|
+
var CONFIG_PATHS = /(^|\/)(package\.json|tsconfig[^/]*\.json|vite\.config[^/]*|\.eslintrc[^/]*|jest\.config[^/]*|vitest\.config[^/]*|\.revdeck\.yml)$/i;
|
|
3657
|
+
var DOC_PATH = /\.(md|mdx|txt|rst)$/i;
|
|
3658
|
+
var POLICY_PATHS = [
|
|
3659
|
+
{ pattern: /(^|\/)(AGENTS|CLAUDE|REVIEW)\.md$/i, reason: "policy-doc" },
|
|
3660
|
+
{ pattern: /(^|\/)\.(agents|claude|codex|cursor)(\/|$)/i, reason: "agent-config" },
|
|
3661
|
+
{ pattern: /(^|\/)skills\//i, reason: "skill-pack" },
|
|
3662
|
+
{ pattern: /(^|\/)\.revdeck\.yml$/i, reason: "review-policy" }
|
|
3663
|
+
];
|
|
3664
|
+
function isSensitivePath(path13) {
|
|
3665
|
+
return SENSITIVE_PATHS.some((item) => item.pattern.test(path13));
|
|
3666
|
+
}
|
|
3667
|
+
function assessReviewRisk(files, stats) {
|
|
3668
|
+
const changedLines = stats.additions + stats.deletions;
|
|
3669
|
+
const reasons = [];
|
|
3670
|
+
const sensitive = files.filter((file) => SENSITIVE_PATHS.some((item) => item.pattern.test(file.path)));
|
|
3671
|
+
for (const file of sensitive.slice(0, 5)) {
|
|
3672
|
+
const matched = SENSITIVE_PATHS.find((item) => item.pattern.test(file.path));
|
|
3673
|
+
reasons.push(`${matched?.reason ?? "sensitive"}:${file.path}`);
|
|
3674
|
+
}
|
|
3675
|
+
const configs = files.filter((file) => CONFIG_PATHS.test(file.path));
|
|
3676
|
+
if (configs.length) reasons.push(`config:${configs[0].path}${configs.length > 1 ? ` (+${configs.length - 1})` : ""}`);
|
|
3677
|
+
const policy = files.filter((file) => POLICY_PATHS.some((item) => item.pattern.test(file.path)));
|
|
3678
|
+
for (const file of policy.slice(0, 5)) {
|
|
3679
|
+
const matched = POLICY_PATHS.find((item) => item.pattern.test(file.path));
|
|
3680
|
+
reasons.push(`${matched?.reason ?? "policy"}:${file.path}`);
|
|
3681
|
+
}
|
|
3682
|
+
if (files.length > 40) reasons.push(`large:files:${files.length}`);
|
|
3683
|
+
if (changedLines > 1500) reasons.push(`large:lines:${changedLines}`);
|
|
3684
|
+
const deleted = files.filter((file) => file.status === "deleted");
|
|
3685
|
+
if (deleted.length) reasons.push(`deleted-files:${deleted.length}`);
|
|
3686
|
+
const docsOnly = files.length > 0 && policy.length === 0 && files.every((file) => DOC_PATH.test(file.path));
|
|
3687
|
+
if (docsOnly) reasons.push("docs-only");
|
|
3688
|
+
const small = files.length <= 5 && changedLines <= 150;
|
|
3689
|
+
if (small) reasons.push("small-diff");
|
|
3690
|
+
let level;
|
|
3691
|
+
if (sensitive.length || policy.length || files.length > 40 || changedLines > 1500 || deleted.length > 0) level = "high";
|
|
3692
|
+
else if (docsOnly || small && configs.length === 0) level = "low";
|
|
3693
|
+
else level = "medium";
|
|
3694
|
+
return {
|
|
3695
|
+
level,
|
|
3696
|
+
mode: level === "low" ? "fast" : "full",
|
|
3697
|
+
files: files.length,
|
|
3698
|
+
changedLines,
|
|
3699
|
+
reasons
|
|
3700
|
+
};
|
|
3701
|
+
}
|
|
3702
|
+
|
|
3703
|
+
// src/core/shard.ts
|
|
3704
|
+
var MAX_SHARDS = 32;
|
|
3705
|
+
function compareKeys(left, right) {
|
|
3706
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
3707
|
+
}
|
|
3708
|
+
var TEST_DIR = /(^|\/)(tests?|__tests__|specs?)(\/|$)/i;
|
|
3709
|
+
var TEST_NAME = /(\.(test|spec)\.[^./]+|_test\.[^./]+)$/i;
|
|
3710
|
+
function stem(path13) {
|
|
3711
|
+
const base = path13.slice(path13.lastIndexOf("/") + 1);
|
|
3712
|
+
return base.replace(TEST_NAME, "").replace(/\.[^.]*$/, "");
|
|
3713
|
+
}
|
|
3714
|
+
function isTestPath(path13) {
|
|
3715
|
+
return TEST_NAME.test(path13) || TEST_DIR.test(path13.slice(0, path13.lastIndexOf("/") + 1));
|
|
3716
|
+
}
|
|
3717
|
+
function directoryOf(path13) {
|
|
3718
|
+
const index = path13.lastIndexOf("/");
|
|
3719
|
+
return index <= 0 ? "." : path13.slice(0, index);
|
|
3720
|
+
}
|
|
3721
|
+
function cohesionGroups(files) {
|
|
3722
|
+
const groups = /* @__PURE__ */ new Map();
|
|
3723
|
+
const add = (key, file) => {
|
|
3724
|
+
const group = groups.get(key) ?? { key, files: [], size: 0, sensitive: false };
|
|
3725
|
+
group.files.push(file);
|
|
3726
|
+
group.size += file.additions + file.deletions;
|
|
3727
|
+
group.sensitive = group.sensitive || isSensitivePath(file.path);
|
|
3728
|
+
groups.set(key, group);
|
|
3729
|
+
};
|
|
3730
|
+
const sources = files.filter((file) => !isTestPath(file.path));
|
|
3731
|
+
const byStem = /* @__PURE__ */ new Map();
|
|
3732
|
+
for (const file of sources) {
|
|
3733
|
+
const key = directoryOf(file.path);
|
|
3734
|
+
const set = byStem.get(stem(file.path)) ?? /* @__PURE__ */ new Set();
|
|
3735
|
+
set.add(key);
|
|
3736
|
+
byStem.set(stem(file.path), set);
|
|
3737
|
+
}
|
|
3738
|
+
for (const file of files) {
|
|
3739
|
+
if (isTestPath(file.path)) {
|
|
3740
|
+
const candidates = byStem.get(stem(file.path));
|
|
3741
|
+
if (candidates?.size === 1) {
|
|
3742
|
+
add([...candidates][0], file);
|
|
3743
|
+
continue;
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
add(directoryOf(file.path), file);
|
|
3747
|
+
}
|
|
3748
|
+
return [...groups.values()];
|
|
3749
|
+
}
|
|
3750
|
+
function splitLargeGroups(groups, target) {
|
|
3751
|
+
const result = [...groups];
|
|
3752
|
+
while (result.length < target) {
|
|
3753
|
+
const candidates = result.filter((group2) => group2.files.length > 1);
|
|
3754
|
+
candidates.sort((left, right) => right.files.length - left.files.length || right.size - left.size || compareKeys(left.key, right.key));
|
|
3755
|
+
const group = candidates[0];
|
|
3756
|
+
if (!group) break;
|
|
3757
|
+
const pieces = group.files.map((file) => ({
|
|
3758
|
+
key: `${group.key}#${file.path}`,
|
|
3759
|
+
files: [file],
|
|
3760
|
+
size: file.additions + file.deletions,
|
|
3761
|
+
sensitive: isSensitivePath(file.path)
|
|
3762
|
+
}));
|
|
3763
|
+
result.splice(result.indexOf(group), 1, ...pieces);
|
|
3764
|
+
}
|
|
3765
|
+
return result;
|
|
3766
|
+
}
|
|
3767
|
+
function partitionShards(files, count) {
|
|
3768
|
+
const requested = Number.isFinite(count) ? Math.trunc(count) : 1;
|
|
3769
|
+
const size = Math.max(1, Math.min(requested, MAX_SHARDS, Math.max(1, files.length)));
|
|
3770
|
+
const buckets = Array.from({ length: size }, () => []);
|
|
3771
|
+
if (buckets.length === 1) return [files];
|
|
3772
|
+
let groups = cohesionGroups(files);
|
|
3773
|
+
if (groups.length < buckets.length) groups = splitLargeGroups(groups, buckets.length);
|
|
3774
|
+
groups.sort(
|
|
3775
|
+
(left, right) => Number(right.sensitive) - Number(left.sensitive) || right.size - left.size || compareKeys(left.key, right.key)
|
|
3776
|
+
);
|
|
3777
|
+
const loads = buckets.map(() => 0);
|
|
3778
|
+
for (const group of groups) {
|
|
3779
|
+
let target = 0;
|
|
3780
|
+
for (let index = 1; index < buckets.length; index++) {
|
|
3781
|
+
if (loads[index] < loads[target]) target = index;
|
|
3782
|
+
}
|
|
3783
|
+
buckets[target].push(...group.files);
|
|
3784
|
+
loads[target] += group.size;
|
|
3785
|
+
}
|
|
3786
|
+
const order = new Map(files.map((file, index) => [file.path, index]));
|
|
3787
|
+
for (const bucket of buckets) bucket.sort((left, right) => order.get(left.path) - order.get(right.path));
|
|
3788
|
+
return buckets;
|
|
3789
|
+
}
|
|
3790
|
+
function shardPaths(files, index, count) {
|
|
3791
|
+
const bucket = partitionShards(files, count)[Math.max(0, Math.trunc(index) - 1)] ?? [];
|
|
3792
|
+
return new Set(bucket.map((file) => file.path));
|
|
3793
|
+
}
|
|
3794
|
+
|
|
3795
|
+
// src/core/evidence.ts
|
|
3796
|
+
init_locale();
|
|
3797
|
+
import { createHash } from "node:crypto";
|
|
3798
|
+
function documentHash(excerpt) {
|
|
3799
|
+
return createHash("sha256").update(excerpt).digest("hex").slice(0, 16);
|
|
3800
|
+
}
|
|
3801
|
+
|
|
3518
3802
|
// src/core/codeowners.ts
|
|
3519
3803
|
function parseCodeowners(text2) {
|
|
3520
3804
|
const entries = [];
|
|
@@ -3731,7 +4015,7 @@ function matchesSignature(buffer, contentType) {
|
|
|
3731
4015
|
|
|
3732
4016
|
// src/core/findings.ts
|
|
3733
4017
|
init_types();
|
|
3734
|
-
import { createHash } from "node:crypto";
|
|
4018
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
3735
4019
|
init_locale();
|
|
3736
4020
|
var LEVEL_ORDER = { blocker: 0, major: 1, minor: 2, question: 3 };
|
|
3737
4021
|
function validateFinding(raw) {
|
|
@@ -3773,7 +4057,7 @@ function validateFinding(raw) {
|
|
|
3773
4057
|
};
|
|
3774
4058
|
}
|
|
3775
4059
|
function fingerprintOf(input) {
|
|
3776
|
-
return
|
|
4060
|
+
return createHash2("sha256").update(`${input.file.trim().toLowerCase()}|${input.level}|${input.title.trim().toLowerCase().replace(/\s+/g, " ")}`).digest("hex");
|
|
3777
4061
|
}
|
|
3778
4062
|
function mergeFindings(previous, incoming, options = {}) {
|
|
3779
4063
|
const now = options.now ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3933,65 +4217,15 @@ init_exec();
|
|
|
3933
4217
|
|
|
3934
4218
|
// src/daemon/view.ts
|
|
3935
4219
|
init_diff();
|
|
3936
|
-
|
|
3937
|
-
// src/core/risk.ts
|
|
3938
|
-
var SENSITIVE_PATHS = [
|
|
3939
|
-
{ pattern: /(^|\/)(migrations?|database|db|schema)(\/|\.|$)/i, reason: "database-or-migration" },
|
|
3940
|
-
{ pattern: /(^|\/)(auth|security|crypto|permissions?|payments?|billing)(\/|\.|$)/i, reason: "security-sensitive" },
|
|
3941
|
-
{ pattern: /(^|\/)\.github\/workflows\//i, reason: "ci-workflow" },
|
|
3942
|
-
{ pattern: /(^|\/)\.(gitlab-ci|circleci|buildkite)(\/|\.|$)/i, reason: "ci-workflow" },
|
|
3943
|
-
{ pattern: /(^|\/)(Jenkinsfile|azure-pipelines[^/]*|bitbucket-pipelines[^/]*)$/i, reason: "ci-workflow" },
|
|
3944
|
-
{ pattern: /(^|\/)(Dockerfile|docker-compose[^/]*)$/i, reason: "container" },
|
|
3945
|
-
{ pattern: /(^|\/)(package-lock\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock|go\.sum|composer\.lock|Gemfile\.lock|poetry\.lock|uv\.lock)$/i, reason: "dependency-lock" },
|
|
3946
|
-
{ pattern: /(^|\/)(openapi|swagger|proto)(\/|\.|$)/i, reason: "public-contract" }
|
|
3947
|
-
];
|
|
3948
|
-
var CONFIG_PATHS = /(^|\/)(package\.json|tsconfig[^/]*\.json|vite\.config[^/]*|\.eslintrc[^/]*|jest\.config[^/]*|vitest\.config[^/]*|\.revdeck\.yml)$/i;
|
|
3949
|
-
var DOC_PATH = /\.(md|mdx|txt|rst)$/i;
|
|
3950
|
-
function assessReviewRisk(files, stats) {
|
|
3951
|
-
const changedLines = stats.additions + stats.deletions;
|
|
3952
|
-
const reasons = [];
|
|
3953
|
-
const sensitive = files.filter((file) => SENSITIVE_PATHS.some((item) => item.pattern.test(file.path)));
|
|
3954
|
-
for (const file of sensitive.slice(0, 5)) {
|
|
3955
|
-
const matched = SENSITIVE_PATHS.find((item) => item.pattern.test(file.path));
|
|
3956
|
-
reasons.push(`${matched?.reason ?? "sensitive"}:${file.path}`);
|
|
3957
|
-
}
|
|
3958
|
-
const configs = files.filter((file) => CONFIG_PATHS.test(file.path));
|
|
3959
|
-
if (configs.length) reasons.push(`config:${configs[0].path}${configs.length > 1 ? ` (+${configs.length - 1})` : ""}`);
|
|
3960
|
-
if (files.length > 40) reasons.push(`large:files:${files.length}`);
|
|
3961
|
-
if (changedLines > 1500) reasons.push(`large:lines:${changedLines}`);
|
|
3962
|
-
const deleted = files.filter((file) => file.status === "deleted");
|
|
3963
|
-
if (deleted.length) reasons.push(`deleted-files:${deleted.length}`);
|
|
3964
|
-
const docsOnly = files.length > 0 && files.every((file) => DOC_PATH.test(file.path));
|
|
3965
|
-
if (docsOnly) reasons.push("docs-only");
|
|
3966
|
-
const small = files.length <= 5 && changedLines <= 150;
|
|
3967
|
-
if (small) reasons.push("small-diff");
|
|
3968
|
-
let level;
|
|
3969
|
-
if (sensitive.length || files.length > 40 || changedLines > 1500 || deleted.length > 0) level = "high";
|
|
3970
|
-
else if (docsOnly || small && configs.length === 0) level = "low";
|
|
3971
|
-
else level = "medium";
|
|
3972
|
-
return {
|
|
3973
|
-
level,
|
|
3974
|
-
mode: level === "low" ? "fast" : "full",
|
|
3975
|
-
files: files.length,
|
|
3976
|
-
changedLines,
|
|
3977
|
-
reasons
|
|
3978
|
-
};
|
|
3979
|
-
}
|
|
3980
|
-
|
|
3981
|
-
// src/daemon/view.ts
|
|
3982
4220
|
var STALE_AFTER_MS = 9e4;
|
|
3983
4221
|
function fileSummaries(diff) {
|
|
3984
|
-
return diff.map((file) => {
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
}
|
|
3992
|
-
}
|
|
3993
|
-
return { path: file.path, oldPath: file.oldPath, status: file.status, binary: file.binary, additions, deletions };
|
|
3994
|
-
});
|
|
4222
|
+
return diff.map((file) => ({
|
|
4223
|
+
path: file.path,
|
|
4224
|
+
oldPath: file.oldPath,
|
|
4225
|
+
status: file.status,
|
|
4226
|
+
binary: file.binary,
|
|
4227
|
+
...countFileLines(file)
|
|
4228
|
+
}));
|
|
3995
4229
|
}
|
|
3996
4230
|
function toReviewView(review, now = Date.now()) {
|
|
3997
4231
|
const { diff, threads, findings, ...rest } = review;
|
|
@@ -4177,6 +4411,15 @@ function when(iso, language = locale()) {
|
|
|
4177
4411
|
return date.toLocaleString(en ? "en-US" : "ru-RU", { dateStyle: "short", timeStyle: "short" });
|
|
4178
4412
|
}
|
|
4179
4413
|
|
|
4414
|
+
// src/core/clip.ts
|
|
4415
|
+
function headTailLines(text2, limit = 12) {
|
|
4416
|
+
const lines = String(text2 ?? "").split("\n");
|
|
4417
|
+
if (lines.length <= limit) return lines;
|
|
4418
|
+
const head = Math.max(1, Math.ceil(limit / 3));
|
|
4419
|
+
const tail = Math.max(1, limit - head - 1);
|
|
4420
|
+
return [...lines.slice(0, head), "\u2026", ...lines.slice(-tail)];
|
|
4421
|
+
}
|
|
4422
|
+
|
|
4180
4423
|
// src/core/scenario.ts
|
|
4181
4424
|
function isOwnReview(review) {
|
|
4182
4425
|
const username = review.user?.username;
|
|
@@ -4193,11 +4436,13 @@ function renderContext(review, rules, options = {}) {
|
|
|
4193
4436
|
const agents = Math.max(1, options.agents ?? rules.agents ?? 1);
|
|
4194
4437
|
const planRoles = options.roles ?? rules.roles ?? effectiveRoleIds(agents, DEFAULT_REVIEW_ROLES);
|
|
4195
4438
|
const roles = Array.isArray(planRoles) && planRoles.length && typeof planRoles[0] === "object" ? planRoles : effectiveRoleIds(agents, planRoles).map((id) => resolveReviewRole(id, language)).filter((role) => Boolean(role));
|
|
4196
|
-
const selectedRole = options.role ? roles.find((role) => role.id === options.role) : void 0;
|
|
4439
|
+
const selectedRole = options.role ? roles.find((role) => role.id === options.role) ?? resolveReviewRole(options.role, language) ?? void 0 : void 0;
|
|
4197
4440
|
if (options.role && !selectedRole) throw new Error(`unknown review role: ${options.role}`);
|
|
4198
4441
|
const shardCount = options.shard?.count ?? 1;
|
|
4199
4442
|
const shardIndex = options.shard?.index ?? 1;
|
|
4200
|
-
const
|
|
4443
|
+
const shardSet = shardCount > 1 ? shardPaths(review.files, shardIndex, shardCount) : null;
|
|
4444
|
+
const visibleFiles = shardSet ? review.files.filter((file) => shardSet.has(file.path)) : review.files;
|
|
4445
|
+
const otherFiles = shardSet ? review.files.filter((file) => !shardSet.has(file.path)) : [];
|
|
4201
4446
|
const visiblePaths = new Set(visibleFiles.map((file) => file.path));
|
|
4202
4447
|
const visibleThreads = shardCount > 1 ? review.threads.filter((thread) => !thread.path || visiblePaths.has(thread.path)) : review.threads;
|
|
4203
4448
|
const visibleNotes = shardCount > 1 ? review.notes.filter((note) => visiblePaths.has(note.file)) : review.notes;
|
|
@@ -4335,14 +4580,24 @@ function renderContext(review, rules, options = {}) {
|
|
|
4335
4580
|
}
|
|
4336
4581
|
if (options.role || shardCount > 1) {
|
|
4337
4582
|
push(t(
|
|
4338
|
-
"\u042D\u0442\u043E \u043D\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u044B\u0439 \
|
|
4339
|
-
"This is an independent
|
|
4583
|
+
"\u042D\u0442\u043E \u043D\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u044B\u0439 \u0440\u0435\u0432\u044C\u044E\u0435\u0440 \u0447\u0430\u0441\u0442\u0438 diff. \u041D\u0435 \u0432\u044B\u0437\u044B\u0432\u0430\u0439 revdeck_draft_findings, revdeck_set_summary, revdeck_draft_reply: \u0432\u0435\u0440\u043D\u0438 \u043B\u0438\u0434-\u0430\u0433\u0435\u043D\u0442\u0443 JSON \u0441 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F\u043C\u0438 \u0438 \u043A\u043E\u0440\u043E\u0442\u043A\u043E\u0439 \u0432\u044B\u0436\u0438\u043C\u043A\u043E\u0439.",
|
|
4584
|
+
"This is an independent reviewer of one diff part. Do not call revdeck_draft_findings, revdeck_set_summary or revdeck_draft_reply: return JSON with findings and a short summary to the lead agent."
|
|
4340
4585
|
));
|
|
4586
|
+
if (shardCount > 1) {
|
|
4587
|
+
push(t(
|
|
4588
|
+
"\u0422\u044B \u0432\u0438\u0434\u0438\u0448\u044C \u0442\u043E\u043B\u044C\u043A\u043E \u0444\u0430\u0439\u043B\u044B \u0441\u0432\u043E\u0435\u0433\u043E \u0448\u0430\u0440\u0434\u0430. \u0421\u043F\u0438\u0441\u043E\u043A \u043E\u0441\u0442\u0430\u043B\u044C\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432 \u043D\u0438\u0436\u0435 \u2014 \u0434\u043B\u044F \u043E\u0440\u0438\u0435\u043D\u0442\u0430\u0446\u0438\u0438: \u0435\u0441\u043B\u0438 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0435 \u0437\u0430\u0434\u0435\u0432\u0430\u0435\u0442 \u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442 \u0432\u043D\u0435 \u0448\u0430\u0440\u0434\u0430 (\u043E\u0431\u0449\u0438\u0439 \u0442\u0438\u043F, \u0432\u044B\u0437\u044B\u0432\u0430\u044E\u0449\u0438\u0439 \u043A\u043E\u0434, \u043A\u043E\u043D\u0444\u0438\u0433), \u0432\u044B\u043D\u0435\u0441\u0438 \u044D\u0442\u043E \u043E\u0442\u0434\u0435\u043B\u044C\u043D\u044B\u043C \u043F\u0443\u043D\u043A\u0442\u043E\u043C \u0432 \u0432\u044B\u0436\u0438\u043C\u043A\u0443 \u0434\u043B\u044F \u043B\u0438\u0434\u0430, \u0430 \u043D\u0435 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0435\u043C.",
|
|
4589
|
+
"You only see the files of your shard. The list of other files below is for orientation: if the change touches a contract outside your shard (shared type, caller, config), report it as a separate item for the lead, not as a finding."
|
|
4590
|
+
));
|
|
4591
|
+
}
|
|
4341
4592
|
} else {
|
|
4342
4593
|
push(t(
|
|
4343
4594
|
"\u0422\u044B \u043B\u0438\u0434-\u0430\u0433\u0435\u043D\u0442: \u0437\u0430\u043F\u0443\u0441\u0442\u0438 \u043F\u043E \u043E\u0434\u043D\u043E\u043C\u0443 \u0441\u0443\u0431\u0430\u0433\u0435\u043D\u0442\u0443 \u043D\u0430 \u0440\u043E\u043B\u044C \u0438 \u0448\u0430\u0440\u0434, \u043F\u0435\u0440\u0435\u0434\u0430\u0439 \u043A\u0430\u0436\u0434\u043E\u043C\u0443 `revdeck_context --role <role> --shard i/N`, \u0441\u043E\u0431\u0435\u0440\u0438 JSON, \u0443\u0431\u0435\u0440\u0438 \u0434\u0443\u0431\u043B\u0438 \u043F\u043E file:line:title \u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u043E\u0442\u043E\u043C \u0437\u0430\u043F\u0438\u0448\u0438 \u0438\u0442\u043E\u0433\u043E\u0432\u044B\u0435 findings \u0438 summary.",
|
|
4344
4595
|
"You are the lead agent: spawn one subagent per role and shard, give each `revdeck_context --role <role> --shard i/N`, collect JSON, deduplicate by file:line:title, and only then write the final findings and summary."
|
|
4345
4596
|
));
|
|
4597
|
+
push(t(
|
|
4598
|
+
"\u0415\u0441\u043B\u0438 \u0432\u044B \u0434\u0435\u043B\u0438\u043B\u0438 diff \u043D\u0430 \u0448\u0430\u0440\u0434\u044B: \u043F\u043E\u0441\u043B\u0435 \u0441\u0431\u043E\u0440\u0430 \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u043E\u0432 \u0441\u0434\u0435\u043B\u0430\u0439 cross-cut \u043F\u0440\u043E\u0445\u043E\u0434 \u043F\u043E \u043F\u043E\u043B\u043D\u043E\u043C\u0443 \u0441\u043F\u0438\u0441\u043A\u0443 \u0444\u0430\u0439\u043B\u043E\u0432 \u0438 \u0438\u0437\u043C\u0435\u043D\u0451\u043D\u043D\u044B\u043C \u043F\u0443\u0431\u043B\u0438\u0447\u043D\u044B\u043C \u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442\u0430\u043C (\u043E\u0431\u0449\u0438\u0439 \u0442\u0438\u043F, \u0432\u044B\u0437\u044B\u0432\u0430\u044E\u0449\u0438\u0439 \u043A\u043E\u0434, \u0441\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u044B \u0432 \u0440\u0430\u0437\u043D\u044B\u0445 \u0448\u0430\u0440\u0434\u0430\u0445) \u2014 \u0448\u0432\u043E\u0432 \u043D\u0435 \u0432\u0438\u0434\u0438\u0442 \u043D\u0438 \u043E\u0434\u0438\u043D \u0432\u043E\u0440\u043A\u0435\u0440. \u0412 `coverage` \u0443\u043A\u0430\u0436\u0438 \u043E\u0441\u0438 \u043F\u0440\u043E\u0433\u043E\u043D\u0430: \u0440\u043E\u043B\u0438, \u0447\u0438\u0441\u043B\u043E \u0448\u0430\u0440\u0434\u043E\u0432, \u0435\u0441\u043B\u0438 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043B\u0438\u0441\u044C, \u0438 \u0447\u0442\u043E \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u043E \u043D\u0430 \u0448\u0432\u0430\u0445.",
|
|
4599
|
+
"If you split the diff into shards: after collecting results, do a cross-cut pass over the full file list and the changed public contracts (shared types, callers, related files in different shards) \u2014 no worker sees those seams. Record the run axes in `coverage`: roles, shard count if any, and what the seam check covered."
|
|
4600
|
+
));
|
|
4346
4601
|
}
|
|
4347
4602
|
push("");
|
|
4348
4603
|
}
|
|
@@ -4387,6 +4642,20 @@ function renderContext(review, rules, options = {}) {
|
|
|
4387
4642
|
for (const file of visibleFiles) {
|
|
4388
4643
|
push(`- ${file.path} (${file.status}, +${file.additions} \u2212${file.deletions})${file.binary ? " [binary]" : ""}`);
|
|
4389
4644
|
}
|
|
4645
|
+
if (shardCount > 1) {
|
|
4646
|
+
if (!visibleFiles.length) {
|
|
4647
|
+
push(t(
|
|
4648
|
+
`> \u0412 \u0448\u0430\u0440\u0434\u0435 ${shardIndex}/${shardCount} \u043D\u0435\u0442 \u0444\u0430\u0439\u043B\u043E\u0432: \u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u0435 \u0447\u0438\u0441\u043B\u043E \u0448\u0430\u0440\u0434\u043E\u0432 \u0438\u043B\u0438 \u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u0448\u0432\u044B \u043A\u0430\u043A \u043B\u0438\u0434.`,
|
|
4649
|
+
`> Shard ${shardIndex}/${shardCount} has no files: reduce the shard count or check the seams as the lead.`
|
|
4650
|
+
));
|
|
4651
|
+
}
|
|
4652
|
+
if (otherFiles.length) {
|
|
4653
|
+
const shown = otherFiles.slice(0, 40).map((file) => `\`${file.path}\``);
|
|
4654
|
+
const rest = otherFiles.length > shown.length ? ` ${t(`\u0438 \u0435\u0449\u0451 ${otherFiles.length - shown.length}`, `and ${otherFiles.length - shown.length} more`)}` : "";
|
|
4655
|
+
push("");
|
|
4656
|
+
push(`${t("\u0412\u043D\u0435 \u044D\u0442\u043E\u0433\u043E \u0448\u0430\u0440\u0434\u0430 (\u0431\u0435\u0437 diff)", "Outside this shard (no diff)")}: ${shown.join(", ")}${rest}`);
|
|
4657
|
+
}
|
|
4658
|
+
}
|
|
4390
4659
|
push("");
|
|
4391
4660
|
if (review.groups?.length) {
|
|
4392
4661
|
push(`## ${t("\u0413\u0440\u0443\u043F\u043F\u044B \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439", "Change groups")}`);
|
|
@@ -4437,11 +4706,47 @@ function renderContext(review, rules, options = {}) {
|
|
|
4437
4706
|
}
|
|
4438
4707
|
push("");
|
|
4439
4708
|
}
|
|
4440
|
-
|
|
4709
|
+
const checkRuns = rules.runs ?? [];
|
|
4710
|
+
if (rules.checks.length || checkRuns.length) {
|
|
4441
4711
|
push(`## ${t("\u041F\u0440\u043E\u0432\u0435\u0440\u043A\u0438", "Checks")}`);
|
|
4442
4712
|
for (const check of rules.checks) {
|
|
4443
4713
|
push(`- ${check.id}: \`${check.argv.join(" ")}\`${check.matched ? "" : ` (${t("\u043D\u0435 \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0441\u044F \u043A diff", "does not match the diff")})`}${check.consent ? ` \xB7 ${t("\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u044F", "requires confirmation")}` : ""}`);
|
|
4444
4714
|
}
|
|
4715
|
+
const matchedChecks = rules.checks.filter((check) => check.matched);
|
|
4716
|
+
if (rules.checks.length && !matchedChecks.length) {
|
|
4717
|
+
push(t("> \u041D\u0438 \u043E\u0434\u043D\u0430 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 \u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C\u0430 \u043A \u044D\u0442\u043E\u043C\u0443 diff.", "> No check applies to this diff."));
|
|
4718
|
+
}
|
|
4719
|
+
if (!checkRuns.length) {
|
|
4720
|
+
if (matchedChecks.length) {
|
|
4721
|
+
push(t(
|
|
4722
|
+
"> \u0424\u0430\u043A\u0442\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043F\u0440\u043E\u0433\u043E\u043D\u043E\u0432 \u043D\u0435\u0442: \u0442\u0438\u043F\u044B \u0438 \u0442\u0435\u0441\u0442\u044B \u043D\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u044B. `coverage` \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u043E\u043F\u0438\u0440\u0430\u0442\u044C\u0441\u044F \u043D\u0430 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438, \u043F\u043E\u043A\u0430 \u0447\u0435\u043B\u043E\u0432\u0435\u043A \u043D\u0435 \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442 \u0438\u0445 \u0432 UI \u0438\u043B\u0438 \u0447\u0435\u0440\u0435\u0437 `revdeck checks --run --yes`.",
|
|
4723
|
+
"> No check runs yet: types and tests are not verified. `coverage` cannot rely on checks until a human runs them in the UI or via `revdeck checks --run --yes`."
|
|
4724
|
+
));
|
|
4725
|
+
}
|
|
4726
|
+
} else {
|
|
4727
|
+
const head = review.info.commit.head;
|
|
4728
|
+
push(t("\u041F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435 \u043F\u0440\u043E\u0433\u043E\u043D\u044B:", "Last check runs:"));
|
|
4729
|
+
let hasStale = false;
|
|
4730
|
+
for (const run2 of checkRuns) {
|
|
4731
|
+
const known = head !== "" && run2.commitSha !== "";
|
|
4732
|
+
const current2 = known && run2.commitSha === head;
|
|
4733
|
+
if (known && !current2) hasStale = true;
|
|
4734
|
+
const stamp = !known ? t("\u043A\u043E\u043C\u043C\u0438\u0442 \u043D\u0435 \u0437\u0430\u043F\u0438\u0441\u0430\u043D", "commit not recorded") : current2 ? t("\u0430\u043A\u0442\u0443\u0430\u043B\u044C\u043D\u044B\u0439 \u043A\u043E\u043C\u043C\u0438\u0442", "current commit") : `${t("\u043A\u043E\u043C\u043C\u0438\u0442", "commit")} ${run2.commitSha.slice(0, 12)} (${t("\u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0439", "stale")})`;
|
|
4735
|
+
const exit = run2.exitCode === null || run2.exitCode === void 0 ? "" : ` (exit ${run2.exitCode})`;
|
|
4736
|
+
push(`- ${run2.checkId}: ${run2.status}${exit} \xB7 ${when(run2.startedAt, language)} \xB7 ${stamp} \xB7 ${Math.round(run2.durationMs)}ms`);
|
|
4737
|
+
if (run2.status !== "passed" && run2.output) {
|
|
4738
|
+
push("```");
|
|
4739
|
+
push(headTailLines(run2.output, 12).join("\n"));
|
|
4740
|
+
push("```");
|
|
4741
|
+
}
|
|
4742
|
+
}
|
|
4743
|
+
if (hasStale) {
|
|
4744
|
+
push(t(
|
|
4745
|
+
"> \u041F\u0440\u043E\u0433\u043E\u043D \u043D\u0430 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u043C \u043A\u043E\u043C\u043C\u0438\u0442\u0435 \u043D\u0435 \u0434\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0435\u0442, \u0447\u0442\u043E \u0442\u0435\u043A\u0443\u0449\u0438\u0439 diff \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D: \u0435\u0433\u043E \u043D\u0443\u0436\u043D\u043E \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C.",
|
|
4746
|
+
"> A run on an older commit does not prove the current diff was checked: repeat it."
|
|
4747
|
+
));
|
|
4748
|
+
}
|
|
4749
|
+
}
|
|
4445
4750
|
push("");
|
|
4446
4751
|
}
|
|
4447
4752
|
push(`## ${t("\u041A\u0430\u043A \u0434\u0435\u0439\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C", "What to do next")}`);
|
|
@@ -4855,7 +5160,7 @@ var ReviewService = class {
|
|
|
4855
5160
|
const history = this.configOf(id)?.review?.history;
|
|
4856
5161
|
if (!history?.enabled) return;
|
|
4857
5162
|
const view = this.getReview(id);
|
|
4858
|
-
const diffHash =
|
|
5163
|
+
const diffHash = createHash3("sha256").update(canonicalJson(diff)).digest("hex");
|
|
4859
5164
|
this.store.addVersion(
|
|
4860
5165
|
id,
|
|
4861
5166
|
{ headSha: info.commit.head, baseSha: info.commit.base, diffHash, data: view },
|
|
@@ -5005,7 +5310,7 @@ var ReviewService = class {
|
|
|
5005
5310
|
...input.host ? { host: input.host } : {},
|
|
5006
5311
|
...input.branch ? { branch: input.branch } : {}
|
|
5007
5312
|
});
|
|
5008
|
-
const id = `preview-${
|
|
5313
|
+
const id = `preview-${createHash3("sha256").update(`${ref.platform}|${ref.host}|${ref.project}|${ref.number}`).digest("hex").slice(0, 16)}`;
|
|
5009
5314
|
const cached = this.previews.get(id);
|
|
5010
5315
|
if (!input.force && cached && this.now().getTime() - cached.at < 60 * 6e4) return cached.view;
|
|
5011
5316
|
const provider = await this.providerFactory(ref, root);
|
|
@@ -6315,7 +6620,7 @@ ${errors.join("\n")}`));
|
|
|
6315
6620
|
this.store.saveSnapshot(id, { ...stored.snapshot, threads });
|
|
6316
6621
|
}
|
|
6317
6622
|
// ---------------------------------------------------------------- rules & checks
|
|
6318
|
-
async rules(id) {
|
|
6623
|
+
async rules(id, shard) {
|
|
6319
6624
|
const stored = this.store.getReview(id);
|
|
6320
6625
|
if (!stored) throw new Error(tr(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E`, `review ${id} not found`));
|
|
6321
6626
|
const info = this.store.info(id);
|
|
@@ -6332,11 +6637,28 @@ ${errors.join("\n")}`));
|
|
|
6332
6637
|
configPath = loaded.path;
|
|
6333
6638
|
}
|
|
6334
6639
|
const language = resolveOutputLanguage(config.output?.language ?? "auto", texts);
|
|
6640
|
+
let files = changedPaths(stored.snapshot.diff);
|
|
6641
|
+
if (shard) {
|
|
6642
|
+
const sizes = diffFileSizes(stored.snapshot.diff);
|
|
6643
|
+
const maxShards = Math.max(1, Math.min(MAX_SHARDS, sizes.length));
|
|
6644
|
+
if (!Number.isInteger(shard.index) || !Number.isInteger(shard.count) || shard.count < 1 || shard.index < 1 || shard.index > shard.count) {
|
|
6645
|
+
throw new Error(tr("\u0448\u0430\u0440\u0434 \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C i/N, 1 \u2264 i \u2264 N", "shard must be i/N with 1 <= i <= N"));
|
|
6646
|
+
}
|
|
6647
|
+
if (shard.count > maxShards) {
|
|
6648
|
+
throw new Error(
|
|
6649
|
+
tr(
|
|
6650
|
+
`\u0448\u0430\u0440\u0434\u043E\u0432 \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u043D\u043E\u0433\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C ${maxShards} \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E diff`,
|
|
6651
|
+
`too many shards: at most ${maxShards} for this diff`
|
|
6652
|
+
)
|
|
6653
|
+
);
|
|
6654
|
+
}
|
|
6655
|
+
files = [...shardPaths(sizes, shard.index, shard.count)];
|
|
6656
|
+
}
|
|
6335
6657
|
const effective = await buildEffectiveRules({
|
|
6336
6658
|
root: stored.row.root,
|
|
6337
6659
|
config,
|
|
6338
6660
|
configPath,
|
|
6339
|
-
files
|
|
6661
|
+
files,
|
|
6340
6662
|
language
|
|
6341
6663
|
});
|
|
6342
6664
|
const maxBytes = config.rules.maxTotalBytes ?? 0;
|
|
@@ -6350,16 +6672,19 @@ ${errors.join("\n")}`));
|
|
|
6350
6672
|
language,
|
|
6351
6673
|
maxBytes,
|
|
6352
6674
|
agents,
|
|
6353
|
-
roles
|
|
6675
|
+
roles,
|
|
6676
|
+
runs: this.store.latestCheckRuns(id)
|
|
6354
6677
|
};
|
|
6355
6678
|
}
|
|
6356
6679
|
async runChecks(id, options) {
|
|
6357
6680
|
this.assertWritable(id);
|
|
6358
6681
|
const stored = this.store.getReview(id);
|
|
6359
6682
|
if (!stored) throw new Error(tr(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E`, `review ${id} not found`));
|
|
6683
|
+
const commitSha = await headSha(stored.row.root);
|
|
6360
6684
|
const { checks } = await this.rules(id);
|
|
6361
6685
|
const matched = checks.filter((check) => check.matched && (!options.ids?.length || options.ids.includes(check.id)));
|
|
6362
6686
|
const results = [];
|
|
6687
|
+
const artifacts = [];
|
|
6363
6688
|
for (const check of matched) {
|
|
6364
6689
|
if (!options.allowRun) {
|
|
6365
6690
|
results.push({
|
|
@@ -6368,10 +6693,12 @@ ${errors.join("\n")}`));
|
|
|
6368
6693
|
argv: check.argv,
|
|
6369
6694
|
status: "skipped",
|
|
6370
6695
|
output: tr("\u0437\u0430\u043F\u0443\u0441\u043A \u043D\u0435 \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0451\u043D: \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 revdeck checks --run --yes", "run not confirmed: use revdeck checks --run --yes"),
|
|
6371
|
-
durationMs: 0
|
|
6696
|
+
durationMs: 0,
|
|
6697
|
+
exitCode: null
|
|
6372
6698
|
});
|
|
6373
6699
|
continue;
|
|
6374
6700
|
}
|
|
6701
|
+
const startedAt = this.now().toISOString();
|
|
6375
6702
|
const started = Date.now();
|
|
6376
6703
|
try {
|
|
6377
6704
|
const { stdout, stderr, code } = await this.runImpl(check.argv[0], check.argv.slice(1), {
|
|
@@ -6379,35 +6706,174 @@ ${errors.join("\n")}`));
|
|
|
6379
6706
|
timeoutMs: stored.snapshot.config.checks?.find((item) => item.id === check.id)?.timeoutMs ?? 3e5,
|
|
6380
6707
|
maxBuffer: 16 * 1024 * 1024
|
|
6381
6708
|
});
|
|
6709
|
+
const output = redactClip(`${stdout}
|
|
6710
|
+
${stderr}`.trim());
|
|
6382
6711
|
results.push({
|
|
6383
6712
|
id: check.id,
|
|
6384
6713
|
name: check.name,
|
|
6385
6714
|
argv: check.argv,
|
|
6386
6715
|
status: code === 0 ? "passed" : "failed",
|
|
6387
|
-
output
|
|
6388
|
-
|
|
6716
|
+
output,
|
|
6717
|
+
durationMs: Date.now() - started,
|
|
6718
|
+
exitCode: code
|
|
6719
|
+
});
|
|
6720
|
+
artifacts.push({
|
|
6721
|
+
reviewId: id,
|
|
6722
|
+
checkId: check.id,
|
|
6723
|
+
name: check.name,
|
|
6724
|
+
argv: check.argv,
|
|
6725
|
+
status: code === 0 ? "passed" : "failed",
|
|
6726
|
+
exitCode: code,
|
|
6727
|
+
output,
|
|
6728
|
+
commitSha,
|
|
6729
|
+
startedAt,
|
|
6389
6730
|
durationMs: Date.now() - started
|
|
6390
6731
|
});
|
|
6391
6732
|
} catch (error) {
|
|
6733
|
+
const details = error;
|
|
6734
|
+
const spawnFailure = details.spawnFailure === true;
|
|
6735
|
+
const rawCode = details.rawCode;
|
|
6736
|
+
const exitCode = spawnFailure ? null : typeof details.code === "number" ? details.code : typeof rawCode === "number" ? rawCode : null;
|
|
6737
|
+
const status = exitCode === null ? "error" : "failed";
|
|
6738
|
+
const raw = spawnFailure ? messageOf(error) : `${typeof details.stdout === "string" ? details.stdout : ""}
|
|
6739
|
+
${typeof details.stderr === "string" ? details.stderr : ""}`;
|
|
6740
|
+
const output = redactClip(raw.trim());
|
|
6392
6741
|
results.push({
|
|
6393
6742
|
id: check.id,
|
|
6394
6743
|
name: check.name,
|
|
6395
6744
|
argv: check.argv,
|
|
6396
|
-
status
|
|
6397
|
-
output
|
|
6398
|
-
durationMs: Date.now() - started
|
|
6745
|
+
status,
|
|
6746
|
+
output,
|
|
6747
|
+
durationMs: Date.now() - started,
|
|
6748
|
+
exitCode
|
|
6399
6749
|
});
|
|
6750
|
+
if (exitCode !== null) {
|
|
6751
|
+
artifacts.push({
|
|
6752
|
+
reviewId: id,
|
|
6753
|
+
checkId: check.id,
|
|
6754
|
+
name: check.name,
|
|
6755
|
+
argv: check.argv,
|
|
6756
|
+
status,
|
|
6757
|
+
exitCode,
|
|
6758
|
+
output,
|
|
6759
|
+
commitSha,
|
|
6760
|
+
startedAt,
|
|
6761
|
+
durationMs: Date.now() - started
|
|
6762
|
+
});
|
|
6763
|
+
}
|
|
6400
6764
|
}
|
|
6401
6765
|
}
|
|
6766
|
+
if (artifacts.length) this.store.saveCheckRuns(id, artifacts);
|
|
6402
6767
|
this.store.audit(id, "checks.run", { count: results.length });
|
|
6403
6768
|
this.event(id, "human", "checks.run", {
|
|
6404
6769
|
count: results.length,
|
|
6405
6770
|
passed: results.filter((item) => item.status === "passed").length,
|
|
6406
6771
|
failed: results.filter((item) => item.status === "failed").length,
|
|
6407
|
-
errors: results.filter((item) => item.status === "error").length
|
|
6772
|
+
errors: results.filter((item) => item.status === "error").length,
|
|
6773
|
+
commitSha: commitSha || void 0
|
|
6408
6774
|
});
|
|
6409
6775
|
return results;
|
|
6410
6776
|
}
|
|
6777
|
+
/** Последние запуски по каждой проверке: доказательство для контекста и UI. */
|
|
6778
|
+
checkRuns(id) {
|
|
6779
|
+
const stored = this.store.getReview(id);
|
|
6780
|
+
if (!stored) throw new Error(tr(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E`, `review ${id} not found`));
|
|
6781
|
+
return this.store.latestCheckRuns(id);
|
|
6782
|
+
}
|
|
6783
|
+
/**
|
|
6784
|
+
* Переносимый паспорт ревью: правила с хэшами, фактически выполненные проверки,
|
|
6785
|
+
* замечания с решениями человека и таймлайн. Всё берётся из снимка и событий,
|
|
6786
|
+
* поэтому артефакт воспроизводим без доступа к платформе.
|
|
6787
|
+
*/
|
|
6788
|
+
async evidence(id) {
|
|
6789
|
+
const stored = this.store.getReview(id);
|
|
6790
|
+
if (!stored) throw new Error(tr(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E`, `review ${id} not found`));
|
|
6791
|
+
const info = this.store.info(id) ?? fallbackInfo(stored.row);
|
|
6792
|
+
const review = this.getReview(id);
|
|
6793
|
+
const config = stored.snapshot.config;
|
|
6794
|
+
const language = resolveOutputLanguage(config.output?.language ?? "auto", [info.title ?? "", info.description ?? ""]);
|
|
6795
|
+
const effective = await buildEffectiveRules({
|
|
6796
|
+
root: stored.row.root,
|
|
6797
|
+
config,
|
|
6798
|
+
configPath: stored.snapshot.configPath,
|
|
6799
|
+
files: changedPaths(stored.snapshot.diff),
|
|
6800
|
+
language
|
|
6801
|
+
});
|
|
6802
|
+
const documents = /* @__PURE__ */ new Map();
|
|
6803
|
+
for (const scope of effective.scopes) {
|
|
6804
|
+
for (const doc of scope.documents) {
|
|
6805
|
+
const key = `${doc.path}#${doc.sections.join(",")}`;
|
|
6806
|
+
if (documents.has(key)) continue;
|
|
6807
|
+
documents.set(key, {
|
|
6808
|
+
path: doc.path,
|
|
6809
|
+
sections: doc.sections,
|
|
6810
|
+
bytes: Buffer.byteLength(doc.excerpt, "utf8"),
|
|
6811
|
+
hash: documentHash(doc.excerpt),
|
|
6812
|
+
truncated: doc.truncated
|
|
6813
|
+
});
|
|
6814
|
+
}
|
|
6815
|
+
}
|
|
6816
|
+
const decisionOf = (finding) => review.decisions[finding.id]?.decision ?? finding.decision;
|
|
6817
|
+
const accepted = review.findings.filter((finding) => decisionOf(finding) === "accept").length;
|
|
6818
|
+
const rejected = review.findings.filter((finding) => decisionOf(finding) === "reject").length;
|
|
6819
|
+
const discussed = review.findings.filter((finding) => decisionOf(finding) === "discuss").length;
|
|
6820
|
+
return {
|
|
6821
|
+
version: 1,
|
|
6822
|
+
generatedAt: this.now().toISOString(),
|
|
6823
|
+
review: {
|
|
6824
|
+
id,
|
|
6825
|
+
platform: info.ref.platform,
|
|
6826
|
+
host: info.ref.host,
|
|
6827
|
+
project: info.ref.project,
|
|
6828
|
+
number: info.ref.number,
|
|
6829
|
+
title: info.title,
|
|
6830
|
+
author: info.author,
|
|
6831
|
+
state: info.state,
|
|
6832
|
+
webUrl: info.webUrl,
|
|
6833
|
+
sourceBranch: info.sourceBranch,
|
|
6834
|
+
targetBranch: info.targetBranch,
|
|
6835
|
+
baseSha: info.commit.base,
|
|
6836
|
+
headSha: info.commit.head,
|
|
6837
|
+
mergeState: info.merge?.state ?? "",
|
|
6838
|
+
syncedAt: review.syncedAt
|
|
6839
|
+
},
|
|
6840
|
+
summary: review.summary,
|
|
6841
|
+
rules: { configPath: effective.configPath, documents: [...documents.values()], warnings: effective.warnings },
|
|
6842
|
+
checks: { planned: effective.checks, runs: this.store.latestCheckRuns(id) },
|
|
6843
|
+
findings: review.findings.map((finding) => ({
|
|
6844
|
+
id: finding.id,
|
|
6845
|
+
level: finding.level,
|
|
6846
|
+
file: finding.file,
|
|
6847
|
+
line: finding.line,
|
|
6848
|
+
title: finding.title,
|
|
6849
|
+
rule: finding.rule ?? "",
|
|
6850
|
+
status: finding.status,
|
|
6851
|
+
decision: decisionOf(finding) ?? "",
|
|
6852
|
+
note: review.decisions[finding.id]?.note ?? finding.note ?? ""
|
|
6853
|
+
})),
|
|
6854
|
+
decisions: { accepted, rejected, discussed, pending: review.findings.length - accepted - rejected - discussed },
|
|
6855
|
+
publish: {
|
|
6856
|
+
findings: review.findings.filter((finding) => finding.status === "published").length,
|
|
6857
|
+
notes: review.notes.filter((note) => note.posted.trim() !== "").length,
|
|
6858
|
+
replies: review.drafts.filter((draft) => draft.replied).length
|
|
6859
|
+
},
|
|
6860
|
+
timeline: this.store.recentEvents(id, 200).map((event) => ({ at: event.at, actor: event.actor, type: event.type })),
|
|
6861
|
+
limitations: [
|
|
6862
|
+
tr(
|
|
6863
|
+
"\u041C\u043E\u0434\u0435\u043B\u044C, \u0445\u0430\u0440\u043D\u0435\u0441\u0441 \u0438 \u0432\u0435\u0440\u0441\u0438\u044F \u0441\u043A\u0438\u043B\u043B\u0430 \u0430\u0433\u0435\u043D\u0442\u0430 \u0432 v1 \u043D\u0435 \u0444\u0438\u043A\u0441\u0438\u0440\u0443\u044E\u0442\u0441\u044F: \u0441\u043E\u0431\u044B\u0442\u0438\u044F \u0445\u0440\u0430\u043D\u044F\u0442 \u0442\u043E\u043B\u044C\u043A\u043E \u0430\u043A\u0442\u043E\u0440\u0430 (`human`/`agent`/`system`).",
|
|
6864
|
+
"The agent model, harness and skill version are not recorded in v1: events store only the actor (`human`/`agent`/`system`)."
|
|
6865
|
+
),
|
|
6866
|
+
tr(
|
|
6867
|
+
"\u0425\u044D\u0448 \u043F\u0440\u0430\u0432\u0438\u043B \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u0432\u044B\u0434\u0435\u0440\u0436\u043A\u0443 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430, \u0430 \u043D\u0435 \u0432\u0435\u0441\u044C \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0439; \u043F\u0435\u0440\u0435\u0433\u0435\u043D\u0435\u0440\u0438\u0440\u0443\u0439\u0442\u0435 \u043F\u0430\u0441\u043F\u043E\u0440\u0442 \u043F\u043E\u0441\u043B\u0435 \u043D\u043E\u0432\u044B\u0445 \u043A\u043E\u043C\u043C\u0438\u0442\u043E\u0432.",
|
|
6868
|
+
"The rule hash covers the document excerpt, not the whole repository; regenerate the evidence after new commits."
|
|
6869
|
+
),
|
|
6870
|
+
tr(
|
|
6871
|
+
"\u0422\u0430\u0439\u043C\u043B\u0430\u0439\u043D \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0435\u043D \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u043C\u0438 200 \u0441\u043E\u0431\u044B\u0442\u0438\u044F\u043C\u0438, \u0432\u044B\u0432\u043E\u0434 \u043F\u0440\u043E\u0432\u0435\u0440\u043E\u043A \u2014 20 000 \u0441\u0438\u043C\u0432\u043E\u043B\u0430\u043C\u0438 (\u0433\u043E\u043B\u043E\u0432\u0430 \u0438 \u0445\u0432\u043E\u0441\u0442).",
|
|
6872
|
+
"The timeline is limited to the last 200 events and check output to 20,000 characters (head and tail)."
|
|
6873
|
+
)
|
|
6874
|
+
]
|
|
6875
|
+
};
|
|
6876
|
+
}
|
|
6411
6877
|
// ---------------------------------------------------------------- sync
|
|
6412
6878
|
startSync() {
|
|
6413
6879
|
if (this.timer || this.syncIntervalMs <= 0) return;
|
|
@@ -6494,7 +6960,7 @@ ${stderr}`.trim()).slice(0, 2e4),
|
|
|
6494
6960
|
}
|
|
6495
6961
|
};
|
|
6496
6962
|
function canonicalHash(reviewId2, kind, items) {
|
|
6497
|
-
return
|
|
6963
|
+
return createHash3("sha256").update(canonicalJson({ reviewId: reviewId2, kind, items })).digest("hex");
|
|
6498
6964
|
}
|
|
6499
6965
|
function fallbackInfo(row) {
|
|
6500
6966
|
return {
|
|
@@ -6724,6 +7190,7 @@ var AGENT_METHODS = /* @__PURE__ */ new Set([
|
|
|
6724
7190
|
"notes.delete",
|
|
6725
7191
|
"messages.list",
|
|
6726
7192
|
"messages.add",
|
|
7193
|
+
"checks.list",
|
|
6727
7194
|
"publish.preview"
|
|
6728
7195
|
]);
|
|
6729
7196
|
var AGENT_POLICY = {
|
|
@@ -6758,6 +7225,13 @@ function assertAgentFeatureNote(service, featureId, noteId, policy) {
|
|
|
6758
7225
|
);
|
|
6759
7226
|
}
|
|
6760
7227
|
}
|
|
7228
|
+
function parseShard(value) {
|
|
7229
|
+
if (value === void 0 || value === null) return void 0;
|
|
7230
|
+
if (typeof value !== "object") throw new Error("shard must be an object with index and count");
|
|
7231
|
+
const item = value;
|
|
7232
|
+
if (!Number.isInteger(item.index) || !Number.isInteger(item.count)) throw new Error("shard must be integers i/N");
|
|
7233
|
+
return { index: item.index, count: item.count };
|
|
7234
|
+
}
|
|
6761
7235
|
async function dispatch(service, method, params, policy = HUMAN_POLICY) {
|
|
6762
7236
|
if (!policy.allows(method)) {
|
|
6763
7237
|
throw new MrReviewError(
|
|
@@ -7044,7 +7518,11 @@ async function dispatch(service, method, params, policy = HUMAN_POLICY) {
|
|
|
7044
7518
|
case "publish.commit":
|
|
7045
7519
|
return { result: await service.publish(String(params.review ?? ""), String(params.approvalId ?? "")) };
|
|
7046
7520
|
case "rules.get":
|
|
7047
|
-
return { rules: await service.rules(String(params.review ?? "")) };
|
|
7521
|
+
return { rules: await service.rules(String(params.review ?? ""), parseShard(params.shard)) };
|
|
7522
|
+
case "checks.list":
|
|
7523
|
+
return { runs: service.checkRuns(String(params.review ?? "")) };
|
|
7524
|
+
case "evidence.get":
|
|
7525
|
+
return { evidence: await service.evidence(String(params.review ?? "")) };
|
|
7048
7526
|
case "checks.run":
|
|
7049
7527
|
return {
|
|
7050
7528
|
results: await service.runChecks(String(params.review ?? ""), {
|
|
@@ -7835,6 +8313,8 @@ data: ${JSON.stringify(event)}
|
|
|
7835
8313
|
reply(res, status, { ok: false, error: redact(messageOf(error)) });
|
|
7836
8314
|
}
|
|
7837
8315
|
});
|
|
8316
|
+
server.keepAliveTimeout = 65e3;
|
|
8317
|
+
server.headersTimeout = 66e3;
|
|
7838
8318
|
await new Promise((resolve, reject) => {
|
|
7839
8319
|
server.once("error", reject);
|
|
7840
8320
|
server.listen(options.port ?? 0, host, () => resolve());
|