revdeck 0.19.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +25 -0
- package/README.ru.md +24 -0
- package/dist/cli.js +266 -17
- package/dist/cli.js.map +4 -4
- package/dist/daemon.js +405 -55
- package/dist/daemon.js.map +4 -4
- package/dist/mcp.js +61 -14
- package/dist/mcp.js.map +3 -3
- package/dist/ui/assets/index-DNDtuzyY.js +21 -0
- package/dist/ui/index.html +1 -1
- package/docs/architecture.md +8 -0
- package/docs/capabilities.md +4 -0
- package/docs/protocol.md +1 -0
- package/docs/ru/architecture.md +8 -0
- package/docs/ru/capabilities.md +3 -0
- package/docs/ru/protocol.md +1 -0
- package/package.json +1 -1
- package/skills/revdeck/en/Sources.md +7 -4
- package/skills/revdeck/ru/Sources.md +7 -3
- package/dist/ui/assets/index-BBiL2dIu.js +0 -21
package/dist/daemon.js
CHANGED
|
@@ -1536,7 +1536,7 @@ async function writeFileAtomic(file, data, mode = 384, dirMode = 448) {
|
|
|
1536
1536
|
init_redact();
|
|
1537
1537
|
|
|
1538
1538
|
// src/version.ts
|
|
1539
|
-
var VERSION = "0.
|
|
1539
|
+
var VERSION = "0.20.0";
|
|
1540
1540
|
var PROTOCOL_VERSION = 2;
|
|
1541
1541
|
|
|
1542
1542
|
// src/daemon/main.ts
|
|
@@ -2863,7 +2863,7 @@ var Store = class {
|
|
|
2863
2863
|
init_redact();
|
|
2864
2864
|
init_errors();
|
|
2865
2865
|
import { EventEmitter } from "node:events";
|
|
2866
|
-
import { createHash as
|
|
2866
|
+
import { createHash as createHash4, randomBytes as randomBytes2 } from "node:crypto";
|
|
2867
2867
|
import { mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
2868
2868
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
2869
2869
|
import path8 from "node:path";
|
|
@@ -3399,6 +3399,130 @@ async function headSha(root) {
|
|
|
3399
3399
|
return "";
|
|
3400
3400
|
}
|
|
3401
3401
|
}
|
|
3402
|
+
async function defaultBranch(root) {
|
|
3403
|
+
try {
|
|
3404
|
+
const { stdout } = await run("git", ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], { cwd: root, timeoutMs: 1e4 });
|
|
3405
|
+
const name = stdout.trim().replace(/^origin\//, "");
|
|
3406
|
+
if (name) return name;
|
|
3407
|
+
} catch {
|
|
3408
|
+
}
|
|
3409
|
+
for (const candidate of ["develop", "main", "master"]) {
|
|
3410
|
+
try {
|
|
3411
|
+
await run("git", ["rev-parse", "--verify", candidate], { cwd: root, timeoutMs: 1e4 });
|
|
3412
|
+
return candidate;
|
|
3413
|
+
} catch {
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
return "main";
|
|
3417
|
+
}
|
|
3418
|
+
async function resolveRef(root, ref) {
|
|
3419
|
+
try {
|
|
3420
|
+
const { stdout } = await run("git", ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`], {
|
|
3421
|
+
cwd: root,
|
|
3422
|
+
timeoutMs: 1e4
|
|
3423
|
+
});
|
|
3424
|
+
return stdout.trim() || null;
|
|
3425
|
+
} catch {
|
|
3426
|
+
return null;
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
async function dirtyFiles(root) {
|
|
3430
|
+
try {
|
|
3431
|
+
const { stdout } = await run("git", ["status", "--porcelain"], { cwd: root, timeoutMs: 1e4 });
|
|
3432
|
+
return stdout.split("\n").filter((line) => line.trim()).length;
|
|
3433
|
+
} catch {
|
|
3434
|
+
return 0;
|
|
3435
|
+
}
|
|
3436
|
+
}
|
|
3437
|
+
async function gitAuthor(root) {
|
|
3438
|
+
for (const key of ["user.name", "user.email"]) {
|
|
3439
|
+
try {
|
|
3440
|
+
const { stdout } = await run("git", ["config", "--get", key], { cwd: root, timeoutMs: 1e4 });
|
|
3441
|
+
const value = stdout.trim();
|
|
3442
|
+
if (value) return value;
|
|
3443
|
+
} catch {
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
return "";
|
|
3447
|
+
}
|
|
3448
|
+
async function gitLog(root, range, limit = 30) {
|
|
3449
|
+
try {
|
|
3450
|
+
const { stdout } = await run("git", ["log", "--no-color", "--format=%h%x09%s", "-n", String(limit), range], {
|
|
3451
|
+
cwd: root,
|
|
3452
|
+
timeoutMs: 15e3
|
|
3453
|
+
});
|
|
3454
|
+
return stdout.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => {
|
|
3455
|
+
const tab = line.indexOf(" ");
|
|
3456
|
+
return tab < 0 ? { sha: line, subject: "" } : { sha: line.slice(0, tab), subject: line.slice(tab + 1) };
|
|
3457
|
+
});
|
|
3458
|
+
} catch {
|
|
3459
|
+
return [];
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
async function localBase(root, explicit, configured) {
|
|
3463
|
+
const headSha2 = await commitOf(root, "HEAD");
|
|
3464
|
+
if (!headSha2) throw new Error("git HEAD is not resolved: not a git repository?");
|
|
3465
|
+
const branchRaw = await currentBranch(root);
|
|
3466
|
+
const detached = !branchRaw || branchRaw === "HEAD";
|
|
3467
|
+
const branch = detached ? `detached-${headSha2.slice(0, 8)}` : branchRaw;
|
|
3468
|
+
const warnings = [];
|
|
3469
|
+
const fallback = await defaultBranch(root);
|
|
3470
|
+
const remoteFallback = `origin/${fallback}`;
|
|
3471
|
+
const candidates = [];
|
|
3472
|
+
if (explicit) candidates.push(explicit);
|
|
3473
|
+
if (configured) candidates.push(configured);
|
|
3474
|
+
candidates.push(remoteFallback, fallback, "origin/HEAD");
|
|
3475
|
+
let base = null;
|
|
3476
|
+
for (const candidate of candidates) {
|
|
3477
|
+
if (await resolveRef(root, candidate)) {
|
|
3478
|
+
base = candidate;
|
|
3479
|
+
break;
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
if (!base) {
|
|
3483
|
+
throw new Error(
|
|
3484
|
+
`no base branch found: tried ${candidates.join(", ")}. Pass --base <ref> or set provider.base in .revdeck.yml`
|
|
3485
|
+
);
|
|
3486
|
+
}
|
|
3487
|
+
if (explicit && explicit !== base) {
|
|
3488
|
+
throw new Error(`base branch ${explicit} does not exist in this repository`);
|
|
3489
|
+
}
|
|
3490
|
+
if (configured && !explicit && configured !== base) {
|
|
3491
|
+
warnings.push(`provider.base ${configured} not found: using ${base}`);
|
|
3492
|
+
}
|
|
3493
|
+
if (base === fallback && !await resolveRef(root, remoteFallback)) {
|
|
3494
|
+
warnings.push(`${remoteFallback} not found: comparing against the local ${fallback}`);
|
|
3495
|
+
}
|
|
3496
|
+
const baseSha = await mergeBase(root, base, "HEAD");
|
|
3497
|
+
if (!baseSha) throw new Error(`no merge-base between ${base} and HEAD: unrelated histories`);
|
|
3498
|
+
const dirty = await dirtyFiles(root);
|
|
3499
|
+
if (detached) warnings.push("detached HEAD: the review is keyed by the commit, not a branch");
|
|
3500
|
+
return { base, baseSha, headSha: headSha2, branch, detached, dirty, warnings };
|
|
3501
|
+
}
|
|
3502
|
+
async function mergeBase(root, a, b) {
|
|
3503
|
+
try {
|
|
3504
|
+
const { stdout } = await run("git", ["merge-base", a, b], { cwd: root, timeoutMs: 3e4 });
|
|
3505
|
+
return stdout.trim();
|
|
3506
|
+
} catch {
|
|
3507
|
+
return "";
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
async function localDiff(root, base) {
|
|
3511
|
+
const { stdout } = await run("git", ["diff", "--no-color", "--no-ext-diff", "--src-prefix=a/", "--dst-prefix=b/", `${base}...HEAD`], {
|
|
3512
|
+
cwd: root,
|
|
3513
|
+
timeoutMs: 6e4,
|
|
3514
|
+
maxBuffer: 64 * 1024 * 1024
|
|
3515
|
+
});
|
|
3516
|
+
return stdout;
|
|
3517
|
+
}
|
|
3518
|
+
async function commitOf(root, ref) {
|
|
3519
|
+
try {
|
|
3520
|
+
const { stdout } = await run("git", ["rev-parse", ref], { cwd: root, timeoutMs: 1e4 });
|
|
3521
|
+
return stdout.trim();
|
|
3522
|
+
} catch {
|
|
3523
|
+
return "";
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3402
3526
|
|
|
3403
3527
|
// src/core/rules.ts
|
|
3404
3528
|
import path6 from "node:path";
|
|
@@ -4156,6 +4280,55 @@ function normalize(value) {
|
|
|
4156
4280
|
|
|
4157
4281
|
// src/daemon/service.ts
|
|
4158
4282
|
init_locale();
|
|
4283
|
+
|
|
4284
|
+
// src/core/local.ts
|
|
4285
|
+
init_locale();
|
|
4286
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
4287
|
+
function localReviewId(projectKey2, root, branch) {
|
|
4288
|
+
return `local-${createHash3("sha256").update(`${projectKey2}|${root}|${branch}`).digest("hex").slice(0, 16)}`;
|
|
4289
|
+
}
|
|
4290
|
+
function localDescription(input) {
|
|
4291
|
+
const lines = [
|
|
4292
|
+
tr(
|
|
4293
|
+
`\u041B\u043E\u043A\u0430\u043B\u044C\u043D\u0430\u044F \u0432\u0435\u0442\u043A\u0430 \`${input.branch}\` \u043F\u0440\u043E\u0442\u0438\u0432 \`${input.base}\`.`,
|
|
4294
|
+
`Local branch \`${input.branch}\` against \`${input.base}\`.`
|
|
4295
|
+
),
|
|
4296
|
+
tr(`Merge-base: \`${input.baseSha.slice(0, 12)}\`.`, `Merge-base: \`${input.baseSha.slice(0, 12)}\`.`)
|
|
4297
|
+
];
|
|
4298
|
+
if (input.commits.length) {
|
|
4299
|
+
lines.push("", tr("### \u041A\u043E\u043C\u043C\u0438\u0442\u044B", "### Commits"));
|
|
4300
|
+
for (const commit of input.commits) lines.push(`- \`${commit.sha}\` ${commit.subject}`);
|
|
4301
|
+
}
|
|
4302
|
+
return lines.join("\n");
|
|
4303
|
+
}
|
|
4304
|
+
function buildLocalInfo(input) {
|
|
4305
|
+
return {
|
|
4306
|
+
// number фиктивный: локальное ревью не адресуется номером на платформе.
|
|
4307
|
+
ref: { ...input.ref, number: 0 },
|
|
4308
|
+
title: input.title,
|
|
4309
|
+
description: localDescription(input),
|
|
4310
|
+
author: input.author,
|
|
4311
|
+
authorName: input.author,
|
|
4312
|
+
state: "local",
|
|
4313
|
+
draft: false,
|
|
4314
|
+
sourceBranch: input.branch,
|
|
4315
|
+
targetBranch: input.base,
|
|
4316
|
+
webUrl: "",
|
|
4317
|
+
local: {
|
|
4318
|
+
branch: input.branch,
|
|
4319
|
+
base: input.base,
|
|
4320
|
+
projectKey: input.projectKey,
|
|
4321
|
+
root: input.root,
|
|
4322
|
+
dirty: input.dirty,
|
|
4323
|
+
detached: input.detached
|
|
4324
|
+
},
|
|
4325
|
+
commit: { base: input.baseSha, start: input.baseSha, head: input.headSha },
|
|
4326
|
+
updatedAt: input.updatedAt,
|
|
4327
|
+
stats: { files: 0, additions: 0, deletions: 0 }
|
|
4328
|
+
};
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4331
|
+
// src/daemon/service.ts
|
|
4159
4332
|
init_types();
|
|
4160
4333
|
|
|
4161
4334
|
// src/providers/provider.ts
|
|
@@ -4450,25 +4623,40 @@ function renderContext(review, rules, options = {}) {
|
|
|
4450
4623
|
const push = (line = "") => {
|
|
4451
4624
|
lines.push(line);
|
|
4452
4625
|
};
|
|
4453
|
-
|
|
4454
|
-
push(review.
|
|
4455
|
-
|
|
4626
|
+
const local = review.info.local;
|
|
4627
|
+
if (local) push(`# ${t("\u0420\u0435\u0432\u044C\u044E \u0432\u0435\u0442\u043A\u0438", "Branch review")} \`${local.branch}\``);
|
|
4628
|
+
else push(`# ${t("\u0420\u0435\u0432\u044C\u044E", "Review")} ${review.info.ref.project}#${review.info.ref.number}: ${review.info.title}`);
|
|
4629
|
+
if (review.info.webUrl) push(review.info.webUrl);
|
|
4630
|
+
const own = local ? null : isOwnReview(review);
|
|
4456
4631
|
const ownSuffix = own === null ? "" : own ? ` \xB7 ${t("\u044D\u0442\u043E \u0432\u0430\u0448 MR", "your MR")}` : ` \xB7 ${t("\u0447\u0443\u0436\u043E\u0439 MR", "someone else's MR")}`;
|
|
4457
|
-
|
|
4632
|
+
const stateLabel = local ? t("\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff", "local diff") : review.info.state;
|
|
4633
|
+
push(`${review.info.sourceBranch} \u2192 ${review.info.targetBranch} \xB7 ${stateLabel} \xB7 ${t("\u0430\u0432\u0442\u043E\u0440", "by")} ${review.info.author}${ownSuffix}`);
|
|
4458
4634
|
push("");
|
|
4459
4635
|
const merge = review.info.merge;
|
|
4460
4636
|
const targetBranch = review.info.targetBranch;
|
|
4461
4637
|
const shortSha = (sha) => sha ? sha.slice(0, 12) : "?";
|
|
4462
4638
|
push(`## ${t("\u0412\u0435\u0442\u043A\u0430 \u0438 \u0431\u0430\u0437\u0430 \u0441\u0440\u0430\u0432\u043D\u0435\u043D\u0438\u044F", "Branch and comparison base")}`);
|
|
4463
4639
|
push(
|
|
4464
|
-
`${t("\u041A\u0443\u0434\u0430 \u043C\u0435\u0440\u0436\u0438\u0442\u0441\u044F", "Merges into")}: ${targetBranch ? `\`${targetBranch}\`` : t("\u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C\u043E (\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff)", "not applicable (local diff)")}`
|
|
4640
|
+
`${local ? t("\u0411\u0430\u0437\u0430 \u0441\u0440\u0430\u0432\u043D\u0435\u043D\u0438\u044F", "Compared against") : t("\u041A\u0443\u0434\u0430 \u043C\u0435\u0440\u0436\u0438\u0442\u0441\u044F", "Merges into")}: ${targetBranch ? `\`${targetBranch}\`` : t("\u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C\u043E (\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff)", "not applicable (local diff)")}`
|
|
4465
4641
|
);
|
|
4466
4642
|
push(`${t("\u0418\u0441\u0442\u043E\u0447\u043D\u0438\u043A", "Source")}: \`${review.info.sourceBranch || "?"}\``);
|
|
4467
4643
|
if (review.info.commit.base || review.info.commit.head) {
|
|
4468
4644
|
push(`${t("\u0421\u043D\u0438\u043C\u043E\u043A diff", "Diff snapshot")}: \`${shortSha(review.info.commit.base)}\` \u2192 \`${shortSha(review.info.commit.head)}\``);
|
|
4469
4645
|
}
|
|
4470
4646
|
push(`${t("\u0421\u043D\u0438\u043C\u043E\u043A \u043E\u0431\u043D\u043E\u0432\u043B\u0451\u043D", "Snapshot updated")}: ${when(review.syncedAt, language)}`);
|
|
4471
|
-
if (
|
|
4647
|
+
if (local) {
|
|
4648
|
+
push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${t("\u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C (\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff)", "not applicable (local diff)")}`);
|
|
4649
|
+
push(t(
|
|
4650
|
+
"> \u042D\u0442\u043E \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff \u0431\u0435\u0437 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B: \u0442\u0440\u0435\u0434\u043E\u0432, \u0440\u0435\u0430\u043A\u0446\u0438\u0439, CI-checks \u0438 approvals \u043D\u0435\u0442. \u0417\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043D\u0435 \u043F\u0443\u0431\u043B\u0438\u043A\u0443\u044E\u0442\u0441\u044F, \u043E\u0442\u0447\u0451\u0442 \u2014 \u0435\u0434\u0438\u043D\u0441\u0442\u0432\u0435\u043D\u043D\u044B\u0439 \u0430\u0440\u0442\u0435\u0444\u0430\u043A\u0442.",
|
|
4651
|
+
"> This is a local diff without a platform: there are no threads, reactions, CI checks or approvals. Findings are not published; the report is the only artifact."
|
|
4652
|
+
));
|
|
4653
|
+
if (local.dirty > 0) {
|
|
4654
|
+
push(t(
|
|
4655
|
+
`> \u0412 \u0440\u0430\u0431\u043E\u0447\u0435\u0439 \u043A\u043E\u043F\u0438\u0438 ${local.dirty} \u0444\u0430\u0439\u043B\u043E\u0432 \u0441 \u043D\u0435\u0437\u0430\u043A\u043E\u043C\u043C\u0438\u0447\u0435\u043D\u043D\u044B\u043C\u0438 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F\u043C\u0438 \u2014 \u043E\u043D\u0438 \u043D\u0435 \u0432\u0445\u043E\u0434\u044F\u0442 \u0432 diff.`,
|
|
4656
|
+
`> The working copy has ${local.dirty} files with uncommitted changes \u2014 they are not part of the diff.`
|
|
4657
|
+
));
|
|
4658
|
+
}
|
|
4659
|
+
} else if (!targetBranch) {
|
|
4472
4660
|
push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${t("\u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C", "not applicable")}`);
|
|
4473
4661
|
} else if (!merge) {
|
|
4474
4662
|
push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${t("\u043D\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u044F\u043B\u0441\u044F", "not checked")}`);
|
|
@@ -4477,8 +4665,8 @@ function renderContext(review, rules, options = {}) {
|
|
|
4477
4665
|
"> No merge status was reported: do not claim there are no findings until the target and conflicts are checked."
|
|
4478
4666
|
));
|
|
4479
4667
|
} else {
|
|
4480
|
-
const
|
|
4481
|
-
push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${
|
|
4668
|
+
const stateLabel2 = merge.state === "clean" ? t("\u0447\u0438\u0441\u0442\u043E", "clean") : merge.state === "conflict" ? t("\u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442", "conflict") : merge.state === "behind" ? t("\u043E\u0442\u0441\u0442\u0430\u0451\u0442 \u043E\u0442 target", "behind target") : merge.state === "unknown" ? t("\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043D", "unknown") : t("\u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0430 \u043D\u0435 \u0441\u043E\u043E\u0431\u0449\u0438\u043B\u0430", "not reported");
|
|
4669
|
+
push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${stateLabel2}${merge.detail ? ` \xB7 ${merge.detail}` : ""}`);
|
|
4482
4670
|
if (merge.targetSha) push(`${t("Target head", "Target head")}: \`${shortSha(merge.targetSha)}\``);
|
|
4483
4671
|
if (merge.state === "conflict") {
|
|
4484
4672
|
push(t(
|
|
@@ -4549,11 +4737,19 @@ function renderContext(review, rules, options = {}) {
|
|
|
4549
4737
|
}
|
|
4550
4738
|
push("");
|
|
4551
4739
|
if (options.scenario === "feedback") {
|
|
4552
|
-
|
|
4553
|
-
push(
|
|
4554
|
-
"\
|
|
4555
|
-
|
|
4556
|
-
|
|
4740
|
+
const local2 = Boolean(review.info.local);
|
|
4741
|
+
push(
|
|
4742
|
+
local2 ? `## ${t("\u0421\u0446\u0435\u043D\u0430\u0440\u0438\u0439: \u0434\u043E\u0440\u0430\u0431\u043E\u0442\u043A\u0430 \u0441\u0432\u043E\u0435\u0439 \u0432\u0435\u0442\u043A\u0438", "Scenario: improving your branch")}` : `## ${t("\u0421\u0446\u0435\u043D\u0430\u0440\u0438\u0439: \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043A \u0441\u0432\u043E\u0435\u043C\u0443 MR", "Scenario: feedback on your own MR")}`
|
|
4743
|
+
);
|
|
4744
|
+
push(
|
|
4745
|
+
local2 ? t(
|
|
4746
|
+
"\u041F\u0440\u043E\u0446\u0435\u0434\u0443\u0440\u0430: `Feedback.md` \u0438\u0437 skill revdeck. \u0421\u0432\u0435\u0440\u044C\u0442\u0435 diff \u0441 \u0431\u0430\u0437\u043E\u0439, \u043E\u0442\u043C\u0435\u0442\u044C\u0442\u0435 \u043D\u0435\u0437\u0430\u043A\u043E\u043C\u043C\u0438\u0447\u0435\u043D\u043D\u043E\u0435 \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0438\u0442\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043D\u044B\u0435 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F; \u043E\u0442\u0447\u0451\u0442 \u0441\u043E\u0431\u0438\u0440\u0430\u0435\u0442 \u0447\u0435\u043B\u043E\u0432\u0435\u043A.",
|
|
4747
|
+
"Procedure: `Feedback.md` from the revdeck skill. Check the diff against the base, note uncommitted changes and work through the findings; the human builds the report."
|
|
4748
|
+
) : t(
|
|
4749
|
+
"\u041F\u0440\u043E\u0446\u0435\u0434\u0443\u0440\u0430: `Feedback.md` \u0438\u0437 skill revdeck. \u0421\u043D\u0430\u0447\u0430\u043B\u0430 \u0441\u0432\u0435\u0440\u044C\u0442\u0435 \u0440\u0430\u0431\u043E\u0447\u0443\u044E \u0432\u0435\u0442\u043A\u0443 \u0441 MR, \u0437\u0430\u0442\u0435\u043C \u0440\u0430\u0437\u0431\u0435\u0440\u0438\u0442\u0435 \u043E\u0442\u043A\u0440\u044B\u0442\u044B\u0435 \u0442\u0440\u0435\u0434\u044B \u0438 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438 \u043A \u0441\u0442\u0440\u043E\u043A\u0430\u043C.",
|
|
4750
|
+
"Procedure: `Feedback.md` from the revdeck skill. First verify the working branch matches the MR, then work through open threads and line comments."
|
|
4751
|
+
)
|
|
4752
|
+
);
|
|
4557
4753
|
push("");
|
|
4558
4754
|
} else if (options.scenario === "review") {
|
|
4559
4755
|
push(`## ${t("\u0421\u0446\u0435\u043D\u0430\u0440\u0438\u0439: \u0440\u0435\u0432\u044C\u044E \u0447\u0443\u0436\u043E\u0433\u043E MR", "Scenario: reviewing someone else's MR")}`);
|
|
@@ -5009,6 +5205,8 @@ var ReviewService = class {
|
|
|
5009
5205
|
/** Полные файлы для раскрытия diff; ключ включает head/base, коммит и путь. */
|
|
5010
5206
|
fileContentCache = /* @__PURE__ */ new Map();
|
|
5011
5207
|
readinessCache = /* @__PURE__ */ new Map();
|
|
5208
|
+
/** Локальные ревью без платформы: не попадают в SQLite и список ревью. */
|
|
5209
|
+
locals = /* @__PURE__ */ new Map();
|
|
5012
5210
|
codeownersCache = /* @__PURE__ */ new Map();
|
|
5013
5211
|
constructor(options) {
|
|
5014
5212
|
this.store = options.store;
|
|
@@ -5063,7 +5261,100 @@ var ReviewService = class {
|
|
|
5063
5261
|
this.event(id, options.actor ?? "system", "review.opened", { ref });
|
|
5064
5262
|
return this.getReview(id);
|
|
5065
5263
|
}
|
|
5264
|
+
/**
|
|
5265
|
+
* Локальное ревью «ветка против базы»: diff из рабочей копии, без платформы.
|
|
5266
|
+
* Снимок живёт в памяти и не попадает в SQLite; id стабилен для ветки, так что
|
|
5267
|
+
* повторный запуск обновляет тот же снимок и сохраняет findings/выжимку.
|
|
5268
|
+
*/
|
|
5269
|
+
async openLocal(rootInput, options = {}) {
|
|
5270
|
+
const root = findRepoRoot(rootInput);
|
|
5271
|
+
const loaded = await loadConfig(root);
|
|
5272
|
+
const context = await projectContext(root, loaded.config);
|
|
5273
|
+
const key = projectKey(context);
|
|
5274
|
+
this.store.registerProject(context, root, this.now().toISOString());
|
|
5275
|
+
const resolved = await localBase(root, options.base, loaded.config.provider.base);
|
|
5276
|
+
const patch = await localDiff(root, resolved.base);
|
|
5277
|
+
let diff;
|
|
5278
|
+
try {
|
|
5279
|
+
diff = parseUnifiedDiff(patch);
|
|
5280
|
+
} catch (error) {
|
|
5281
|
+
throw new Error(tr(`\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C diff: ${messageOf(error)}`, `could not parse the diff: ${messageOf(error)}`));
|
|
5282
|
+
}
|
|
5283
|
+
if (!diff.length) {
|
|
5284
|
+
throw new Error(
|
|
5285
|
+
tr(
|
|
5286
|
+
`\u043D\u0435\u0442 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439 \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0435\u043B\u044C\u043D\u043E ${resolved.base}: \u0432\u0435\u0442\u043A\u0430 ${resolved.branch} \u0441\u043E\u0432\u043F\u0430\u0434\u0430\u0435\u0442 \u0441 \u0431\u0430\u0437\u043E\u0439`,
|
|
5287
|
+
`no changes against ${resolved.base}: branch ${resolved.branch} matches the base`
|
|
5288
|
+
)
|
|
5289
|
+
);
|
|
5290
|
+
}
|
|
5291
|
+
const id = localReviewId(key, root, resolved.branch);
|
|
5292
|
+
const previous = this.locals.get(id)?.review;
|
|
5293
|
+
const commits = await gitLog(root, `${resolved.baseSha}..${resolved.headSha}`);
|
|
5294
|
+
const info = buildLocalInfo({
|
|
5295
|
+
ref: context,
|
|
5296
|
+
projectKey: key,
|
|
5297
|
+
root,
|
|
5298
|
+
branch: resolved.branch,
|
|
5299
|
+
detached: resolved.detached,
|
|
5300
|
+
base: resolved.base,
|
|
5301
|
+
baseSha: resolved.baseSha,
|
|
5302
|
+
headSha: resolved.headSha,
|
|
5303
|
+
dirty: resolved.dirty,
|
|
5304
|
+
author: await gitAuthor(root) || tr("\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C", "local user"),
|
|
5305
|
+
title: resolved.branch,
|
|
5306
|
+
commits,
|
|
5307
|
+
updatedAt: this.now().toISOString()
|
|
5308
|
+
});
|
|
5309
|
+
info.stats = diffStats(diff);
|
|
5310
|
+
const config = loaded.config;
|
|
5311
|
+
const review = {
|
|
5312
|
+
id,
|
|
5313
|
+
info,
|
|
5314
|
+
diff,
|
|
5315
|
+
threads: [],
|
|
5316
|
+
reactions: [],
|
|
5317
|
+
groups: computeGroups(diff, config.review?.groups ?? []),
|
|
5318
|
+
summary: previous?.summary ?? null,
|
|
5319
|
+
findings: this.markLocalFindings(previous?.findings ?? [], diff),
|
|
5320
|
+
drafts: [],
|
|
5321
|
+
notes: [],
|
|
5322
|
+
agentMessages: [],
|
|
5323
|
+
decisions: previous?.decisions ?? {},
|
|
5324
|
+
user: null,
|
|
5325
|
+
syncedAt: this.now().toISOString(),
|
|
5326
|
+
errors: resolved.warnings,
|
|
5327
|
+
readOnly: process.env.REVDECK_READ_ONLY === "1" || config.review?.readOnly === true
|
|
5328
|
+
};
|
|
5329
|
+
this.locals.set(id, {
|
|
5330
|
+
review,
|
|
5331
|
+
root,
|
|
5332
|
+
base: resolved.base,
|
|
5333
|
+
config,
|
|
5334
|
+
configPath: loaded.path,
|
|
5335
|
+
at: this.now().getTime()
|
|
5336
|
+
});
|
|
5337
|
+
while (this.locals.size > 16) {
|
|
5338
|
+
const oldest = [...this.locals.entries()].sort((left, right) => left[1].at - right[1].at)[0];
|
|
5339
|
+
if (!oldest) break;
|
|
5340
|
+
this.locals.delete(oldest[0]);
|
|
5341
|
+
}
|
|
5342
|
+
this.emit(id);
|
|
5343
|
+
return review;
|
|
5344
|
+
}
|
|
5345
|
+
/** Замечание, чья строка исчезла из diff, помечается stale — как в MR-потоке. */
|
|
5346
|
+
markLocalFindings(findings, diff) {
|
|
5347
|
+
return findings.map((finding) => {
|
|
5348
|
+
if (finding.status === "published" || finding.status === "stale" || finding.line === null) return finding;
|
|
5349
|
+
return findNewLine(diff, finding.file, finding.line) ? finding : { ...finding, status: "stale" };
|
|
5350
|
+
});
|
|
5351
|
+
}
|
|
5066
5352
|
async refreshReview(id, actor = "system") {
|
|
5353
|
+
const local = this.locals.get(id);
|
|
5354
|
+
if (local) {
|
|
5355
|
+
await this.openLocal(local.root, { base: local.base });
|
|
5356
|
+
return this.getReview(id);
|
|
5357
|
+
}
|
|
5067
5358
|
const meta = this.store.getReview(id);
|
|
5068
5359
|
if (!meta) throw new Error(tr(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E: \u0441\u043D\u0430\u0447\u0430\u043B\u0430 \u043E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u0435\u0433\u043E`, `review ${id} not found: open it first`));
|
|
5069
5360
|
const loaded = await loadConfig(meta.row.root).catch((error) => ({
|
|
@@ -5160,7 +5451,7 @@ var ReviewService = class {
|
|
|
5160
5451
|
const history = this.configOf(id)?.review?.history;
|
|
5161
5452
|
if (!history?.enabled) return;
|
|
5162
5453
|
const view = this.getReview(id);
|
|
5163
|
-
const diffHash =
|
|
5454
|
+
const diffHash = createHash4("sha256").update(canonicalJson(diff)).digest("hex");
|
|
5164
5455
|
this.store.addVersion(
|
|
5165
5456
|
id,
|
|
5166
5457
|
{ headSha: info.commit.head, baseSha: info.commit.base, diffHash, data: view },
|
|
@@ -5183,6 +5474,8 @@ var ReviewService = class {
|
|
|
5183
5474
|
if (changed) this.emit(id);
|
|
5184
5475
|
}
|
|
5185
5476
|
getReview(id) {
|
|
5477
|
+
const local = this.locals.get(id);
|
|
5478
|
+
if (local) return local.review;
|
|
5186
5479
|
const stored = this.store.getReview(id);
|
|
5187
5480
|
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`));
|
|
5188
5481
|
const { row, snapshot } = stored;
|
|
@@ -5310,7 +5603,7 @@ var ReviewService = class {
|
|
|
5310
5603
|
...input.host ? { host: input.host } : {},
|
|
5311
5604
|
...input.branch ? { branch: input.branch } : {}
|
|
5312
5605
|
});
|
|
5313
|
-
const id = `preview-${
|
|
5606
|
+
const id = `preview-${createHash4("sha256").update(`${ref.platform}|${ref.host}|${ref.project}|${ref.number}`).digest("hex").slice(0, 16)}`;
|
|
5314
5607
|
const cached = this.previews.get(id);
|
|
5315
5608
|
if (!input.force && cached && this.now().getTime() - cached.at < 60 * 6e4) return cached.view;
|
|
5316
5609
|
const provider = await this.providerFactory(ref, root);
|
|
@@ -5532,6 +5825,10 @@ var ReviewService = class {
|
|
|
5532
5825
|
return projectKey(context);
|
|
5533
5826
|
}
|
|
5534
5827
|
removeReview(id) {
|
|
5828
|
+
if (this.locals.delete(id)) {
|
|
5829
|
+
this.emit(id);
|
|
5830
|
+
return;
|
|
5831
|
+
}
|
|
5535
5832
|
this.requireReview(id);
|
|
5536
5833
|
const features = this.store.featuresForReview(id);
|
|
5537
5834
|
if (features.length) {
|
|
@@ -5811,6 +6108,7 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
5811
6108
|
return { items: await provider.list({ scope, limit }), platform: context.platform, project: context.project };
|
|
5812
6109
|
}
|
|
5813
6110
|
isStale(id) {
|
|
6111
|
+
if (this.locals.has(id)) return false;
|
|
5814
6112
|
const stored = this.store.getReview(id);
|
|
5815
6113
|
if (!stored) return true;
|
|
5816
6114
|
return this.now().getTime() - new Date(stored.snapshot.syncedAt).getTime() > this.refreshTtlMs;
|
|
@@ -5824,6 +6122,11 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
5824
6122
|
});
|
|
5825
6123
|
}
|
|
5826
6124
|
diffFile(id, file) {
|
|
6125
|
+
const local = this.locals.get(id);
|
|
6126
|
+
if (local) {
|
|
6127
|
+
const found2 = local.review.diff.find((item) => item.path === file);
|
|
6128
|
+
return found2 ? { path: found2.path, status: found2.status, binary: found2.binary, hunks: found2.hunks } : null;
|
|
6129
|
+
}
|
|
5827
6130
|
const preview = this.previews.get(id);
|
|
5828
6131
|
if (preview && this.now().getTime() - preview.at < 60 * 6e4) {
|
|
5829
6132
|
const found2 = preview.diff.find((item) => item.path === file);
|
|
@@ -5837,6 +6140,9 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
5837
6140
|
}
|
|
5838
6141
|
/** CI/approvals платформы; кешируется на минуту, чтобы Overview не дёргал API на каждый рендер. */
|
|
5839
6142
|
async readiness(id, force = false) {
|
|
6143
|
+
if (this.locals.has(id)) {
|
|
6144
|
+
return { checks: [], approvals: null, errors: [], checkedAt: this.now().toISOString() };
|
|
6145
|
+
}
|
|
5840
6146
|
const cached = this.readinessCache.get(id);
|
|
5841
6147
|
if (!force && cached && this.now().getTime() - cached.at < 6e4) return cached.value;
|
|
5842
6148
|
const preview = this.previews.get(id);
|
|
@@ -5869,12 +6175,13 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
5869
6175
|
async codeowners(id, force = false) {
|
|
5870
6176
|
const cached = this.codeownersCache.get(id);
|
|
5871
6177
|
if (!force && cached && this.now().getTime() - cached.at < 5 * 6e4) return cached.value;
|
|
6178
|
+
const local = this.locals.get(id);
|
|
5872
6179
|
const preview = this.previews.get(id);
|
|
5873
|
-
const stored = preview ? null : this.store.getReview(id);
|
|
5874
|
-
if (!preview && !stored) throw Object.assign(new Error(tr(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E`, `review ${id} not found`)), { status: 404 });
|
|
5875
|
-
const info = preview?.view.info ?? this.store.info(id);
|
|
5876
|
-
const root = preview?.root ?? stored.row.root;
|
|
5877
|
-
const files = (preview?.diff ?? stored.snapshot.diff).map((file) => file.path);
|
|
6180
|
+
const stored = preview || local ? null : this.store.getReview(id);
|
|
6181
|
+
if (!preview && !local && !stored) throw Object.assign(new Error(tr(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E`, `review ${id} not found`)), { status: 404 });
|
|
6182
|
+
const info = preview?.view.info ?? local?.review.info ?? this.store.info(id);
|
|
6183
|
+
const root = preview?.root ?? local?.root ?? stored.row.root;
|
|
6184
|
+
const files = (preview?.diff ?? local?.review.diff ?? stored.snapshot.diff).map((file) => file.path);
|
|
5878
6185
|
const candidates = [".github/CODEOWNERS", "CODEOWNERS", "docs/CODEOWNERS", ".gitlab/CODEOWNERS"];
|
|
5879
6186
|
let text2 = null;
|
|
5880
6187
|
let foundPath = null;
|
|
@@ -5886,7 +6193,7 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
5886
6193
|
} catch {
|
|
5887
6194
|
}
|
|
5888
6195
|
}
|
|
5889
|
-
if (text2 === null && info.commit.head) {
|
|
6196
|
+
if (text2 === null && info.commit.head && !local) {
|
|
5890
6197
|
try {
|
|
5891
6198
|
const provider = preview ? await this.providerFactory(preview.ref, preview.root) : await this.providerFor(id);
|
|
5892
6199
|
for (const candidate of candidates) {
|
|
@@ -5925,13 +6232,14 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
5925
6232
|
async fileContent(id, file) {
|
|
5926
6233
|
const cachedPreview = this.previews.get(id);
|
|
5927
6234
|
const preview = cachedPreview && this.now().getTime() - cachedPreview.at < 60 * 6e4 ? cachedPreview : null;
|
|
5928
|
-
const
|
|
5929
|
-
|
|
6235
|
+
const local = this.locals.get(id);
|
|
6236
|
+
const stored = preview || local ? null : this.store.getReview(id);
|
|
6237
|
+
if (!preview && !local && !stored) {
|
|
5930
6238
|
throw Object.assign(new Error(tr(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E`, `review ${id} not found`)), { status: 404 });
|
|
5931
6239
|
}
|
|
5932
|
-
const diff = preview?.diff ?? stored.snapshot.diff;
|
|
5933
|
-
const info = preview?.view.info ?? this.store.info(id) ?? (stored ? fallbackInfo(stored.row) : null);
|
|
5934
|
-
const root = preview?.root ?? stored.row.root;
|
|
6240
|
+
const diff = preview?.diff ?? local?.review.diff ?? stored.snapshot.diff;
|
|
6241
|
+
const info = preview?.view.info ?? local?.review.info ?? this.store.info(id) ?? (stored ? fallbackInfo(stored.row) : null);
|
|
6242
|
+
const root = preview?.root ?? local?.root ?? stored.row.root;
|
|
5935
6243
|
const found = diff.find((item) => item.path === file || item.oldPath === file);
|
|
5936
6244
|
if (!found || !info) {
|
|
5937
6245
|
throw Object.assign(new Error(tr("\u0444\u0430\u0439\u043B\u0430 \u043D\u0435\u0442 \u0432 diff", "the file is not in the diff")), { status: 404 });
|
|
@@ -5950,16 +6258,23 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
5950
6258
|
if (hit && this.now().getTime() - hit.at < 10 * 6e4) return hit.value;
|
|
5951
6259
|
let text2;
|
|
5952
6260
|
try {
|
|
5953
|
-
const
|
|
5954
|
-
try {
|
|
6261
|
+
const readCommit = async () => {
|
|
5955
6262
|
const result = await this.runImpl("git", ["show", `${sha}:${path13}`], {
|
|
5956
6263
|
cwd: root,
|
|
5957
6264
|
timeoutMs: 3e4,
|
|
5958
6265
|
maxBuffer: 16 * 1024 * 1024
|
|
5959
6266
|
});
|
|
5960
|
-
|
|
5961
|
-
}
|
|
5962
|
-
|
|
6267
|
+
return result.stdout;
|
|
6268
|
+
};
|
|
6269
|
+
if (local) {
|
|
6270
|
+
text2 = await readCommit();
|
|
6271
|
+
} else {
|
|
6272
|
+
const provider = preview ? await this.providerFactory(preview.ref, preview.root) : await this.providerFor(id);
|
|
6273
|
+
try {
|
|
6274
|
+
text2 = await readCommit();
|
|
6275
|
+
} catch {
|
|
6276
|
+
text2 = await provider.fileContent(path13, sha);
|
|
6277
|
+
}
|
|
5963
6278
|
}
|
|
5964
6279
|
} catch (error) {
|
|
5965
6280
|
throw Object.assign(
|
|
@@ -5990,13 +6305,10 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
5990
6305
|
return value;
|
|
5991
6306
|
}
|
|
5992
6307
|
// ---------------------------------------------------------------- summary
|
|
5993
|
-
|
|
5994
|
-
this.requireReview(id);
|
|
5995
|
-
this.assertWritable(id);
|
|
6308
|
+
normalizeSummary(input, previous) {
|
|
5996
6309
|
const value = input ?? {};
|
|
5997
|
-
const previous = this.store.getSummary(id);
|
|
5998
6310
|
const list = (item, limit) => (Array.isArray(item) ? item : []).map((entry) => String(entry ?? "").trim()).filter(Boolean).slice(0, limit).map((entry) => entry.slice(0, 4e3));
|
|
5999
|
-
|
|
6311
|
+
return {
|
|
6000
6312
|
title: String(value.title ?? "").slice(0, 1e3),
|
|
6001
6313
|
scope: String(value.scope ?? "").slice(0, 2e3),
|
|
6002
6314
|
summary: String(value.summary ?? "").slice(0, 2e4),
|
|
@@ -6007,6 +6319,17 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
6007
6319
|
duplicates: value.duplicates === void 0 ? previous?.duplicates ?? [] : list(value.duplicates, 100),
|
|
6008
6320
|
ruleCandidates: value.ruleCandidates === void 0 ? previous?.ruleCandidates ?? [] : list(value.ruleCandidates, 100)
|
|
6009
6321
|
};
|
|
6322
|
+
}
|
|
6323
|
+
setSummary(id, input, actor = "system") {
|
|
6324
|
+
this.requireReview(id);
|
|
6325
|
+
this.assertWritable(id);
|
|
6326
|
+
const local = this.locals.get(id);
|
|
6327
|
+
if (local) {
|
|
6328
|
+
local.review.summary = this.normalizeSummary(input, local.review.summary);
|
|
6329
|
+
this.emit(id);
|
|
6330
|
+
return local.review.summary;
|
|
6331
|
+
}
|
|
6332
|
+
const summary = this.normalizeSummary(input, this.store.getSummary(id));
|
|
6010
6333
|
this.store.setSummary(id, summary);
|
|
6011
6334
|
this.event(id, actor, "summary.saved", {
|
|
6012
6335
|
title: summary.title,
|
|
@@ -6025,7 +6348,8 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
6025
6348
|
this.assertWritable(id);
|
|
6026
6349
|
const review = this.getReview(id);
|
|
6027
6350
|
if (!Array.isArray(raw)) throw new Error(tr("findings: \u043E\u0436\u0438\u0434\u0430\u043B\u0441\u044F \u043C\u0430\u0441\u0441\u0438\u0432", "findings: expected an array"));
|
|
6028
|
-
const
|
|
6351
|
+
const local = this.locals.get(id);
|
|
6352
|
+
const existing = local ? review.findings : this.store.listFindings(id);
|
|
6029
6353
|
const knownIds = new Set(existing.map((finding) => finding.id));
|
|
6030
6354
|
const knownPrints = new Set(existing.map((finding) => finding.fingerprint));
|
|
6031
6355
|
const drafts = [];
|
|
@@ -6062,7 +6386,12 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0444\u0438\u0447\
|
|
|
6062
6386
|
if (errors.length) throw new Error(tr(`\u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043E\u0442\u043A\u043B\u043E\u043D\u0435\u043D\u044B:
|
|
6063
6387
|
${errors.join("\n")}`, `findings rejected:
|
|
6064
6388
|
${errors.join("\n")}`));
|
|
6065
|
-
const merged = mergeFindings(
|
|
6389
|
+
const merged = mergeFindings(existing, drafts, { now: this.now().toISOString() });
|
|
6390
|
+
if (local) {
|
|
6391
|
+
local.review.findings = merged;
|
|
6392
|
+
this.emit(id);
|
|
6393
|
+
return merged;
|
|
6394
|
+
}
|
|
6066
6395
|
this.store.replaceFindings(id, merged);
|
|
6067
6396
|
this.event(id, actor, "findings.drafted", {
|
|
6068
6397
|
count: drafts.length,
|
|
@@ -6089,6 +6418,12 @@ ${errors.join("\n")}`));
|
|
|
6089
6418
|
note: String(item.note ?? "").slice(0, 4e3)
|
|
6090
6419
|
};
|
|
6091
6420
|
}
|
|
6421
|
+
const local = this.locals.get(id);
|
|
6422
|
+
if (local) {
|
|
6423
|
+
local.review.decisions = { ...local.review.decisions, ...patch };
|
|
6424
|
+
this.emit(id);
|
|
6425
|
+
return local.review.decisions;
|
|
6426
|
+
}
|
|
6092
6427
|
this.store.setDecisions(id, patch);
|
|
6093
6428
|
this.event(id, actor, "decisions.saved", {
|
|
6094
6429
|
count: Object.keys(patch).length,
|
|
@@ -6621,25 +6956,28 @@ ${errors.join("\n")}`));
|
|
|
6621
6956
|
}
|
|
6622
6957
|
// ---------------------------------------------------------------- rules & checks
|
|
6623
6958
|
async rules(id, shard) {
|
|
6624
|
-
const
|
|
6625
|
-
|
|
6626
|
-
|
|
6959
|
+
const local = this.locals.get(id);
|
|
6960
|
+
const stored = local ? null : this.store.getReview(id);
|
|
6961
|
+
if (!local && !stored) throw new Error(tr(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E`, `review ${id} not found`));
|
|
6962
|
+
const info = local ? local.review.info : this.store.info(id);
|
|
6963
|
+
const root = local ? local.root : stored.row.root;
|
|
6964
|
+
const diff = local ? local.review.diff : stored.snapshot.diff;
|
|
6627
6965
|
const texts = [
|
|
6628
6966
|
info?.title ?? "",
|
|
6629
6967
|
info?.description ?? "",
|
|
6630
|
-
...stored.snapshot.threads.flatMap((thread) => thread.notes.map((note) => note.body))
|
|
6968
|
+
...local ? [] : stored.snapshot.threads.flatMap((thread) => thread.notes.map((note) => note.body))
|
|
6631
6969
|
];
|
|
6632
|
-
let config = stored.snapshot.config;
|
|
6633
|
-
let configPath = stored.snapshot.configPath;
|
|
6970
|
+
let config = local ? local.config : stored.snapshot.config;
|
|
6971
|
+
let configPath = local ? local.configPath : stored.snapshot.configPath;
|
|
6634
6972
|
if (!config?.rules) {
|
|
6635
|
-
const loaded = await loadConfig(
|
|
6973
|
+
const loaded = await loadConfig(root);
|
|
6636
6974
|
config = loaded.config;
|
|
6637
6975
|
configPath = loaded.path;
|
|
6638
6976
|
}
|
|
6639
6977
|
const language = resolveOutputLanguage(config.output?.language ?? "auto", texts);
|
|
6640
|
-
let files = changedPaths(
|
|
6978
|
+
let files = changedPaths(diff);
|
|
6641
6979
|
if (shard) {
|
|
6642
|
-
const sizes = diffFileSizes(
|
|
6980
|
+
const sizes = diffFileSizes(diff);
|
|
6643
6981
|
const maxShards = Math.max(1, Math.min(MAX_SHARDS, sizes.length));
|
|
6644
6982
|
if (!Number.isInteger(shard.index) || !Number.isInteger(shard.count) || shard.count < 1 || shard.index < 1 || shard.index > shard.count) {
|
|
6645
6983
|
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"));
|
|
@@ -6655,7 +6993,7 @@ ${errors.join("\n")}`));
|
|
|
6655
6993
|
files = [...shardPaths(sizes, shard.index, shard.count)];
|
|
6656
6994
|
}
|
|
6657
6995
|
const effective = await buildEffectiveRules({
|
|
6658
|
-
root
|
|
6996
|
+
root,
|
|
6659
6997
|
config,
|
|
6660
6998
|
configPath,
|
|
6661
6999
|
files,
|
|
@@ -6673,7 +7011,7 @@ ${errors.join("\n")}`));
|
|
|
6673
7011
|
maxBytes,
|
|
6674
7012
|
agents,
|
|
6675
7013
|
roles,
|
|
6676
|
-
runs: this.store.latestCheckRuns(id)
|
|
7014
|
+
runs: local ? [] : this.store.latestCheckRuns(id)
|
|
6677
7015
|
};
|
|
6678
7016
|
}
|
|
6679
7017
|
async runChecks(id, options) {
|
|
@@ -6926,14 +7264,17 @@ ${typeof details.stderr === "string" ? details.stderr : ""}`;
|
|
|
6926
7264
|
this.events.emit("feature", { featureId: id, at: this.now().toISOString() });
|
|
6927
7265
|
}
|
|
6928
7266
|
requireReview(id) {
|
|
7267
|
+
if (this.locals.has(id)) return;
|
|
6929
7268
|
if (!this.store.getReview(id)) throw new Error(`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E`);
|
|
6930
7269
|
}
|
|
6931
7270
|
changedFiles(id) {
|
|
7271
|
+
const local = this.locals.get(id);
|
|
7272
|
+
if (local) return changedPaths(local.review.diff);
|
|
6932
7273
|
const stored = this.store.getReview(id);
|
|
6933
7274
|
return stored ? changedPaths(stored.snapshot.diff) : [];
|
|
6934
7275
|
}
|
|
6935
7276
|
diffFor(id) {
|
|
6936
|
-
return this.store.getReview(id)?.snapshot.diff ?? [];
|
|
7277
|
+
return this.locals.get(id)?.review.diff ?? this.store.getReview(id)?.snapshot.diff ?? [];
|
|
6937
7278
|
}
|
|
6938
7279
|
threadSnippet(id, file, line) {
|
|
6939
7280
|
if (line === null) return null;
|
|
@@ -6953,14 +7294,14 @@ ${typeof details.stderr === "string" ? details.stderr : ""}`;
|
|
|
6953
7294
|
return this.store.getVersion(id, versionId);
|
|
6954
7295
|
}
|
|
6955
7296
|
configOf(id) {
|
|
6956
|
-
return this.store.getReview(id)?.snapshot.config ?? null;
|
|
7297
|
+
return this.locals.get(id)?.config ?? this.store.getReview(id)?.snapshot.config ?? null;
|
|
6957
7298
|
}
|
|
6958
7299
|
rootOf(id) {
|
|
6959
|
-
return this.store.getReview(id)?.row.root ?? null;
|
|
7300
|
+
return this.locals.get(id)?.root ?? this.store.getReview(id)?.row.root ?? null;
|
|
6960
7301
|
}
|
|
6961
7302
|
};
|
|
6962
7303
|
function canonicalHash(reviewId2, kind, items) {
|
|
6963
|
-
return
|
|
7304
|
+
return createHash4("sha256").update(canonicalJson({ reviewId: reviewId2, kind, items })).digest("hex");
|
|
6964
7305
|
}
|
|
6965
7306
|
function fallbackInfo(row) {
|
|
6966
7307
|
return {
|
|
@@ -7165,6 +7506,7 @@ var AGENT_METHODS = /* @__PURE__ */ new Set([
|
|
|
7165
7506
|
"reviews.list",
|
|
7166
7507
|
"reviews.get",
|
|
7167
7508
|
"reviews.open",
|
|
7509
|
+
"reviews.openLocal",
|
|
7168
7510
|
"reviews.refresh",
|
|
7169
7511
|
"reviews.remoteList",
|
|
7170
7512
|
"versions.list",
|
|
@@ -7394,6 +7736,14 @@ async function dispatch(service, method, params, policy = HUMAN_POLICY) {
|
|
|
7394
7736
|
});
|
|
7395
7737
|
return { review: service.getView(review.id), reviews: service.listReviews() };
|
|
7396
7738
|
}
|
|
7739
|
+
case "reviews.openLocal": {
|
|
7740
|
+
const root = String(params.root ?? "");
|
|
7741
|
+
if (!root) throw new MrReviewError("\u043D\u0443\u0436\u0435\u043D root \u0440\u0430\u0431\u043E\u0447\u0435\u0439 \u043A\u043E\u043F\u0438\u0438");
|
|
7742
|
+
const review = await service.openLocal(root, {
|
|
7743
|
+
...typeof params.base === "string" && params.base.trim() ? { base: params.base.trim() } : {}
|
|
7744
|
+
});
|
|
7745
|
+
return { review: service.getView(review.id) };
|
|
7746
|
+
}
|
|
7397
7747
|
case "reviews.refresh": {
|
|
7398
7748
|
const review = await service.refreshReview(String(params.review ?? ""), policy.name);
|
|
7399
7749
|
return { review: service.getView(review.id), reviews: service.listReviews() };
|