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/mcp.js
CHANGED
|
@@ -10,12 +10,15 @@ var __esm = (fn, res, err) => function __init() {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/core/redact.ts
|
|
13
|
-
function
|
|
13
|
+
function sanitize(value) {
|
|
14
14
|
let text = String(value ?? "").replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, " ");
|
|
15
15
|
for (const [pattern, replacement] of TOKEN_PATTERNS) {
|
|
16
16
|
text = text.replace(pattern, replacement);
|
|
17
17
|
}
|
|
18
|
-
return text
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
function redact(value) {
|
|
21
|
+
return sanitize(value).slice(0, 4e3);
|
|
19
22
|
}
|
|
20
23
|
var TOKEN_PATTERNS;
|
|
21
24
|
var init_redact = __esm({
|
|
@@ -180,11 +183,23 @@ var init_exec = __esm({
|
|
|
180
183
|
shell: false
|
|
181
184
|
},
|
|
182
185
|
(error, stdout, stderr) => {
|
|
183
|
-
const
|
|
184
|
-
const
|
|
186
|
+
const rawCode = error?.code;
|
|
187
|
+
const signal = error?.signal;
|
|
188
|
+
const spawnFailure = Boolean(error) && typeof rawCode !== "number";
|
|
189
|
+
const code = typeof rawCode === "number" ? rawCode : error ? 1 : 0;
|
|
185
190
|
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
186
191
|
const reason = (stderr || stdout || error.message).trim();
|
|
187
|
-
reject(
|
|
192
|
+
reject(
|
|
193
|
+
Object.assign(new Error(reason.slice(0, 4e3)), {
|
|
194
|
+
command,
|
|
195
|
+
code,
|
|
196
|
+
rawCode,
|
|
197
|
+
signal,
|
|
198
|
+
spawnFailure,
|
|
199
|
+
stderr,
|
|
200
|
+
stdout
|
|
201
|
+
})
|
|
202
|
+
);
|
|
188
203
|
return;
|
|
189
204
|
}
|
|
190
205
|
resolve({ stdout, stderr, code });
|
|
@@ -291,7 +306,7 @@ async function readTextNoFollow(file, maxBytes = 4 * 1024 * 1024) {
|
|
|
291
306
|
}
|
|
292
307
|
|
|
293
308
|
// src/version.ts
|
|
294
|
-
var VERSION = "0.
|
|
309
|
+
var VERSION = "0.19.1";
|
|
295
310
|
|
|
296
311
|
// src/client.ts
|
|
297
312
|
var RpcError = class extends Error {
|
|
@@ -565,7 +580,8 @@ var REVIEW_ROLE_IDS = [
|
|
|
565
580
|
"observability",
|
|
566
581
|
"build",
|
|
567
582
|
"privacy",
|
|
568
|
-
"general"
|
|
583
|
+
"general",
|
|
584
|
+
"verifier"
|
|
569
585
|
];
|
|
570
586
|
var DEFAULT_REVIEW_ROLES = ["correctness", "architecture", "tests"];
|
|
571
587
|
var REVIEW_ROLES = {
|
|
@@ -644,6 +660,18 @@ var REVIEW_ROLES = {
|
|
|
644
660
|
title: { ru: "\u041F\u0440\u0438\u0432\u0430\u0442\u043D\u043E\u0441\u0442\u044C", en: "Privacy" },
|
|
645
661
|
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" }
|
|
646
662
|
},
|
|
663
|
+
verifier: {
|
|
664
|
+
criteria: ["7", "12"],
|
|
665
|
+
title: { ru: "\u0412\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440", en: "Verifier" },
|
|
666
|
+
focus: {
|
|
667
|
+
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",
|
|
668
|
+
en: "confirm or refute every candidate against the line and the rule"
|
|
669
|
+
},
|
|
670
|
+
instructions: {
|
|
671
|
+
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.",
|
|
672
|
+
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."
|
|
673
|
+
}
|
|
674
|
+
},
|
|
647
675
|
general: {
|
|
648
676
|
criteria: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
|
|
649
677
|
title: { ru: "\u041E\u0431\u0449\u0435\u0435 \u0440\u0435\u0432\u044C\u044E", en: "General review" },
|
|
@@ -662,7 +690,7 @@ function resolveReviewRole(id, language, custom = {}) {
|
|
|
662
690
|
title: role2.title[language],
|
|
663
691
|
description: role2.focus[language],
|
|
664
692
|
criteria: role2.criteria,
|
|
665
|
-
instructions: ""
|
|
693
|
+
instructions: role2.instructions?.[language] ?? ""
|
|
666
694
|
};
|
|
667
695
|
}
|
|
668
696
|
const role = custom[id];
|
|
@@ -679,6 +707,122 @@ function roleCriteriaText(role) {
|
|
|
679
707
|
return role.criteria.length ? `\xA7${role.criteria.join(", \xA7")}` : "";
|
|
680
708
|
}
|
|
681
709
|
|
|
710
|
+
// src/core/risk.ts
|
|
711
|
+
var SENSITIVE_PATHS = [
|
|
712
|
+
{ pattern: /(^|\/)(migrations?|database|db|schema)(\/|\.|$)/i, reason: "database-or-migration" },
|
|
713
|
+
{ pattern: /(^|\/)(auth|security|crypto|permissions?|payments?|billing)(\/|\.|$)/i, reason: "security-sensitive" },
|
|
714
|
+
{ pattern: /(^|\/)\.github\/workflows\//i, reason: "ci-workflow" },
|
|
715
|
+
{ pattern: /(^|\/)\.(gitlab-ci|circleci|buildkite)(\/|\.|$)/i, reason: "ci-workflow" },
|
|
716
|
+
{ pattern: /(^|\/)(Jenkinsfile|azure-pipelines[^/]*|bitbucket-pipelines[^/]*)$/i, reason: "ci-workflow" },
|
|
717
|
+
{ pattern: /(^|\/)(Dockerfile|docker-compose[^/]*)$/i, reason: "container" },
|
|
718
|
+
{ 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" },
|
|
719
|
+
{ pattern: /(^|\/)(openapi|swagger|proto)(\/|\.|$)/i, reason: "public-contract" }
|
|
720
|
+
];
|
|
721
|
+
function isSensitivePath(path5) {
|
|
722
|
+
return SENSITIVE_PATHS.some((item) => item.pattern.test(path5));
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// src/core/shard.ts
|
|
726
|
+
var MAX_SHARDS = 32;
|
|
727
|
+
function compareKeys(left, right) {
|
|
728
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
729
|
+
}
|
|
730
|
+
var TEST_DIR = /(^|\/)(tests?|__tests__|specs?)(\/|$)/i;
|
|
731
|
+
var TEST_NAME = /(\.(test|spec)\.[^./]+|_test\.[^./]+)$/i;
|
|
732
|
+
function stem(path5) {
|
|
733
|
+
const base = path5.slice(path5.lastIndexOf("/") + 1);
|
|
734
|
+
return base.replace(TEST_NAME, "").replace(/\.[^.]*$/, "");
|
|
735
|
+
}
|
|
736
|
+
function isTestPath(path5) {
|
|
737
|
+
return TEST_NAME.test(path5) || TEST_DIR.test(path5.slice(0, path5.lastIndexOf("/") + 1));
|
|
738
|
+
}
|
|
739
|
+
function directoryOf(path5) {
|
|
740
|
+
const index = path5.lastIndexOf("/");
|
|
741
|
+
return index <= 0 ? "." : path5.slice(0, index);
|
|
742
|
+
}
|
|
743
|
+
function cohesionGroups(files) {
|
|
744
|
+
const groups = /* @__PURE__ */ new Map();
|
|
745
|
+
const add = (key, file) => {
|
|
746
|
+
const group = groups.get(key) ?? { key, files: [], size: 0, sensitive: false };
|
|
747
|
+
group.files.push(file);
|
|
748
|
+
group.size += file.additions + file.deletions;
|
|
749
|
+
group.sensitive = group.sensitive || isSensitivePath(file.path);
|
|
750
|
+
groups.set(key, group);
|
|
751
|
+
};
|
|
752
|
+
const sources = files.filter((file) => !isTestPath(file.path));
|
|
753
|
+
const byStem = /* @__PURE__ */ new Map();
|
|
754
|
+
for (const file of sources) {
|
|
755
|
+
const key = directoryOf(file.path);
|
|
756
|
+
const set = byStem.get(stem(file.path)) ?? /* @__PURE__ */ new Set();
|
|
757
|
+
set.add(key);
|
|
758
|
+
byStem.set(stem(file.path), set);
|
|
759
|
+
}
|
|
760
|
+
for (const file of files) {
|
|
761
|
+
if (isTestPath(file.path)) {
|
|
762
|
+
const candidates = byStem.get(stem(file.path));
|
|
763
|
+
if (candidates?.size === 1) {
|
|
764
|
+
add([...candidates][0], file);
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
add(directoryOf(file.path), file);
|
|
769
|
+
}
|
|
770
|
+
return [...groups.values()];
|
|
771
|
+
}
|
|
772
|
+
function splitLargeGroups(groups, target) {
|
|
773
|
+
const result = [...groups];
|
|
774
|
+
while (result.length < target) {
|
|
775
|
+
const candidates = result.filter((group2) => group2.files.length > 1);
|
|
776
|
+
candidates.sort((left, right) => right.files.length - left.files.length || right.size - left.size || compareKeys(left.key, right.key));
|
|
777
|
+
const group = candidates[0];
|
|
778
|
+
if (!group) break;
|
|
779
|
+
const pieces = group.files.map((file) => ({
|
|
780
|
+
key: `${group.key}#${file.path}`,
|
|
781
|
+
files: [file],
|
|
782
|
+
size: file.additions + file.deletions,
|
|
783
|
+
sensitive: isSensitivePath(file.path)
|
|
784
|
+
}));
|
|
785
|
+
result.splice(result.indexOf(group), 1, ...pieces);
|
|
786
|
+
}
|
|
787
|
+
return result;
|
|
788
|
+
}
|
|
789
|
+
function partitionShards(files, count) {
|
|
790
|
+
const requested = Number.isFinite(count) ? Math.trunc(count) : 1;
|
|
791
|
+
const size = Math.max(1, Math.min(requested, MAX_SHARDS, Math.max(1, files.length)));
|
|
792
|
+
const buckets = Array.from({ length: size }, () => []);
|
|
793
|
+
if (buckets.length === 1) return [files];
|
|
794
|
+
let groups = cohesionGroups(files);
|
|
795
|
+
if (groups.length < buckets.length) groups = splitLargeGroups(groups, buckets.length);
|
|
796
|
+
groups.sort(
|
|
797
|
+
(left, right) => Number(right.sensitive) - Number(left.sensitive) || right.size - left.size || compareKeys(left.key, right.key)
|
|
798
|
+
);
|
|
799
|
+
const loads = buckets.map(() => 0);
|
|
800
|
+
for (const group of groups) {
|
|
801
|
+
let target = 0;
|
|
802
|
+
for (let index = 1; index < buckets.length; index++) {
|
|
803
|
+
if (loads[index] < loads[target]) target = index;
|
|
804
|
+
}
|
|
805
|
+
buckets[target].push(...group.files);
|
|
806
|
+
loads[target] += group.size;
|
|
807
|
+
}
|
|
808
|
+
const order = new Map(files.map((file, index) => [file.path, index]));
|
|
809
|
+
for (const bucket of buckets) bucket.sort((left, right) => order.get(left.path) - order.get(right.path));
|
|
810
|
+
return buckets;
|
|
811
|
+
}
|
|
812
|
+
function shardPaths(files, index, count) {
|
|
813
|
+
const bucket = partitionShards(files, count)[Math.max(0, Math.trunc(index) - 1)] ?? [];
|
|
814
|
+
return new Set(bucket.map((file) => file.path));
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// src/core/clip.ts
|
|
818
|
+
function headTailLines(text, limit = 12) {
|
|
819
|
+
const lines = String(text ?? "").split("\n");
|
|
820
|
+
if (lines.length <= limit) return lines;
|
|
821
|
+
const head = Math.max(1, Math.ceil(limit / 3));
|
|
822
|
+
const tail = Math.max(1, limit - head - 1);
|
|
823
|
+
return [...lines.slice(0, head), "\u2026", ...lines.slice(-tail)];
|
|
824
|
+
}
|
|
825
|
+
|
|
682
826
|
// src/core/scenario.ts
|
|
683
827
|
function isOwnReview(review) {
|
|
684
828
|
const username = review.user?.username;
|
|
@@ -699,11 +843,13 @@ function renderContext(review, rules, options = {}) {
|
|
|
699
843
|
const agents = Math.max(1, options.agents ?? rules.agents ?? 1);
|
|
700
844
|
const planRoles = options.roles ?? rules.roles ?? effectiveRoleIds(agents, DEFAULT_REVIEW_ROLES);
|
|
701
845
|
const roles = Array.isArray(planRoles) && planRoles.length && typeof planRoles[0] === "object" ? planRoles : effectiveRoleIds(agents, planRoles).map((id) => resolveReviewRole(id, language)).filter((role) => Boolean(role));
|
|
702
|
-
const selectedRole = options.role ? roles.find((role) => role.id === options.role) : void 0;
|
|
846
|
+
const selectedRole = options.role ? roles.find((role) => role.id === options.role) ?? resolveReviewRole(options.role, language) ?? void 0 : void 0;
|
|
703
847
|
if (options.role && !selectedRole) throw new Error(`unknown review role: ${options.role}`);
|
|
704
848
|
const shardCount = options.shard?.count ?? 1;
|
|
705
849
|
const shardIndex = options.shard?.index ?? 1;
|
|
706
|
-
const
|
|
850
|
+
const shardSet = shardCount > 1 ? shardPaths(review.files, shardIndex, shardCount) : null;
|
|
851
|
+
const visibleFiles = shardSet ? review.files.filter((file) => shardSet.has(file.path)) : review.files;
|
|
852
|
+
const otherFiles = shardSet ? review.files.filter((file) => !shardSet.has(file.path)) : [];
|
|
707
853
|
const visiblePaths = new Set(visibleFiles.map((file) => file.path));
|
|
708
854
|
const visibleThreads = shardCount > 1 ? review.threads.filter((thread) => !thread.path || visiblePaths.has(thread.path)) : review.threads;
|
|
709
855
|
const visibleNotes = shardCount > 1 ? review.notes.filter((note) => visiblePaths.has(note.file)) : review.notes;
|
|
@@ -841,14 +987,24 @@ function renderContext(review, rules, options = {}) {
|
|
|
841
987
|
}
|
|
842
988
|
if (options.role || shardCount > 1) {
|
|
843
989
|
push(t(
|
|
844
|
-
"\u042D\u0442\u043E \u043D\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u044B\u0439 \
|
|
845
|
-
"This is an independent
|
|
990
|
+
"\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.",
|
|
991
|
+
"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."
|
|
846
992
|
));
|
|
993
|
+
if (shardCount > 1) {
|
|
994
|
+
push(t(
|
|
995
|
+
"\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.",
|
|
996
|
+
"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."
|
|
997
|
+
));
|
|
998
|
+
}
|
|
847
999
|
} else {
|
|
848
1000
|
push(t(
|
|
849
1001
|
"\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.",
|
|
850
1002
|
"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."
|
|
851
1003
|
));
|
|
1004
|
+
push(t(
|
|
1005
|
+
"\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.",
|
|
1006
|
+
"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."
|
|
1007
|
+
));
|
|
852
1008
|
}
|
|
853
1009
|
push("");
|
|
854
1010
|
}
|
|
@@ -893,6 +1049,20 @@ function renderContext(review, rules, options = {}) {
|
|
|
893
1049
|
for (const file of visibleFiles) {
|
|
894
1050
|
push(`- ${file.path} (${file.status}, +${file.additions} \u2212${file.deletions})${file.binary ? " [binary]" : ""}`);
|
|
895
1051
|
}
|
|
1052
|
+
if (shardCount > 1) {
|
|
1053
|
+
if (!visibleFiles.length) {
|
|
1054
|
+
push(t(
|
|
1055
|
+
`> \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.`,
|
|
1056
|
+
`> Shard ${shardIndex}/${shardCount} has no files: reduce the shard count or check the seams as the lead.`
|
|
1057
|
+
));
|
|
1058
|
+
}
|
|
1059
|
+
if (otherFiles.length) {
|
|
1060
|
+
const shown = otherFiles.slice(0, 40).map((file) => `\`${file.path}\``);
|
|
1061
|
+
const rest = otherFiles.length > shown.length ? ` ${t(`\u0438 \u0435\u0449\u0451 ${otherFiles.length - shown.length}`, `and ${otherFiles.length - shown.length} more`)}` : "";
|
|
1062
|
+
push("");
|
|
1063
|
+
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}`);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
896
1066
|
push("");
|
|
897
1067
|
if (review.groups?.length) {
|
|
898
1068
|
push(`## ${t("\u0413\u0440\u0443\u043F\u043F\u044B \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439", "Change groups")}`);
|
|
@@ -943,11 +1113,47 @@ function renderContext(review, rules, options = {}) {
|
|
|
943
1113
|
}
|
|
944
1114
|
push("");
|
|
945
1115
|
}
|
|
946
|
-
|
|
1116
|
+
const checkRuns = rules.runs ?? [];
|
|
1117
|
+
if (rules.checks.length || checkRuns.length) {
|
|
947
1118
|
push(`## ${t("\u041F\u0440\u043E\u0432\u0435\u0440\u043A\u0438", "Checks")}`);
|
|
948
1119
|
for (const check of rules.checks) {
|
|
949
1120
|
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")}` : ""}`);
|
|
950
1121
|
}
|
|
1122
|
+
const matchedChecks = rules.checks.filter((check) => check.matched);
|
|
1123
|
+
if (rules.checks.length && !matchedChecks.length) {
|
|
1124
|
+
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."));
|
|
1125
|
+
}
|
|
1126
|
+
if (!checkRuns.length) {
|
|
1127
|
+
if (matchedChecks.length) {
|
|
1128
|
+
push(t(
|
|
1129
|
+
"> \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`.",
|
|
1130
|
+
"> 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`."
|
|
1131
|
+
));
|
|
1132
|
+
}
|
|
1133
|
+
} else {
|
|
1134
|
+
const head = review.info.commit.head;
|
|
1135
|
+
push(t("\u041F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435 \u043F\u0440\u043E\u0433\u043E\u043D\u044B:", "Last check runs:"));
|
|
1136
|
+
let hasStale = false;
|
|
1137
|
+
for (const run2 of checkRuns) {
|
|
1138
|
+
const known = head !== "" && run2.commitSha !== "";
|
|
1139
|
+
const current2 = known && run2.commitSha === head;
|
|
1140
|
+
if (known && !current2) hasStale = true;
|
|
1141
|
+
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")})`;
|
|
1142
|
+
const exit = run2.exitCode === null || run2.exitCode === void 0 ? "" : ` (exit ${run2.exitCode})`;
|
|
1143
|
+
push(`- ${run2.checkId}: ${run2.status}${exit} \xB7 ${when(run2.startedAt, language)} \xB7 ${stamp} \xB7 ${Math.round(run2.durationMs)}ms`);
|
|
1144
|
+
if (run2.status !== "passed" && run2.output) {
|
|
1145
|
+
push("```");
|
|
1146
|
+
push(headTailLines(run2.output, 12).join("\n"));
|
|
1147
|
+
push("```");
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
if (hasStale) {
|
|
1151
|
+
push(t(
|
|
1152
|
+
"> \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.",
|
|
1153
|
+
"> A run on an older commit does not prove the current diff was checked: repeat it."
|
|
1154
|
+
));
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
951
1157
|
push("");
|
|
952
1158
|
}
|
|
953
1159
|
push(`## ${t("\u041A\u0430\u043A \u0434\u0435\u0439\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C", "What to do next")}`);
|
|
@@ -980,18 +1186,24 @@ function renderContext(review, rules, options = {}) {
|
|
|
980
1186
|
|
|
981
1187
|
[${t("\u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u043E\u0431\u0440\u0435\u0437\u0430\u043D", "context truncated")}: ${text.length} > ${limit} ${t("\u0431\u0430\u0439\u0442", "bytes")}]` : text;
|
|
982
1188
|
}
|
|
983
|
-
function contextPayload(review, rules, scenario) {
|
|
1189
|
+
function contextPayload(review, rules, scenario, options = {}) {
|
|
1190
|
+
const shard = options.shard && options.shard.count > 1 ? options.shard : null;
|
|
1191
|
+
const shardSet = shard ? shardPaths(review.files, shard.index, shard.count) : null;
|
|
1192
|
+
const files = shardSet ? review.files.filter((file) => shardSet.has(file.path)) : review.files;
|
|
1193
|
+
const visiblePaths = new Set(files.map((file) => file.path));
|
|
1194
|
+
const threads = shardSet ? review.threads.filter((thread) => !thread.path || visiblePaths.has(thread.path)) : review.threads;
|
|
1195
|
+
const notes = shardSet ? review.notes.filter((note) => visiblePaths.has(note.file)) : review.notes;
|
|
984
1196
|
return {
|
|
985
1197
|
review: {
|
|
986
1198
|
id: review.id,
|
|
987
1199
|
info: review.info,
|
|
988
1200
|
stats: review.stats,
|
|
989
|
-
files
|
|
1201
|
+
files,
|
|
990
1202
|
summary: review.summary,
|
|
991
|
-
threads
|
|
1203
|
+
threads,
|
|
992
1204
|
findings: review.findings,
|
|
993
1205
|
drafts: review.drafts,
|
|
994
|
-
notes
|
|
1206
|
+
notes,
|
|
995
1207
|
agentMessages: review.agentMessages ?? [],
|
|
996
1208
|
errors: review.errors,
|
|
997
1209
|
stale: review.stale,
|
|
@@ -1760,7 +1972,6 @@ server.registerTool(
|
|
|
1760
1972
|
try {
|
|
1761
1973
|
await scopedReview(review);
|
|
1762
1974
|
const { review: view } = await call("reviews.get", { review, refresh: refresh === true });
|
|
1763
|
-
const { rules } = await call("rules.get", { review });
|
|
1764
1975
|
const parsedShard = shard ? (() => {
|
|
1765
1976
|
const [index, count] = shard.split("/").map(Number);
|
|
1766
1977
|
if (!Number.isInteger(index) || !Number.isInteger(count) || index < 1 || count < 1 || index > count) {
|
|
@@ -1768,6 +1979,10 @@ server.registerTool(
|
|
|
1768
1979
|
}
|
|
1769
1980
|
return { index, count };
|
|
1770
1981
|
})() : void 0;
|
|
1982
|
+
const { rules } = await call("rules.get", {
|
|
1983
|
+
review,
|
|
1984
|
+
...parsedShard ? { shard: parsedShard } : {}
|
|
1985
|
+
});
|
|
1771
1986
|
let text = renderContext(view, rules, {
|
|
1772
1987
|
maxBytes: max_bytes ?? rules.maxBytes ?? 2e5,
|
|
1773
1988
|
language: rules.language,
|
|
@@ -1796,7 +2011,7 @@ server.registerTool(
|
|
|
1796
2011
|
text += "```";
|
|
1797
2012
|
}
|
|
1798
2013
|
}
|
|
1799
|
-
return ok(text, contextPayload(view, rules, scenario));
|
|
2014
|
+
return ok(text, contextPayload(view, rules, scenario, parsedShard ? { shard: parsedShard } : {}));
|
|
1800
2015
|
} catch (error) {
|
|
1801
2016
|
return failure(error);
|
|
1802
2017
|
}
|
|
@@ -2030,6 +2245,49 @@ server.registerTool(
|
|
|
2030
2245
|
}
|
|
2031
2246
|
}
|
|
2032
2247
|
);
|
|
2248
|
+
server.registerTool(
|
|
2249
|
+
"revdeck_checks",
|
|
2250
|
+
{
|
|
2251
|
+
title: "Checks and last runs",
|
|
2252
|
+
description: "Configured project checks and the last recorded run of each: status, exit code, commit and output tail. Read-only evidence for `coverage`. Running checks stays human-only (`revdeck checks --run --yes` or the UI); this tool cannot run them.",
|
|
2253
|
+
inputSchema: { review: reviewSchema }
|
|
2254
|
+
},
|
|
2255
|
+
async ({ review }) => {
|
|
2256
|
+
try {
|
|
2257
|
+
await scopedReview(review);
|
|
2258
|
+
const { rules } = await call("rules.get", { review });
|
|
2259
|
+
const { review: view } = await call("reviews.get", { review });
|
|
2260
|
+
const runs = rules.runs ?? [];
|
|
2261
|
+
const head = view.info.commit.head;
|
|
2262
|
+
const lines = [];
|
|
2263
|
+
if (rules.checks.length) {
|
|
2264
|
+
lines.push("Configured checks:");
|
|
2265
|
+
for (const check of rules.checks) {
|
|
2266
|
+
lines.push(`- ${check.id}: \`${check.argv.join(" ")}\`${check.matched ? "" : " (does not match the diff)"}${check.consent ? " \xB7 requires confirmation" : ""}`);
|
|
2267
|
+
}
|
|
2268
|
+
} else {
|
|
2269
|
+
lines.push("No checks are configured in .revdeck.yml.");
|
|
2270
|
+
}
|
|
2271
|
+
lines.push("");
|
|
2272
|
+
if (!runs.length) {
|
|
2273
|
+
lines.push("No runs recorded: types and tests are not verified. A human must run the checks; then repeat revdeck_context.");
|
|
2274
|
+
} else {
|
|
2275
|
+
lines.push("Last runs:");
|
|
2276
|
+
for (const run2 of runs) {
|
|
2277
|
+
const current2 = head !== "" && run2.commitSha === head;
|
|
2278
|
+
const exit = run2.exitCode === null ? "" : ` (exit ${run2.exitCode})`;
|
|
2279
|
+
lines.push(`- ${run2.checkId}: ${run2.status}${exit} \xB7 ${run2.startedAt} \xB7 ${current2 ? "current commit" : `commit ${run2.commitSha.slice(0, 12) || "?"}`} \xB7 ${Math.round(run2.durationMs)}ms`);
|
|
2280
|
+
if (run2.status !== "passed" && run2.output) {
|
|
2281
|
+
lines.push(...headTailLines(run2.output, 15).map((line) => ` ${line}`));
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
return ok(lines.join("\n"), { checks: rules.checks, runs });
|
|
2286
|
+
} catch (error) {
|
|
2287
|
+
return failure(error);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
);
|
|
2033
2291
|
server.registerTool(
|
|
2034
2292
|
"revdeck_publish_preview",
|
|
2035
2293
|
{
|