revdeck 0.5.0 → 0.6.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 +58 -1
- package/README.md +57 -8
- package/README.ru.md +58 -11
- package/dist/cli.js +1202 -481
- package/dist/cli.js.map +4 -4
- package/dist/daemon.js +1389 -203
- package/dist/daemon.js.map +4 -4
- package/dist/mcp.js +947 -112
- package/dist/mcp.js.map +4 -4
- package/dist/ui/assets/index-BH0dNFhd.css +1 -0
- package/dist/ui/assets/index-Wz1DYbiv.js +14 -0
- package/dist/ui/index.html +2 -2
- package/docs/README.md +1 -1
- package/docs/architecture.md +51 -6
- package/docs/capabilities.md +227 -0
- package/docs/configuration.md +63 -0
- package/docs/integrations.md +35 -0
- package/docs/protocol.md +52 -2
- package/docs/ru/README.md +1 -1
- package/docs/ru/architecture.md +51 -5
- package/docs/ru/capabilities.md +227 -0
- package/docs/ru/configuration.md +54 -0
- package/docs/ru/integrations.md +36 -0
- package/docs/ru/protocol.md +51 -2
- package/docs/ru/threat-model.md +28 -0
- package/docs/screenshot.png +0 -0
- package/docs/screenshot.ru.png +0 -0
- package/docs/threat-model.md +29 -0
- package/examples/analytics-platform.yml +40 -0
- package/examples/monorepo.yml +1 -1
- package/package.json +1 -1
- package/skills/revdeck/en/Feature.md +61 -0
- package/skills/revdeck/en/SKILL.md +17 -1
- package/skills/revdeck/ru/Feature.md +61 -0
- package/skills/revdeck/ru/SKILL.md +18 -1
- package/dist/ui/assets/index-CcmcJhhu.css +0 -1
- package/dist/ui/assets/index-CuvK5owY.js +0 -10
- package/docs/adr/0001-daemon-first.md +0 -65
- package/docs/ru/adr/0001-daemon-first.md +0 -63
- package/examples/web-chat-core.yml +0 -45
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ var __esm = (fn, res, err) => function __init() {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/core/paths.ts
|
|
13
|
-
import { existsSync } from "node:fs";
|
|
13
|
+
import { constants, existsSync } from "node:fs";
|
|
14
14
|
import { lstat, mkdir, open, realpath, rename, unlink } from "node:fs/promises";
|
|
15
15
|
import path from "node:path";
|
|
16
16
|
import os from "node:os";
|
|
@@ -79,18 +79,31 @@ async function ensureDir(dir, mode = 448) {
|
|
|
79
79
|
await chmod(dir, mode);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
function isInside(root, target) {
|
|
83
|
+
const relative = path.relative(path.resolve(root), path.resolve(target));
|
|
84
|
+
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
85
|
+
}
|
|
82
86
|
async function readTextNoFollow(file, maxBytes = 4 * 1024 * 1024) {
|
|
83
87
|
const info = await lstat(file);
|
|
84
88
|
if (info.isSymbolicLink()) throw new Error(`${path.basename(file)}: symbolic link, read refused`);
|
|
85
89
|
if (!info.isFile()) throw new Error(`${path.basename(file)}: not a regular file`);
|
|
86
90
|
if (info.size > maxBytes) throw new Error(`${path.basename(file)}: file is larger than ${Math.round(maxBytes / 1024)} KB`);
|
|
87
|
-
const
|
|
91
|
+
const flags = process.platform === "win32" ? "r" : constants.O_RDONLY | constants.O_NOFOLLOW;
|
|
92
|
+
const handle = await open(file, flags);
|
|
88
93
|
try {
|
|
89
94
|
return await handle.readFile({ encoding: "utf8" });
|
|
90
95
|
} finally {
|
|
91
96
|
await handle.close();
|
|
92
97
|
}
|
|
93
98
|
}
|
|
99
|
+
async function resolveInsideRoot(root, target) {
|
|
100
|
+
const realRoot = await realpath(path.resolve(root));
|
|
101
|
+
const realTarget = await realpath(path.resolve(target));
|
|
102
|
+
if (!isInside(realRoot, realTarget)) {
|
|
103
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
104
|
+
}
|
|
105
|
+
return realTarget;
|
|
106
|
+
}
|
|
94
107
|
function packageRoot() {
|
|
95
108
|
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
96
109
|
for (; ; ) {
|
|
@@ -110,6 +123,97 @@ var init_paths = __esm({
|
|
|
110
123
|
}
|
|
111
124
|
});
|
|
112
125
|
|
|
126
|
+
// src/core/errors.ts
|
|
127
|
+
var MrReviewError, ConfigError, ProviderError;
|
|
128
|
+
var init_errors = __esm({
|
|
129
|
+
"src/core/errors.ts"() {
|
|
130
|
+
"use strict";
|
|
131
|
+
MrReviewError = class extends Error {
|
|
132
|
+
code;
|
|
133
|
+
hint;
|
|
134
|
+
constructor(message, code = "REVDECK_ERROR", hint) {
|
|
135
|
+
super(message);
|
|
136
|
+
this.name = "MrReviewError";
|
|
137
|
+
this.code = code;
|
|
138
|
+
this.hint = hint;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
ConfigError = class extends MrReviewError {
|
|
142
|
+
constructor(message, hint) {
|
|
143
|
+
super(message, "CONFIG", hint);
|
|
144
|
+
this.name = "ConfigError";
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
ProviderError = class extends MrReviewError {
|
|
148
|
+
constructor(message, hint) {
|
|
149
|
+
super(message, "PROVIDER", hint);
|
|
150
|
+
this.name = "ProviderError";
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// src/core/glob.ts
|
|
157
|
+
function globToRegExp(glob) {
|
|
158
|
+
let source = "";
|
|
159
|
+
let index = 0;
|
|
160
|
+
const pattern = glob.replace(/^\.\//, "").replace(/^\/+/, "");
|
|
161
|
+
while (index < pattern.length) {
|
|
162
|
+
const char = pattern[index];
|
|
163
|
+
if (char === "*") {
|
|
164
|
+
if (pattern[index + 1] === "*") {
|
|
165
|
+
if (pattern[index + 2] === "/") {
|
|
166
|
+
source += "(?:[^/]+/)*";
|
|
167
|
+
index += 3;
|
|
168
|
+
} else {
|
|
169
|
+
source += ".*";
|
|
170
|
+
index += 2;
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
source += "[^/]*";
|
|
174
|
+
index += 1;
|
|
175
|
+
}
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (char === "?") {
|
|
179
|
+
source += "[^/]";
|
|
180
|
+
index += 1;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (char === "{") {
|
|
184
|
+
const end = pattern.indexOf("}", index);
|
|
185
|
+
if (end > index) {
|
|
186
|
+
const options = pattern.slice(index + 1, end).split(",").map((item) => escapeRegExp(item.trim()));
|
|
187
|
+
source += `(?:${options.join("|")})`;
|
|
188
|
+
index = end + 1;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
source += escapeRegExp(char);
|
|
193
|
+
index += 1;
|
|
194
|
+
}
|
|
195
|
+
return new RegExp(`^${source}$`);
|
|
196
|
+
}
|
|
197
|
+
function escapeRegExp(value) {
|
|
198
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
199
|
+
}
|
|
200
|
+
function classifyFile(path11) {
|
|
201
|
+
const lower = path11.toLowerCase();
|
|
202
|
+
if (/(^|\/)(node_modules|dist|build|coverage|vendor)\//.test(lower)) return "generated";
|
|
203
|
+
if (/\.(md|mdx|rst|txt|adoc)$/.test(lower) || /(^|\/)(docs?|adr)\//.test(lower)) return "docs";
|
|
204
|
+
if (/(^|\/)(__tests__|tests?|spec|e2e)\//.test(lower) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /_test\.go$/.test(lower)) return "test";
|
|
205
|
+
if (/\.(css|scss|sass|less|styl)$/.test(lower)) return "style";
|
|
206
|
+
if (/(^|\/)(package(-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|tsconfig[^/]*\.json|[^/]*\.config\.[cm]?[jt]s|\.eslintrc[^/]*|\.prettierrc[^/]*|Dockerfile|Makefile|\.github\/workflows\/|\.gitlab-ci\.yml)/.test(lower)) return "config";
|
|
207
|
+
if (/\.(generated|g)\.[cm]?[jt]s$|\.d\.ts$|(^|\/)generated\//.test(lower)) return "generated";
|
|
208
|
+
if (/\.(ts|tsx|js|jsx|mjs|cjs|vue|svelte|py|go|rs|java|kt|rb|php|cs|c|cpp|h|hpp|swift|scala|ex|exs)$/.test(lower)) return "app";
|
|
209
|
+
return "other";
|
|
210
|
+
}
|
|
211
|
+
var init_glob = __esm({
|
|
212
|
+
"src/core/glob.ts"() {
|
|
213
|
+
"use strict";
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
113
217
|
// src/core/locale.ts
|
|
114
218
|
function detectLocale(explicit) {
|
|
115
219
|
const value = (explicit ?? process.env.REVDECK_LANG ?? process.env.LC_ALL ?? process.env.LANG ?? "").toLowerCase();
|
|
@@ -278,6 +382,205 @@ var init_review_roles = __esm({
|
|
|
278
382
|
}
|
|
279
383
|
});
|
|
280
384
|
|
|
385
|
+
// src/core/config.ts
|
|
386
|
+
import { z } from "zod";
|
|
387
|
+
import { parse as parseYaml } from "yaml";
|
|
388
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
389
|
+
import path2 from "node:path";
|
|
390
|
+
function isRecord(value) {
|
|
391
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
392
|
+
}
|
|
393
|
+
function parseYamlData(text, source) {
|
|
394
|
+
try {
|
|
395
|
+
return parseYaml(text);
|
|
396
|
+
} catch (error) {
|
|
397
|
+
throw new ConfigError(tr(`${source}: \u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 YAML: ${error.message}`, `${source}: invalid YAML: ${error.message}`));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function mergeConfigData(base, local) {
|
|
401
|
+
if (!isRecord(base) || !isRecord(local)) return local;
|
|
402
|
+
const result = { ...base };
|
|
403
|
+
for (const [key, value] of Object.entries(local)) {
|
|
404
|
+
const current2 = result[key];
|
|
405
|
+
result[key] = isRecord(current2) && isRecord(value) ? mergeConfigData(current2, value) : value;
|
|
406
|
+
}
|
|
407
|
+
return result;
|
|
408
|
+
}
|
|
409
|
+
async function loadConfig(root = findRepoRoot()) {
|
|
410
|
+
const warnings = [];
|
|
411
|
+
const file = findConfigFile(root);
|
|
412
|
+
const localFile = findLocalConfigFile(root);
|
|
413
|
+
const baseData = file ? parseYamlData(await readTextNoFollow(file), path2.relative(root, file) || file) : {};
|
|
414
|
+
const localData = localFile ? parseYamlData(await readTextNoFollow(localFile), path2.relative(root, localFile) || localFile) : {};
|
|
415
|
+
if (!file && !localFile) {
|
|
416
|
+
warnings.push(tr("\u0444\u0430\u0439\u043B .revdeck.yml \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u043F\u0440\u0430\u0432\u0438\u043B\u0430 \u0432\u0437\u044F\u0442\u044B \u0438\u0437 \u0430\u0432\u0442\u043E\u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432", ".revdeck.yml not found: rules come from auto-discovered documents"));
|
|
417
|
+
}
|
|
418
|
+
const merged = mergeConfigData(baseData, localData);
|
|
419
|
+
const config2 = reviewConfigSchema.parse(merged);
|
|
420
|
+
const baseReadOnly = isRecord(baseData) && isRecord(baseData.review) && baseData.review.readOnly === true;
|
|
421
|
+
const localReadOnly = isRecord(localData) && isRecord(localData.review) && localData.review.readOnly === true;
|
|
422
|
+
config2.review.readOnly = baseReadOnly || localReadOnly;
|
|
423
|
+
if (!config2.rules.sources.length && !config2.rules.map.length) {
|
|
424
|
+
const found = DISCOVERED_SOURCES.filter((item) => existsSync2(path2.join(root, item)));
|
|
425
|
+
config2.rules.sources = found;
|
|
426
|
+
if (!found.length) {
|
|
427
|
+
warnings.push(tr("\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u044B \u0441 \u043F\u0440\u0430\u0432\u0438\u043B\u0430\u043C\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B: \u0440\u0435\u0432\u044C\u044E \u0431\u0443\u0434\u0435\u0442 \u043E\u043F\u0438\u0440\u0430\u0442\u044C\u0441\u044F \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \u043A\u043E\u0434 \u0438 \u0437\u0434\u0440\u0430\u0432\u044B\u0439 \u0441\u043C\u044B\u0441\u043B", "no rule documents found: the review will rely on the code only"));
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
config: config2,
|
|
432
|
+
path: file,
|
|
433
|
+
localPath: localFile,
|
|
434
|
+
warnings
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function assertConfigPath(root, relative) {
|
|
438
|
+
const cleaned = relative.split("#")[0];
|
|
439
|
+
const resolved = path2.resolve(root, cleaned);
|
|
440
|
+
const rel = path2.relative(root, resolved);
|
|
441
|
+
if (rel.startsWith("..") || path2.isAbsolute(rel)) {
|
|
442
|
+
throw new ConfigError(tr(`\u043F\u0443\u0442\u044C ${relative} \u0432\u044B\u0445\u043E\u0434\u0438\u0442 \u0437\u0430 \u043F\u0440\u0435\u0434\u0435\u043B\u044B \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F`, `path ${relative} escapes the repository`));
|
|
443
|
+
}
|
|
444
|
+
return resolved;
|
|
445
|
+
}
|
|
446
|
+
async function readConfigFile(root, relative, maxBytes = 4 * 1024 * 1024) {
|
|
447
|
+
const resolved = assertConfigPath(root, relative);
|
|
448
|
+
const actual = await resolveInsideRoot(root, resolved);
|
|
449
|
+
return readTextNoFollow(actual, maxBytes);
|
|
450
|
+
}
|
|
451
|
+
function checksForPaths(config2, paths) {
|
|
452
|
+
return config2.checks.map((check) => {
|
|
453
|
+
const matched = !check.when.length || paths.some((file) => check.when.some((pattern) => globToRegExp(pattern).test(file)));
|
|
454
|
+
return { id: check.id, name: check.name ?? check.id, argv: check.argv, consent: check.consent, matched };
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
var matchSchema, customRoleSchema, reviewConfigSchema, DISCOVERED_SOURCES;
|
|
458
|
+
var init_config = __esm({
|
|
459
|
+
"src/core/config.ts"() {
|
|
460
|
+
"use strict";
|
|
461
|
+
init_paths();
|
|
462
|
+
init_errors();
|
|
463
|
+
init_glob();
|
|
464
|
+
init_locale();
|
|
465
|
+
init_review_roles();
|
|
466
|
+
matchSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
467
|
+
customRoleSchema = z.object({
|
|
468
|
+
title: z.string().min(1).max(120),
|
|
469
|
+
description: z.string().min(1).max(2e3),
|
|
470
|
+
criteria: z.array(z.string().min(1).max(20)).max(20).default([]),
|
|
471
|
+
focus: z.string().max(2e3).optional(),
|
|
472
|
+
instructions: z.string().max(8e3).optional()
|
|
473
|
+
});
|
|
474
|
+
reviewConfigSchema = z.object({
|
|
475
|
+
version: z.literal(1).default(1),
|
|
476
|
+
provider: z.object({
|
|
477
|
+
/** auto — по git remote; иначе явная платформа. */
|
|
478
|
+
type: z.enum(["auto", "gitlab", "github"]).default("auto"),
|
|
479
|
+
host: z.string().min(1).optional(),
|
|
480
|
+
/** GitLab: group/project. GitHub: owner/repo. */
|
|
481
|
+
project: z.string().min(1).optional(),
|
|
482
|
+
/** База для локального diff, когда ревью идёт по ветке. */
|
|
483
|
+
base: z.string().min(1).optional()
|
|
484
|
+
}).prefault({}),
|
|
485
|
+
output: z.object({
|
|
486
|
+
language: z.enum(["auto", "ru", "en"]).default("auto")
|
|
487
|
+
}).prefault({}),
|
|
488
|
+
context: z.object({
|
|
489
|
+
/** Документы о приложении: архитектура, интерфейсы, деплой. Не правила оценки. */
|
|
490
|
+
sources: z.array(z.string().min(1)).default([]),
|
|
491
|
+
/** 0 — использовать бюджет feature-контекста; иначе предел профиля проекта. */
|
|
492
|
+
maxBytes: z.number().int().nonnegative().default(0)
|
|
493
|
+
}).prefault({}),
|
|
494
|
+
review: z.object({
|
|
495
|
+
/** Сколько независимых ревьюеров запускать. */
|
|
496
|
+
agents: z.number().int().min(1).max(8).default(3),
|
|
497
|
+
/** Роли агентов; встроенные id или ключи customRoles. */
|
|
498
|
+
roles: z.array(z.string().min(1).max(64)).min(1).max(10).default([...DEFAULT_REVIEW_ROLES]),
|
|
499
|
+
/** Пользовательские роли с описанием и инструкциями. */
|
|
500
|
+
customRoles: z.record(z.string().min(1).max(64), customRoleSchema).default({}),
|
|
501
|
+
/** Явные группы изменений; остальные группируются по типу и модулю. */
|
|
502
|
+
groups: z.array(
|
|
503
|
+
z.object({
|
|
504
|
+
id: z.string().min(1).max(64),
|
|
505
|
+
title: z.string().min(1).max(120),
|
|
506
|
+
match: matchSchema
|
|
507
|
+
})
|
|
508
|
+
).max(100).default([]),
|
|
509
|
+
/** Опциональный скан секретов; по умолчанию выключен. */
|
|
510
|
+
secrets: z.object({
|
|
511
|
+
enabled: z.boolean().default(false),
|
|
512
|
+
scan: z.enum(["diff", "files", "both"]).default("diff"),
|
|
513
|
+
includeTests: z.boolean().default(false),
|
|
514
|
+
/** Glob-пути или id правила (`rule:generic-secret`). */
|
|
515
|
+
allowlist: z.array(z.string().min(1)).default([])
|
|
516
|
+
}).prefault({}),
|
|
517
|
+
/** История версий ревью (снимки по commit SHA). */
|
|
518
|
+
history: z.object({
|
|
519
|
+
enabled: z.boolean().default(false),
|
|
520
|
+
keep: z.number().int().min(1).max(100).default(20)
|
|
521
|
+
}).prefault({}),
|
|
522
|
+
/** Запрет любых изменений: drafts, findings, публикация. */
|
|
523
|
+
readOnly: z.boolean().default(false)
|
|
524
|
+
}).prefault({}).superRefine((value, ctx) => {
|
|
525
|
+
for (const key of Object.keys(value.customRoles)) {
|
|
526
|
+
if (REVIEW_ROLE_IDS.includes(key)) {
|
|
527
|
+
ctx.addIssue({ code: "custom", path: ["customRoles", key], message: `role ${key} is built in and cannot be overridden` });
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
for (const role of value.roles) {
|
|
531
|
+
if (!REVIEW_ROLE_IDS.includes(role) && !(role in value.customRoles)) {
|
|
532
|
+
ctx.addIssue({ code: "custom", path: ["roles"], message: `unknown role: ${role}` });
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}),
|
|
536
|
+
rules: z.object({
|
|
537
|
+
/** Общие документы, если ни одна строка map не подошла. Пусто — автообнаружение. */
|
|
538
|
+
sources: z.array(z.string().min(1)).default([]),
|
|
539
|
+
/** Привязка путей к документам: match — glob, docs — пути с необязательной секцией `#…`. */
|
|
540
|
+
map: z.array(
|
|
541
|
+
z.object({
|
|
542
|
+
match: matchSchema,
|
|
543
|
+
docs: z.array(z.string().min(1)).min(1),
|
|
544
|
+
note: z.string().optional()
|
|
545
|
+
})
|
|
546
|
+
).default([]),
|
|
547
|
+
/** Пути, которые не ревьюятся (сгенерированный код и т.п.). */
|
|
548
|
+
ignore: z.array(z.string().min(1)).default([]),
|
|
549
|
+
/** 0 — без ограничения; иначе документ обрезается до этого размера. */
|
|
550
|
+
maxDocumentBytes: z.number().int().nonnegative().default(0),
|
|
551
|
+
/** 0 — без ограничения; иначе общий контекст правил обрезается. */
|
|
552
|
+
maxTotalBytes: z.number().int().nonnegative().default(0)
|
|
553
|
+
}).prefault({}),
|
|
554
|
+
checks: z.array(
|
|
555
|
+
z.object({
|
|
556
|
+
id: z.string().min(1),
|
|
557
|
+
name: z.string().optional(),
|
|
558
|
+
/** argv без shell: первым идёт исполняемый файл. */
|
|
559
|
+
argv: z.array(z.string()).min(1),
|
|
560
|
+
/** Запускать, только если diff затронул эти glob-пути. */
|
|
561
|
+
when: z.array(z.string()).default([]),
|
|
562
|
+
consent: z.boolean().default(true),
|
|
563
|
+
timeoutMs: z.number().int().positive().max(36e5).default(3e5)
|
|
564
|
+
})
|
|
565
|
+
).default([]),
|
|
566
|
+
publish: z.object({
|
|
567
|
+
requireApproval: z.boolean().default(true),
|
|
568
|
+
maxComments: z.number().int().positive().max(200).default(50)
|
|
569
|
+
}).prefault({})
|
|
570
|
+
});
|
|
571
|
+
DISCOVERED_SOURCES = [
|
|
572
|
+
"AGENTS.md",
|
|
573
|
+
"CLAUDE.md",
|
|
574
|
+
"CONTRIBUTING.md",
|
|
575
|
+
"docs/ARCHITECTURE.md",
|
|
576
|
+
"docs/Architecture.md",
|
|
577
|
+
"docs/STYLEGUIDE.md",
|
|
578
|
+
"docs/Styleguide.md",
|
|
579
|
+
"docs/CONTRIBUTING.md"
|
|
580
|
+
];
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
|
|
281
584
|
// src/core/redact.ts
|
|
282
585
|
function redact(value) {
|
|
283
586
|
let text = String(value ?? "").replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, " ");
|
|
@@ -313,7 +616,7 @@ var VERSION;
|
|
|
313
616
|
var init_version = __esm({
|
|
314
617
|
"src/version.ts"() {
|
|
315
618
|
"use strict";
|
|
316
|
-
VERSION = "0.
|
|
619
|
+
VERSION = "0.6.0";
|
|
317
620
|
}
|
|
318
621
|
});
|
|
319
622
|
|
|
@@ -563,6 +866,212 @@ var init_client = __esm({
|
|
|
563
866
|
}
|
|
564
867
|
});
|
|
565
868
|
|
|
869
|
+
// src/core/exec.ts
|
|
870
|
+
import { execFile } from "node:child_process";
|
|
871
|
+
import { access, constants as constants2 } from "node:fs/promises";
|
|
872
|
+
import os2 from "node:os";
|
|
873
|
+
import path5 from "node:path";
|
|
874
|
+
function scrubEnv(extra) {
|
|
875
|
+
const env = {};
|
|
876
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
877
|
+
if (SECRET_ENV.includes(key)) continue;
|
|
878
|
+
env[key] = value;
|
|
879
|
+
}
|
|
880
|
+
env.PAGER = "cat";
|
|
881
|
+
env.GIT_PAGER = "cat";
|
|
882
|
+
env.GIT_TERMINAL_PROMPT = "0";
|
|
883
|
+
env.NO_COLOR = "1";
|
|
884
|
+
env.CLICOLOR = "0";
|
|
885
|
+
env.FORCE_COLOR = "0";
|
|
886
|
+
env.TERM = "dumb";
|
|
887
|
+
return { ...env, ...extra };
|
|
888
|
+
}
|
|
889
|
+
async function resolveExecutable(command) {
|
|
890
|
+
if (command.includes("/") || command.includes("\\")) {
|
|
891
|
+
try {
|
|
892
|
+
await access(command, constants2.X_OK);
|
|
893
|
+
return command;
|
|
894
|
+
} catch {
|
|
895
|
+
return null;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
const override = process.env[`REVDECK_${command.toUpperCase()}`];
|
|
899
|
+
if (override) return override;
|
|
900
|
+
const cached = RESOLVED.get(command);
|
|
901
|
+
if (cached) return cached;
|
|
902
|
+
const dirs = [
|
|
903
|
+
...(process.env.PATH ?? "").split(path5.delimiter),
|
|
904
|
+
path5.join(os2.homedir(), ".local", "bin"),
|
|
905
|
+
path5.join(os2.homedir(), ".local", "share", "mise", "shims"),
|
|
906
|
+
path5.join(os2.homedir(), ".asdf", "shims"),
|
|
907
|
+
path5.join(os2.homedir(), ".npm-global", "bin"),
|
|
908
|
+
"/opt/homebrew/bin",
|
|
909
|
+
"/usr/local/bin",
|
|
910
|
+
"/usr/bin",
|
|
911
|
+
"/bin"
|
|
912
|
+
].filter(Boolean);
|
|
913
|
+
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
914
|
+
for (const dir of [...new Set(dirs)]) {
|
|
915
|
+
for (const extension of extensions) {
|
|
916
|
+
const candidate = path5.join(dir, `${command}${extension}`);
|
|
917
|
+
try {
|
|
918
|
+
await access(candidate, constants2.X_OK);
|
|
919
|
+
RESOLVED.set(command, candidate);
|
|
920
|
+
return candidate;
|
|
921
|
+
} catch {
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
var SECRET_ENV, RESOLVED, run;
|
|
928
|
+
var init_exec = __esm({
|
|
929
|
+
"src/core/exec.ts"() {
|
|
930
|
+
"use strict";
|
|
931
|
+
SECRET_ENV = [
|
|
932
|
+
"GITLAB_TOKEN",
|
|
933
|
+
"GITLAB_PRIVATE_TOKEN",
|
|
934
|
+
"GLAB_TOKEN",
|
|
935
|
+
"CI_JOB_TOKEN",
|
|
936
|
+
"GH_TOKEN",
|
|
937
|
+
"GITHUB_TOKEN",
|
|
938
|
+
"GITHUB_ENTERPRISE_TOKEN",
|
|
939
|
+
"GIT_ASKPASS",
|
|
940
|
+
"SSH_ASKPASS",
|
|
941
|
+
"REVDECK_TOKEN"
|
|
942
|
+
];
|
|
943
|
+
RESOLVED = /* @__PURE__ */ new Map();
|
|
944
|
+
run = async (command, args, options = {}) => {
|
|
945
|
+
const executable = await resolveExecutable(command) ?? command;
|
|
946
|
+
return new Promise((resolve, reject) => {
|
|
947
|
+
const child = execFile(
|
|
948
|
+
executable,
|
|
949
|
+
args,
|
|
950
|
+
{
|
|
951
|
+
cwd: options.cwd,
|
|
952
|
+
env: scrubEnv(options.env),
|
|
953
|
+
timeout: options.timeoutMs ?? 12e4,
|
|
954
|
+
maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
|
|
955
|
+
encoding: "utf8",
|
|
956
|
+
windowsHide: true,
|
|
957
|
+
shell: false
|
|
958
|
+
},
|
|
959
|
+
(error, stdout, stderr) => {
|
|
960
|
+
const exitCode = error?.code;
|
|
961
|
+
const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
|
|
962
|
+
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
963
|
+
const reason = (stderr || stdout || error.message).trim();
|
|
964
|
+
reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
resolve({ stdout, stderr, code });
|
|
968
|
+
}
|
|
969
|
+
);
|
|
970
|
+
if (options.input !== void 0) {
|
|
971
|
+
child.stdin?.end(options.input);
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
// src/core/git.ts
|
|
979
|
+
function parseRemote(url) {
|
|
980
|
+
const value = url.trim();
|
|
981
|
+
if (!value) return null;
|
|
982
|
+
let host = "";
|
|
983
|
+
let projectPath = "";
|
|
984
|
+
const http = /^(?:https?|git|ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+?)(?:\.git)?\/?$/.exec(value);
|
|
985
|
+
if (http) {
|
|
986
|
+
host = http[1];
|
|
987
|
+
projectPath = http[2];
|
|
988
|
+
} else {
|
|
989
|
+
const scp = SSH_SCP.exec(value);
|
|
990
|
+
if (!scp) return null;
|
|
991
|
+
host = scp[1];
|
|
992
|
+
projectPath = scp[3];
|
|
993
|
+
}
|
|
994
|
+
projectPath = projectPath.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
995
|
+
if (!host || !projectPath || !projectPath.includes("/")) return null;
|
|
996
|
+
return { host, project: projectPath, platform: detectPlatform(host), url: value };
|
|
997
|
+
}
|
|
998
|
+
function detectPlatform(host) {
|
|
999
|
+
const lower = host.toLowerCase();
|
|
1000
|
+
if (lower === "github.com" || lower.endsWith(".github.com") || lower.includes("github")) return "github";
|
|
1001
|
+
if (lower === "gitlab.com" || lower.endsWith(".gitlab.com") || lower.includes("gitlab")) return "gitlab";
|
|
1002
|
+
return null;
|
|
1003
|
+
}
|
|
1004
|
+
async function gitRemote(root, remote = "origin") {
|
|
1005
|
+
try {
|
|
1006
|
+
const { stdout } = await run("git", ["config", "--get", `remote.${remote}.url`], { cwd: root, timeoutMs: 1e4 });
|
|
1007
|
+
return parseRemote(stdout.trim());
|
|
1008
|
+
} catch {
|
|
1009
|
+
return null;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
var SSH_SCP;
|
|
1013
|
+
var init_git = __esm({
|
|
1014
|
+
"src/core/git.ts"() {
|
|
1015
|
+
"use strict";
|
|
1016
|
+
init_exec();
|
|
1017
|
+
SSH_SCP = /^(?:ssh:\/\/)?(?:[^@/]+@)?([^:/]+)(?::(\d+))?[:/](.+?)(?:\.git)?\/?$/;
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1021
|
+
// src/core/types.ts
|
|
1022
|
+
var init_types = __esm({
|
|
1023
|
+
"src/core/types.ts"() {
|
|
1024
|
+
"use strict";
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
// src/core/refs.ts
|
|
1029
|
+
function reviewId(ref) {
|
|
1030
|
+
return `${ref.platform}:${ref.host}/${ref.project}!${ref.number}`;
|
|
1031
|
+
}
|
|
1032
|
+
function parseReviewId(id) {
|
|
1033
|
+
const match = /^(gitlab|github):([^/]+)\/(.+)!(\d+)$/.exec(id);
|
|
1034
|
+
if (!match) throw new Error(`invalid review id: ${id}`);
|
|
1035
|
+
return {
|
|
1036
|
+
platform: match[1],
|
|
1037
|
+
host: match[2],
|
|
1038
|
+
project: match[3],
|
|
1039
|
+
number: Number(match[4])
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
function parseReviewUrl(input) {
|
|
1043
|
+
const value = input.trim();
|
|
1044
|
+
const gitlab = GITLAB_URL.exec(value);
|
|
1045
|
+
if (gitlab) {
|
|
1046
|
+
return { platform: "gitlab", host: gitlab[1], project: gitlab[2], number: Number(gitlab[3]) };
|
|
1047
|
+
}
|
|
1048
|
+
const github = GITHUB_URL.exec(value);
|
|
1049
|
+
if (github) {
|
|
1050
|
+
return { platform: "github", host: github[1], project: github[2], number: Number(github[3]) };
|
|
1051
|
+
}
|
|
1052
|
+
const short = /^(.+?)([#!])(\d+)$/.exec(value);
|
|
1053
|
+
if (short) {
|
|
1054
|
+
return {
|
|
1055
|
+
platform: short[2] === "!" ? "gitlab" : "github",
|
|
1056
|
+
host: short[2] === "!" ? "gitlab.com" : "github.com",
|
|
1057
|
+
project: short[1],
|
|
1058
|
+
number: Number(short[3])
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
throw new Error(
|
|
1062
|
+
"could not parse the MR/PR reference: expected https://<host>/<project>/-/merge_requests/<N> or https://<host>/<owner>/<repo>/pull/<N>, or project!N / owner/repo#N"
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
var GITLAB_URL, GITHUB_URL;
|
|
1066
|
+
var init_refs = __esm({
|
|
1067
|
+
"src/core/refs.ts"() {
|
|
1068
|
+
"use strict";
|
|
1069
|
+
init_types();
|
|
1070
|
+
GITLAB_URL = /^(?:https?:\/\/)?([^/]+)\/(.+?)\/-\/merge_requests\/(\d+)(?:[/?#].*)?$/;
|
|
1071
|
+
GITHUB_URL = /^(?:https?:\/\/)?([^/]+)\/([^/]+\/[^/]+)\/pull\/(\d+)(?:[/?#].*)?$/;
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
|
|
566
1075
|
// src/cli/format.ts
|
|
567
1076
|
function printJson(value) {
|
|
568
1077
|
writers.out(JSON.stringify(value, null, 2));
|
|
@@ -823,6 +1332,146 @@ var init_context = __esm({
|
|
|
823
1332
|
}
|
|
824
1333
|
});
|
|
825
1334
|
|
|
1335
|
+
// src/core/projects.ts
|
|
1336
|
+
function projectKey(ref) {
|
|
1337
|
+
return `${ref.platform}:${ref.host.trim().toLowerCase()}/${ref.project.trim().toLowerCase()}`;
|
|
1338
|
+
}
|
|
1339
|
+
function projectTitle(project) {
|
|
1340
|
+
const parts = project.split("/").filter(Boolean);
|
|
1341
|
+
return parts[parts.length - 1] ?? project;
|
|
1342
|
+
}
|
|
1343
|
+
var init_projects = __esm({
|
|
1344
|
+
"src/core/projects.ts"() {
|
|
1345
|
+
"use strict";
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
|
|
1349
|
+
// src/providers/provider.ts
|
|
1350
|
+
async function projectContext(root, config2, overrides = {}) {
|
|
1351
|
+
const remote = await gitRemote(root);
|
|
1352
|
+
const platform = overrides.platform ?? (config2.provider.type !== "auto" ? config2.provider.type : remote?.platform ?? void 0);
|
|
1353
|
+
const host = overrides.host ?? config2.provider.host ?? remote?.host;
|
|
1354
|
+
const project = overrides.project ?? config2.provider.project ?? remote?.project;
|
|
1355
|
+
if (!platform) {
|
|
1356
|
+
throw new ProviderError(
|
|
1357
|
+
tr("\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u044C \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0443: \u0443\u043A\u0430\u0436\u0438\u0442\u0435 provider.type \u0432 .revdeck.yml \u0438\u043B\u0438 --platform", "could not determine the platform: set provider.type in .revdeck.yml or pass --platform"),
|
|
1358
|
+
tr("git remote \u043D\u0435 \u043F\u043E\u0445\u043E\u0436 \u043D\u0430 GitHub/GitLab (\u0441\u0430\u043C\u043E\u0441\u0442\u043E\u044F\u0442\u0435\u043B\u044C\u043D\u044B\u0439 \u0445\u043E\u0441\u0442 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u0435 \u044F\u0432\u043D\u043E)", "git remote does not look like GitHub/GitLab (set a self-hosted platform explicitly)")
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
if (!host || !project) {
|
|
1362
|
+
throw new ProviderError(tr("\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u044C \u0445\u043E\u0441\u0442 \u0438 \u043F\u0440\u043E\u0435\u043A\u0442", "could not determine host and project"), tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 project \u0438 host \u0432 .revdeck.yml \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 URL \u0440\u0435\u0432\u044C\u044E", "set project and host in .revdeck.yml or pass the review URL"));
|
|
1363
|
+
}
|
|
1364
|
+
return { platform, host, project };
|
|
1365
|
+
}
|
|
1366
|
+
var init_provider = __esm({
|
|
1367
|
+
"src/providers/provider.ts"() {
|
|
1368
|
+
"use strict";
|
|
1369
|
+
init_git();
|
|
1370
|
+
init_errors();
|
|
1371
|
+
init_refs();
|
|
1372
|
+
init_locale();
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
|
|
1376
|
+
// src/mcp/scope.ts
|
|
1377
|
+
async function resolveScope(rootInput) {
|
|
1378
|
+
const root = findRepoRoot(rootInput);
|
|
1379
|
+
const loaded = await loadConfig(root);
|
|
1380
|
+
const context2 = await projectContext(root, loaded.config);
|
|
1381
|
+
return {
|
|
1382
|
+
root,
|
|
1383
|
+
...context2,
|
|
1384
|
+
key: projectKey(context2),
|
|
1385
|
+
title: projectTitle(context2.project)
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
function reviewRefFromInput(input) {
|
|
1389
|
+
const value = input.trim();
|
|
1390
|
+
if (!value || /^\d+$/.test(value)) return null;
|
|
1391
|
+
if (/^(gitlab|github):/.test(value)) {
|
|
1392
|
+
try {
|
|
1393
|
+
return parseReviewId(value);
|
|
1394
|
+
} catch {
|
|
1395
|
+
return null;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
if (value.includes("/") || /[#!]\d+$/.test(value)) {
|
|
1399
|
+
try {
|
|
1400
|
+
return parseReviewUrl(value);
|
|
1401
|
+
} catch {
|
|
1402
|
+
return null;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
return null;
|
|
1406
|
+
}
|
|
1407
|
+
function featureReviewId(ref, scope2) {
|
|
1408
|
+
if (!scope2.feature) return null;
|
|
1409
|
+
for (const id of scope2.feature.reviewIds) {
|
|
1410
|
+
try {
|
|
1411
|
+
const member = parseReviewId(id);
|
|
1412
|
+
if (projectKey(member) === projectKey(ref) && member.number === ref.number) return id;
|
|
1413
|
+
} catch {
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
return null;
|
|
1417
|
+
}
|
|
1418
|
+
function assertReviewInScope(review, scope2) {
|
|
1419
|
+
const ref = reviewRefFromInput(review);
|
|
1420
|
+
if (scope2.feature) {
|
|
1421
|
+
if (!ref) {
|
|
1422
|
+
const error3 = new Error(
|
|
1423
|
+
tr(
|
|
1424
|
+
"\u0432 \u0441\u0435\u0441\u0441\u0438\u0438 \u0444\u0438\u0447\u0438 \u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043F\u043E\u043B\u043D\u044B\u0439 id \u0438\u043B\u0438 \u0441\u0441\u044B\u043B\u043A\u0443 \u043D\u0430 \u0440\u0435\u0432\u044C\u044E, \u0430 \u043D\u0435 \u043D\u043E\u043C\u0435\u0440",
|
|
1425
|
+
"in a feature session pass a full review id or URL, not a number"
|
|
1426
|
+
)
|
|
1427
|
+
);
|
|
1428
|
+
error3.hint = tr(
|
|
1429
|
+
"\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 id \u0438\u0437 revdeck_feature \u0438\u043B\u0438 revdeck_status.",
|
|
1430
|
+
"Use an id from revdeck_feature or revdeck_status."
|
|
1431
|
+
);
|
|
1432
|
+
throw error3;
|
|
1433
|
+
}
|
|
1434
|
+
const id = featureReviewId(ref, scope2) ?? reviewId(ref);
|
|
1435
|
+
if (featureReviewId(ref, scope2)) return;
|
|
1436
|
+
const error2 = new Error(
|
|
1437
|
+
tr(
|
|
1438
|
+
`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u0432\u0445\u043E\u0434\u0438\u0442 \u0432 \u0444\u0438\u0447\u0443 ${scope2.feature.id}`,
|
|
1439
|
+
`review ${id} is not a member of feature ${scope2.feature.id}`
|
|
1440
|
+
)
|
|
1441
|
+
);
|
|
1442
|
+
error2.hint = tr(
|
|
1443
|
+
"\u0424\u0438\u0447\u0430 \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0435\u043D\u0430 \u0442\u043E\u043B\u044C\u043A\u043E \u0441\u0432\u043E\u0438\u043C\u0438 \u0440\u0435\u0432\u044C\u044E. \u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u0440\u0435\u0432\u044C\u044E \u0432 \u0444\u0438\u0447\u0443 \u0432 UI \u0438\u043B\u0438 CLI.",
|
|
1444
|
+
"A feature session is limited to its reviews. Add the review in the UI or CLI."
|
|
1445
|
+
);
|
|
1446
|
+
throw error2;
|
|
1447
|
+
}
|
|
1448
|
+
if (!ref) return;
|
|
1449
|
+
if (projectKey(ref) === scope2.key) return;
|
|
1450
|
+
const error = new Error(
|
|
1451
|
+
tr(
|
|
1452
|
+
`\u0440\u0435\u0432\u044C\u044E ${ref.project}#${ref.number} \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0441\u044F \u043A \u043F\u0440\u043E\u0435\u043A\u0442\u0443 ${projectKey(ref)}, \u0430 \u044D\u0442\u0430 \u0441\u0435\u0441\u0441\u0438\u044F \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0435\u043D\u0430 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u043C ${scope2.key}`,
|
|
1453
|
+
`review ${ref.project}#${ref.number} belongs to project ${projectKey(ref)}, but this session is scoped to ${scope2.key}`
|
|
1454
|
+
)
|
|
1455
|
+
);
|
|
1456
|
+
error.hint = tr(
|
|
1457
|
+
"\u041E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u043E\u0442\u0434\u0435\u043B\u044C\u043D\u0443\u044E \u0441\u0435\u0441\u0441\u0438\u044E \u0432 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0438 \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u043E\u0435\u043A\u0442\u0430. \u041A\u0440\u043E\u0441\u0441-\u043F\u0440\u043E\u0435\u043A\u0442\u043D\u044B\u0439 \u0434\u043E\u0441\u0442\u0443\u043F \u043F\u043E\u044F\u0432\u0438\u0442\u0441\u044F \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0435\u0440\u0435\u0437 \u044F\u0432\u043D\u0443\u044E \u0444\u0438\u0447\u0443.",
|
|
1458
|
+
"Open a separate session in that repository. Cross-project access will only be available through an explicit feature."
|
|
1459
|
+
);
|
|
1460
|
+
throw error;
|
|
1461
|
+
}
|
|
1462
|
+
var init_scope = __esm({
|
|
1463
|
+
"src/mcp/scope.ts"() {
|
|
1464
|
+
"use strict";
|
|
1465
|
+
init_config();
|
|
1466
|
+
init_paths();
|
|
1467
|
+
init_projects();
|
|
1468
|
+
init_refs();
|
|
1469
|
+
init_refs();
|
|
1470
|
+
init_locale();
|
|
1471
|
+
init_provider();
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
|
|
826
1475
|
// src/mcp/main.ts
|
|
827
1476
|
var main_exports = {};
|
|
828
1477
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -832,6 +1481,48 @@ async function client() {
|
|
|
832
1481
|
if (!clientPromise) clientPromise = ensureDaemon().then((result) => result.client);
|
|
833
1482
|
return clientPromise;
|
|
834
1483
|
}
|
|
1484
|
+
async function scope() {
|
|
1485
|
+
if (!scopePromise) {
|
|
1486
|
+
scopePromise = (async () => {
|
|
1487
|
+
const base = await resolveScope(defaultRoot);
|
|
1488
|
+
if (!featureId) return base;
|
|
1489
|
+
const { feature: feature2 } = await call("features.get", { feature: featureId });
|
|
1490
|
+
if (!feature2.members.some((member) => member.review.projectKey === base.key)) {
|
|
1491
|
+
const error = new Error(
|
|
1492
|
+
tr(
|
|
1493
|
+
`\u0442\u0435\u043A\u0443\u0449\u0438\u0439 \u043F\u0440\u043E\u0435\u043A\u0442 ${base.key} \u043D\u0435 \u0432\u0445\u043E\u0434\u0438\u0442 \u0432 \u0444\u0438\u0447\u0443 ${feature2.id}`,
|
|
1494
|
+
`the current project ${base.key} is not a member of feature ${feature2.id}`
|
|
1495
|
+
)
|
|
1496
|
+
);
|
|
1497
|
+
error.hint = tr(
|
|
1498
|
+
"\u0417\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0435 feature-\u0441\u0435\u0441\u0441\u0438\u044E \u0438\u0437 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F, \u043A\u043E\u0442\u043E\u0440\u044B\u0439 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D \u0432 \u0444\u0438\u0447\u0443.",
|
|
1499
|
+
"Start the feature session from a repository that is part of the feature."
|
|
1500
|
+
);
|
|
1501
|
+
throw error;
|
|
1502
|
+
}
|
|
1503
|
+
return {
|
|
1504
|
+
...base,
|
|
1505
|
+
feature: { id: feature2.id, title: feature2.title, reviewIds: feature2.members.map((member) => member.review.id) }
|
|
1506
|
+
};
|
|
1507
|
+
})();
|
|
1508
|
+
}
|
|
1509
|
+
return scopePromise;
|
|
1510
|
+
}
|
|
1511
|
+
async function refreshFeatureScope(current2) {
|
|
1512
|
+
if (!current2.feature) return;
|
|
1513
|
+
const { feature: feature2 } = await call("features.get", {
|
|
1514
|
+
feature: current2.feature.id
|
|
1515
|
+
});
|
|
1516
|
+
if (!feature2.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1517
|
+
throw new Error(`the current project ${current2.key} is no longer a member of feature ${current2.feature.id}`);
|
|
1518
|
+
}
|
|
1519
|
+
current2.feature.reviewIds = feature2.members.map((member) => member.review.id);
|
|
1520
|
+
}
|
|
1521
|
+
async function scopedReview(review) {
|
|
1522
|
+
const current2 = await scope();
|
|
1523
|
+
await refreshFeatureScope(current2);
|
|
1524
|
+
assertReviewInScope(review, current2);
|
|
1525
|
+
}
|
|
835
1526
|
async function call(method, params = {}) {
|
|
836
1527
|
const current2 = await client();
|
|
837
1528
|
try {
|
|
@@ -878,33 +1569,66 @@ async function main() {
|
|
|
878
1569
|
process.stderr.write(`revdeck MCP ${VERSION} ${tr("\u0433\u043E\u0442\u043E\u0432", "ready")} (root: ${defaultRoot})
|
|
879
1570
|
`);
|
|
880
1571
|
}
|
|
881
|
-
var server, defaultRoot, clientPromise,
|
|
1572
|
+
var server, defaultRoot, featureId, clientPromise, scopePromise, reviewSchema;
|
|
882
1573
|
var init_main = __esm({
|
|
883
1574
|
"src/mcp/main.ts"() {
|
|
884
1575
|
"use strict";
|
|
885
1576
|
init_client();
|
|
886
1577
|
init_context();
|
|
887
1578
|
init_redact();
|
|
1579
|
+
init_paths();
|
|
888
1580
|
init_version();
|
|
889
1581
|
init_locale();
|
|
1582
|
+
init_scope();
|
|
1583
|
+
init_refs();
|
|
890
1584
|
setLocale(detectLocale());
|
|
891
1585
|
server = new McpServer({ name: "revdeck", version: VERSION });
|
|
892
|
-
defaultRoot = process.env.REVDECK_ROOT ?? process.cwd();
|
|
1586
|
+
defaultRoot = findRepoRoot(process.env.REVDECK_ROOT ?? process.cwd());
|
|
1587
|
+
featureId = process.env.REVDECK_FEATURE?.trim() || null;
|
|
893
1588
|
clientPromise = null;
|
|
894
|
-
|
|
895
|
-
|
|
1589
|
+
scopePromise = null;
|
|
1590
|
+
reviewSchema = z2.string().min(1).describe("Review: id (gitlab:host/project!42) or MR/PR URL; a bare number is accepted only in a project session");
|
|
896
1591
|
server.registerTool(
|
|
897
1592
|
"revdeck_status",
|
|
898
1593
|
{
|
|
899
1594
|
title: "revdeck status",
|
|
900
|
-
description: "Check that the daemon and provider are available, and list open reviews. Start here if you do not know a review id.",
|
|
1595
|
+
description: "Check that the daemon and provider are available, and list open reviews in the repository project this server is scoped to. Start here if you do not know a review id.",
|
|
901
1596
|
inputSchema: {}
|
|
902
1597
|
},
|
|
903
1598
|
async () => {
|
|
904
1599
|
try {
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
|
|
1600
|
+
const current2 = await scope();
|
|
1601
|
+
if (current2.feature) {
|
|
1602
|
+
const { feature: feature2 } = await call("features.get", { feature: current2.feature.id });
|
|
1603
|
+
if (!feature2.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1604
|
+
throw new Error(`the current project ${current2.key} is no longer a member of feature ${current2.feature.id}`);
|
|
1605
|
+
}
|
|
1606
|
+
const lines2 = feature2.members.map(
|
|
1607
|
+
(member) => `- ${member.review.id} \u2014 #${member.review.number} ${member.review.title} (${member.review.project}${member.role ? `, ${member.role}` : ""})`
|
|
1608
|
+
);
|
|
1609
|
+
return ok(
|
|
1610
|
+
[`revdeck daemon ${VERSION} is available.`, `Feature: ${feature2.title} (${feature2.id})`, ...lines2].join("\n"),
|
|
1611
|
+
{ feature: feature2.id, reviews: feature2.members.map((member) => member.review) }
|
|
1612
|
+
);
|
|
1613
|
+
}
|
|
1614
|
+
const { reviews } = await call(
|
|
1615
|
+
"reviews.list",
|
|
1616
|
+
{ project: current2.key }
|
|
1617
|
+
);
|
|
1618
|
+
const { features } = await call("features.list", { project: current2.key });
|
|
1619
|
+
const lines = reviews.length ? reviews.map((item) => `- ${item.id} \u2014 #${item.number} ${item.title} (${item.author})`) : ["No open reviews in this project."];
|
|
1620
|
+
const featureLines = features.length ? ["", "Features:", ...features.map((feature2) => `- ${feature2.id} \u2014 ${feature2.title} (${feature2.reviews} reviews)`)].join("\n") : "";
|
|
1621
|
+
return ok(
|
|
1622
|
+
[
|
|
1623
|
+
`revdeck daemon ${VERSION} is available.`,
|
|
1624
|
+
`Project: ${current2.key}`,
|
|
1625
|
+
...lines,
|
|
1626
|
+
featureLines,
|
|
1627
|
+
"",
|
|
1628
|
+
"Open one with revdeck_open and a number or URL."
|
|
1629
|
+
].join("\n"),
|
|
1630
|
+
{ project: current2.key, reviews, features }
|
|
1631
|
+
);
|
|
908
1632
|
} catch (error) {
|
|
909
1633
|
return failure(error);
|
|
910
1634
|
}
|
|
@@ -914,22 +1638,35 @@ var init_main = __esm({
|
|
|
914
1638
|
"revdeck_list",
|
|
915
1639
|
{
|
|
916
1640
|
title: "Review list",
|
|
917
|
-
description: "List reviews. scope=tracked \u2014 already opened locally; open/mine/reviewing query the platform
|
|
1641
|
+
description: "List reviews in the current repository project. scope=tracked \u2014 already opened locally; open/mine/reviewing query the platform for this project.",
|
|
918
1642
|
inputSchema: {
|
|
919
1643
|
scope: z2.enum(["tracked", "open", "mine", "reviewing"]).optional().describe("Defaults to tracked; open/mine/reviewing require platform access"),
|
|
920
|
-
limit: z2.number().int().positive().max(100).optional()
|
|
921
|
-
root: rootSchema
|
|
1644
|
+
limit: z2.number().int().positive().max(100).optional()
|
|
922
1645
|
}
|
|
923
1646
|
},
|
|
924
|
-
async ({ scope, limit
|
|
1647
|
+
async ({ scope: listScope, limit }) => {
|
|
925
1648
|
try {
|
|
926
|
-
|
|
927
|
-
|
|
1649
|
+
const current2 = await scope();
|
|
1650
|
+
if (current2.feature) {
|
|
1651
|
+
if (listScope && listScope !== "tracked") {
|
|
1652
|
+
return failure(new Error("remote review list is not available in a feature session"));
|
|
1653
|
+
}
|
|
1654
|
+
const { feature: feature2 } = await call("features.get", {
|
|
1655
|
+
feature: current2.feature.id
|
|
1656
|
+
});
|
|
1657
|
+
if (!feature2.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1658
|
+
throw new Error(`the current project ${current2.key} is no longer a member of feature ${current2.feature.id}`);
|
|
1659
|
+
}
|
|
1660
|
+
const reviews = feature2.members.map((member) => member.review);
|
|
1661
|
+
return ok(JSON.stringify(reviews, null, 2), { reviews });
|
|
1662
|
+
}
|
|
1663
|
+
if (!listScope || listScope === "tracked") {
|
|
1664
|
+
const { reviews } = await call("reviews.list", { project: current2.key });
|
|
928
1665
|
return ok(JSON.stringify(reviews, null, 2), { reviews });
|
|
929
1666
|
}
|
|
930
1667
|
const result = await call(
|
|
931
1668
|
"reviews.remoteList",
|
|
932
|
-
{ root: root
|
|
1669
|
+
{ root: current2.root, scope: listScope, limit: limit ?? 50 }
|
|
933
1670
|
);
|
|
934
1671
|
const text = result.items.map((item) => `#${item.ref.number} ${item.title} \xB7 ${item.author} \xB7 ${item.updatedAt}`).join("\n") || "Empty.";
|
|
935
1672
|
return ok(`${result.platform}:${result.project}
|
|
@@ -943,28 +1680,31 @@ ${text}`, result);
|
|
|
943
1680
|
"revdeck_open",
|
|
944
1681
|
{
|
|
945
1682
|
title: "Open review",
|
|
946
|
-
description: "Load one or more MR/PR by number or URL: description, diff, threads. Returns the id used by other tools.",
|
|
1683
|
+
description: "Load one or more MR/PR in the current repository project by number or URL: description, diff, threads. Returns the id used by other tools. A review from another project is rejected.",
|
|
947
1684
|
inputSchema: {
|
|
948
|
-
input: z2.union([z2.string().min(1), z2.array(z2.string().min(1)).min(1).max(8)]).describe("Number, URL, project!N, owner/repo#N, or an array of them")
|
|
949
|
-
root: rootSchema,
|
|
950
|
-
platform: z2.enum(["gitlab", "github"]).optional(),
|
|
951
|
-
project: z2.string().optional(),
|
|
952
|
-
host: z2.string().optional(),
|
|
953
|
-
branch: z2.string().optional()
|
|
1685
|
+
input: z2.union([z2.string().min(1), z2.array(z2.string().min(1)).min(1).max(8)]).describe("Number, URL, project!N, owner/repo#N, or an array of them; must belong to the current project")
|
|
954
1686
|
}
|
|
955
1687
|
},
|
|
956
|
-
async ({ input
|
|
1688
|
+
async ({ input }) => {
|
|
957
1689
|
try {
|
|
1690
|
+
const current2 = await scope();
|
|
1691
|
+
await refreshFeatureScope(current2);
|
|
958
1692
|
const inputs = Array.isArray(input) ? input : [input];
|
|
1693
|
+
for (const value of inputs) assertReviewInScope(value, current2);
|
|
959
1694
|
const reviews = [];
|
|
960
1695
|
for (const value of inputs) {
|
|
1696
|
+
if (current2.feature) {
|
|
1697
|
+
const ref = reviewRefFromInput(value);
|
|
1698
|
+
if (!ref) throw new Error("feature session requires a full review id or URL");
|
|
1699
|
+
const id = featureReviewId(ref, current2);
|
|
1700
|
+
if (!id) throw new Error(`review ${reviewId(ref)} is not a member of feature ${current2.feature.id}`);
|
|
1701
|
+
const result2 = await call("reviews.get", { review: id });
|
|
1702
|
+
reviews.push(result2.review);
|
|
1703
|
+
continue;
|
|
1704
|
+
}
|
|
961
1705
|
const result = await call("reviews.open", {
|
|
962
|
-
root: root
|
|
963
|
-
input: value
|
|
964
|
-
...platform ? { platform } : {},
|
|
965
|
-
...project ? { project } : {},
|
|
966
|
-
...host ? { host } : {},
|
|
967
|
-
...branch ? { branch } : {}
|
|
1706
|
+
root: current2.root,
|
|
1707
|
+
input: value
|
|
968
1708
|
});
|
|
969
1709
|
reviews.push(result.review);
|
|
970
1710
|
}
|
|
@@ -977,6 +1717,106 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
977
1717
|
}
|
|
978
1718
|
}
|
|
979
1719
|
);
|
|
1720
|
+
server.registerTool(
|
|
1721
|
+
"revdeck_feature",
|
|
1722
|
+
{
|
|
1723
|
+
title: "Feature context",
|
|
1724
|
+
description: "Read features created by the human. In a project session only features containing this project are visible; in a feature session the current feature is available. context returns the brief/contract and all member reviews. Features are read-only here; membership is changed by the human in the UI or CLI.",
|
|
1725
|
+
inputSchema: {
|
|
1726
|
+
action: z2.enum(["list", "get", "context", "notes"]).default("list"),
|
|
1727
|
+
feature: z2.string().optional().describe("Feature id; optional in a feature session"),
|
|
1728
|
+
max_bytes: z2.number().int().positive().max(5e5).optional()
|
|
1729
|
+
}
|
|
1730
|
+
},
|
|
1731
|
+
async ({ action, feature: requested, max_bytes }) => {
|
|
1732
|
+
try {
|
|
1733
|
+
const current2 = await scope();
|
|
1734
|
+
if (action === "list") {
|
|
1735
|
+
if (current2.feature) {
|
|
1736
|
+
const { feature: feature3 } = await call("features.get", { feature: current2.feature.id });
|
|
1737
|
+
if (!feature3.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1738
|
+
throw new Error(`the current project ${current2.key} is no longer a member of feature ${current2.feature.id}`);
|
|
1739
|
+
}
|
|
1740
|
+
return ok(JSON.stringify(feature3, null, 2), { feature: feature3 });
|
|
1741
|
+
}
|
|
1742
|
+
const { features } = await call("features.list", { project: current2.key });
|
|
1743
|
+
return ok(JSON.stringify(features, null, 2), { features });
|
|
1744
|
+
}
|
|
1745
|
+
const id = current2.feature?.id ?? requested;
|
|
1746
|
+
if (!id) throw new Error("feature id is required");
|
|
1747
|
+
if (current2.feature && id !== current2.feature.id) throw new Error(`this session is scoped to feature ${current2.feature.id}`);
|
|
1748
|
+
const { feature: feature2 } = await call("features.get", { feature: id });
|
|
1749
|
+
if (!feature2.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1750
|
+
throw new Error(`feature ${id} does not include project ${current2.key}`);
|
|
1751
|
+
}
|
|
1752
|
+
if (action === "get") return ok(JSON.stringify(feature2, null, 2), { feature: feature2 });
|
|
1753
|
+
if (action === "notes") return ok(JSON.stringify(feature2.notes, null, 2), { notes: feature2.notes });
|
|
1754
|
+
const result = await call("features.context", {
|
|
1755
|
+
feature: id,
|
|
1756
|
+
...max_bytes ? { maxBytes: max_bytes } : {}
|
|
1757
|
+
});
|
|
1758
|
+
return ok(result.markdown, { feature: result.feature, markdown: result.markdown });
|
|
1759
|
+
} catch (error) {
|
|
1760
|
+
return failure(error);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
);
|
|
1764
|
+
server.registerTool(
|
|
1765
|
+
"revdeck_feature_note",
|
|
1766
|
+
{
|
|
1767
|
+
title: "Feature note",
|
|
1768
|
+
description: "Write a cross-project note or finding on the current feature. Only available in a feature session (REVDECK_FEATURE). Notes are never published; actionable findings still belong to a review. Only notes authored by an agent can be updated or deleted.",
|
|
1769
|
+
inputSchema: {
|
|
1770
|
+
action: z2.enum(["add", "update", "delete"]).default("add"),
|
|
1771
|
+
note_id: z2.string().optional().describe("Note id for update/delete"),
|
|
1772
|
+
kind: z2.enum(["note", "finding"]).optional(),
|
|
1773
|
+
level: z2.enum(["blocker", "major", "minor", "question"]).optional(),
|
|
1774
|
+
title: z2.string().min(1).max(300).optional(),
|
|
1775
|
+
body: z2.string().max(2e4).optional()
|
|
1776
|
+
}
|
|
1777
|
+
},
|
|
1778
|
+
async ({ action, note_id, kind, level, title, body }) => {
|
|
1779
|
+
try {
|
|
1780
|
+
const current2 = await scope();
|
|
1781
|
+
if (!current2.feature) throw new Error("feature notes can only be written in a feature session (REVDECK_FEATURE)");
|
|
1782
|
+
await refreshFeatureScope(current2);
|
|
1783
|
+
if (action === "add") {
|
|
1784
|
+
if (!title) throw new Error("title is required");
|
|
1785
|
+
const { note: note2 } = await call("features.addNote", {
|
|
1786
|
+
feature: current2.feature.id,
|
|
1787
|
+
kind: kind ?? "note",
|
|
1788
|
+
...level ? { level } : {},
|
|
1789
|
+
title,
|
|
1790
|
+
body: body ?? "",
|
|
1791
|
+
author: "agent"
|
|
1792
|
+
});
|
|
1793
|
+
return ok(`Feature note saved: ${note2.id}. It is not published.`, { note: note2 });
|
|
1794
|
+
}
|
|
1795
|
+
if (!note_id) throw new Error("note_id is required");
|
|
1796
|
+
const { feature: feature2 } = await call("features.get", { feature: current2.feature.id });
|
|
1797
|
+
const existing = feature2.notes.find((note2) => note2.id === note_id);
|
|
1798
|
+
if (!existing) throw new Error(`feature note ${note_id} not found`);
|
|
1799
|
+
if (existing.author !== "agent") {
|
|
1800
|
+
throw new Error("only feature notes authored by an agent can be changed; ask the human to edit or delete their note");
|
|
1801
|
+
}
|
|
1802
|
+
if (action === "delete") {
|
|
1803
|
+
await call("features.deleteNote", { feature: current2.feature.id, note: note_id });
|
|
1804
|
+
return ok("Feature note deleted.");
|
|
1805
|
+
}
|
|
1806
|
+
const { note } = await call("features.updateNote", {
|
|
1807
|
+
feature: current2.feature.id,
|
|
1808
|
+
note: note_id,
|
|
1809
|
+
...kind ? { kind } : {},
|
|
1810
|
+
...level ? { level } : {},
|
|
1811
|
+
...title ? { title } : {},
|
|
1812
|
+
...body !== void 0 ? { body } : {}
|
|
1813
|
+
});
|
|
1814
|
+
return ok("Feature note updated. It is not published.", { note });
|
|
1815
|
+
} catch (error) {
|
|
1816
|
+
return failure(error);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
);
|
|
980
1820
|
server.registerTool(
|
|
981
1821
|
"revdeck_context",
|
|
982
1822
|
{
|
|
@@ -988,12 +1828,12 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
988
1828
|
file: z2.string().optional().describe("Append the diff of one file"),
|
|
989
1829
|
max_bytes: z2.number().int().positive().max(5e5).optional(),
|
|
990
1830
|
role: z2.string().max(64).optional().describe("Role for an independent shard reviewer"),
|
|
991
|
-
shard: z2.string().regex(/^\d+\/\d+$/).optional().describe("Shard as i/N, for example 1/3")
|
|
992
|
-
root: rootSchema
|
|
1831
|
+
shard: z2.string().regex(/^\d+\/\d+$/).optional().describe("Shard as i/N, for example 1/3")
|
|
993
1832
|
}
|
|
994
1833
|
},
|
|
995
1834
|
async ({ review, refresh, file, max_bytes, role, shard }) => {
|
|
996
1835
|
try {
|
|
1836
|
+
await scopedReview(review);
|
|
997
1837
|
const { review: view } = await call("reviews.get", { review, refresh: refresh === true });
|
|
998
1838
|
const { rules: rules2 } = await call("rules.get", { review });
|
|
999
1839
|
const parsedShard = shard ? (() => {
|
|
@@ -1045,6 +1885,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1045
1885
|
},
|
|
1046
1886
|
async ({ review }) => {
|
|
1047
1887
|
try {
|
|
1888
|
+
await scopedReview(review);
|
|
1048
1889
|
const { review: view } = await call("reviews.get", { review });
|
|
1049
1890
|
return ok(JSON.stringify(view.threads, null, 2), { threads: view.threads });
|
|
1050
1891
|
} catch (error) {
|
|
@@ -1065,6 +1906,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1065
1906
|
},
|
|
1066
1907
|
async ({ review, file, max_lines }) => {
|
|
1067
1908
|
try {
|
|
1909
|
+
await scopedReview(review);
|
|
1068
1910
|
if (!file) {
|
|
1069
1911
|
const { review: view } = await call("reviews.get", { review });
|
|
1070
1912
|
const text = view.files.map((item) => `${item.status} +${item.additions} -${item.deletions} ${item.path}`).join("\n");
|
|
@@ -1106,6 +1948,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1106
1948
|
},
|
|
1107
1949
|
async ({ review, thread_id, body, resolve }) => {
|
|
1108
1950
|
try {
|
|
1951
|
+
await scopedReview(review);
|
|
1109
1952
|
const { draft } = await call("drafts.put", {
|
|
1110
1953
|
review,
|
|
1111
1954
|
threadId: thread_id,
|
|
@@ -1141,6 +1984,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1141
1984
|
},
|
|
1142
1985
|
async ({ review, findings: findings2 }) => {
|
|
1143
1986
|
try {
|
|
1987
|
+
await scopedReview(review);
|
|
1144
1988
|
const { findings: saved } = await call("findings.put", { review, findings: findings2 });
|
|
1145
1989
|
return ok(`Findings saved: ${saved.length}.`, { findings: saved });
|
|
1146
1990
|
} catch (error) {
|
|
@@ -1162,11 +2006,12 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1162
2006
|
focus: z2.array(z2.string()).optional()
|
|
1163
2007
|
}
|
|
1164
2008
|
},
|
|
1165
|
-
async ({ review, title, scope, summary: summary2, changes, focus }) => {
|
|
2009
|
+
async ({ review, title, scope: scope2, summary: summary2, changes, focus }) => {
|
|
1166
2010
|
try {
|
|
2011
|
+
await scopedReview(review);
|
|
1167
2012
|
const { summary: saved } = await call("summary.put", {
|
|
1168
2013
|
review,
|
|
1169
|
-
summary: { title: title ?? "", scope:
|
|
2014
|
+
summary: { title: title ?? "", scope: scope2 ?? "", summary: summary2 ?? "", changes: changes ?? [], focus: focus ?? [] }
|
|
1170
2015
|
});
|
|
1171
2016
|
return ok("Summary saved.", { summary: saved });
|
|
1172
2017
|
} catch (error) {
|
|
@@ -1188,6 +2033,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1188
2033
|
},
|
|
1189
2034
|
async ({ review, action, note_id, text }) => {
|
|
1190
2035
|
try {
|
|
2036
|
+
await scopedReview(review);
|
|
1191
2037
|
if (action === "reply") {
|
|
1192
2038
|
if (!note_id || !text) return ok("reply requires note_id and text.");
|
|
1193
2039
|
const { note } = await call("notes.update", { review, noteId: note_id, patch: { agentReply: text } });
|
|
@@ -1209,6 +2055,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1209
2055
|
},
|
|
1210
2056
|
async ({ review }) => {
|
|
1211
2057
|
try {
|
|
2058
|
+
await scopedReview(review);
|
|
1212
2059
|
const { rules: rules2 } = await call("rules.get", { review });
|
|
1213
2060
|
return ok(rules2.markdown, rules2);
|
|
1214
2061
|
} catch (error) {
|
|
@@ -1229,6 +2076,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1229
2076
|
},
|
|
1230
2077
|
async ({ review, kind, ids }) => {
|
|
1231
2078
|
try {
|
|
2079
|
+
await scopedReview(review);
|
|
1232
2080
|
const { review: view } = await call("reviews.get", { review });
|
|
1233
2081
|
const selected = ids ?? defaultSelection(view, kind);
|
|
1234
2082
|
const { preview } = await call("publish.preview", { review, kind, ids: selected });
|
|
@@ -1253,6 +2101,7 @@ ${preview.warnings.join("\n")}` : ""), { preview });
|
|
|
1253
2101
|
},
|
|
1254
2102
|
async ({ review, approval_id }) => {
|
|
1255
2103
|
try {
|
|
2104
|
+
await scopedReview(review);
|
|
1256
2105
|
const { result } = await call("publish.commit", {
|
|
1257
2106
|
review,
|
|
1258
2107
|
approvalId: approval_id
|
|
@@ -1305,6 +2154,46 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
|
|
|
1305
2154
|
]
|
|
1306
2155
|
})
|
|
1307
2156
|
);
|
|
2157
|
+
server.registerPrompt(
|
|
2158
|
+
"review-feature",
|
|
2159
|
+
{
|
|
2160
|
+
title: "Review a cross-project feature",
|
|
2161
|
+
description: "A full feature pass: brief and contract, every member review, cross-project integration checks.",
|
|
2162
|
+
argsSchema: { feature: z2.string().describe("Feature id, for example ft-a1b2c3") }
|
|
2163
|
+
},
|
|
2164
|
+
({ feature: feature2 }) => ({
|
|
2165
|
+
messages: [
|
|
2166
|
+
{
|
|
2167
|
+
role: "user",
|
|
2168
|
+
content: {
|
|
2169
|
+
type: "text",
|
|
2170
|
+
text: [
|
|
2171
|
+
tr(
|
|
2172
|
+
[
|
|
2173
|
+
`\u041F\u0440\u043E\u0432\u0435\u0434\u0438 \u0440\u0435\u0432\u044C\u044E \u0444\u0438\u0447\u0438 ${feature2} \u0441 \u043F\u043E\u043C\u043E\u0449\u044C\u044E revdeck.`,
|
|
2174
|
+
"1. revdeck_feature action=context: \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0439 \u0431\u0440\u0438\u0444, \u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442 \u0438 \u043F\u043E\u0440\u044F\u0434\u043E\u043A \u0432\u044B\u043A\u0430\u0442\u0430.",
|
|
2175
|
+
"2. \u0414\u043B\u044F \u043A\u0430\u0436\u0434\u043E\u0433\u043E MR-\u0447\u043B\u0435\u043D\u0430 \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0439 \u0435\u0433\u043E \u0441\u043E\u0431\u0441\u0442\u0432\u0435\u043D\u043D\u044B\u0439 revdeck_context \u0438 \u0435\u0433\u043E \u043F\u0440\u0430\u0432\u0438\u043B\u0430.",
|
|
2176
|
+
"3. \u0421\u0434\u0435\u043B\u0430\u0439 \u043E\u0442\u0434\u0435\u043B\u044C\u043D\u044B\u0439 \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043E\u043D\u043D\u044B\u0439 \u043F\u0440\u043E\u0445\u043E\u0434: \u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442 API, \u0441\u043E\u0432\u043C\u0435\u0441\u0442\u0438\u043C\u043E\u0441\u0442\u044C, auth, \u0434\u0430\u043D\u043D\u044B\u0435, \u0440\u0435\u0442\u0440\u0430\u0438, \u043F\u043E\u0440\u044F\u0434\u043E\u043A \u0432\u044B\u043A\u0430\u0442\u0430.",
|
|
2177
|
+
"4. \u041D\u0435 \u0441\u043C\u0435\u0448\u0438\u0432\u0430\u0439 \u043F\u0440\u0430\u0432\u0438\u043B\u0430 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432. \u041A\u0430\u0436\u0434\u043E\u0435 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0435 \u2014 \u0432 \u0440\u0435\u0432\u044C\u044E-\u0432\u043B\u0430\u0434\u0435\u043B\u044C\u0446\u0430, \u0441\u043E \u0441\u0441\u044B\u043B\u043A\u043E\u0439 \u043D\u0430 \u0434\u0440\u0443\u0433\u043E\u0439 MR \u0432 \u0442\u0435\u043A\u0441\u0442\u0435.",
|
|
2178
|
+
"5. \u0415\u0441\u043B\u0438 \u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442\u0430 \u0438\u043B\u0438 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u0430 \u043D\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u2014 \u0437\u0430\u0434\u0430\u0439 \u0432\u043E\u043F\u0440\u043E\u0441, \u043D\u0435 \u0432\u044B\u0434\u0443\u043C\u044B\u0432\u0430\u0439.",
|
|
2179
|
+
"6. \u041F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F \u2014 \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u043E\u043C, \u043F\u043E \u043A\u0430\u0436\u0434\u043E\u043C\u0443 \u0440\u0435\u0432\u044C\u044E \u043E\u0442\u0434\u0435\u043B\u044C\u043D\u043E."
|
|
2180
|
+
].join("\n"),
|
|
2181
|
+
[
|
|
2182
|
+
`Review feature ${feature2} with revdeck.`,
|
|
2183
|
+
"1. Call revdeck_feature action=context: read the brief, contract and rollout order.",
|
|
2184
|
+
"2. For every member MR read its own revdeck_context and its own project rules.",
|
|
2185
|
+
"3. Do a separate integration pass: API contract, compatibility, auth, data, retries, rollout order.",
|
|
2186
|
+
"4. Never mix project rules. Put each finding on its owning review and reference the other MR in the text.",
|
|
2187
|
+
"5. If the contract or context is missing, ask; do not invent it.",
|
|
2188
|
+
"6. Publishing is done only by a human, per review."
|
|
2189
|
+
].join("\n")
|
|
2190
|
+
)
|
|
2191
|
+
].join("\n")
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
]
|
|
2195
|
+
})
|
|
2196
|
+
);
|
|
1308
2197
|
server.registerPrompt(
|
|
1309
2198
|
"close-feedback",
|
|
1310
2199
|
{
|
|
@@ -1335,292 +2224,36 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
|
|
|
1335
2224
|
"3. Draft replies with revdeck_draft_reply; show code changes to the human.",
|
|
1336
2225
|
"4. Use revdeck_notes to answer the human comments on lines.",
|
|
1337
2226
|
"Publishing is done only by a human after confirmation."
|
|
1338
|
-
].join("\n")
|
|
1339
|
-
)
|
|
1340
|
-
].join("\n")
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
]
|
|
1344
|
-
})
|
|
1345
|
-
);
|
|
1346
|
-
main().catch((error) => {
|
|
1347
|
-
process.stderr.write(`revdeck MCP: ${redact(error instanceof Error ? error.message : error)}
|
|
1348
|
-
`);
|
|
1349
|
-
process.exit(1);
|
|
1350
|
-
});
|
|
1351
|
-
}
|
|
1352
|
-
});
|
|
1353
|
-
|
|
1354
|
-
// src/cli/main.ts
|
|
1355
|
-
init_paths();
|
|
1356
|
-
import { readFile as readFile7, stat } from "node:fs/promises";
|
|
1357
|
-
import { readFileSync } from "node:fs";
|
|
1358
|
-
import { parseArgs } from "node:util";
|
|
1359
|
-
import path10 from "node:path";
|
|
1360
|
-
|
|
1361
|
-
// src/core/config.ts
|
|
1362
|
-
init_paths();
|
|
1363
|
-
import { z } from "zod";
|
|
1364
|
-
|
|
1365
|
-
// src/core/errors.ts
|
|
1366
|
-
var MrReviewError = class extends Error {
|
|
1367
|
-
code;
|
|
1368
|
-
hint;
|
|
1369
|
-
constructor(message, code = "REVDECK_ERROR", hint) {
|
|
1370
|
-
super(message);
|
|
1371
|
-
this.name = "MrReviewError";
|
|
1372
|
-
this.code = code;
|
|
1373
|
-
this.hint = hint;
|
|
1374
|
-
}
|
|
1375
|
-
};
|
|
1376
|
-
var ConfigError = class extends MrReviewError {
|
|
1377
|
-
constructor(message, hint) {
|
|
1378
|
-
super(message, "CONFIG", hint);
|
|
1379
|
-
this.name = "ConfigError";
|
|
1380
|
-
}
|
|
1381
|
-
};
|
|
1382
|
-
|
|
1383
|
-
// src/core/config.ts
|
|
1384
|
-
import { parse as parseYaml } from "yaml";
|
|
1385
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
1386
|
-
import path2 from "node:path";
|
|
1387
|
-
|
|
1388
|
-
// src/core/glob.ts
|
|
1389
|
-
function globToRegExp(glob) {
|
|
1390
|
-
let source = "";
|
|
1391
|
-
let index = 0;
|
|
1392
|
-
const pattern = glob.replace(/^\.\//, "").replace(/^\/+/, "");
|
|
1393
|
-
while (index < pattern.length) {
|
|
1394
|
-
const char = pattern[index];
|
|
1395
|
-
if (char === "*") {
|
|
1396
|
-
if (pattern[index + 1] === "*") {
|
|
1397
|
-
if (pattern[index + 2] === "/") {
|
|
1398
|
-
source += "(?:[^/]+/)*";
|
|
1399
|
-
index += 3;
|
|
1400
|
-
} else {
|
|
1401
|
-
source += ".*";
|
|
1402
|
-
index += 2;
|
|
1403
|
-
}
|
|
1404
|
-
} else {
|
|
1405
|
-
source += "[^/]*";
|
|
1406
|
-
index += 1;
|
|
1407
|
-
}
|
|
1408
|
-
continue;
|
|
1409
|
-
}
|
|
1410
|
-
if (char === "?") {
|
|
1411
|
-
source += "[^/]";
|
|
1412
|
-
index += 1;
|
|
1413
|
-
continue;
|
|
1414
|
-
}
|
|
1415
|
-
if (char === "{") {
|
|
1416
|
-
const end = pattern.indexOf("}", index);
|
|
1417
|
-
if (end > index) {
|
|
1418
|
-
const options = pattern.slice(index + 1, end).split(",").map((item) => escapeRegExp(item.trim()));
|
|
1419
|
-
source += `(?:${options.join("|")})`;
|
|
1420
|
-
index = end + 1;
|
|
1421
|
-
continue;
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
source += escapeRegExp(char);
|
|
1425
|
-
index += 1;
|
|
1426
|
-
}
|
|
1427
|
-
return new RegExp(`^${source}$`);
|
|
1428
|
-
}
|
|
1429
|
-
function escapeRegExp(value) {
|
|
1430
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1431
|
-
}
|
|
1432
|
-
function classifyFile(path11) {
|
|
1433
|
-
const lower = path11.toLowerCase();
|
|
1434
|
-
if (/(^|\/)(node_modules|dist|build|coverage|vendor)\//.test(lower)) return "generated";
|
|
1435
|
-
if (/\.(md|mdx|rst|txt|adoc)$/.test(lower) || /(^|\/)(docs?|adr)\//.test(lower)) return "docs";
|
|
1436
|
-
if (/(^|\/)(__tests__|tests?|spec|e2e)\//.test(lower) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /_test\.go$/.test(lower)) return "test";
|
|
1437
|
-
if (/\.(css|scss|sass|less|styl)$/.test(lower)) return "style";
|
|
1438
|
-
if (/(^|\/)(package(-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|tsconfig[^/]*\.json|[^/]*\.config\.[cm]?[jt]s|\.eslintrc[^/]*|\.prettierrc[^/]*|Dockerfile|Makefile|\.github\/workflows\/|\.gitlab-ci\.yml)/.test(lower)) return "config";
|
|
1439
|
-
if (/\.(generated|g)\.[cm]?[jt]s$|\.d\.ts$|(^|\/)generated\//.test(lower)) return "generated";
|
|
1440
|
-
if (/\.(ts|tsx|js|jsx|mjs|cjs|vue|svelte|py|go|rs|java|kt|rb|php|cs|c|cpp|h|hpp|swift|scala|ex|exs)$/.test(lower)) return "app";
|
|
1441
|
-
return "other";
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
// src/core/config.ts
|
|
1445
|
-
init_locale();
|
|
1446
|
-
init_review_roles();
|
|
1447
|
-
var matchSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
1448
|
-
var customRoleSchema = z.object({
|
|
1449
|
-
title: z.string().min(1).max(120),
|
|
1450
|
-
description: z.string().min(1).max(2e3),
|
|
1451
|
-
criteria: z.array(z.string().min(1).max(20)).max(20).default([]),
|
|
1452
|
-
focus: z.string().max(2e3).optional(),
|
|
1453
|
-
instructions: z.string().max(8e3).optional()
|
|
1454
|
-
});
|
|
1455
|
-
var reviewConfigSchema = z.object({
|
|
1456
|
-
version: z.literal(1).default(1),
|
|
1457
|
-
provider: z.object({
|
|
1458
|
-
/** auto — по git remote; иначе явная платформа. */
|
|
1459
|
-
type: z.enum(["auto", "gitlab", "github"]).default("auto"),
|
|
1460
|
-
host: z.string().min(1).optional(),
|
|
1461
|
-
/** GitLab: group/project. GitHub: owner/repo. */
|
|
1462
|
-
project: z.string().min(1).optional(),
|
|
1463
|
-
/** База для локального diff, когда ревью идёт по ветке. */
|
|
1464
|
-
base: z.string().min(1).optional()
|
|
1465
|
-
}).prefault({}),
|
|
1466
|
-
output: z.object({
|
|
1467
|
-
language: z.enum(["auto", "ru", "en"]).default("auto")
|
|
1468
|
-
}).prefault({}),
|
|
1469
|
-
review: z.object({
|
|
1470
|
-
/** Сколько независимых ревьюеров запускать. */
|
|
1471
|
-
agents: z.number().int().min(1).max(8).default(3),
|
|
1472
|
-
/** Роли агентов; встроенные id или ключи customRoles. */
|
|
1473
|
-
roles: z.array(z.string().min(1).max(64)).min(1).max(10).default([...DEFAULT_REVIEW_ROLES]),
|
|
1474
|
-
/** Пользовательские роли с описанием и инструкциями. */
|
|
1475
|
-
customRoles: z.record(z.string().min(1).max(64), customRoleSchema).default({}),
|
|
1476
|
-
/** Явные группы изменений; остальные группируются по типу и модулю. */
|
|
1477
|
-
groups: z.array(
|
|
1478
|
-
z.object({
|
|
1479
|
-
id: z.string().min(1).max(64),
|
|
1480
|
-
title: z.string().min(1).max(120),
|
|
1481
|
-
match: matchSchema
|
|
1482
|
-
})
|
|
1483
|
-
).max(100).default([]),
|
|
1484
|
-
/** Опциональный скан секретов; по умолчанию выключен. */
|
|
1485
|
-
secrets: z.object({
|
|
1486
|
-
enabled: z.boolean().default(false),
|
|
1487
|
-
scan: z.enum(["diff", "files", "both"]).default("diff"),
|
|
1488
|
-
includeTests: z.boolean().default(false),
|
|
1489
|
-
/** Glob-пути или id правила (`rule:generic-secret`). */
|
|
1490
|
-
allowlist: z.array(z.string().min(1)).default([])
|
|
1491
|
-
}).prefault({}),
|
|
1492
|
-
/** История версий ревью (снимки по commit SHA). */
|
|
1493
|
-
history: z.object({
|
|
1494
|
-
enabled: z.boolean().default(false),
|
|
1495
|
-
keep: z.number().int().min(1).max(100).default(20)
|
|
1496
|
-
}).prefault({}),
|
|
1497
|
-
/** Запрет любых изменений: drafts, findings, публикация. */
|
|
1498
|
-
readOnly: z.boolean().default(false)
|
|
1499
|
-
}).prefault({}).superRefine((value, ctx) => {
|
|
1500
|
-
for (const key of Object.keys(value.customRoles)) {
|
|
1501
|
-
if (REVIEW_ROLE_IDS.includes(key)) {
|
|
1502
|
-
ctx.addIssue({ code: "custom", path: ["customRoles", key], message: `role ${key} is built in and cannot be overridden` });
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
for (const role of value.roles) {
|
|
1506
|
-
if (!REVIEW_ROLE_IDS.includes(role) && !(role in value.customRoles)) {
|
|
1507
|
-
ctx.addIssue({ code: "custom", path: ["roles"], message: `unknown role: ${role}` });
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
}),
|
|
1511
|
-
rules: z.object({
|
|
1512
|
-
/** Общие документы, если ни одна строка map не подошла. Пусто — автообнаружение. */
|
|
1513
|
-
sources: z.array(z.string().min(1)).default([]),
|
|
1514
|
-
/** Привязка путей к документам: match — glob, docs — пути с необязательной секцией `#…`. */
|
|
1515
|
-
map: z.array(
|
|
1516
|
-
z.object({
|
|
1517
|
-
match: matchSchema,
|
|
1518
|
-
docs: z.array(z.string().min(1)).min(1),
|
|
1519
|
-
note: z.string().optional()
|
|
2227
|
+
].join("\n")
|
|
2228
|
+
)
|
|
2229
|
+
].join("\n")
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
]
|
|
1520
2233
|
})
|
|
1521
|
-
)
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
maxTotalBytes: z.number().int().nonnegative().default(0)
|
|
1528
|
-
}).prefault({}),
|
|
1529
|
-
checks: z.array(
|
|
1530
|
-
z.object({
|
|
1531
|
-
id: z.string().min(1),
|
|
1532
|
-
name: z.string().optional(),
|
|
1533
|
-
/** argv без shell: первым идёт исполняемый файл. */
|
|
1534
|
-
argv: z.array(z.string()).min(1),
|
|
1535
|
-
/** Запускать, только если diff затронул эти glob-пути. */
|
|
1536
|
-
when: z.array(z.string()).default([]),
|
|
1537
|
-
consent: z.boolean().default(true),
|
|
1538
|
-
timeoutMs: z.number().int().positive().max(36e5).default(3e5)
|
|
1539
|
-
})
|
|
1540
|
-
).default([]),
|
|
1541
|
-
publish: z.object({
|
|
1542
|
-
requireApproval: z.boolean().default(true),
|
|
1543
|
-
maxComments: z.number().int().positive().max(200).default(50)
|
|
1544
|
-
}).prefault({})
|
|
1545
|
-
});
|
|
1546
|
-
var DISCOVERED_SOURCES = [
|
|
1547
|
-
"AGENTS.md",
|
|
1548
|
-
"CLAUDE.md",
|
|
1549
|
-
"CONTRIBUTING.md",
|
|
1550
|
-
"docs/ARCHITECTURE.md",
|
|
1551
|
-
"docs/Architecture.md",
|
|
1552
|
-
"docs/STYLEGUIDE.md",
|
|
1553
|
-
"docs/Styleguide.md",
|
|
1554
|
-
"docs/CONTRIBUTING.md"
|
|
1555
|
-
];
|
|
1556
|
-
function isRecord(value) {
|
|
1557
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1558
|
-
}
|
|
1559
|
-
function parseYamlData(text, source) {
|
|
1560
|
-
try {
|
|
1561
|
-
return parseYaml(text);
|
|
1562
|
-
} catch (error) {
|
|
1563
|
-
throw new ConfigError(tr(`${source}: \u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 YAML: ${error.message}`, `${source}: invalid YAML: ${error.message}`));
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
function mergeConfigData(base, local) {
|
|
1567
|
-
if (!isRecord(base) || !isRecord(local)) return local;
|
|
1568
|
-
const result = { ...base };
|
|
1569
|
-
for (const [key, value] of Object.entries(local)) {
|
|
1570
|
-
const current2 = result[key];
|
|
1571
|
-
result[key] = isRecord(current2) && isRecord(value) ? mergeConfigData(current2, value) : value;
|
|
1572
|
-
}
|
|
1573
|
-
return result;
|
|
1574
|
-
}
|
|
1575
|
-
async function loadConfig(root = findRepoRoot()) {
|
|
1576
|
-
const warnings = [];
|
|
1577
|
-
const file = findConfigFile(root);
|
|
1578
|
-
const localFile = findLocalConfigFile(root);
|
|
1579
|
-
const baseData = file ? parseYamlData(await readTextNoFollow(file), path2.relative(root, file) || file) : {};
|
|
1580
|
-
const localData = localFile ? parseYamlData(await readTextNoFollow(localFile), path2.relative(root, localFile) || localFile) : {};
|
|
1581
|
-
if (!file && !localFile) {
|
|
1582
|
-
warnings.push(tr("\u0444\u0430\u0439\u043B .revdeck.yml \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u043F\u0440\u0430\u0432\u0438\u043B\u0430 \u0432\u0437\u044F\u0442\u044B \u0438\u0437 \u0430\u0432\u0442\u043E\u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432", ".revdeck.yml not found: rules come from auto-discovered documents"));
|
|
1583
|
-
}
|
|
1584
|
-
const merged = mergeConfigData(baseData, localData);
|
|
1585
|
-
const config2 = reviewConfigSchema.parse(merged);
|
|
1586
|
-
const baseReadOnly = isRecord(baseData) && isRecord(baseData.review) && baseData.review.readOnly === true;
|
|
1587
|
-
const localReadOnly = isRecord(localData) && isRecord(localData.review) && localData.review.readOnly === true;
|
|
1588
|
-
config2.review.readOnly = baseReadOnly || localReadOnly;
|
|
1589
|
-
if (!config2.rules.sources.length && !config2.rules.map.length) {
|
|
1590
|
-
const found = DISCOVERED_SOURCES.filter((item) => existsSync2(path2.join(root, item)));
|
|
1591
|
-
config2.rules.sources = found;
|
|
1592
|
-
if (!found.length) {
|
|
1593
|
-
warnings.push(tr("\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u044B \u0441 \u043F\u0440\u0430\u0432\u0438\u043B\u0430\u043C\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B: \u0440\u0435\u0432\u044C\u044E \u0431\u0443\u0434\u0435\u0442 \u043E\u043F\u0438\u0440\u0430\u0442\u044C\u0441\u044F \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \u043A\u043E\u0434 \u0438 \u0437\u0434\u0440\u0430\u0432\u044B\u0439 \u0441\u043C\u044B\u0441\u043B", "no rule documents found: the review will rely on the code only"));
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
return {
|
|
1597
|
-
config: config2,
|
|
1598
|
-
path: file,
|
|
1599
|
-
localPath: localFile,
|
|
1600
|
-
warnings
|
|
1601
|
-
};
|
|
1602
|
-
}
|
|
1603
|
-
function assertConfigPath(root, relative) {
|
|
1604
|
-
const cleaned = relative.split("#")[0];
|
|
1605
|
-
const resolved = path2.resolve(root, cleaned);
|
|
1606
|
-
const rel = path2.relative(root, resolved);
|
|
1607
|
-
if (rel.startsWith("..") || path2.isAbsolute(rel)) {
|
|
1608
|
-
throw new ConfigError(tr(`\u043F\u0443\u0442\u044C ${relative} \u0432\u044B\u0445\u043E\u0434\u0438\u0442 \u0437\u0430 \u043F\u0440\u0435\u0434\u0435\u043B\u044B \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F`, `path ${relative} escapes the repository`));
|
|
2234
|
+
);
|
|
2235
|
+
main().catch((error) => {
|
|
2236
|
+
process.stderr.write(`revdeck MCP: ${redact(error instanceof Error ? error.message : error)}
|
|
2237
|
+
`);
|
|
2238
|
+
process.exit(1);
|
|
2239
|
+
});
|
|
1609
2240
|
}
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
}
|
|
2241
|
+
});
|
|
2242
|
+
|
|
2243
|
+
// src/cli/main.ts
|
|
2244
|
+
init_paths();
|
|
2245
|
+
init_config();
|
|
2246
|
+
import { readFile as readFile7, stat } from "node:fs/promises";
|
|
2247
|
+
import { readFileSync } from "node:fs";
|
|
2248
|
+
import { parseArgs } from "node:util";
|
|
2249
|
+
import path10 from "node:path";
|
|
1618
2250
|
|
|
1619
2251
|
// src/core/rules.ts
|
|
2252
|
+
init_config();
|
|
2253
|
+
init_glob();
|
|
2254
|
+
init_redact();
|
|
1620
2255
|
import path3 from "node:path";
|
|
1621
2256
|
import { existsSync as existsSync3 } from "node:fs";
|
|
1622
|
-
init_paths();
|
|
1623
|
-
init_redact();
|
|
1624
2257
|
var MAX_READ_BYTES = 16 * 1024 * 1024;
|
|
1625
2258
|
async function buildEffectiveRules(options) {
|
|
1626
2259
|
const { root, config: config2, configPath } = options;
|
|
@@ -1652,7 +2285,7 @@ async function buildEffectiveRules(options) {
|
|
|
1652
2285
|
} else {
|
|
1653
2286
|
try {
|
|
1654
2287
|
const readLimit = Number.isFinite(documentLimit) ? Math.max(documentLimit * 2, 4096) : MAX_READ_BYTES;
|
|
1655
|
-
const raw = await
|
|
2288
|
+
const raw = await readConfigFile(root, relative, readLimit);
|
|
1656
2289
|
const truncated = Number.isFinite(documentLimit) && raw.length > documentLimit;
|
|
1657
2290
|
cached = { exists: true, text: truncated ? raw.slice(0, documentLimit) : raw, truncated };
|
|
1658
2291
|
} catch (error) {
|
|
@@ -1772,10 +2405,10 @@ function renderRules(rules2, options = {}) {
|
|
|
1772
2405
|
if (rules2.warnings.length) out.push(`${t("\u041F\u0440\u0435\u0434\u0443\u043F\u0440\u0435\u0436\u0434\u0435\u043D\u0438\u044F", "Warnings")}:
|
|
1773
2406
|
${rules2.warnings.map((item) => `- ${item}`).join("\n")}`);
|
|
1774
2407
|
const seen = /* @__PURE__ */ new Set();
|
|
1775
|
-
for (const
|
|
2408
|
+
for (const scope2 of rules2.scopes) {
|
|
1776
2409
|
out.push(`
|
|
1777
|
-
## ${
|
|
1778
|
-
for (const doc of
|
|
2410
|
+
## ${scope2.file || `(${t("\u043E\u0431\u0449\u0438\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u0430", "general rules")})`} \u2014 ${scope2.kind}`);
|
|
2411
|
+
for (const doc of scope2.documents) {
|
|
1779
2412
|
const key = `${doc.path}#${doc.sections.join(",")}`;
|
|
1780
2413
|
const label = `${doc.path}${doc.sections.length ? `#${doc.sections.join(", ")}` : ""}`;
|
|
1781
2414
|
out.push(`- ${label}${doc.exists ? "" : ` (${t("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D", "not found")})`}`);
|
|
@@ -1807,162 +2440,25 @@ ${doc.excerpt}${doc.truncated ? `
|
|
|
1807
2440
|
|
|
1808
2441
|
// src/cli/main.ts
|
|
1809
2442
|
init_client();
|
|
1810
|
-
|
|
1811
|
-
// src/core/exec.ts
|
|
1812
|
-
import { execFile } from "node:child_process";
|
|
1813
|
-
import { access, constants } from "node:fs/promises";
|
|
1814
|
-
import os2 from "node:os";
|
|
1815
|
-
import path5 from "node:path";
|
|
1816
|
-
var SECRET_ENV = [
|
|
1817
|
-
"GITLAB_TOKEN",
|
|
1818
|
-
"GITLAB_PRIVATE_TOKEN",
|
|
1819
|
-
"GLAB_TOKEN",
|
|
1820
|
-
"CI_JOB_TOKEN",
|
|
1821
|
-
"GH_TOKEN",
|
|
1822
|
-
"GITHUB_TOKEN",
|
|
1823
|
-
"GITHUB_ENTERPRISE_TOKEN",
|
|
1824
|
-
"GIT_ASKPASS",
|
|
1825
|
-
"SSH_ASKPASS",
|
|
1826
|
-
"REVDECK_TOKEN"
|
|
1827
|
-
];
|
|
1828
|
-
function scrubEnv(extra) {
|
|
1829
|
-
const env = {};
|
|
1830
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
1831
|
-
if (SECRET_ENV.includes(key)) continue;
|
|
1832
|
-
env[key] = value;
|
|
1833
|
-
}
|
|
1834
|
-
env.PAGER = "cat";
|
|
1835
|
-
env.GIT_PAGER = "cat";
|
|
1836
|
-
env.GIT_TERMINAL_PROMPT = "0";
|
|
1837
|
-
env.NO_COLOR = "1";
|
|
1838
|
-
env.CLICOLOR = "0";
|
|
1839
|
-
env.FORCE_COLOR = "0";
|
|
1840
|
-
env.TERM = "dumb";
|
|
1841
|
-
return { ...env, ...extra };
|
|
1842
|
-
}
|
|
1843
|
-
var RESOLVED = /* @__PURE__ */ new Map();
|
|
1844
|
-
async function resolveExecutable(command) {
|
|
1845
|
-
if (command.includes("/") || command.includes("\\")) {
|
|
1846
|
-
try {
|
|
1847
|
-
await access(command, constants.X_OK);
|
|
1848
|
-
return command;
|
|
1849
|
-
} catch {
|
|
1850
|
-
return null;
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
const override = process.env[`REVDECK_${command.toUpperCase()}`];
|
|
1854
|
-
if (override) return override;
|
|
1855
|
-
const cached = RESOLVED.get(command);
|
|
1856
|
-
if (cached) return cached;
|
|
1857
|
-
const dirs = [
|
|
1858
|
-
...(process.env.PATH ?? "").split(path5.delimiter),
|
|
1859
|
-
path5.join(os2.homedir(), ".local", "bin"),
|
|
1860
|
-
path5.join(os2.homedir(), ".local", "share", "mise", "shims"),
|
|
1861
|
-
path5.join(os2.homedir(), ".asdf", "shims"),
|
|
1862
|
-
path5.join(os2.homedir(), ".npm-global", "bin"),
|
|
1863
|
-
"/opt/homebrew/bin",
|
|
1864
|
-
"/usr/local/bin",
|
|
1865
|
-
"/usr/bin",
|
|
1866
|
-
"/bin"
|
|
1867
|
-
].filter(Boolean);
|
|
1868
|
-
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
1869
|
-
for (const dir of [...new Set(dirs)]) {
|
|
1870
|
-
for (const extension of extensions) {
|
|
1871
|
-
const candidate = path5.join(dir, `${command}${extension}`);
|
|
1872
|
-
try {
|
|
1873
|
-
await access(candidate, constants.X_OK);
|
|
1874
|
-
RESOLVED.set(command, candidate);
|
|
1875
|
-
return candidate;
|
|
1876
|
-
} catch {
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
1879
|
-
}
|
|
1880
|
-
return null;
|
|
1881
|
-
}
|
|
1882
|
-
var run = async (command, args, options = {}) => {
|
|
1883
|
-
const executable = await resolveExecutable(command) ?? command;
|
|
1884
|
-
return new Promise((resolve, reject) => {
|
|
1885
|
-
const child = execFile(
|
|
1886
|
-
executable,
|
|
1887
|
-
args,
|
|
1888
|
-
{
|
|
1889
|
-
cwd: options.cwd,
|
|
1890
|
-
env: scrubEnv(options.env),
|
|
1891
|
-
timeout: options.timeoutMs ?? 12e4,
|
|
1892
|
-
maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
|
|
1893
|
-
encoding: "utf8",
|
|
1894
|
-
windowsHide: true,
|
|
1895
|
-
shell: false
|
|
1896
|
-
},
|
|
1897
|
-
(error, stdout, stderr) => {
|
|
1898
|
-
const exitCode = error?.code;
|
|
1899
|
-
const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
|
|
1900
|
-
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
1901
|
-
const reason = (stderr || stdout || error.message).trim();
|
|
1902
|
-
reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
|
|
1903
|
-
return;
|
|
1904
|
-
}
|
|
1905
|
-
resolve({ stdout, stderr, code });
|
|
1906
|
-
}
|
|
1907
|
-
);
|
|
1908
|
-
if (options.input !== void 0) {
|
|
1909
|
-
child.stdin?.end(options.input);
|
|
1910
|
-
}
|
|
1911
|
-
});
|
|
1912
|
-
};
|
|
1913
|
-
|
|
1914
|
-
// src/cli/main.ts
|
|
2443
|
+
init_exec();
|
|
1915
2444
|
init_redact();
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
var SSH_SCP = /^(?:ssh:\/\/)?(?:[^@/]+@)?([^:/]+)(?::(\d+))?[:/](.+?)(?:\.git)?\/?$/;
|
|
1919
|
-
function parseRemote(url) {
|
|
1920
|
-
const value = url.trim();
|
|
1921
|
-
if (!value) return null;
|
|
1922
|
-
let host = "";
|
|
1923
|
-
let projectPath = "";
|
|
1924
|
-
const http = /^(?:https?|git|ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+?)(?:\.git)?\/?$/.exec(value);
|
|
1925
|
-
if (http) {
|
|
1926
|
-
host = http[1];
|
|
1927
|
-
projectPath = http[2];
|
|
1928
|
-
} else {
|
|
1929
|
-
const scp = SSH_SCP.exec(value);
|
|
1930
|
-
if (!scp) return null;
|
|
1931
|
-
host = scp[1];
|
|
1932
|
-
projectPath = scp[3];
|
|
1933
|
-
}
|
|
1934
|
-
projectPath = projectPath.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
1935
|
-
if (!host || !projectPath || !projectPath.includes("/")) return null;
|
|
1936
|
-
return { host, project: projectPath, platform: detectPlatform(host), url: value };
|
|
1937
|
-
}
|
|
1938
|
-
function detectPlatform(host) {
|
|
1939
|
-
const lower = host.toLowerCase();
|
|
1940
|
-
if (lower === "github.com" || lower.endsWith(".github.com") || lower.includes("github")) return "github";
|
|
1941
|
-
if (lower === "gitlab.com" || lower.endsWith(".gitlab.com") || lower.includes("gitlab")) return "gitlab";
|
|
1942
|
-
return null;
|
|
1943
|
-
}
|
|
1944
|
-
async function gitRemote(root, remote = "origin") {
|
|
1945
|
-
try {
|
|
1946
|
-
const { stdout } = await run("git", ["config", "--get", `remote.${remote}.url`], { cwd: root, timeoutMs: 1e4 });
|
|
1947
|
-
return parseRemote(stdout.trim());
|
|
1948
|
-
} catch {
|
|
1949
|
-
return null;
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
// src/cli/main.ts
|
|
2445
|
+
init_git();
|
|
2446
|
+
init_refs();
|
|
1954
2447
|
init_version();
|
|
1955
2448
|
init_locale();
|
|
1956
2449
|
init_format();
|
|
1957
2450
|
|
|
1958
2451
|
// src/cli/init.ts
|
|
1959
2452
|
init_paths();
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
import path6 from "node:path";
|
|
2453
|
+
init_git();
|
|
2454
|
+
init_config();
|
|
1963
2455
|
init_redact();
|
|
1964
2456
|
init_locale();
|
|
2457
|
+
init_exec();
|
|
1965
2458
|
init_format();
|
|
2459
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
2460
|
+
import { cp, lstat as lstat2, mkdir as mkdir2, readdir, readFile as readFile3, rm, symlink, writeFile } from "node:fs/promises";
|
|
2461
|
+
import path6 from "node:path";
|
|
1966
2462
|
function mcpServer(locale2) {
|
|
1967
2463
|
return { command: "npx", args: ["-y", "revdeck", "mcp"], env: { REVDECK_LANG: locale2 } };
|
|
1968
2464
|
}
|
|
@@ -2996,6 +3492,7 @@ var OPTIONS = {
|
|
|
2996
3492
|
limit: { type: "string" },
|
|
2997
3493
|
decision: { type: "string" },
|
|
2998
3494
|
note: { type: "string" },
|
|
3495
|
+
level: { type: "string" },
|
|
2999
3496
|
emoji: { type: "string" },
|
|
3000
3497
|
text: { type: "string" },
|
|
3001
3498
|
line: { type: "string" },
|
|
@@ -3004,7 +3501,14 @@ var OPTIONS = {
|
|
|
3004
3501
|
all: { type: "boolean", default: false },
|
|
3005
3502
|
lang: { type: "string" },
|
|
3006
3503
|
role: { type: "string" },
|
|
3007
|
-
shard: { type: "string" }
|
|
3504
|
+
shard: { type: "string" },
|
|
3505
|
+
title: { type: "string" },
|
|
3506
|
+
brief: { type: "string" },
|
|
3507
|
+
contract: { type: "string" },
|
|
3508
|
+
status: { type: "string" },
|
|
3509
|
+
"max-bytes": { type: "string" },
|
|
3510
|
+
feature: { type: "string" },
|
|
3511
|
+
archived: { type: "boolean", default: false }
|
|
3008
3512
|
};
|
|
3009
3513
|
function parse(argv) {
|
|
3010
3514
|
try {
|
|
@@ -3021,7 +3525,9 @@ var HELP_RU = `revdeck ${VERSION} \u2014 \u0440\u0435\u0432\u044C\u044E GitLab/G
|
|
|
3021
3525
|
revdeck devcontainer \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C devcontainer \u043A \u0434\u0435\u043C\u043E\u043D\u0443 \u0445\u043E\u0441\u0442\u0430 (--write)
|
|
3022
3526
|
revdeck doctor \u043F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u0435 \u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u044B
|
|
3023
3527
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
3024
|
-
revdeck
|
|
3528
|
+
revdeck projects \u043F\u0440\u043E\u0435\u043A\u0442\u044B \u0438 \u0438\u0445 \u0440\u0430\u0431\u043E\u0447\u0438\u0435 \u043A\u043E\u043F\u0438\u0438 (add <path> \u2014 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u0442\u044C)
|
|
3529
|
+
revdeck feature \u0444\u0438\u0447\u0438: list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete
|
|
3530
|
+
revdeck list \u0440\u0435\u0432\u044C\u044E \u0442\u0435\u043A\u0443\u0449\u0435\u0433\u043E \u043F\u0440\u043E\u0435\u043A\u0442\u0430 (--all \u2014 \u0432\u0441\u0435 \u043F\u0440\u043E\u0435\u043A\u0442\u044B; --remote \u2014 \u0441 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B)
|
|
3025
3531
|
revdeck open <url|N...> \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u043E\u0434\u043D\u043E \u0438\u043B\u0438 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0440\u0435\u0432\u044C\u044E
|
|
3026
3532
|
revdeck ui [N] \u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441
|
|
3027
3533
|
revdeck context <N> \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0434\u043B\u044F \u0430\u0433\u0435\u043D\u0442\u0430: \u043F\u0440\u0430\u0432\u0438\u043B\u0430, diff, \u0442\u0440\u0435\u0434\u044B [--role <\u0440\u043E\u043B\u044C>] [--shard i/N]
|
|
@@ -3053,7 +3559,9 @@ var HELP_EN = `revdeck ${VERSION} \u2014 code review for GitLab/GitHub, for huma
|
|
|
3053
3559
|
revdeck devcontainer connect a devcontainer to the host daemon (--write)
|
|
3054
3560
|
revdeck doctor check the environment and access
|
|
3055
3561
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
3056
|
-
revdeck
|
|
3562
|
+
revdeck projects projects and their working copies (add <path> \u2014 register)
|
|
3563
|
+
revdeck feature features: list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete
|
|
3564
|
+
revdeck list reviews of the current project (--all \u2014 all projects; --remote \u2014 from the platform)
|
|
3057
3565
|
revdeck open <url|N...> open one or more reviews
|
|
3058
3566
|
revdeck ui [N] link to the local UI
|
|
3059
3567
|
revdeck context <N> agent context: rules, diff, threads [--role <role>] [--shard i/N]
|
|
@@ -3110,6 +3618,10 @@ async function main2() {
|
|
|
3110
3618
|
return doctor(root);
|
|
3111
3619
|
case "daemon":
|
|
3112
3620
|
return daemon(positionals[0] ?? "status", values);
|
|
3621
|
+
case "projects":
|
|
3622
|
+
return projects(root, positionals, values);
|
|
3623
|
+
case "feature":
|
|
3624
|
+
return feature(root, positionals, values);
|
|
3113
3625
|
case "list":
|
|
3114
3626
|
return list(root, values);
|
|
3115
3627
|
case "open":
|
|
@@ -3117,7 +3629,7 @@ async function main2() {
|
|
|
3117
3629
|
case "ui":
|
|
3118
3630
|
return ui(positionals[0], values);
|
|
3119
3631
|
case "status":
|
|
3120
|
-
return status();
|
|
3632
|
+
return status(root, values);
|
|
3121
3633
|
case "context":
|
|
3122
3634
|
case "review":
|
|
3123
3635
|
return context(root, positionals[0], values);
|
|
@@ -3226,12 +3738,220 @@ async function list(root, values) {
|
|
|
3226
3738
|
return;
|
|
3227
3739
|
}
|
|
3228
3740
|
await withClient(async ({ client: client2 }) => {
|
|
3229
|
-
const
|
|
3741
|
+
const project = typeof values.project === "string" && values.project.trim() ? values.project.trim() : void 0;
|
|
3742
|
+
const params = values.all === true ? {} : project ? { project } : { root };
|
|
3743
|
+
const { reviews } = await client2.request("reviews.list", params);
|
|
3230
3744
|
if (values.json) return printJson({ reviews });
|
|
3231
|
-
if (!reviews.length) return writers.out(tr("\u0440\u0435\u0432\u044C\u044E \u0435\u0449\u0451 \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0438\u0441\u044C: revdeck open <N>", "no reviews opened yet: revdeck open <N>"));
|
|
3745
|
+
if (!reviews.length) return writers.out(tr("\u0432 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0435 \u0440\u0435\u0432\u044C\u044E \u0435\u0449\u0451 \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0438\u0441\u044C: revdeck open <N>", "no reviews opened in this project yet: revdeck open <N>"));
|
|
3232
3746
|
for (const item of reviews) writers.out(reviewLine(item));
|
|
3233
3747
|
});
|
|
3234
3748
|
}
|
|
3749
|
+
async function projects(root, args, values) {
|
|
3750
|
+
const action = args[0] ?? "list";
|
|
3751
|
+
await withClient(async ({ client: client2 }) => {
|
|
3752
|
+
if (action === "add") {
|
|
3753
|
+
const target = args[1] ?? values.root ?? root;
|
|
3754
|
+
const result = await client2.request("projects.register", { root: target });
|
|
3755
|
+
if (values.json) return printJson(result);
|
|
3756
|
+
if (!result.project) return writers.out(tr("\u043F\u0440\u043E\u0435\u043A\u0442 \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0451\u043D: \u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 git remote \u0438 .revdeck.yml", "could not determine the project: check git remote and .revdeck.yml"));
|
|
3757
|
+
writers.out(`${tr("\u043F\u0440\u043E\u0435\u043A\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D", "project registered")}: ${result.project.key}`);
|
|
3758
|
+
return;
|
|
3759
|
+
}
|
|
3760
|
+
if (action !== "list") usage([tr("revdeck projects [add <path>]", "revdeck projects [add <path>]")]);
|
|
3761
|
+
const { projects: projects2 } = await client2.request("projects.list");
|
|
3762
|
+
if (values.json) return printJson({ projects: projects2 });
|
|
3763
|
+
if (!projects2.length) return writers.out(tr("\u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432 \u043F\u043E\u043A\u0430 \u043D\u0435\u0442: revdeck open <N> \u0438\u043B\u0438 revdeck projects add <path>", "no projects yet: revdeck open <N> or revdeck projects add <path>"));
|
|
3764
|
+
for (const item of projects2) {
|
|
3765
|
+
writers.out(`${item.key} ${item.title} ${item.reviews} ${tr("\u0440\u0435\u0432\u044C\u044E", "reviews")} ${item.roots[0] ?? ""}`);
|
|
3766
|
+
}
|
|
3767
|
+
});
|
|
3768
|
+
}
|
|
3769
|
+
function featureRef(value) {
|
|
3770
|
+
const input = value.trim();
|
|
3771
|
+
if (/^(gitlab|github):/.test(input)) return input;
|
|
3772
|
+
if (/^\d+$/.test(input)) fail(tr("\u0432 \u0444\u0438\u0447\u0435 \u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043F\u043E\u043B\u043D\u044B\u0439 id \u0438\u043B\u0438 \u0441\u0441\u044B\u043B\u043A\u0443 \u043D\u0430 \u0440\u0435\u0432\u044C\u044E", "in a feature pass the full review id or URL"));
|
|
3773
|
+
try {
|
|
3774
|
+
return reviewId(parseReviewUrl(input));
|
|
3775
|
+
} catch {
|
|
3776
|
+
fail(tr(`\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C \u0440\u0435\u0432\u044C\u044E: ${value}`, `could not parse the review: ${value}`), tr("\u043F\u0440\u0438\u043C\u0435\u0440: https://gitlab.com/group/project/-/merge_requests/42", "example: https://gitlab.com/group/project/-/merge_requests/42"));
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
async function textFromFile(file, label) {
|
|
3780
|
+
if (typeof file !== "string" || !file.trim()) return void 0;
|
|
3781
|
+
try {
|
|
3782
|
+
return await readFile7(file, "utf8");
|
|
3783
|
+
} catch (error) {
|
|
3784
|
+
fail(tr(`\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C ${label}: ${error.message}`, `could not read the ${label}: ${error.message}`));
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
async function briefFrom(values) {
|
|
3788
|
+
return textFromFile(typeof values.brief === "string" ? values.brief : void 0, tr("\u0431\u0440\u0438\u0444", "brief"));
|
|
3789
|
+
}
|
|
3790
|
+
function printFeature(feature2) {
|
|
3791
|
+
writers.out(`${feature2.id} ${feature2.status} ${feature2.reviews} ${tr("\u0440\u0435\u0432\u044C\u044E", "reviews")} ${feature2.title}`);
|
|
3792
|
+
for (const project of feature2.projects) writers.out(` ${project.key}`);
|
|
3793
|
+
for (const member of feature2.members ?? []) {
|
|
3794
|
+
writers.out(` ${member.review.id} ${member.role || "\u2014"} #${member.review.number} ${member.review.title} (${member.review.state})`);
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3797
|
+
async function feature(_root, args, values) {
|
|
3798
|
+
const action = args[0] ?? "list";
|
|
3799
|
+
await withClient(async ({ client: client2 }) => {
|
|
3800
|
+
if (action === "list") {
|
|
3801
|
+
const project = typeof values.project === "string" && values.project.trim() ? values.project.trim() : void 0;
|
|
3802
|
+
const includeArchived = values.all === true || values.archived === true;
|
|
3803
|
+
const { features } = await client2.request("features.list", {
|
|
3804
|
+
...project ? { project } : {},
|
|
3805
|
+
includeArchived
|
|
3806
|
+
});
|
|
3807
|
+
if (values.json) return printJson({ features });
|
|
3808
|
+
if (!features.length) return writers.out(tr("\u0444\u0438\u0447 \u043F\u043E\u043A\u0430 \u043D\u0435\u0442", "no features yet"));
|
|
3809
|
+
for (const item of features) {
|
|
3810
|
+
writers.out(`${item.id} ${item.status} ${item.reviews} ${tr("\u0440\u0435\u0432\u044C\u044E", "reviews")} ${item.projects.length} ${tr("\u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432", "projects")} ${item.title}`);
|
|
3811
|
+
}
|
|
3812
|
+
return;
|
|
3813
|
+
}
|
|
3814
|
+
if (action === "get") {
|
|
3815
|
+
const id = args[1];
|
|
3816
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3817
|
+
const { feature: feature2 } = await client2.request("features.get", { feature: id });
|
|
3818
|
+
if (values.json) return printJson(feature2);
|
|
3819
|
+
printFeature(feature2);
|
|
3820
|
+
if (feature2.brief.trim()) writers.out(`
|
|
3821
|
+
${feature2.brief}`);
|
|
3822
|
+
if (feature2.contract.trim()) writers.out(`
|
|
3823
|
+
${feature2.contract}`);
|
|
3824
|
+
return;
|
|
3825
|
+
}
|
|
3826
|
+
if (action === "create") {
|
|
3827
|
+
const title = args[1] ?? (typeof values.title === "string" ? values.title : "");
|
|
3828
|
+
if (!title.trim()) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u0444\u0438\u0447\u0438", "pass the feature title"));
|
|
3829
|
+
const reviews = args.slice(2).map((value) => ({ review: featureRef(value), ...values.role ? { role: String(values.role) } : {} }));
|
|
3830
|
+
const brief = await briefFrom(values);
|
|
3831
|
+
const contract = await textFromFile(typeof values.contract === "string" ? values.contract : void 0, tr("\u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442", "contract"));
|
|
3832
|
+
const { feature: feature2 } = await client2.request("features.create", {
|
|
3833
|
+
title,
|
|
3834
|
+
...brief !== void 0 ? { brief } : {},
|
|
3835
|
+
...contract !== void 0 ? { contract } : {},
|
|
3836
|
+
...reviews.length ? { reviews } : {}
|
|
3837
|
+
});
|
|
3838
|
+
if (values.json) return printJson(feature2);
|
|
3839
|
+
writers.out(`${tr("\u0444\u0438\u0447\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0430", "feature created")}: ${feature2.id}`);
|
|
3840
|
+
printFeature(feature2);
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
if (action === "add") {
|
|
3844
|
+
const id = args[1];
|
|
3845
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3846
|
+
const reviews = args.slice(2).map((value) => ({ review: featureRef(value), ...values.role ? { role: String(values.role) } : {} }));
|
|
3847
|
+
if (!reviews.length) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u0445\u043E\u0442\u044F \u0431\u044B \u043E\u0434\u043D\u043E \u0440\u0435\u0432\u044C\u044E", "pass at least one review"));
|
|
3848
|
+
const { feature: feature2 } = await client2.request("features.addReviews", { feature: id, reviews });
|
|
3849
|
+
if (values.json) return printJson(feature2);
|
|
3850
|
+
printFeature(feature2);
|
|
3851
|
+
return;
|
|
3852
|
+
}
|
|
3853
|
+
if (action === "reorder") {
|
|
3854
|
+
const id = args[1];
|
|
3855
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3856
|
+
const reviews = args.slice(2).map(featureRef);
|
|
3857
|
+
if (!reviews.length) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043F\u043E\u0440\u044F\u0434\u043E\u043A \u0440\u0435\u0432\u044C\u044E", "pass the review order"));
|
|
3858
|
+
const { feature: feature2 } = await client2.request("features.reorder", { feature: id, reviews });
|
|
3859
|
+
if (values.json) return printJson(feature2);
|
|
3860
|
+
printFeature(feature2);
|
|
3861
|
+
return;
|
|
3862
|
+
}
|
|
3863
|
+
if (action === "notes") {
|
|
3864
|
+
const id = args[1];
|
|
3865
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3866
|
+
const { feature: feature2 } = await client2.request("features.get", { feature: id });
|
|
3867
|
+
if (values.json) return printJson(feature2.notes ?? []);
|
|
3868
|
+
for (const note of feature2.notes ?? []) {
|
|
3869
|
+
writers.out(`${note.id} ${note.kind}${note.level ? `/${note.level}` : ""} ${note.author} ${note.title}`);
|
|
3870
|
+
if (note.body) writers.out(` ${note.body}`);
|
|
3871
|
+
}
|
|
3872
|
+
return;
|
|
3873
|
+
}
|
|
3874
|
+
if (action === "note") {
|
|
3875
|
+
const id = args[1];
|
|
3876
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3877
|
+
const title = typeof values.title === "string" ? values.title : "";
|
|
3878
|
+
const body = typeof values.body === "string" ? values.body : "";
|
|
3879
|
+
if (!title.trim()) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 --title", "pass --title"));
|
|
3880
|
+
const { note } = await client2.request("features.addNote", {
|
|
3881
|
+
feature: id,
|
|
3882
|
+
kind: values.kind === "finding" ? "finding" : "note",
|
|
3883
|
+
...values.level ? { level: String(values.level) } : {},
|
|
3884
|
+
title,
|
|
3885
|
+
body
|
|
3886
|
+
});
|
|
3887
|
+
if (values.json) return printJson(note);
|
|
3888
|
+
writers.out(`${tr("\u0437\u0430\u043C\u0435\u0442\u043A\u0430 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0430", "note added")}: ${note.id}`);
|
|
3889
|
+
return;
|
|
3890
|
+
}
|
|
3891
|
+
if (action === "note-delete") {
|
|
3892
|
+
const id = args[1];
|
|
3893
|
+
const note = args[2];
|
|
3894
|
+
if (!id || !note) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438 \u0438 \u0437\u0430\u043C\u0435\u0442\u043A\u0438", "pass the feature id and note id"));
|
|
3895
|
+
await client2.request("features.deleteNote", { feature: id, note });
|
|
3896
|
+
writers.out(tr("\u0437\u0430\u043C\u0435\u0442\u043A\u0430 \u0443\u0434\u0430\u043B\u0435\u043D\u0430", "note deleted"));
|
|
3897
|
+
return;
|
|
3898
|
+
}
|
|
3899
|
+
if (action === "remove") {
|
|
3900
|
+
const id = args[1];
|
|
3901
|
+
const review = args[2];
|
|
3902
|
+
if (!id || !review) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438 \u0438 \u0440\u0435\u0432\u044C\u044E", "pass the feature id and a review"));
|
|
3903
|
+
const { feature: feature2 } = await client2.request("features.removeReview", { feature: id, review: featureRef(review) });
|
|
3904
|
+
if (values.json) return printJson(feature2);
|
|
3905
|
+
printFeature(feature2);
|
|
3906
|
+
return;
|
|
3907
|
+
}
|
|
3908
|
+
if (action === "context") {
|
|
3909
|
+
const id = args[1];
|
|
3910
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3911
|
+
const result = await client2.request("features.context", {
|
|
3912
|
+
feature: id,
|
|
3913
|
+
...values["max-bytes"] ? { maxBytes: Number(values["max-bytes"]) } : {}
|
|
3914
|
+
});
|
|
3915
|
+
if (values.json) return printJson(result);
|
|
3916
|
+
writers.out(result.markdown);
|
|
3917
|
+
return;
|
|
3918
|
+
}
|
|
3919
|
+
if (action === "update") {
|
|
3920
|
+
const id = args[1];
|
|
3921
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3922
|
+
const brief = await briefFrom(values);
|
|
3923
|
+
const contract = await textFromFile(typeof values.contract === "string" ? values.contract : void 0, tr("\u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442", "contract"));
|
|
3924
|
+
const patch = {
|
|
3925
|
+
...typeof values.title === "string" ? { title: values.title } : {},
|
|
3926
|
+
...brief !== void 0 ? { brief } : {},
|
|
3927
|
+
...contract !== void 0 ? { contract } : {},
|
|
3928
|
+
...values.status === "open" || values.status === "archived" ? { status: values.status } : {}
|
|
3929
|
+
};
|
|
3930
|
+
if (!Object.keys(patch).length) fail(tr("\u043D\u0435\u0447\u0435\u0433\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0442\u044C: --title, --brief, --contract \u0438\u043B\u0438 --status", "nothing to update: --title, --brief, --contract or --status"));
|
|
3931
|
+
const { feature: feature2 } = await client2.request("features.update", { feature: id, ...patch });
|
|
3932
|
+
if (values.json) return printJson(feature2);
|
|
3933
|
+
printFeature(feature2);
|
|
3934
|
+
return;
|
|
3935
|
+
}
|
|
3936
|
+
if (action === "archive") {
|
|
3937
|
+
const id = args[1];
|
|
3938
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3939
|
+
const { feature: feature2 } = await client2.request("features.update", { feature: id, status: "archived" });
|
|
3940
|
+
if (values.json) return printJson(feature2);
|
|
3941
|
+
writers.out(`${tr("\u0444\u0438\u0447\u0430 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043E\u0432\u0430\u043D\u0430", "feature archived")}: ${feature2.id}`);
|
|
3942
|
+
return;
|
|
3943
|
+
}
|
|
3944
|
+
if (action === "delete") {
|
|
3945
|
+
const id = args[1];
|
|
3946
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3947
|
+
if (values.yes !== true) fail(tr("\u0443\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u0444\u0438\u0447\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 --yes", "deleting a feature requires --yes"));
|
|
3948
|
+
await client2.request("features.delete", { feature: id });
|
|
3949
|
+
writers.out(`${tr("\u0444\u0438\u0447\u0430 \u0443\u0434\u0430\u043B\u0435\u043D\u0430", "feature deleted")}: ${id}`);
|
|
3950
|
+
return;
|
|
3951
|
+
}
|
|
3952
|
+
usage([tr("revdeck feature list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete", "revdeck feature list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete")]);
|
|
3953
|
+
});
|
|
3954
|
+
}
|
|
3235
3955
|
async function openReview(root, args, values) {
|
|
3236
3956
|
if (!args.length) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043D\u043E\u043C\u0435\u0440 \u0438\u043B\u0438 \u0441\u0441\u044B\u043B\u043A\u0443 \u043D\u0430 \u0440\u0435\u0432\u044C\u044E", "pass a review number or URL"));
|
|
3237
3957
|
await withClient(async ({ client: client2 }) => {
|
|
@@ -3274,10 +3994,10 @@ async function ui(arg, values) {
|
|
|
3274
3994
|
writers.out(url);
|
|
3275
3995
|
if (values.open) openBrowser(url);
|
|
3276
3996
|
}
|
|
3277
|
-
function printUi(
|
|
3997
|
+
function printUi(reviewId2, values) {
|
|
3278
3998
|
const info = daemonInfoSync();
|
|
3279
3999
|
if (!info) return writers.err(tr("\u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D: revdeck daemon start", "the daemon is not running: revdeck daemon start"));
|
|
3280
|
-
const url = `${uiBaseUrl(info)}/?t=${info.token}${
|
|
4000
|
+
const url = `${uiBaseUrl(info)}/?t=${info.token}${reviewId2 ? `&review=${encodeURIComponent(reviewId2)}` : ""}`;
|
|
3281
4001
|
writers.out(`UI: ${url}`);
|
|
3282
4002
|
if (values.open) openBrowser(url);
|
|
3283
4003
|
}
|
|
@@ -3369,11 +4089,12 @@ async function daemon(action, values = {}) {
|
|
|
3369
4089
|
}
|
|
3370
4090
|
usage(["daemon <start|stop|status|restart|logs|install|uninstall>"]);
|
|
3371
4091
|
}
|
|
3372
|
-
async function status() {
|
|
4092
|
+
async function status(root, values) {
|
|
3373
4093
|
await withClient(async ({ client: client2 }) => {
|
|
3374
|
-
const
|
|
4094
|
+
const params = values.all === true ? {} : { root };
|
|
4095
|
+
const { reviews } = await client2.request("reviews.list", params);
|
|
3375
4096
|
if (!reviews.length) {
|
|
3376
|
-
writers.out(tr("\u0440\u0435\u0432\u044C\u044E \u0435\u0449\u0451 \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0438\u0441\u044C", "no reviews opened yet"));
|
|
4097
|
+
writers.out(tr("\u0432 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0435 \u0440\u0435\u0432\u044C\u044E \u0435\u0449\u0451 \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0438\u0441\u044C", "no reviews opened in this project yet"));
|
|
3377
4098
|
return;
|
|
3378
4099
|
}
|
|
3379
4100
|
for (const item of reviews) writers.out(reviewLine(item));
|
|
@@ -3649,9 +4370,9 @@ function defaultSelection2(review, kind) {
|
|
|
3649
4370
|
}
|
|
3650
4371
|
return review.notes.filter((note) => !note.posted).map((note) => note.id);
|
|
3651
4372
|
}
|
|
3652
|
-
async function publishSelection(client2,
|
|
4373
|
+
async function publishSelection(client2, reviewId2, kind, ids, values) {
|
|
3653
4374
|
const { preview } = await client2.request("publish.preview", {
|
|
3654
|
-
review:
|
|
4375
|
+
review: reviewId2,
|
|
3655
4376
|
kind,
|
|
3656
4377
|
ids
|
|
3657
4378
|
});
|
|
@@ -3673,13 +4394,13 @@ async function publishSelection(client2, reviewId, kind, ids, values) {
|
|
|
3673
4394
|
return;
|
|
3674
4395
|
}
|
|
3675
4396
|
const { approval } = await client2.request("publish.approve", {
|
|
3676
|
-
review:
|
|
4397
|
+
review: reviewId2,
|
|
3677
4398
|
kind,
|
|
3678
4399
|
ids,
|
|
3679
4400
|
hash: preview.plan.hash
|
|
3680
4401
|
});
|
|
3681
4402
|
const { result } = await client2.request("publish.commit", {
|
|
3682
|
-
review:
|
|
4403
|
+
review: reviewId2,
|
|
3683
4404
|
approvalId: approval.id
|
|
3684
4405
|
});
|
|
3685
4406
|
for (const item of result.results) {
|