revdeck 0.4.6 → 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 +81 -1
- package/README.md +95 -9
- package/README.ru.md +96 -12
- package/dist/cli.js +1648 -531
- package/dist/cli.js.map +4 -4
- package/dist/daemon.js +1932 -240
- package/dist/daemon.js.map +4 -4
- package/dist/mcp.js +1143 -125
- 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 +196 -1
- 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 +189 -1
- 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 +37 -1
- package/skills/revdeck/ru/Feature.md +61 -0
- package/skills/revdeck/ru/SKILL.md +38 -1
- package/dist/ui/assets/index-DP2dIReT.js +0 -10
- package/dist/ui/assets/index-DZ9XSSBl.css +0 -1
- 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";
|
|
@@ -31,6 +31,13 @@ function findConfigFile(root) {
|
|
|
31
31
|
}
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
|
+
function findLocalConfigFile(root) {
|
|
35
|
+
for (const name of LOCAL_CONFIG_FILES) {
|
|
36
|
+
const candidate = path.join(root, name);
|
|
37
|
+
if (existsSync(candidate)) return candidate;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
34
41
|
function stateDir() {
|
|
35
42
|
if (process.env.REVDECK_STATE_DIR) return path.resolve(process.env.REVDECK_STATE_DIR);
|
|
36
43
|
const base = process.env.XDG_STATE_HOME || path.join(os.homedir(), ".local", "state");
|
|
@@ -72,18 +79,31 @@ async function ensureDir(dir, mode = 448) {
|
|
|
72
79
|
await chmod(dir, mode);
|
|
73
80
|
}
|
|
74
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
|
+
}
|
|
75
86
|
async function readTextNoFollow(file, maxBytes = 4 * 1024 * 1024) {
|
|
76
87
|
const info = await lstat(file);
|
|
77
88
|
if (info.isSymbolicLink()) throw new Error(`${path.basename(file)}: symbolic link, read refused`);
|
|
78
89
|
if (!info.isFile()) throw new Error(`${path.basename(file)}: not a regular file`);
|
|
79
90
|
if (info.size > maxBytes) throw new Error(`${path.basename(file)}: file is larger than ${Math.round(maxBytes / 1024)} KB`);
|
|
80
|
-
const
|
|
91
|
+
const flags = process.platform === "win32" ? "r" : constants.O_RDONLY | constants.O_NOFOLLOW;
|
|
92
|
+
const handle = await open(file, flags);
|
|
81
93
|
try {
|
|
82
94
|
return await handle.readFile({ encoding: "utf8" });
|
|
83
95
|
} finally {
|
|
84
96
|
await handle.close();
|
|
85
97
|
}
|
|
86
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
|
+
}
|
|
87
107
|
function packageRoot() {
|
|
88
108
|
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
89
109
|
for (; ; ) {
|
|
@@ -94,11 +114,103 @@ function packageRoot() {
|
|
|
94
114
|
dir = parent;
|
|
95
115
|
}
|
|
96
116
|
}
|
|
97
|
-
var CONFIG_FILES;
|
|
117
|
+
var CONFIG_FILES, LOCAL_CONFIG_FILES;
|
|
98
118
|
var init_paths = __esm({
|
|
99
119
|
"src/core/paths.ts"() {
|
|
100
120
|
"use strict";
|
|
101
121
|
CONFIG_FILES = [".revdeck.yml", ".revdeck.yaml"];
|
|
122
|
+
LOCAL_CONFIG_FILES = [".revdeck.local.yml", ".revdeck.local.yaml"];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
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";
|
|
102
214
|
}
|
|
103
215
|
});
|
|
104
216
|
|
|
@@ -133,6 +245,342 @@ var init_locale = __esm({
|
|
|
133
245
|
}
|
|
134
246
|
});
|
|
135
247
|
|
|
248
|
+
// src/core/review-roles.ts
|
|
249
|
+
function effectiveRoleIds(agents, roles) {
|
|
250
|
+
const base = roles.length ? roles : DEFAULT_REVIEW_ROLES;
|
|
251
|
+
return Array.from({ length: agents }, (_, index) => base[index % base.length]);
|
|
252
|
+
}
|
|
253
|
+
function resolveReviewRole(id, language, custom = {}) {
|
|
254
|
+
if (id in REVIEW_ROLES) {
|
|
255
|
+
const role2 = REVIEW_ROLES[id];
|
|
256
|
+
return {
|
|
257
|
+
id,
|
|
258
|
+
title: role2.title[language],
|
|
259
|
+
description: role2.focus[language],
|
|
260
|
+
criteria: role2.criteria,
|
|
261
|
+
instructions: ""
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const role = custom[id];
|
|
265
|
+
if (!role) return null;
|
|
266
|
+
return {
|
|
267
|
+
id,
|
|
268
|
+
title: role.title,
|
|
269
|
+
description: role.description,
|
|
270
|
+
criteria: role.criteria,
|
|
271
|
+
instructions: role.instructions ?? ""
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function roleCriteriaText(role) {
|
|
275
|
+
return role.criteria.length ? `\xA7${role.criteria.join(", \xA7")}` : "";
|
|
276
|
+
}
|
|
277
|
+
var REVIEW_ROLE_IDS, DEFAULT_REVIEW_ROLES, REVIEW_ROLES;
|
|
278
|
+
var init_review_roles = __esm({
|
|
279
|
+
"src/core/review-roles.ts"() {
|
|
280
|
+
"use strict";
|
|
281
|
+
REVIEW_ROLE_IDS = [
|
|
282
|
+
"correctness",
|
|
283
|
+
"architecture",
|
|
284
|
+
"tests",
|
|
285
|
+
"security",
|
|
286
|
+
"performance",
|
|
287
|
+
"compatibility",
|
|
288
|
+
"docs",
|
|
289
|
+
"concurrency",
|
|
290
|
+
"ux",
|
|
291
|
+
"data",
|
|
292
|
+
"api",
|
|
293
|
+
"dependencies",
|
|
294
|
+
"observability",
|
|
295
|
+
"build",
|
|
296
|
+
"privacy",
|
|
297
|
+
"general"
|
|
298
|
+
];
|
|
299
|
+
DEFAULT_REVIEW_ROLES = ["correctness", "architecture", "tests"];
|
|
300
|
+
REVIEW_ROLES = {
|
|
301
|
+
correctness: {
|
|
302
|
+
criteria: ["6", "10"],
|
|
303
|
+
title: { ru: "\u041A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u043E\u0441\u0442\u044C", en: "Correctness" },
|
|
304
|
+
focus: { ru: "\u043B\u043E\u0433\u0438\u043A\u0430, \u0433\u0440\u0430\u043D\u0438\u0447\u043D\u044B\u0435 \u0441\u043B\u0443\u0447\u0430\u0438, \u043E\u0448\u0438\u0431\u043A\u0438, null/undefined, async \u0438 \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435", en: "logic, edge cases, errors, null/undefined, async and state" }
|
|
305
|
+
},
|
|
306
|
+
architecture: {
|
|
307
|
+
criteria: ["3", "4", "5", "7"],
|
|
308
|
+
title: { ru: "\u0410\u0440\u0445\u0438\u0442\u0435\u043A\u0442\u0443\u0440\u0430", en: "Architecture" },
|
|
309
|
+
focus: { ru: "\u0441\u043B\u043E\u0438 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438, \u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043D\u043D\u043E\u0441\u0442\u044C, \u0441\u0432\u044F\u0437\u043D\u043E\u0441\u0442\u044C, \u043F\u0440\u0435\u0446\u0435\u0434\u0435\u043D\u0442\u044B \u0438 ADR", en: "layers and dependencies, responsibility, coupling, precedents and ADRs" }
|
|
310
|
+
},
|
|
311
|
+
tests: {
|
|
312
|
+
criteria: ["8"],
|
|
313
|
+
title: { ru: "\u0422\u0435\u0441\u0442\u044B", en: "Tests" },
|
|
314
|
+
focus: { ru: "\u043F\u043E\u043A\u0440\u044B\u0442\u0438\u0435, assertions, \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044E\u0449\u0438\u0435 \u0441\u0446\u0435\u043D\u0430\u0440\u0438\u0438 \u0438 \u043D\u0435\u0441\u0442\u0430\u0431\u0438\u043B\u044C\u043D\u044B\u0435 \u0442\u0435\u0441\u0442\u044B", en: "coverage, assertions, missing scenarios and flaky tests" }
|
|
315
|
+
},
|
|
316
|
+
security: {
|
|
317
|
+
criteria: ["10"],
|
|
318
|
+
title: { ru: "\u0411\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0441\u0442\u044C", en: "Security" },
|
|
319
|
+
focus: { ru: "\u0430\u0432\u0442\u043E\u0440\u0438\u0437\u0430\u0446\u0438\u044F, \u0432\u0430\u043B\u0438\u0434\u0430\u0446\u0438\u044F \u0432\u0432\u043E\u0434\u0430, \u0441\u0435\u043A\u0440\u0435\u0442\u044B, \u0438\u043D\u044A\u0435\u043A\u0446\u0438\u0438, shell \u0438 \u043E\u043F\u0430\u0441\u043D\u044B\u0435 \u043F\u0440\u0430\u0432\u0430", en: "authorization, input validation, secrets, injections, shell and dangerous permissions" }
|
|
320
|
+
},
|
|
321
|
+
performance: {
|
|
322
|
+
criteria: ["10"],
|
|
323
|
+
title: { ru: "\u041F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C", en: "Performance" },
|
|
324
|
+
focus: { ru: "\u0441\u043B\u043E\u0436\u043D\u043E\u0441\u0442\u044C, N+1, \u043B\u0438\u0448\u043D\u0438\u0435 \u0430\u043B\u043B\u043E\u043A\u0430\u0446\u0438\u0438, \u043A\u0435\u0448\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0438 \u0431\u043B\u043E\u043A\u0438\u0440\u0443\u044E\u0449\u0438\u0435 \u043E\u043F\u0435\u0440\u0430\u0446\u0438\u0438", en: "complexity, N+1, extra allocations, caching and blocking operations" }
|
|
325
|
+
},
|
|
326
|
+
compatibility: {
|
|
327
|
+
criteria: ["6", "7"],
|
|
328
|
+
title: { ru: "\u0421\u043E\u0432\u043C\u0435\u0441\u0442\u0438\u043C\u043E\u0441\u0442\u044C", en: "Compatibility" },
|
|
329
|
+
focus: { ru: "\u043F\u0443\u0431\u043B\u0438\u0447\u043D\u044B\u0439 API, \u043E\u0431\u0440\u0430\u0442\u043D\u0430\u044F \u0441\u043E\u0432\u043C\u0435\u0441\u0442\u0438\u043C\u043E\u0441\u0442\u044C, \u043C\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F \u043A\u043E\u043D\u0444\u0438\u0433\u043E\u0432", en: "public API, backward compatibility, migrations and config changes" }
|
|
330
|
+
},
|
|
331
|
+
docs: {
|
|
332
|
+
criteria: ["9"],
|
|
333
|
+
title: { ru: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u044F", en: "Documentation" },
|
|
334
|
+
focus: { ru: "\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u044F, \u043A\u043E\u043D\u0444\u0438\u0433\u0438, CHANGELOG \u0438 \u0441\u043E\u0433\u043B\u0430\u0441\u043E\u0432\u0430\u043D\u043D\u043E\u0441\u0442\u044C AI-\u0438\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u0439", en: "documentation, configs, CHANGELOG and consistency of AI instructions" }
|
|
335
|
+
},
|
|
336
|
+
concurrency: {
|
|
337
|
+
criteria: ["10"],
|
|
338
|
+
title: { ru: "\u041A\u043E\u043D\u043A\u0443\u0440\u0435\u043D\u0442\u043D\u043E\u0441\u0442\u044C", en: "Concurrency" },
|
|
339
|
+
focus: { ru: "\u0433\u043E\u043D\u043A\u0438, \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0438, \u0438\u0434\u0435\u043C\u043F\u043E\u0442\u0435\u043D\u0442\u043D\u043E\u0441\u0442\u044C, retries \u0438 \u043E\u0442\u043C\u0435\u043D\u0430 \u043E\u043F\u0435\u0440\u0430\u0446\u0438\u0439", en: "races, locks, idempotency, retries and cancellation" }
|
|
340
|
+
},
|
|
341
|
+
ux: {
|
|
342
|
+
criteria: ["9", "10"],
|
|
343
|
+
title: { ru: "UX \u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0441\u0442\u044C", en: "UX and accessibility" },
|
|
344
|
+
focus: { ru: "\u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u044F UI, \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0441\u0442\u044C, \u043E\u0448\u0438\u0431\u043A\u0438 \u0438 \u043F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u0435 \u043D\u0430 \u0443\u0437\u043A\u0438\u0445 \u044D\u043A\u0440\u0430\u043D\u0430\u0445", en: "UI states, accessibility, errors and narrow-screen behavior" }
|
|
345
|
+
},
|
|
346
|
+
data: {
|
|
347
|
+
criteria: ["3", "10"],
|
|
348
|
+
title: { ru: "\u0414\u0430\u043D\u043D\u044B\u0435 \u0438 \u043C\u0438\u0433\u0440\u0430\u0446\u0438\u0438", en: "Data and migrations" },
|
|
349
|
+
focus: { ru: "\u0441\u0445\u0435\u043C\u044B, \u043C\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435, \u043E\u0431\u0440\u0430\u0442\u043D\u0430\u044F \u0441\u043E\u0432\u043C\u0435\u0441\u0442\u0438\u043C\u043E\u0441\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0445", en: "schemas, migrations, storage and data backward compatibility" }
|
|
350
|
+
},
|
|
351
|
+
api: {
|
|
352
|
+
criteria: ["6", "7"],
|
|
353
|
+
title: { ru: "\u041F\u0443\u0431\u043B\u0438\u0447\u043D\u044B\u0439 API", en: "Public API" },
|
|
354
|
+
focus: { ru: "\u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442\u044B, \u0432\u0435\u0440\u0441\u0438\u043E\u043D\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 API, \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u043A\u0430 \u043E\u0448\u0438\u0431\u043E\u043A \u0438 \u0441\u043E\u0432\u043C\u0435\u0441\u0442\u0438\u043C\u043E\u0441\u0442\u044C \u043A\u043B\u0438\u0435\u043D\u0442\u043E\u0432", en: "contracts, API versioning, error handling and client compatibility" }
|
|
355
|
+
},
|
|
356
|
+
dependencies: {
|
|
357
|
+
criteria: ["3", "10"],
|
|
358
|
+
title: { ru: "\u0417\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438", en: "Dependencies" },
|
|
359
|
+
focus: { ru: "\u0432\u0435\u0440\u0441\u0438\u0438, \u043B\u0438\u0446\u0435\u043D\u0437\u0438\u0438, supply chain \u0438 \u043B\u0438\u0448\u043D\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438", en: "versions, licenses, supply chain and unnecessary dependencies" }
|
|
360
|
+
},
|
|
361
|
+
observability: {
|
|
362
|
+
criteria: ["9", "10"],
|
|
363
|
+
title: { ru: "\u041D\u0430\u0431\u043B\u044E\u0434\u0430\u0435\u043C\u043E\u0441\u0442\u044C", en: "Observability" },
|
|
364
|
+
focus: { ru: "\u043B\u043E\u0433\u0438, \u043C\u0435\u0442\u0440\u0438\u043A\u0438, \u0442\u0440\u0435\u0439\u0441\u044B, \u043E\u0448\u0438\u0431\u043A\u0438 \u0438 \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0434\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u043A\u0438", en: "logs, metrics, traces, errors and missing diagnostics" }
|
|
365
|
+
},
|
|
366
|
+
build: {
|
|
367
|
+
criteria: ["8", "9"],
|
|
368
|
+
title: { ru: "\u0421\u0431\u043E\u0440\u043A\u0430 \u0438 CI", en: "Build and CI" },
|
|
369
|
+
focus: { ru: "CI, \u0441\u0431\u043E\u0440\u043A\u0430, \u0443\u043F\u0430\u043A\u043E\u0432\u043A\u0430, \u043A\u0435\u0448\u0438 \u0438 \u0432\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0438\u043C\u043E\u0441\u0442\u044C", en: "CI, builds, packaging, caches and reproducibility" }
|
|
370
|
+
},
|
|
371
|
+
privacy: {
|
|
372
|
+
criteria: ["9", "10"],
|
|
373
|
+
title: { ru: "\u041F\u0440\u0438\u0432\u0430\u0442\u043D\u043E\u0441\u0442\u044C", en: "Privacy" },
|
|
374
|
+
focus: { ru: "PII, \u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0441\u043E\u043D\u0430\u043B\u044C\u043D\u044B\u0445 \u0434\u0430\u043D\u043D\u044B\u0445, \u043B\u043E\u0433\u0438 \u0438 \u0443\u0442\u0435\u0447\u043A\u0438", en: "PII, personal data storage, logs and leaks" }
|
|
375
|
+
},
|
|
376
|
+
general: {
|
|
377
|
+
criteria: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
|
|
378
|
+
title: { ru: "\u041E\u0431\u0449\u0435\u0435 \u0440\u0435\u0432\u044C\u044E", en: "General review" },
|
|
379
|
+
focus: { ru: "\u043F\u043E\u043B\u043D\u043E\u0435 \u0440\u0435\u0432\u044C\u044E \u043F\u043E \u0432\u0441\u0435\u043C \u0440\u0430\u0437\u0434\u0435\u043B\u0430\u043C Criteria.md", en: "full review across all Criteria.md sections" }
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
});
|
|
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
|
+
|
|
136
584
|
// src/core/redact.ts
|
|
137
585
|
function redact(value) {
|
|
138
586
|
let text = String(value ?? "").replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, " ");
|
|
@@ -168,7 +616,7 @@ var VERSION;
|
|
|
168
616
|
var init_version = __esm({
|
|
169
617
|
"src/version.ts"() {
|
|
170
618
|
"use strict";
|
|
171
|
-
VERSION = "0.
|
|
619
|
+
VERSION = "0.6.0";
|
|
172
620
|
}
|
|
173
621
|
});
|
|
174
622
|
|
|
@@ -418,6 +866,212 @@ var init_client = __esm({
|
|
|
418
866
|
}
|
|
419
867
|
});
|
|
420
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
|
+
|
|
421
1075
|
// src/cli/format.ts
|
|
422
1076
|
function printJson(value) {
|
|
423
1077
|
writers.out(JSON.stringify(value, null, 2));
|
|
@@ -479,6 +1133,17 @@ function renderContext(review, rules2, options = {}) {
|
|
|
479
1133
|
const limit = maxBytes > 0 ? maxBytes : Number.POSITIVE_INFINITY;
|
|
480
1134
|
const language = options.language ?? rules2.language ?? "en";
|
|
481
1135
|
const t = (ru, en) => language === "ru" ? ru : en;
|
|
1136
|
+
const agents = Math.max(1, options.agents ?? rules2.agents ?? 1);
|
|
1137
|
+
const planRoles = options.roles ?? rules2.roles ?? effectiveRoleIds(agents, DEFAULT_REVIEW_ROLES);
|
|
1138
|
+
const roles = Array.isArray(planRoles) && planRoles.length && typeof planRoles[0] === "object" ? planRoles : effectiveRoleIds(agents, planRoles).map((id) => resolveReviewRole(id, language)).filter((role) => Boolean(role));
|
|
1139
|
+
const selectedRole = options.role ? roles.find((role) => role.id === options.role) : void 0;
|
|
1140
|
+
if (options.role && !selectedRole) throw new Error(`unknown review role: ${options.role}`);
|
|
1141
|
+
const shardCount = options.shard?.count ?? 1;
|
|
1142
|
+
const shardIndex = options.shard?.index ?? 1;
|
|
1143
|
+
const visibleFiles = shardCount > 1 ? review.files.filter((_, index) => index % shardCount === shardIndex - 1) : review.files;
|
|
1144
|
+
const visiblePaths = new Set(visibleFiles.map((file) => file.path));
|
|
1145
|
+
const visibleThreads = shardCount > 1 ? review.threads.filter((thread) => !thread.path || visiblePaths.has(thread.path)) : review.threads;
|
|
1146
|
+
const visibleNotes = shardCount > 1 ? review.notes.filter((note) => visiblePaths.has(note.file)) : review.notes;
|
|
482
1147
|
const lines = [];
|
|
483
1148
|
const push = (line = "") => {
|
|
484
1149
|
lines.push(line);
|
|
@@ -502,6 +1167,34 @@ function renderContext(review, rules2, options = {}) {
|
|
|
502
1167
|
push("**\u042F\u0437\u044B\u043A \u0432\u044B\u0432\u043E\u0434\u0430:** \u043F\u0438\u0448\u0438 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F, \u043E\u0442\u0432\u0435\u0442\u044B \u0438 \u0432\u044B\u0436\u0438\u043C\u043A\u0443 \u043F\u043E-\u0440\u0443\u0441\u0441\u043A\u0438. \u041F\u0440\u0430\u0432\u0438\u043B\u0430 \u043F\u0440\u043E\u0435\u043A\u0442\u0430 \u043C\u043E\u0433\u0443\u0442 \u0431\u044B\u0442\u044C \u043D\u0430 \u0434\u0440\u0443\u0433\u043E\u043C \u044F\u0437\u044B\u043A\u0435 \u2014 \u0446\u0438\u0442\u0438\u0440\u0443\u0439 \u0438\u0445 \u043A\u0430\u043A \u0435\u0441\u0442\u044C.");
|
|
503
1168
|
}
|
|
504
1169
|
push("");
|
|
1170
|
+
if (agents > 1 || options.role || shardCount > 1) {
|
|
1171
|
+
push(`## ${t("\u041C\u043D\u043E\u0433\u043E\u0430\u0433\u0435\u043D\u0442\u043D\u043E\u0435 \u0440\u0435\u0432\u044C\u044E", "Multi-agent review")}`);
|
|
1172
|
+
push(`${t("\u0410\u0433\u0435\u043D\u0442\u043E\u0432", "Agents")}: ${agents}`);
|
|
1173
|
+
push(`${t("\u0420\u043E\u043B\u0438", "Roles")}: ${roles.map((role) => role.title).join(", ")}`);
|
|
1174
|
+
if (selectedRole) {
|
|
1175
|
+
push(`### ${t("\u0420\u043E\u043B\u044C", "Role")}: ${selectedRole.title}`);
|
|
1176
|
+
if (selectedRole.criteria.length) push(`${t("\u041A\u0440\u0438\u0442\u0435\u0440\u0438\u0438", "Criteria")}: Criteria.md ${roleCriteriaText(selectedRole)}`);
|
|
1177
|
+
push(`${t("\u0424\u043E\u043A\u0443\u0441", "Focus")}: ${selectedRole.description}`);
|
|
1178
|
+
if (selectedRole.instructions) push(`${t("\u0418\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u0438", "Instructions")}: ${selectedRole.instructions}`);
|
|
1179
|
+
}
|
|
1180
|
+
if (shardCount > 1) {
|
|
1181
|
+
push(`### ${t("\u0428\u0430\u0440\u0434", "Shard")}: ${shardIndex}/${shardCount}`);
|
|
1182
|
+
push(t("\u0424\u0430\u0439\u043B\u044B \u044D\u0442\u043E\u0433\u043E \u0448\u0430\u0440\u0434\u0430:", "Files in this shard:"));
|
|
1183
|
+
for (const file of visibleFiles) push(`- ${file.path}`);
|
|
1184
|
+
}
|
|
1185
|
+
if (options.role || shardCount > 1) {
|
|
1186
|
+
push(t(
|
|
1187
|
+
"\u042D\u0442\u043E \u043D\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u044B\u0439 \u0448\u0430\u0440\u0434-\u0440\u0435\u0432\u044C\u044E\u0435\u0440. \u041D\u0435 \u0432\u044B\u0437\u044B\u0432\u0430\u0439 revdeck_draft_findings, revdeck_set_summary, revdeck_draft_reply: \u0432\u0435\u0440\u043D\u0438 \u043B\u0438\u0434-\u0430\u0433\u0435\u043D\u0442\u0443 JSON \u0441 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F\u043C\u0438 \u0438 \u043A\u043E\u0440\u043E\u0442\u043A\u043E\u0439 \u0432\u044B\u0436\u0438\u043C\u043A\u043E\u0439.",
|
|
1188
|
+
"This is an independent shard reviewer. Do not call revdeck_draft_findings, revdeck_set_summary or revdeck_draft_reply: return JSON with findings and a short summary to the lead agent."
|
|
1189
|
+
));
|
|
1190
|
+
} else {
|
|
1191
|
+
push(t(
|
|
1192
|
+
"\u0422\u044B \u043B\u0438\u0434-\u0430\u0433\u0435\u043D\u0442: \u0437\u0430\u043F\u0443\u0441\u0442\u0438 \u043F\u043E \u043E\u0434\u043D\u043E\u043C\u0443 \u0441\u0443\u0431\u0430\u0433\u0435\u043D\u0442\u0443 \u043D\u0430 \u0440\u043E\u043B\u044C \u0438 \u0448\u0430\u0440\u0434, \u043F\u0435\u0440\u0435\u0434\u0430\u0439 \u043A\u0430\u0436\u0434\u043E\u043C\u0443 `revdeck_context --role <role> --shard i/N`, \u0441\u043E\u0431\u0435\u0440\u0438 JSON, \u0443\u0431\u0435\u0440\u0438 \u0434\u0443\u0431\u043B\u0438 \u043F\u043E file:line:title \u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u043E\u0442\u043E\u043C \u0437\u0430\u043F\u0438\u0448\u0438 \u0438\u0442\u043E\u0433\u043E\u0432\u044B\u0435 findings \u0438 summary.",
|
|
1193
|
+
"You are the lead agent: spawn one subagent per role and shard, give each `revdeck_context --role <role> --shard i/N`, collect JSON, deduplicate by file:line:title, and only then write the final findings and summary."
|
|
1194
|
+
));
|
|
1195
|
+
}
|
|
1196
|
+
push("");
|
|
1197
|
+
}
|
|
505
1198
|
if (review.summary) {
|
|
506
1199
|
push(`## ${t("\u0412\u044B\u0436\u0438\u043C\u043A\u0430", "Summary")}`);
|
|
507
1200
|
if (review.summary.title) push(`**${review.summary.title}**`);
|
|
@@ -517,16 +1210,23 @@ function renderContext(review, rules2, options = {}) {
|
|
|
517
1210
|
}
|
|
518
1211
|
push("");
|
|
519
1212
|
}
|
|
520
|
-
push(`## ${t("\u0424\u0430\u0439\u043B\u044B", "Files")} (${review.files.length})`);
|
|
521
|
-
for (const file of
|
|
1213
|
+
push(`## ${t("\u0424\u0430\u0439\u043B\u044B", "Files")} (${visibleFiles.length}${shardCount > 1 ? ` / ${review.files.length}` : ""})`);
|
|
1214
|
+
for (const file of visibleFiles) {
|
|
522
1215
|
push(`- ${file.path} (${file.status}, +${file.additions} \u2212${file.deletions})${file.binary ? " [binary]" : ""}`);
|
|
523
1216
|
}
|
|
524
1217
|
push("");
|
|
1218
|
+
if (review.groups?.length) {
|
|
1219
|
+
push(`## ${t("\u0413\u0440\u0443\u043F\u043F\u044B \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439", "Change groups")}`);
|
|
1220
|
+
for (const group of review.groups) {
|
|
1221
|
+
push(`- ${group.title}: ${group.files.length} ${t("\u0444\u0430\u0439\u043B(\u043E\u0432)", "file(s)")}, +${group.additions} \u2212${group.deletions}`);
|
|
1222
|
+
}
|
|
1223
|
+
push("");
|
|
1224
|
+
}
|
|
525
1225
|
push(rules2.markdown.trim());
|
|
526
1226
|
push("");
|
|
527
|
-
const openThreads =
|
|
528
|
-
push(`## ${t("\u041E\u0431\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u044F", "Discussions")} (${review.threads.length}, ${t("\u043E\u0442\u043A\u0440\u044B\u0442\u044B\u0445", "open")} ${openThreads.length})`);
|
|
529
|
-
for (const thread of
|
|
1227
|
+
const openThreads = visibleThreads.filter((thread) => !thread.resolved);
|
|
1228
|
+
push(`## ${t("\u041E\u0431\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u044F", "Discussions")} (${visibleThreads.length}${shardCount > 1 ? ` / ${review.threads.length}` : ""}, ${t("\u043E\u0442\u043A\u0440\u044B\u0442\u044B\u0445", "open")} ${openThreads.length})`);
|
|
1229
|
+
for (const thread of visibleThreads) {
|
|
530
1230
|
const place = thread.path ? `${thread.path}:${thread.line ?? "?"}` : t("\u043E\u0431\u0449\u0438\u0439", "general");
|
|
531
1231
|
push(`### ${place} \xB7 ${thread.resolved ? t("\u0437\u0430\u043A\u0440\u044B\u0442", "resolved") : t("\u043E\u0442\u043A\u0440\u044B\u0442", "open")} \xB7 \`${thread.id}\``);
|
|
532
1232
|
if (thread.snippet) {
|
|
@@ -554,9 +1254,9 @@ function renderContext(review, rules2, options = {}) {
|
|
|
554
1254
|
if (finding.agentNote) push(` \u2192 ${t("\u0430\u0433\u0435\u043D\u0442\u0443", "to agent")}: ${truncate(finding.agentNote, 500)}`);
|
|
555
1255
|
}
|
|
556
1256
|
push("");
|
|
557
|
-
if (
|
|
558
|
-
push(`## ${t("\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044F \u043A \u0441\u0442\u0440\u043E\u043A\u0430\u043C", "Line comments from the human")} (${
|
|
559
|
-
for (const note of
|
|
1257
|
+
if (visibleNotes.length) {
|
|
1258
|
+
push(`## ${t("\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044F \u043A \u0441\u0442\u0440\u043E\u043A\u0430\u043C", "Line comments from the human")} (${visibleNotes.length})`);
|
|
1259
|
+
for (const note of visibleNotes) {
|
|
560
1260
|
push(`- \`${note.id}\` \xB7 ${note.file}:${note.line} \xB7 ${note.toAgent ? t("\u0430\u0433\u0435\u043D\u0442\u0443", "to agent") : t("\u0441\u0435\u0431\u0435", "private")}${note.agentAction ? ` \xB7 ${note.agentAction}` : ""}`);
|
|
561
1261
|
push(` ${truncate(note.text, 500)}`);
|
|
562
1262
|
if (note.agentReply) push(` \u2192 ${truncate(note.agentReply, 500)}`);
|
|
@@ -568,62 +1268,207 @@ function renderContext(review, rules2, options = {}) {
|
|
|
568
1268
|
for (const check of rules2.checks) {
|
|
569
1269
|
push(`- ${check.id}: \`${check.argv.join(" ")}\`${check.matched ? "" : ` (${t("\u043D\u0435 \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0441\u044F \u043A diff", "does not match the diff")})`}${check.consent ? ` \xB7 ${t("\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u044F", "requires confirmation")}` : ""}`);
|
|
570
1270
|
}
|
|
571
|
-
push("");
|
|
572
|
-
}
|
|
573
|
-
push(`## ${t("\u041A\u0430\u043A \u0434\u0435\u0439\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C", "What to do next")}`);
|
|
574
|
-
push(
|
|
575
|
-
t(
|
|
576
|
-
"- \u0417\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F: `revdeck_draft_findings` (MCP) \u0438\u043B\u0438 `revdeck findings <N> set --file findings.json`.",
|
|
577
|
-
"- Findings: `revdeck_draft_findings` (MCP) or `revdeck findings <N> set --file findings.json`."
|
|
578
|
-
)
|
|
579
|
-
);
|
|
580
|
-
push(
|
|
581
|
-
t(
|
|
582
|
-
"- \u041E\u0442\u0432\u0435\u0442\u044B: `revdeck_draft_reply` / `revdeck reply <N> --thread <id> --body ...`.",
|
|
583
|
-
"- Replies: `revdeck_draft_reply` / `revdeck reply <N> --thread <id> --body ...`."
|
|
584
|
-
)
|
|
585
|
-
);
|
|
586
|
-
push(
|
|
587
|
-
t(
|
|
588
|
-
"- \u0412\u044B\u0436\u0438\u043C\u043A\u0430: `revdeck_set_summary` / `revdeck context` \u043F\u043E\u0441\u043B\u0435 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F.",
|
|
589
|
-
"- Summary: `revdeck_set_summary` / `revdeck context` after refreshing."
|
|
1271
|
+
push("");
|
|
1272
|
+
}
|
|
1273
|
+
push(`## ${t("\u041A\u0430\u043A \u0434\u0435\u0439\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C", "What to do next")}`);
|
|
1274
|
+
push(
|
|
1275
|
+
t(
|
|
1276
|
+
"- \u0417\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F: `revdeck_draft_findings` (MCP) \u0438\u043B\u0438 `revdeck findings <N> set --file findings.json`.",
|
|
1277
|
+
"- Findings: `revdeck_draft_findings` (MCP) or `revdeck findings <N> set --file findings.json`."
|
|
1278
|
+
)
|
|
1279
|
+
);
|
|
1280
|
+
push(
|
|
1281
|
+
t(
|
|
1282
|
+
"- \u041E\u0442\u0432\u0435\u0442\u044B: `revdeck_draft_reply` / `revdeck reply <N> --thread <id> --body ...`.",
|
|
1283
|
+
"- Replies: `revdeck_draft_reply` / `revdeck reply <N> --thread <id> --body ...`."
|
|
1284
|
+
)
|
|
1285
|
+
);
|
|
1286
|
+
push(
|
|
1287
|
+
t(
|
|
1288
|
+
"- \u0412\u044B\u0436\u0438\u043C\u043A\u0430: `revdeck_set_summary` / `revdeck context` \u043F\u043E\u0441\u043B\u0435 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F.",
|
|
1289
|
+
"- Summary: `revdeck_set_summary` / `revdeck context` after refreshing."
|
|
1290
|
+
)
|
|
1291
|
+
);
|
|
1292
|
+
push(
|
|
1293
|
+
t(
|
|
1294
|
+
"- \u041F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F: \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u043E\u0441\u043B\u0435 \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u044F \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u043E\u043C; \u0430\u0433\u0435\u043D\u0442 \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u0442\u044C \u0441\u0430\u043C.",
|
|
1295
|
+
"- Publishing: only after human confirmation; the agent cannot publish on its own."
|
|
1296
|
+
)
|
|
1297
|
+
);
|
|
1298
|
+
const text = lines.join("\n");
|
|
1299
|
+
return Number.isFinite(limit) && text.length > limit ? `${text.slice(0, limit)}
|
|
1300
|
+
|
|
1301
|
+
[${t("\u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u043E\u0431\u0440\u0435\u0437\u0430\u043D", "context truncated")}: ${text.length} > ${limit} ${t("\u0431\u0430\u0439\u0442", "bytes")}]` : text;
|
|
1302
|
+
}
|
|
1303
|
+
function contextPayload(review, rules2) {
|
|
1304
|
+
return {
|
|
1305
|
+
review: {
|
|
1306
|
+
id: review.id,
|
|
1307
|
+
info: review.info,
|
|
1308
|
+
stats: review.stats,
|
|
1309
|
+
files: review.files,
|
|
1310
|
+
summary: review.summary,
|
|
1311
|
+
threads: review.threads,
|
|
1312
|
+
findings: review.findings,
|
|
1313
|
+
drafts: review.drafts,
|
|
1314
|
+
notes: review.notes,
|
|
1315
|
+
errors: review.errors,
|
|
1316
|
+
stale: review.stale,
|
|
1317
|
+
syncedAt: review.syncedAt
|
|
1318
|
+
},
|
|
1319
|
+
rules: rules2,
|
|
1320
|
+
language: rules2.language,
|
|
1321
|
+
multiAgent: {
|
|
1322
|
+
agents: rules2.agents ?? 1,
|
|
1323
|
+
roles: rules2.roles ?? DEFAULT_REVIEW_ROLES.map((id) => resolveReviewRole(id, rules2.language)).filter(Boolean)
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
var init_context = __esm({
|
|
1328
|
+
"src/context.ts"() {
|
|
1329
|
+
"use strict";
|
|
1330
|
+
init_format();
|
|
1331
|
+
init_review_roles();
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
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}`
|
|
590
1454
|
)
|
|
591
1455
|
);
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
"- Publishing: only after human confirmation; the agent cannot publish on its own."
|
|
596
|
-
)
|
|
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."
|
|
597
1459
|
);
|
|
598
|
-
|
|
599
|
-
return Number.isFinite(limit) && text.length > limit ? `${text.slice(0, limit)}
|
|
600
|
-
|
|
601
|
-
[${t("\u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u043E\u0431\u0440\u0435\u0437\u0430\u043D", "context truncated")}: ${text.length} > ${limit} ${t("\u0431\u0430\u0439\u0442", "bytes")}]` : text;
|
|
602
|
-
}
|
|
603
|
-
function contextPayload(review, rules2) {
|
|
604
|
-
return {
|
|
605
|
-
review: {
|
|
606
|
-
id: review.id,
|
|
607
|
-
info: review.info,
|
|
608
|
-
stats: review.stats,
|
|
609
|
-
files: review.files,
|
|
610
|
-
summary: review.summary,
|
|
611
|
-
threads: review.threads,
|
|
612
|
-
findings: review.findings,
|
|
613
|
-
drafts: review.drafts,
|
|
614
|
-
notes: review.notes,
|
|
615
|
-
errors: review.errors,
|
|
616
|
-
stale: review.stale,
|
|
617
|
-
syncedAt: review.syncedAt
|
|
618
|
-
},
|
|
619
|
-
rules: rules2,
|
|
620
|
-
language: rules2.language
|
|
621
|
-
};
|
|
1460
|
+
throw error;
|
|
622
1461
|
}
|
|
623
|
-
var
|
|
624
|
-
"src/
|
|
1462
|
+
var init_scope = __esm({
|
|
1463
|
+
"src/mcp/scope.ts"() {
|
|
625
1464
|
"use strict";
|
|
626
|
-
|
|
1465
|
+
init_config();
|
|
1466
|
+
init_paths();
|
|
1467
|
+
init_projects();
|
|
1468
|
+
init_refs();
|
|
1469
|
+
init_refs();
|
|
1470
|
+
init_locale();
|
|
1471
|
+
init_provider();
|
|
627
1472
|
}
|
|
628
1473
|
});
|
|
629
1474
|
|
|
@@ -636,6 +1481,48 @@ async function client() {
|
|
|
636
1481
|
if (!clientPromise) clientPromise = ensureDaemon().then((result) => result.client);
|
|
637
1482
|
return clientPromise;
|
|
638
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
|
+
}
|
|
639
1526
|
async function call(method, params = {}) {
|
|
640
1527
|
const current2 = await client();
|
|
641
1528
|
try {
|
|
@@ -682,33 +1569,66 @@ async function main() {
|
|
|
682
1569
|
process.stderr.write(`revdeck MCP ${VERSION} ${tr("\u0433\u043E\u0442\u043E\u0432", "ready")} (root: ${defaultRoot})
|
|
683
1570
|
`);
|
|
684
1571
|
}
|
|
685
|
-
var server, defaultRoot, clientPromise,
|
|
1572
|
+
var server, defaultRoot, featureId, clientPromise, scopePromise, reviewSchema;
|
|
686
1573
|
var init_main = __esm({
|
|
687
1574
|
"src/mcp/main.ts"() {
|
|
688
1575
|
"use strict";
|
|
689
1576
|
init_client();
|
|
690
1577
|
init_context();
|
|
691
1578
|
init_redact();
|
|
1579
|
+
init_paths();
|
|
692
1580
|
init_version();
|
|
693
1581
|
init_locale();
|
|
1582
|
+
init_scope();
|
|
1583
|
+
init_refs();
|
|
694
1584
|
setLocale(detectLocale());
|
|
695
1585
|
server = new McpServer({ name: "revdeck", version: VERSION });
|
|
696
|
-
defaultRoot = process.env.REVDECK_ROOT ?? process.cwd();
|
|
1586
|
+
defaultRoot = findRepoRoot(process.env.REVDECK_ROOT ?? process.cwd());
|
|
1587
|
+
featureId = process.env.REVDECK_FEATURE?.trim() || null;
|
|
697
1588
|
clientPromise = null;
|
|
698
|
-
|
|
699
|
-
|
|
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");
|
|
700
1591
|
server.registerTool(
|
|
701
1592
|
"revdeck_status",
|
|
702
1593
|
{
|
|
703
1594
|
title: "revdeck status",
|
|
704
|
-
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.",
|
|
705
1596
|
inputSchema: {}
|
|
706
1597
|
},
|
|
707
1598
|
async () => {
|
|
708
1599
|
try {
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
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
|
+
);
|
|
712
1632
|
} catch (error) {
|
|
713
1633
|
return failure(error);
|
|
714
1634
|
}
|
|
@@ -718,22 +1638,35 @@ var init_main = __esm({
|
|
|
718
1638
|
"revdeck_list",
|
|
719
1639
|
{
|
|
720
1640
|
title: "Review list",
|
|
721
|
-
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.",
|
|
722
1642
|
inputSchema: {
|
|
723
1643
|
scope: z2.enum(["tracked", "open", "mine", "reviewing"]).optional().describe("Defaults to tracked; open/mine/reviewing require platform access"),
|
|
724
|
-
limit: z2.number().int().positive().max(100).optional()
|
|
725
|
-
root: rootSchema
|
|
1644
|
+
limit: z2.number().int().positive().max(100).optional()
|
|
726
1645
|
}
|
|
727
1646
|
},
|
|
728
|
-
async ({ scope, limit
|
|
1647
|
+
async ({ scope: listScope, limit }) => {
|
|
729
1648
|
try {
|
|
730
|
-
|
|
731
|
-
|
|
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 });
|
|
732
1665
|
return ok(JSON.stringify(reviews, null, 2), { reviews });
|
|
733
1666
|
}
|
|
734
1667
|
const result = await call(
|
|
735
1668
|
"reviews.remoteList",
|
|
736
|
-
{ root: root
|
|
1669
|
+
{ root: current2.root, scope: listScope, limit: limit ?? 50 }
|
|
737
1670
|
);
|
|
738
1671
|
const text = result.items.map((item) => `#${item.ref.number} ${item.title} \xB7 ${item.author} \xB7 ${item.updatedAt}`).join("\n") || "Empty.";
|
|
739
1672
|
return ok(`${result.platform}:${result.project}
|
|
@@ -747,29 +1680,138 @@ ${text}`, result);
|
|
|
747
1680
|
"revdeck_open",
|
|
748
1681
|
{
|
|
749
1682
|
title: "Open review",
|
|
750
|
-
description: "Load
|
|
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.",
|
|
1684
|
+
inputSchema: {
|
|
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")
|
|
1686
|
+
}
|
|
1687
|
+
},
|
|
1688
|
+
async ({ input }) => {
|
|
1689
|
+
try {
|
|
1690
|
+
const current2 = await scope();
|
|
1691
|
+
await refreshFeatureScope(current2);
|
|
1692
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
1693
|
+
for (const value of inputs) assertReviewInScope(value, current2);
|
|
1694
|
+
const reviews = [];
|
|
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
|
+
}
|
|
1705
|
+
const result = await call("reviews.open", {
|
|
1706
|
+
root: current2.root,
|
|
1707
|
+
input: value
|
|
1708
|
+
});
|
|
1709
|
+
reviews.push(result.review);
|
|
1710
|
+
}
|
|
1711
|
+
const text = reviews.map((review) => `${summarize(review)}
|
|
1712
|
+
Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
1713
|
+
if (reviews.length === 1) return ok(text, { reviewId: reviews[0].id });
|
|
1714
|
+
return ok(text, { reviewIds: reviews.map((review) => review.id) });
|
|
1715
|
+
} catch (error) {
|
|
1716
|
+
return failure(error);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
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.",
|
|
751
1725
|
inputSchema: {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
project: z2.string().optional(),
|
|
756
|
-
host: z2.string().optional(),
|
|
757
|
-
branch: z2.string().optional()
|
|
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()
|
|
758
1729
|
}
|
|
759
1730
|
},
|
|
760
|
-
async ({
|
|
1731
|
+
async ({ action, feature: requested, max_bytes }) => {
|
|
761
1732
|
try {
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
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 } : {}
|
|
769
1757
|
});
|
|
770
|
-
return ok(
|
|
771
|
-
|
|
772
|
-
|
|
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 });
|
|
773
1815
|
} catch (error) {
|
|
774
1816
|
return failure(error);
|
|
775
1817
|
}
|
|
@@ -785,14 +1827,28 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
785
1827
|
refresh: z2.boolean().optional().describe("Fetch fresh diff and threads from the platform"),
|
|
786
1828
|
file: z2.string().optional().describe("Append the diff of one file"),
|
|
787
1829
|
max_bytes: z2.number().int().positive().max(5e5).optional(),
|
|
788
|
-
|
|
1830
|
+
role: z2.string().max(64).optional().describe("Role for an independent shard reviewer"),
|
|
1831
|
+
shard: z2.string().regex(/^\d+\/\d+$/).optional().describe("Shard as i/N, for example 1/3")
|
|
789
1832
|
}
|
|
790
1833
|
},
|
|
791
|
-
async ({ review, refresh, file, max_bytes }) => {
|
|
1834
|
+
async ({ review, refresh, file, max_bytes, role, shard }) => {
|
|
792
1835
|
try {
|
|
1836
|
+
await scopedReview(review);
|
|
793
1837
|
const { review: view } = await call("reviews.get", { review, refresh: refresh === true });
|
|
794
1838
|
const { rules: rules2 } = await call("rules.get", { review });
|
|
795
|
-
|
|
1839
|
+
const parsedShard = shard ? (() => {
|
|
1840
|
+
const [index, count] = shard.split("/").map(Number);
|
|
1841
|
+
if (!Number.isInteger(index) || !Number.isInteger(count) || index < 1 || count < 1 || index > count) {
|
|
1842
|
+
throw new Error("shard must be i/N with 1 <= i <= N");
|
|
1843
|
+
}
|
|
1844
|
+
return { index, count };
|
|
1845
|
+
})() : void 0;
|
|
1846
|
+
let text = renderContext(view, rules2, {
|
|
1847
|
+
maxBytes: max_bytes ?? rules2.maxBytes ?? 2e5,
|
|
1848
|
+
language: rules2.language,
|
|
1849
|
+
...role ? { role } : {},
|
|
1850
|
+
...parsedShard ? { shard: parsedShard } : {}
|
|
1851
|
+
});
|
|
796
1852
|
if (file) {
|
|
797
1853
|
const { file: diff2 } = await call("diff.get", {
|
|
798
1854
|
review,
|
|
@@ -829,6 +1885,7 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
829
1885
|
},
|
|
830
1886
|
async ({ review }) => {
|
|
831
1887
|
try {
|
|
1888
|
+
await scopedReview(review);
|
|
832
1889
|
const { review: view } = await call("reviews.get", { review });
|
|
833
1890
|
return ok(JSON.stringify(view.threads, null, 2), { threads: view.threads });
|
|
834
1891
|
} catch (error) {
|
|
@@ -849,6 +1906,7 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
849
1906
|
},
|
|
850
1907
|
async ({ review, file, max_lines }) => {
|
|
851
1908
|
try {
|
|
1909
|
+
await scopedReview(review);
|
|
852
1910
|
if (!file) {
|
|
853
1911
|
const { review: view } = await call("reviews.get", { review });
|
|
854
1912
|
const text = view.files.map((item) => `${item.status} +${item.additions} -${item.deletions} ${item.path}`).join("\n");
|
|
@@ -890,6 +1948,7 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
890
1948
|
},
|
|
891
1949
|
async ({ review, thread_id, body, resolve }) => {
|
|
892
1950
|
try {
|
|
1951
|
+
await scopedReview(review);
|
|
893
1952
|
const { draft } = await call("drafts.put", {
|
|
894
1953
|
review,
|
|
895
1954
|
threadId: thread_id,
|
|
@@ -925,6 +1984,7 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
925
1984
|
},
|
|
926
1985
|
async ({ review, findings: findings2 }) => {
|
|
927
1986
|
try {
|
|
1987
|
+
await scopedReview(review);
|
|
928
1988
|
const { findings: saved } = await call("findings.put", { review, findings: findings2 });
|
|
929
1989
|
return ok(`Findings saved: ${saved.length}.`, { findings: saved });
|
|
930
1990
|
} catch (error) {
|
|
@@ -946,11 +2006,12 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
946
2006
|
focus: z2.array(z2.string()).optional()
|
|
947
2007
|
}
|
|
948
2008
|
},
|
|
949
|
-
async ({ review, title, scope, summary: summary2, changes, focus }) => {
|
|
2009
|
+
async ({ review, title, scope: scope2, summary: summary2, changes, focus }) => {
|
|
950
2010
|
try {
|
|
2011
|
+
await scopedReview(review);
|
|
951
2012
|
const { summary: saved } = await call("summary.put", {
|
|
952
2013
|
review,
|
|
953
|
-
summary: { title: title ?? "", scope:
|
|
2014
|
+
summary: { title: title ?? "", scope: scope2 ?? "", summary: summary2 ?? "", changes: changes ?? [], focus: focus ?? [] }
|
|
954
2015
|
});
|
|
955
2016
|
return ok("Summary saved.", { summary: saved });
|
|
956
2017
|
} catch (error) {
|
|
@@ -972,6 +2033,7 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
972
2033
|
},
|
|
973
2034
|
async ({ review, action, note_id, text }) => {
|
|
974
2035
|
try {
|
|
2036
|
+
await scopedReview(review);
|
|
975
2037
|
if (action === "reply") {
|
|
976
2038
|
if (!note_id || !text) return ok("reply requires note_id and text.");
|
|
977
2039
|
const { note } = await call("notes.update", { review, noteId: note_id, patch: { agentReply: text } });
|
|
@@ -993,6 +2055,7 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
993
2055
|
},
|
|
994
2056
|
async ({ review }) => {
|
|
995
2057
|
try {
|
|
2058
|
+
await scopedReview(review);
|
|
996
2059
|
const { rules: rules2 } = await call("rules.get", { review });
|
|
997
2060
|
return ok(rules2.markdown, rules2);
|
|
998
2061
|
} catch (error) {
|
|
@@ -1013,6 +2076,7 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
1013
2076
|
},
|
|
1014
2077
|
async ({ review, kind, ids }) => {
|
|
1015
2078
|
try {
|
|
2079
|
+
await scopedReview(review);
|
|
1016
2080
|
const { review: view } = await call("reviews.get", { review });
|
|
1017
2081
|
const selected = ids ?? defaultSelection(view, kind);
|
|
1018
2082
|
const { preview } = await call("publish.preview", { review, kind, ids: selected });
|
|
@@ -1037,6 +2101,7 @@ ${preview.warnings.join("\n")}` : ""), { preview });
|
|
|
1037
2101
|
},
|
|
1038
2102
|
async ({ review, approval_id }) => {
|
|
1039
2103
|
try {
|
|
2104
|
+
await scopedReview(review);
|
|
1040
2105
|
const { result } = await call("publish.commit", {
|
|
1041
2106
|
review,
|
|
1042
2107
|
approvalId: approval_id
|
|
@@ -1090,13 +2155,13 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
|
|
|
1090
2155
|
})
|
|
1091
2156
|
);
|
|
1092
2157
|
server.registerPrompt(
|
|
1093
|
-
"
|
|
2158
|
+
"review-feature",
|
|
1094
2159
|
{
|
|
1095
|
-
title: "
|
|
1096
|
-
description: "
|
|
1097
|
-
argsSchema: {
|
|
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") }
|
|
1098
2163
|
},
|
|
1099
|
-
({
|
|
2164
|
+
({ feature: feature2 }) => ({
|
|
1100
2165
|
messages: [
|
|
1101
2166
|
{
|
|
1102
2167
|
role: "user",
|
|
@@ -1105,20 +2170,22 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
|
|
|
1105
2170
|
text: [
|
|
1106
2171
|
tr(
|
|
1107
2172
|
[
|
|
1108
|
-
`\
|
|
1109
|
-
"1.
|
|
1110
|
-
"2. \
|
|
1111
|
-
"3. \
|
|
1112
|
-
"4.
|
|
1113
|
-
"\
|
|
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."
|
|
1114
2180
|
].join("\n"),
|
|
1115
2181
|
[
|
|
1116
|
-
`
|
|
1117
|
-
"1.
|
|
1118
|
-
"2.
|
|
1119
|
-
"3.
|
|
1120
|
-
"4.
|
|
1121
|
-
"
|
|
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."
|
|
1122
2189
|
].join("\n")
|
|
1123
2190
|
)
|
|
1124
2191
|
].join("\n")
|
|
@@ -1127,221 +2194,66 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
|
|
|
1127
2194
|
]
|
|
1128
2195
|
})
|
|
1129
2196
|
);
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
function globToRegExp(glob) {
|
|
1174
|
-
let source = "";
|
|
1175
|
-
let index = 0;
|
|
1176
|
-
const pattern = glob.replace(/^\.\//, "").replace(/^\/+/, "");
|
|
1177
|
-
while (index < pattern.length) {
|
|
1178
|
-
const char = pattern[index];
|
|
1179
|
-
if (char === "*") {
|
|
1180
|
-
if (pattern[index + 1] === "*") {
|
|
1181
|
-
if (pattern[index + 2] === "/") {
|
|
1182
|
-
source += "(?:[^/]+/)*";
|
|
1183
|
-
index += 3;
|
|
1184
|
-
} else {
|
|
1185
|
-
source += ".*";
|
|
1186
|
-
index += 2;
|
|
1187
|
-
}
|
|
1188
|
-
} else {
|
|
1189
|
-
source += "[^/]*";
|
|
1190
|
-
index += 1;
|
|
1191
|
-
}
|
|
1192
|
-
continue;
|
|
1193
|
-
}
|
|
1194
|
-
if (char === "?") {
|
|
1195
|
-
source += "[^/]";
|
|
1196
|
-
index += 1;
|
|
1197
|
-
continue;
|
|
1198
|
-
}
|
|
1199
|
-
if (char === "{") {
|
|
1200
|
-
const end = pattern.indexOf("}", index);
|
|
1201
|
-
if (end > index) {
|
|
1202
|
-
const options = pattern.slice(index + 1, end).split(",").map((item) => escapeRegExp(item.trim()));
|
|
1203
|
-
source += `(?:${options.join("|")})`;
|
|
1204
|
-
index = end + 1;
|
|
1205
|
-
continue;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
source += escapeRegExp(char);
|
|
1209
|
-
index += 1;
|
|
1210
|
-
}
|
|
1211
|
-
return new RegExp(`^${source}$`);
|
|
1212
|
-
}
|
|
1213
|
-
function escapeRegExp(value) {
|
|
1214
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1215
|
-
}
|
|
1216
|
-
function classifyFile(path11) {
|
|
1217
|
-
const lower = path11.toLowerCase();
|
|
1218
|
-
if (/(^|\/)(node_modules|dist|build|coverage|vendor)\//.test(lower)) return "generated";
|
|
1219
|
-
if (/\.(md|mdx|rst|txt|adoc)$/.test(lower) || /(^|\/)(docs?|adr)\//.test(lower)) return "docs";
|
|
1220
|
-
if (/(^|\/)(__tests__|tests?|spec|e2e)\//.test(lower) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /_test\.go$/.test(lower)) return "test";
|
|
1221
|
-
if (/\.(css|scss|sass|less|styl)$/.test(lower)) return "style";
|
|
1222
|
-
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";
|
|
1223
|
-
if (/\.(generated|g)\.[cm]?[jt]s$|\.d\.ts$|(^|\/)generated\//.test(lower)) return "generated";
|
|
1224
|
-
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";
|
|
1225
|
-
return "other";
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
// src/core/config.ts
|
|
1229
|
-
init_locale();
|
|
1230
|
-
var matchSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
1231
|
-
var reviewConfigSchema = z.object({
|
|
1232
|
-
version: z.literal(1).default(1),
|
|
1233
|
-
provider: z.object({
|
|
1234
|
-
/** auto — по git remote; иначе явная платформа. */
|
|
1235
|
-
type: z.enum(["auto", "gitlab", "github"]).default("auto"),
|
|
1236
|
-
host: z.string().min(1).optional(),
|
|
1237
|
-
/** GitLab: group/project. GitHub: owner/repo. */
|
|
1238
|
-
project: z.string().min(1).optional(),
|
|
1239
|
-
/** База для локального diff, когда ревью идёт по ветке. */
|
|
1240
|
-
base: z.string().min(1).optional()
|
|
1241
|
-
}).prefault({}),
|
|
1242
|
-
output: z.object({
|
|
1243
|
-
language: z.enum(["auto", "ru", "en"]).default("auto")
|
|
1244
|
-
}).prefault({}),
|
|
1245
|
-
rules: z.object({
|
|
1246
|
-
/** Общие документы, если ни одна строка map не подошла. Пусто — автообнаружение. */
|
|
1247
|
-
sources: z.array(z.string().min(1)).default([]),
|
|
1248
|
-
/** Привязка путей к документам: match — glob, docs — пути с необязательной секцией `#…`. */
|
|
1249
|
-
map: z.array(
|
|
1250
|
-
z.object({
|
|
1251
|
-
match: matchSchema,
|
|
1252
|
-
docs: z.array(z.string().min(1)).min(1),
|
|
1253
|
-
note: z.string().optional()
|
|
1254
|
-
})
|
|
1255
|
-
).default([]),
|
|
1256
|
-
/** Пути, которые не ревьюятся (сгенерированный код и т.п.). */
|
|
1257
|
-
ignore: z.array(z.string().min(1)).default([]),
|
|
1258
|
-
/** 0 — без ограничения; иначе документ обрезается до этого размера. */
|
|
1259
|
-
maxDocumentBytes: z.number().int().nonnegative().default(0),
|
|
1260
|
-
/** 0 — без ограничения; иначе общий контекст правил обрезается. */
|
|
1261
|
-
maxTotalBytes: z.number().int().nonnegative().default(0)
|
|
1262
|
-
}).prefault({}),
|
|
1263
|
-
checks: z.array(
|
|
1264
|
-
z.object({
|
|
1265
|
-
id: z.string().min(1),
|
|
1266
|
-
name: z.string().optional(),
|
|
1267
|
-
/** argv без shell: первым идёт исполняемый файл. */
|
|
1268
|
-
argv: z.array(z.string()).min(1),
|
|
1269
|
-
/** Запускать, только если diff затронул эти glob-пути. */
|
|
1270
|
-
when: z.array(z.string()).default([]),
|
|
1271
|
-
consent: z.boolean().default(true),
|
|
1272
|
-
timeoutMs: z.number().int().positive().max(36e5).default(3e5)
|
|
1273
|
-
})
|
|
1274
|
-
).default([]),
|
|
1275
|
-
publish: z.object({
|
|
1276
|
-
requireApproval: z.boolean().default(true),
|
|
1277
|
-
maxComments: z.number().int().positive().max(200).default(50)
|
|
1278
|
-
}).prefault({})
|
|
1279
|
-
});
|
|
1280
|
-
var DISCOVERED_SOURCES = [
|
|
1281
|
-
"AGENTS.md",
|
|
1282
|
-
"CLAUDE.md",
|
|
1283
|
-
"CONTRIBUTING.md",
|
|
1284
|
-
"docs/ARCHITECTURE.md",
|
|
1285
|
-
"docs/Architecture.md",
|
|
1286
|
-
"docs/STYLEGUIDE.md",
|
|
1287
|
-
"docs/Styleguide.md",
|
|
1288
|
-
"docs/CONTRIBUTING.md"
|
|
1289
|
-
];
|
|
1290
|
-
function parseConfig(text, source = ".revdeck.yml") {
|
|
1291
|
-
let data;
|
|
1292
|
-
try {
|
|
1293
|
-
data = parseYaml(text);
|
|
1294
|
-
} catch (error) {
|
|
1295
|
-
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}`));
|
|
1296
|
-
}
|
|
1297
|
-
if (data === null || data === void 0) data = {};
|
|
1298
|
-
const result = reviewConfigSchema.safeParse(data);
|
|
1299
|
-
if (!result.success) {
|
|
1300
|
-
const issues = result.error.issues.slice(0, 10).map((issue) => `${issue.path.join(".") || "<\u043A\u043E\u0440\u0435\u043D\u044C>"}: ${issue.message}`).join("; ");
|
|
1301
|
-
throw new ConfigError(`${source}: ${issues}`, tr("\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u0441\u0445\u0435\u043C\u0443 \u0432 docs/configuration.md", "check the schema in docs/configuration.md"));
|
|
1302
|
-
}
|
|
1303
|
-
return result.data;
|
|
1304
|
-
}
|
|
1305
|
-
async function loadConfig(root = findRepoRoot()) {
|
|
1306
|
-
const warnings = [];
|
|
1307
|
-
const file = findConfigFile(root);
|
|
1308
|
-
let config2;
|
|
1309
|
-
if (file) {
|
|
1310
|
-
config2 = parseConfig(await readTextNoFollow(file), path2.relative(root, file) || file);
|
|
1311
|
-
} else {
|
|
1312
|
-
config2 = reviewConfigSchema.parse({});
|
|
1313
|
-
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"));
|
|
1314
|
-
}
|
|
1315
|
-
if (!config2.rules.sources.length && !config2.rules.map.length) {
|
|
1316
|
-
const found = DISCOVERED_SOURCES.filter((item) => existsSync2(path2.join(root, item)));
|
|
1317
|
-
config2.rules.sources = found;
|
|
1318
|
-
if (!found.length) {
|
|
1319
|
-
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"));
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
return { config: config2, path: file, warnings };
|
|
1323
|
-
}
|
|
1324
|
-
function assertConfigPath(root, relative) {
|
|
1325
|
-
const cleaned = relative.split("#")[0];
|
|
1326
|
-
const resolved = path2.resolve(root, cleaned);
|
|
1327
|
-
const rel = path2.relative(root, resolved);
|
|
1328
|
-
if (rel.startsWith("..") || path2.isAbsolute(rel)) {
|
|
1329
|
-
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`));
|
|
2197
|
+
server.registerPrompt(
|
|
2198
|
+
"close-feedback",
|
|
2199
|
+
{
|
|
2200
|
+
title: "Close feedback on your MR",
|
|
2201
|
+
description: "\u0420\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C \u0442\u0440\u0435\u0434\u044B, \u043F\u043E\u0434\u0433\u043E\u0442\u043E\u0432\u0438\u0442\u044C \u043F\u0440\u0430\u0432\u043A\u0438 \u0438 \u043E\u0442\u0432\u0435\u0442\u044B.",
|
|
2202
|
+
argsSchema: { review: z2.string().describe("Review number or URL") }
|
|
2203
|
+
},
|
|
2204
|
+
({ review }) => ({
|
|
2205
|
+
messages: [
|
|
2206
|
+
{
|
|
2207
|
+
role: "user",
|
|
2208
|
+
content: {
|
|
2209
|
+
type: "text",
|
|
2210
|
+
text: [
|
|
2211
|
+
tr(
|
|
2212
|
+
[
|
|
2213
|
+
`\u0420\u0430\u0437\u0431\u0435\u0440\u0438 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043A \u0441\u0432\u043E\u0435\u043C\u0443 \u0440\u0435\u0432\u044C\u044E ${review}.`,
|
|
2214
|
+
"1. revdeck_open \u0438 revdeck_context; revdeck_threads \u2014 \u0432\u0441\u0435 \u043E\u0442\u043A\u0440\u044B\u0442\u044B\u0435 \u0442\u0440\u0435\u0434\u044B.",
|
|
2215
|
+
"2. \u041F\u043E \u043A\u0430\u0436\u0434\u043E\u043C\u0443 \u0442\u0440\u0435\u0434\u0443 \u043F\u0440\u043E\u0432\u0435\u0440\u044C \u043A\u043E\u0434, \u043A\u043B\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0439: \u0438\u0441\u043F\u0440\u0430\u0432\u0438\u0442\u044C, \u043E\u0442\u0432\u0435\u0442\u0438\u0442\u044C, \u043D\u0435 \u0441\u043E\u0433\u043B\u0430\u0441\u0435\u043D, \u043D\u0435\u044F\u0441\u043D\u043E, \u0432\u043D\u0435 MR.",
|
|
2216
|
+
"3. \u0427\u0435\u0440\u043D\u043E\u0432\u0438\u043A\u0438 \u043E\u0442\u0432\u0435\u0442\u043E\u0432 \u2014 revdeck_draft_reply; \u043F\u0440\u0430\u0432\u043A\u0438 \u043A\u043E\u0434\u0430 \u043F\u043E\u043A\u0430\u0436\u0438 \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u0443.",
|
|
2217
|
+
"4. revdeck_notes: \u043E\u0442\u0432\u0435\u0442\u044C \u043D\u0430 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438 \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u0430 \u043A \u0441\u0442\u0440\u043E\u043A\u0430\u043C.",
|
|
2218
|
+
"\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\u0441\u043B\u0435 \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u044F."
|
|
2219
|
+
].join("\n"),
|
|
2220
|
+
[
|
|
2221
|
+
`Work through the feedback on your review ${review}.`,
|
|
2222
|
+
"1. revdeck_open and revdeck_context; revdeck_threads lists every open thread.",
|
|
2223
|
+
"2. Check the code for each thread and classify it: fix, reply, disagree, unclear, out of scope.",
|
|
2224
|
+
"3. Draft replies with revdeck_draft_reply; show code changes to the human.",
|
|
2225
|
+
"4. Use revdeck_notes to answer the human comments on lines.",
|
|
2226
|
+
"Publishing is done only by a human after confirmation."
|
|
2227
|
+
].join("\n")
|
|
2228
|
+
)
|
|
2229
|
+
].join("\n")
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
]
|
|
2233
|
+
})
|
|
2234
|
+
);
|
|
2235
|
+
main().catch((error) => {
|
|
2236
|
+
process.stderr.write(`revdeck MCP: ${redact(error instanceof Error ? error.message : error)}
|
|
2237
|
+
`);
|
|
2238
|
+
process.exit(1);
|
|
2239
|
+
});
|
|
1330
2240
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
}
|
|
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";
|
|
1339
2250
|
|
|
1340
2251
|
// src/core/rules.ts
|
|
2252
|
+
init_config();
|
|
2253
|
+
init_glob();
|
|
2254
|
+
init_redact();
|
|
1341
2255
|
import path3 from "node:path";
|
|
1342
2256
|
import { existsSync as existsSync3 } from "node:fs";
|
|
1343
|
-
init_paths();
|
|
1344
|
-
init_redact();
|
|
1345
2257
|
var MAX_READ_BYTES = 16 * 1024 * 1024;
|
|
1346
2258
|
async function buildEffectiveRules(options) {
|
|
1347
2259
|
const { root, config: config2, configPath } = options;
|
|
@@ -1373,7 +2285,7 @@ async function buildEffectiveRules(options) {
|
|
|
1373
2285
|
} else {
|
|
1374
2286
|
try {
|
|
1375
2287
|
const readLimit = Number.isFinite(documentLimit) ? Math.max(documentLimit * 2, 4096) : MAX_READ_BYTES;
|
|
1376
|
-
const raw = await
|
|
2288
|
+
const raw = await readConfigFile(root, relative, readLimit);
|
|
1377
2289
|
const truncated = Number.isFinite(documentLimit) && raw.length > documentLimit;
|
|
1378
2290
|
cached = { exists: true, text: truncated ? raw.slice(0, documentLimit) : raw, truncated };
|
|
1379
2291
|
} catch (error) {
|
|
@@ -1493,10 +2405,10 @@ function renderRules(rules2, options = {}) {
|
|
|
1493
2405
|
if (rules2.warnings.length) out.push(`${t("\u041F\u0440\u0435\u0434\u0443\u043F\u0440\u0435\u0436\u0434\u0435\u043D\u0438\u044F", "Warnings")}:
|
|
1494
2406
|
${rules2.warnings.map((item) => `- ${item}`).join("\n")}`);
|
|
1495
2407
|
const seen = /* @__PURE__ */ new Set();
|
|
1496
|
-
for (const
|
|
2408
|
+
for (const scope2 of rules2.scopes) {
|
|
1497
2409
|
out.push(`
|
|
1498
|
-
## ${
|
|
1499
|
-
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) {
|
|
1500
2412
|
const key = `${doc.path}#${doc.sections.join(",")}`;
|
|
1501
2413
|
const label = `${doc.path}${doc.sections.length ? `#${doc.sections.join(", ")}` : ""}`;
|
|
1502
2414
|
out.push(`- ${label}${doc.exists ? "" : ` (${t("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D", "not found")})`}`);
|
|
@@ -1528,162 +2440,25 @@ ${doc.excerpt}${doc.truncated ? `
|
|
|
1528
2440
|
|
|
1529
2441
|
// src/cli/main.ts
|
|
1530
2442
|
init_client();
|
|
1531
|
-
|
|
1532
|
-
// src/core/exec.ts
|
|
1533
|
-
import { execFile } from "node:child_process";
|
|
1534
|
-
import { access, constants } from "node:fs/promises";
|
|
1535
|
-
import os2 from "node:os";
|
|
1536
|
-
import path5 from "node:path";
|
|
1537
|
-
var SECRET_ENV = [
|
|
1538
|
-
"GITLAB_TOKEN",
|
|
1539
|
-
"GITLAB_PRIVATE_TOKEN",
|
|
1540
|
-
"GLAB_TOKEN",
|
|
1541
|
-
"CI_JOB_TOKEN",
|
|
1542
|
-
"GH_TOKEN",
|
|
1543
|
-
"GITHUB_TOKEN",
|
|
1544
|
-
"GITHUB_ENTERPRISE_TOKEN",
|
|
1545
|
-
"GIT_ASKPASS",
|
|
1546
|
-
"SSH_ASKPASS",
|
|
1547
|
-
"REVDECK_TOKEN"
|
|
1548
|
-
];
|
|
1549
|
-
function scrubEnv(extra) {
|
|
1550
|
-
const env = {};
|
|
1551
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
1552
|
-
if (SECRET_ENV.includes(key)) continue;
|
|
1553
|
-
env[key] = value;
|
|
1554
|
-
}
|
|
1555
|
-
env.PAGER = "cat";
|
|
1556
|
-
env.GIT_PAGER = "cat";
|
|
1557
|
-
env.GIT_TERMINAL_PROMPT = "0";
|
|
1558
|
-
env.NO_COLOR = "1";
|
|
1559
|
-
env.CLICOLOR = "0";
|
|
1560
|
-
env.FORCE_COLOR = "0";
|
|
1561
|
-
env.TERM = "dumb";
|
|
1562
|
-
return { ...env, ...extra };
|
|
1563
|
-
}
|
|
1564
|
-
var RESOLVED = /* @__PURE__ */ new Map();
|
|
1565
|
-
async function resolveExecutable(command) {
|
|
1566
|
-
if (command.includes("/") || command.includes("\\")) {
|
|
1567
|
-
try {
|
|
1568
|
-
await access(command, constants.X_OK);
|
|
1569
|
-
return command;
|
|
1570
|
-
} catch {
|
|
1571
|
-
return null;
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
const override = process.env[`REVDECK_${command.toUpperCase()}`];
|
|
1575
|
-
if (override) return override;
|
|
1576
|
-
const cached = RESOLVED.get(command);
|
|
1577
|
-
if (cached) return cached;
|
|
1578
|
-
const dirs = [
|
|
1579
|
-
...(process.env.PATH ?? "").split(path5.delimiter),
|
|
1580
|
-
path5.join(os2.homedir(), ".local", "bin"),
|
|
1581
|
-
path5.join(os2.homedir(), ".local", "share", "mise", "shims"),
|
|
1582
|
-
path5.join(os2.homedir(), ".asdf", "shims"),
|
|
1583
|
-
path5.join(os2.homedir(), ".npm-global", "bin"),
|
|
1584
|
-
"/opt/homebrew/bin",
|
|
1585
|
-
"/usr/local/bin",
|
|
1586
|
-
"/usr/bin",
|
|
1587
|
-
"/bin"
|
|
1588
|
-
].filter(Boolean);
|
|
1589
|
-
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
1590
|
-
for (const dir of [...new Set(dirs)]) {
|
|
1591
|
-
for (const extension of extensions) {
|
|
1592
|
-
const candidate = path5.join(dir, `${command}${extension}`);
|
|
1593
|
-
try {
|
|
1594
|
-
await access(candidate, constants.X_OK);
|
|
1595
|
-
RESOLVED.set(command, candidate);
|
|
1596
|
-
return candidate;
|
|
1597
|
-
} catch {
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
return null;
|
|
1602
|
-
}
|
|
1603
|
-
var run = async (command, args, options = {}) => {
|
|
1604
|
-
const executable = await resolveExecutable(command) ?? command;
|
|
1605
|
-
return new Promise((resolve, reject) => {
|
|
1606
|
-
const child = execFile(
|
|
1607
|
-
executable,
|
|
1608
|
-
args,
|
|
1609
|
-
{
|
|
1610
|
-
cwd: options.cwd,
|
|
1611
|
-
env: scrubEnv(options.env),
|
|
1612
|
-
timeout: options.timeoutMs ?? 12e4,
|
|
1613
|
-
maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
|
|
1614
|
-
encoding: "utf8",
|
|
1615
|
-
windowsHide: true,
|
|
1616
|
-
shell: false
|
|
1617
|
-
},
|
|
1618
|
-
(error, stdout, stderr) => {
|
|
1619
|
-
const exitCode = error?.code;
|
|
1620
|
-
const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
|
|
1621
|
-
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
1622
|
-
const reason = (stderr || stdout || error.message).trim();
|
|
1623
|
-
reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
|
|
1624
|
-
return;
|
|
1625
|
-
}
|
|
1626
|
-
resolve({ stdout, stderr, code });
|
|
1627
|
-
}
|
|
1628
|
-
);
|
|
1629
|
-
if (options.input !== void 0) {
|
|
1630
|
-
child.stdin?.end(options.input);
|
|
1631
|
-
}
|
|
1632
|
-
});
|
|
1633
|
-
};
|
|
1634
|
-
|
|
1635
|
-
// src/cli/main.ts
|
|
2443
|
+
init_exec();
|
|
1636
2444
|
init_redact();
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
var SSH_SCP = /^(?:ssh:\/\/)?(?:[^@/]+@)?([^:/]+)(?::(\d+))?[:/](.+?)(?:\.git)?\/?$/;
|
|
1640
|
-
function parseRemote(url) {
|
|
1641
|
-
const value = url.trim();
|
|
1642
|
-
if (!value) return null;
|
|
1643
|
-
let host = "";
|
|
1644
|
-
let projectPath = "";
|
|
1645
|
-
const http = /^(?:https?|git|ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+?)(?:\.git)?\/?$/.exec(value);
|
|
1646
|
-
if (http) {
|
|
1647
|
-
host = http[1];
|
|
1648
|
-
projectPath = http[2];
|
|
1649
|
-
} else {
|
|
1650
|
-
const scp = SSH_SCP.exec(value);
|
|
1651
|
-
if (!scp) return null;
|
|
1652
|
-
host = scp[1];
|
|
1653
|
-
projectPath = scp[3];
|
|
1654
|
-
}
|
|
1655
|
-
projectPath = projectPath.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
1656
|
-
if (!host || !projectPath || !projectPath.includes("/")) return null;
|
|
1657
|
-
return { host, project: projectPath, platform: detectPlatform(host), url: value };
|
|
1658
|
-
}
|
|
1659
|
-
function detectPlatform(host) {
|
|
1660
|
-
const lower = host.toLowerCase();
|
|
1661
|
-
if (lower === "github.com" || lower.endsWith(".github.com") || lower.includes("github")) return "github";
|
|
1662
|
-
if (lower === "gitlab.com" || lower.endsWith(".gitlab.com") || lower.includes("gitlab")) return "gitlab";
|
|
1663
|
-
return null;
|
|
1664
|
-
}
|
|
1665
|
-
async function gitRemote(root, remote = "origin") {
|
|
1666
|
-
try {
|
|
1667
|
-
const { stdout } = await run("git", ["config", "--get", `remote.${remote}.url`], { cwd: root, timeoutMs: 1e4 });
|
|
1668
|
-
return parseRemote(stdout.trim());
|
|
1669
|
-
} catch {
|
|
1670
|
-
return null;
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
// src/cli/main.ts
|
|
2445
|
+
init_git();
|
|
2446
|
+
init_refs();
|
|
1675
2447
|
init_version();
|
|
1676
2448
|
init_locale();
|
|
1677
2449
|
init_format();
|
|
1678
2450
|
|
|
1679
2451
|
// src/cli/init.ts
|
|
1680
2452
|
init_paths();
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
import path6 from "node:path";
|
|
2453
|
+
init_git();
|
|
2454
|
+
init_config();
|
|
1684
2455
|
init_redact();
|
|
1685
2456
|
init_locale();
|
|
2457
|
+
init_exec();
|
|
1686
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";
|
|
1687
2462
|
function mcpServer(locale2) {
|
|
1688
2463
|
return { command: "npx", args: ["-y", "revdeck", "mcp"], env: { REVDECK_LANG: locale2 } };
|
|
1689
2464
|
}
|
|
@@ -1710,6 +2485,17 @@ async function runInit(rootInput, options) {
|
|
|
1710
2485
|
"output:",
|
|
1711
2486
|
tr(" # auto \u2014 \u044F\u0437\u044B\u043A \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u044F MR/\u043E\u0431\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u0439, \u043B\u0438\u0431\u043E \u044F\u0432\u043D\u043E ru/en", " # auto \u2014 MR/thread language, or explicit ru/en"),
|
|
1712
2487
|
` language: ${options.outputLanguage}`,
|
|
2488
|
+
"review:",
|
|
2489
|
+
tr(" # \u0427\u0438\u0441\u043B\u043E \u043D\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u044B\u0445 \u0440\u0435\u0432\u044C\u044E\u0435\u0440\u043E\u0432 \u0438 \u0438\u0445 \u0440\u043E\u043B\u0438; \u0440\u043E\u043B\u0438 \u043A\u043E\u0440\u043E\u0447\u0435 agents \u043F\u043E\u0432\u0442\u043E\u0440\u044F\u044E\u0442\u0441\u044F.", " # Number of independent reviewers and their roles; shorter role lists repeat."),
|
|
2490
|
+
" agents: 3",
|
|
2491
|
+
" roles:",
|
|
2492
|
+
" - correctness",
|
|
2493
|
+
" - architecture",
|
|
2494
|
+
" - tests",
|
|
2495
|
+
tr(" # customRoles:", " # customRoles:"),
|
|
2496
|
+
tr(" # accessibility:", " # accessibility:"),
|
|
2497
|
+
tr(' # title: "\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0441\u0442\u044C"', ' # title: "Accessibility"'),
|
|
2498
|
+
tr(' # description: "\u041A\u043B\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0430, ARIA, \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442."', ' # description: "Keyboard, ARIA, contrast."'),
|
|
1713
2499
|
"rules:",
|
|
1714
2500
|
tr(" # \u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u044B \u0441 \u043F\u0440\u0430\u0432\u0438\u043B\u0430\u043C\u0438. \u0415\u0441\u043B\u0438 \u043F\u0443\u0441\u0442\u043E \u2014 \u0438\u0449\u0443\u0442\u0441\u044F AGENTS.md, CLAUDE.md, CONTRIBUTING.md, docs/*.", " # Rule documents. When empty, AGENTS.md, CLAUDE.md, CONTRIBUTING.md and docs/* are discovered."),
|
|
1715
2501
|
...sources.length ? [" sources:", ...sources.map((item) => ` - ${item}`)] : [tr(" # \u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u044B \u043F\u0435\u0440\u0435\u0447\u0438\u0441\u043B\u044F\u044E\u0442\u0441\u044F \u0437\u0434\u0435\u0441\u044C; \u043F\u0443\u0441\u0442\u043E\u0439 \u0441\u043F\u0438\u0441\u043E\u043A \u0432\u043A\u043B\u044E\u0447\u0430\u0435\u0442 \u0430\u0432\u0442\u043E\u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u0438\u0435.", " # List documents here; an empty list enables auto-discovery."), " sources: []"],
|
|
@@ -1920,11 +2706,18 @@ async function mergeMcpJson(file, root, mcp) {
|
|
|
1920
2706
|
}
|
|
1921
2707
|
async function ensureGitignore(root) {
|
|
1922
2708
|
const file = path6.join(root, ".gitignore");
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
2709
|
+
let current2 = existsSync5(file) ? await readFile3(file, "utf8") : "";
|
|
2710
|
+
const entries = [".revdeck/", ".revdeck.local.yml", ".revdeck.local.yaml"];
|
|
2711
|
+
const added = [];
|
|
2712
|
+
for (const entry of entries) {
|
|
2713
|
+
if (new RegExp(`(^|\\n)${entry.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$`, "m").test(current2)) continue;
|
|
2714
|
+
current2 += `${current2 && !current2.endsWith("\n") ? "\n" : ""}${entry}
|
|
2715
|
+
`;
|
|
2716
|
+
added.push(entry);
|
|
2717
|
+
}
|
|
2718
|
+
if (!added.length) return;
|
|
2719
|
+
await writeFile(file, current2);
|
|
2720
|
+
writers.out(tr(`\u2714 ${added.join(", ")} \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u044B \u0432 .gitignore`, `\u2714 ${added.join(", ")} added to .gitignore`));
|
|
1928
2721
|
}
|
|
1929
2722
|
async function installService(host) {
|
|
1930
2723
|
const glab = await resolveExecutable("glab");
|
|
@@ -2084,7 +2877,7 @@ function parseJsonc(text) {
|
|
|
2084
2877
|
}
|
|
2085
2878
|
return JSON.parse(cleaned);
|
|
2086
2879
|
}
|
|
2087
|
-
function
|
|
2880
|
+
function isRecord2(value) {
|
|
2088
2881
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2089
2882
|
}
|
|
2090
2883
|
|
|
@@ -2128,15 +2921,15 @@ function mergeDevcontainerConfig(existing, patch) {
|
|
|
2128
2921
|
const result = { ...existing };
|
|
2129
2922
|
const currentMounts = Array.isArray(existing.mounts) ? [...existing.mounts] : [];
|
|
2130
2923
|
for (const mount of patch.mounts) {
|
|
2131
|
-
const index = currentMounts.findIndex((item) =>
|
|
2924
|
+
const index = currentMounts.findIndex((item) => isRecord2(item) && item.target === mount.target);
|
|
2132
2925
|
if (index >= 0) currentMounts[index] = mount;
|
|
2133
2926
|
else currentMounts.push(mount);
|
|
2134
2927
|
}
|
|
2135
2928
|
result.mounts = currentMounts;
|
|
2136
|
-
const containerEnv =
|
|
2929
|
+
const containerEnv = isRecord2(existing.containerEnv) ? { ...existing.containerEnv } : {};
|
|
2137
2930
|
Object.assign(containerEnv, patch.containerEnv);
|
|
2138
2931
|
result.containerEnv = containerEnv;
|
|
2139
|
-
const remoteEnv =
|
|
2932
|
+
const remoteEnv = isRecord2(existing.remoteEnv) ? { ...existing.remoteEnv } : {};
|
|
2140
2933
|
Object.assign(remoteEnv, patch.remoteEnv);
|
|
2141
2934
|
result.remoteEnv = remoteEnv;
|
|
2142
2935
|
const runArgs = Array.isArray(existing.runArgs) ? existing.runArgs.filter((item) => typeof item === "string") : [];
|
|
@@ -2147,11 +2940,11 @@ function mergeDevcontainerConfig(existing, patch) {
|
|
|
2147
2940
|
function applyDevcontainerPatch(text, patch) {
|
|
2148
2941
|
let current2 = text;
|
|
2149
2942
|
const parsed = parseJsonc2(current2);
|
|
2150
|
-
if (!
|
|
2943
|
+
if (!isRecord2(parsed)) throw new Error("devcontainer.json: expected an object");
|
|
2151
2944
|
const formatting = { formattingOptions: { insertSpaces: true, tabSize: 2 } };
|
|
2152
2945
|
const mounts = Array.isArray(parsed.mounts) ? [...parsed.mounts] : [];
|
|
2153
2946
|
for (const mount of patch.mounts) {
|
|
2154
|
-
const index = mounts.findIndex((item) =>
|
|
2947
|
+
const index = mounts.findIndex((item) => isRecord2(item) && item.target === mount.target);
|
|
2155
2948
|
const path11 = ["mounts", index >= 0 ? index : mounts.length];
|
|
2156
2949
|
current2 = applyEdits(current2, modify(current2, path11, mount, formatting));
|
|
2157
2950
|
if (index >= 0) mounts[index] = mount;
|
|
@@ -2242,10 +3035,10 @@ async function mergeMcpEnv(root, env) {
|
|
|
2242
3035
|
if (!existsSync6(file)) continue;
|
|
2243
3036
|
try {
|
|
2244
3037
|
const data = JSON.parse(await readFile4(file, "utf8"));
|
|
2245
|
-
const servers =
|
|
2246
|
-
const server2 = servers &&
|
|
3038
|
+
const servers = isRecord2(data.mcpServers) ? data.mcpServers : null;
|
|
3039
|
+
const server2 = servers && isRecord2(servers.revdeck) ? servers.revdeck : null;
|
|
2247
3040
|
if (!server2) continue;
|
|
2248
|
-
server2.env = { ...
|
|
3041
|
+
server2.env = { ...isRecord2(server2.env) ? server2.env : {}, ...env };
|
|
2249
3042
|
await writeFile2(file, `${JSON.stringify(data, null, 2)}
|
|
2250
3043
|
`);
|
|
2251
3044
|
changed += 1;
|
|
@@ -2329,19 +3122,19 @@ async function runEject(rootInput, options) {
|
|
|
2329
3122
|
const text = await readFile5(devcontainer, "utf8");
|
|
2330
3123
|
try {
|
|
2331
3124
|
const parsed = parseJsonc(text);
|
|
2332
|
-
if (
|
|
3125
|
+
if (isRecord2(parsed)) {
|
|
2333
3126
|
const formatting = { formattingOptions: { insertSpaces: true, tabSize: 2 } };
|
|
2334
3127
|
let current2 = text;
|
|
2335
3128
|
let changed = false;
|
|
2336
3129
|
if (Array.isArray(parsed.mounts)) {
|
|
2337
|
-
const mounts = parsed.mounts.filter((item) => !(
|
|
3130
|
+
const mounts = parsed.mounts.filter((item) => !(isRecord2(item) && (item.target === CONTAINER_RUNTIME_DIR || item.target === CONTAINER_STATE_DIR)));
|
|
2338
3131
|
if (mounts.length !== parsed.mounts.length) {
|
|
2339
3132
|
current2 = applyEdits2(current2, modify2(current2, ["mounts"], mounts, formatting));
|
|
2340
3133
|
changed = true;
|
|
2341
3134
|
}
|
|
2342
3135
|
}
|
|
2343
3136
|
for (const key of ["containerEnv", "remoteEnv"]) {
|
|
2344
|
-
if (!
|
|
3137
|
+
if (!isRecord2(parsed[key])) continue;
|
|
2345
3138
|
const env = { ...parsed[key] };
|
|
2346
3139
|
for (const name of ["REVDECK_RUNTIME_DIR", "REVDECK_STATE_DIR", "REVDECK_DEV_CONTAINER", "REVDECK_UI_HOST"]) delete env[name];
|
|
2347
3140
|
if (Object.keys(env).length !== Object.keys(parsed[key]).length) {
|
|
@@ -2699,13 +3492,23 @@ var OPTIONS = {
|
|
|
2699
3492
|
limit: { type: "string" },
|
|
2700
3493
|
decision: { type: "string" },
|
|
2701
3494
|
note: { type: "string" },
|
|
3495
|
+
level: { type: "string" },
|
|
2702
3496
|
emoji: { type: "string" },
|
|
2703
3497
|
text: { type: "string" },
|
|
2704
3498
|
line: { type: "string" },
|
|
2705
3499
|
id: { type: "string" },
|
|
2706
3500
|
toAgent: { type: "boolean", default: true },
|
|
2707
3501
|
all: { type: "boolean", default: false },
|
|
2708
|
-
lang: { type: "string" }
|
|
3502
|
+
lang: { type: "string" },
|
|
3503
|
+
role: { 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 }
|
|
2709
3512
|
};
|
|
2710
3513
|
function parse(argv) {
|
|
2711
3514
|
try {
|
|
@@ -2722,10 +3525,15 @@ var HELP_RU = `revdeck ${VERSION} \u2014 \u0440\u0435\u0432\u044C\u044E GitLab/G
|
|
|
2722
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)
|
|
2723
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
|
|
2724
3527
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
2725
|
-
revdeck
|
|
2726
|
-
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)
|
|
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
|
|
2727
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
|
|
2728
|
-
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
|
|
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]
|
|
3534
|
+
revdeck stats <N> \u0430\u043D\u0430\u043B\u0438\u0442\u0438\u043A\u0430 \u0440\u0435\u0432\u044C\u044E: \u0440\u0435\u0448\u0435\u043D\u0438\u044F, \u043E\u0442\u043A\u043B\u043E\u043D\u0435\u043D\u0438\u044F, \u0442\u0440\u0435\u0434\u044B
|
|
3535
|
+
revdeck scan <N> \u0441\u043A\u0430\u043D \u0441\u0435\u043A\u0440\u0435\u0442\u043E\u0432 (\u0435\u0441\u043B\u0438 \u0432\u043A\u043B\u044E\u0447\u0451\u043D review.secrets)
|
|
3536
|
+
revdeck versions <N> \u0438\u0441\u0442\u043E\u0440\u0438\u044F \u0432\u0435\u0440\u0441\u0438\u0439 \u0440\u0435\u0432\u044C\u044E
|
|
2729
3537
|
revdeck threads <N> \u043E\u0431\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u044F
|
|
2730
3538
|
revdeck diff <N> [--file <\u043F\u0443\u0442\u044C>]
|
|
2731
3539
|
revdeck findings <N> [list|set --file <json>|decide --id <id> --decision accept|reject|discuss]
|
|
@@ -2751,10 +3559,15 @@ var HELP_EN = `revdeck ${VERSION} \u2014 code review for GitLab/GitHub, for huma
|
|
|
2751
3559
|
revdeck devcontainer connect a devcontainer to the host daemon (--write)
|
|
2752
3560
|
revdeck doctor check the environment and access
|
|
2753
3561
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
2754
|
-
revdeck
|
|
2755
|
-
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)
|
|
3565
|
+
revdeck open <url|N...> open one or more reviews
|
|
2756
3566
|
revdeck ui [N] link to the local UI
|
|
2757
|
-
revdeck context <N> agent context: rules, diff, threads
|
|
3567
|
+
revdeck context <N> agent context: rules, diff, threads [--role <role>] [--shard i/N]
|
|
3568
|
+
revdeck stats <N> review analytics: decisions, rejections, threads
|
|
3569
|
+
revdeck scan <N> secret scan (when review.secrets is enabled)
|
|
3570
|
+
revdeck versions <N> review version history
|
|
2758
3571
|
revdeck threads <N> discussions
|
|
2759
3572
|
revdeck diff <N> [--file <path>]
|
|
2760
3573
|
revdeck findings <N> [list|set --file <json>|decide --id <id> --decision accept|reject|discuss]
|
|
@@ -2805,17 +3618,29 @@ async function main2() {
|
|
|
2805
3618
|
return doctor(root);
|
|
2806
3619
|
case "daemon":
|
|
2807
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);
|
|
2808
3625
|
case "list":
|
|
2809
3626
|
return list(root, values);
|
|
2810
3627
|
case "open":
|
|
2811
|
-
return openReview(root, positionals
|
|
3628
|
+
return openReview(root, positionals, values);
|
|
2812
3629
|
case "ui":
|
|
2813
3630
|
return ui(positionals[0], values);
|
|
2814
3631
|
case "status":
|
|
2815
|
-
return status();
|
|
3632
|
+
return status(root, values);
|
|
2816
3633
|
case "context":
|
|
2817
3634
|
case "review":
|
|
2818
3635
|
return context(root, positionals[0], values);
|
|
3636
|
+
case "stats":
|
|
3637
|
+
case "analytics":
|
|
3638
|
+
return stats(positionals[0], values);
|
|
3639
|
+
case "scan":
|
|
3640
|
+
case "secrets":
|
|
3641
|
+
return secrets(positionals[0], values);
|
|
3642
|
+
case "versions":
|
|
3643
|
+
return versions(positionals[0], values);
|
|
2819
3644
|
case "threads":
|
|
2820
3645
|
return threads(positionals[0], values);
|
|
2821
3646
|
case "diff":
|
|
@@ -2913,29 +3738,250 @@ async function list(root, values) {
|
|
|
2913
3738
|
return;
|
|
2914
3739
|
}
|
|
2915
3740
|
await withClient(async ({ client: client2 }) => {
|
|
2916
|
-
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);
|
|
2917
3744
|
if (values.json) return printJson({ reviews });
|
|
2918
|
-
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>"));
|
|
2919
3746
|
for (const item of reviews) writers.out(reviewLine(item));
|
|
2920
3747
|
});
|
|
2921
3748
|
}
|
|
2922
|
-
async function
|
|
2923
|
-
|
|
3749
|
+
async function projects(root, args, values) {
|
|
3750
|
+
const action = args[0] ?? "list";
|
|
2924
3751
|
await withClient(async ({ client: client2 }) => {
|
|
2925
|
-
|
|
2926
|
-
root
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
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
|
+
}
|
|
3955
|
+
async function openReview(root, args, values) {
|
|
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"));
|
|
3957
|
+
await withClient(async ({ client: client2 }) => {
|
|
3958
|
+
const requests = args.map(async (input) => {
|
|
3959
|
+
const result = await client2.request("reviews.open", {
|
|
3960
|
+
root,
|
|
3961
|
+
input,
|
|
3962
|
+
...values.platform ? { platform: values.platform } : {},
|
|
3963
|
+
...values.project ? { project: values.project } : {},
|
|
3964
|
+
...values.host ? { host: values.host } : {},
|
|
3965
|
+
...values.branch ? { branch: values.branch } : {}
|
|
3966
|
+
});
|
|
3967
|
+
return result.review;
|
|
2932
3968
|
});
|
|
2933
|
-
const
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
if (
|
|
3969
|
+
const settled = await Promise.allSettled(requests);
|
|
3970
|
+
const reviews = settled.flatMap((item) => item.status === "fulfilled" ? [item.value] : []);
|
|
3971
|
+
const failures = settled.flatMap((item) => item.status === "rejected" ? [item.reason] : []);
|
|
3972
|
+
if (values.json) {
|
|
3973
|
+
if (args.length === 1 && reviews[0]) return printJson(reviews[0]);
|
|
3974
|
+
if (!reviews.length) fail(failures[0]?.message ?? tr("\u0440\u0435\u0432\u044C\u044E \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0442\u043E", "no review was opened"));
|
|
3975
|
+
return printJson(reviews);
|
|
3976
|
+
}
|
|
3977
|
+
for (const review of reviews) {
|
|
3978
|
+
writers.out(formatInfo(review).join("\n"));
|
|
3979
|
+
if (review.errors.length) writers.err(`${tr("\u043F\u0440\u0435\u0434\u0443\u043F\u0440\u0435\u0436\u0434\u0435\u043D\u0438\u044F", "warnings")}:
|
|
2937
3980
|
${review.errors.map((item) => ` ${item}`).join("\n")}`);
|
|
2938
|
-
|
|
3981
|
+
}
|
|
3982
|
+
for (const failure2 of failures) writers.err(tr(`\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0442\u043A\u0440\u044B\u0442\u044C: ${failure2.message}`, `could not open: ${failure2.message}`));
|
|
3983
|
+
if (values.ui && reviews.length) printUi(reviews[reviews.length - 1].id, values);
|
|
3984
|
+
if (!reviews.length) fail(failures[0]?.message ?? tr("\u0440\u0435\u0432\u044C\u044E \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0442\u043E", "no review was opened"));
|
|
2939
3985
|
});
|
|
2940
3986
|
}
|
|
2941
3987
|
async function ui(arg, values) {
|
|
@@ -2948,10 +3994,10 @@ async function ui(arg, values) {
|
|
|
2948
3994
|
writers.out(url);
|
|
2949
3995
|
if (values.open) openBrowser(url);
|
|
2950
3996
|
}
|
|
2951
|
-
function printUi(
|
|
3997
|
+
function printUi(reviewId2, values) {
|
|
2952
3998
|
const info = daemonInfoSync();
|
|
2953
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"));
|
|
2954
|
-
const url = `${uiBaseUrl(info)}/?t=${info.token}${
|
|
4000
|
+
const url = `${uiBaseUrl(info)}/?t=${info.token}${reviewId2 ? `&review=${encodeURIComponent(reviewId2)}` : ""}`;
|
|
2955
4001
|
writers.out(`UI: ${url}`);
|
|
2956
4002
|
if (values.open) openBrowser(url);
|
|
2957
4003
|
}
|
|
@@ -3043,16 +4089,30 @@ async function daemon(action, values = {}) {
|
|
|
3043
4089
|
}
|
|
3044
4090
|
usage(["daemon <start|stop|status|restart|logs|install|uninstall>"]);
|
|
3045
4091
|
}
|
|
3046
|
-
async function status() {
|
|
4092
|
+
async function status(root, values) {
|
|
3047
4093
|
await withClient(async ({ client: client2 }) => {
|
|
3048
|
-
const
|
|
4094
|
+
const params = values.all === true ? {} : { root };
|
|
4095
|
+
const { reviews } = await client2.request("reviews.list", params);
|
|
3049
4096
|
if (!reviews.length) {
|
|
3050
|
-
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"));
|
|
3051
4098
|
return;
|
|
3052
4099
|
}
|
|
3053
4100
|
for (const item of reviews) writers.out(reviewLine(item));
|
|
3054
4101
|
});
|
|
3055
4102
|
}
|
|
4103
|
+
function parseRole(value) {
|
|
4104
|
+
if (!value) return void 0;
|
|
4105
|
+
return value;
|
|
4106
|
+
}
|
|
4107
|
+
function parseShard(value) {
|
|
4108
|
+
if (!value) return void 0;
|
|
4109
|
+
const match = /^(\d+)\/(\d+)$/.exec(value);
|
|
4110
|
+
if (!match) fail(tr(`\u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0448\u0430\u0440\u0434 ${value}`, `invalid shard ${value}`), tr("\u0444\u043E\u0440\u043C\u0430\u0442: --shard 1/3", "format: --shard 1/3"));
|
|
4111
|
+
const index = Number(match[1]);
|
|
4112
|
+
const count = Number(match[2]);
|
|
4113
|
+
if (index < 1 || count < 1 || index > count) fail(tr(`\u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0448\u0430\u0440\u0434 ${value}`, `invalid shard ${value}`), tr("\u0438\u043D\u0434\u0435\u043A\u0441 \u043E\u0442 1 \u0434\u043E \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u0430", "index must be between 1 and the count"));
|
|
4114
|
+
return { index, count };
|
|
4115
|
+
}
|
|
3056
4116
|
async function context(root, arg, values) {
|
|
3057
4117
|
await withClient(async ({ client: client2 }) => {
|
|
3058
4118
|
const { review } = await resolveReview(client2, root, reviewArg(values, arg), values);
|
|
@@ -3060,7 +4120,61 @@ async function context(root, arg, values) {
|
|
|
3060
4120
|
review: review.id
|
|
3061
4121
|
});
|
|
3062
4122
|
if (values.json) return printJson(contextPayload(review, rules2));
|
|
3063
|
-
|
|
4123
|
+
const role = parseRole(values.role);
|
|
4124
|
+
if (role && !rules2.roles.some((item) => item.id === role)) {
|
|
4125
|
+
fail(tr(`\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u0440\u043E\u043B\u044C ${role}`, `unknown role ${role}`), `--role <${rules2.roles.map((item) => item.id).join("|")}>`);
|
|
4126
|
+
}
|
|
4127
|
+
const shard = parseShard(values.shard);
|
|
4128
|
+
writers.out(renderContext(review, rules2, {
|
|
4129
|
+
language: rules2.language,
|
|
4130
|
+
...rules2.maxBytes !== void 0 ? { maxBytes: rules2.maxBytes } : {},
|
|
4131
|
+
...role ? { role } : {},
|
|
4132
|
+
...shard ? { shard } : {}
|
|
4133
|
+
}));
|
|
4134
|
+
});
|
|
4135
|
+
}
|
|
4136
|
+
async function versions(arg, values) {
|
|
4137
|
+
await withClient(async ({ client: client2 }) => {
|
|
4138
|
+
const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);
|
|
4139
|
+
const { versions: versions2 } = await client2.request("versions.list", { review: review.id });
|
|
4140
|
+
if (values.json) return printJson(versions2);
|
|
4141
|
+
if (!versions2.length) {
|
|
4142
|
+
writers.out(tr("\u0438\u0441\u0442\u043E\u0440\u0438\u044F \u0432\u0435\u0440\u0441\u0438\u0439 \u043F\u0443\u0441\u0442\u0430: \u0432\u043A\u043B\u044E\u0447\u0438\u0442\u0435 review.history.enabled", "version history is empty: enable review.history.enabled"));
|
|
4143
|
+
return;
|
|
4144
|
+
}
|
|
4145
|
+
for (const version of versions2) {
|
|
4146
|
+
writers.out(`#${version.id} \xB7 ${version.headSha.slice(0, 12) || "\u2014"} \xB7 ${version.createdAt} \xB7 ${version.files} ${tr("\u0444\u0430\u0439\u043B\u043E\u0432", "files")} \xB7 +${version.additions} \u2212${version.deletions} \xB7 ${version.findings} ${tr("\u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0439", "findings")}`);
|
|
4147
|
+
}
|
|
4148
|
+
});
|
|
4149
|
+
}
|
|
4150
|
+
async function secrets(arg, values) {
|
|
4151
|
+
await withClient(async ({ client: client2 }) => {
|
|
4152
|
+
const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);
|
|
4153
|
+
const result = await client2.request("secrets.get", { review: review.id });
|
|
4154
|
+
if (values.json) return printJson(result);
|
|
4155
|
+
if (!result.enabled) {
|
|
4156
|
+
writers.out(tr("\u0441\u043A\u0430\u043D \u0441\u0435\u043A\u0440\u0435\u0442\u043E\u0432 \u0432\u044B\u043A\u043B\u044E\u0447\u0435\u043D: review.secrets.enabled: true", "secret scan is disabled: set review.secrets.enabled: true"));
|
|
4157
|
+
return;
|
|
4158
|
+
}
|
|
4159
|
+
writers.out(`${tr("\u0441\u043A\u0430\u043D", "scan")}: ${result.scan} \xB7 ${result.findings.length} ${tr("\u043D\u0430\u0445\u043E\u0434\u043E\u043A", "findings")}`);
|
|
4160
|
+
for (const finding of result.findings) writers.out(`\u2716 ${finding.rule} \xB7 ${finding.file}:${finding.line} \xB7 ${finding.preview}`);
|
|
4161
|
+
});
|
|
4162
|
+
}
|
|
4163
|
+
async function stats(arg, values) {
|
|
4164
|
+
await withClient(async ({ client: client2 }) => {
|
|
4165
|
+
const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);
|
|
4166
|
+
const { analytics } = await client2.request("analytics.get", { review: review.id });
|
|
4167
|
+
if (values.json) return printJson(analytics);
|
|
4168
|
+
const findings2 = analytics.findings;
|
|
4169
|
+
const threads2 = analytics.threads;
|
|
4170
|
+
const rate = analytics.acceptanceRate;
|
|
4171
|
+
writers.out(`#${review.info.ref.number} ${review.info.title}`);
|
|
4172
|
+
writers.out(`${tr("\u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F", "findings")}: ${findings2.total} \xB7 ${tr("\u043F\u0440\u0438\u043D\u044F\u0442\u043E", "accepted")} ${findings2.accepted} \xB7 ${tr("\u043E\u0442\u043A\u043B\u043E\u043D\u0435\u043D\u043E", "rejected")} ${findings2.rejected} \xB7 ${tr("\u0431\u0435\u0437 \u0440\u0435\u0448\u0435\u043D\u0438\u044F", "pending")} ${findings2.pending} \xB7 ${tr("\u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D\u043E", "published")} ${findings2.published}`);
|
|
4173
|
+
writers.out(`${tr("\u0442\u0440\u0435\u0434\u044B", "threads")}: ${threads2.total} \xB7 ${tr("\u043E\u0442\u043A\u0440\u044B\u0442\u043E", "open")} ${threads2.open} \xB7 ${tr("\u0437\u0430\u043A\u0440\u044B\u0442\u043E", "resolved")} ${threads2.resolved}`);
|
|
4174
|
+
writers.out(`${tr("acceptance rate", "acceptance rate")}: ${rate == null ? "\u2014" : `${Math.round(rate * 100)}%`}`);
|
|
4175
|
+
for (const rejection of analytics.rejections) {
|
|
4176
|
+
writers.out(`\u2716 ${rejection.level} ${rejection.title} (${rejection.file}:${rejection.line ?? "\u2014"})${rejection.note ? ` \u2014 ${rejection.note}` : ""}`);
|
|
4177
|
+
}
|
|
3064
4178
|
});
|
|
3065
4179
|
}
|
|
3066
4180
|
async function threads(arg, values) {
|
|
@@ -3256,9 +4370,9 @@ function defaultSelection2(review, kind) {
|
|
|
3256
4370
|
}
|
|
3257
4371
|
return review.notes.filter((note) => !note.posted).map((note) => note.id);
|
|
3258
4372
|
}
|
|
3259
|
-
async function publishSelection(client2,
|
|
4373
|
+
async function publishSelection(client2, reviewId2, kind, ids, values) {
|
|
3260
4374
|
const { preview } = await client2.request("publish.preview", {
|
|
3261
|
-
review:
|
|
4375
|
+
review: reviewId2,
|
|
3262
4376
|
kind,
|
|
3263
4377
|
ids
|
|
3264
4378
|
});
|
|
@@ -3280,13 +4394,13 @@ async function publishSelection(client2, reviewId, kind, ids, values) {
|
|
|
3280
4394
|
return;
|
|
3281
4395
|
}
|
|
3282
4396
|
const { approval } = await client2.request("publish.approve", {
|
|
3283
|
-
review:
|
|
4397
|
+
review: reviewId2,
|
|
3284
4398
|
kind,
|
|
3285
4399
|
ids,
|
|
3286
4400
|
hash: preview.plan.hash
|
|
3287
4401
|
});
|
|
3288
4402
|
const { result } = await client2.request("publish.commit", {
|
|
3289
|
-
review:
|
|
4403
|
+
review: reviewId2,
|
|
3290
4404
|
approvalId: approval.id
|
|
3291
4405
|
});
|
|
3292
4406
|
for (const item of result.results) {
|
|
@@ -3333,8 +4447,10 @@ async function checks(root, arg, values) {
|
|
|
3333
4447
|
}
|
|
3334
4448
|
async function config(root, values) {
|
|
3335
4449
|
const loaded = await loadConfig(root);
|
|
3336
|
-
if (values.json) return printJson({ path: loaded.path, config: loaded.config, warnings: loaded.warnings });
|
|
4450
|
+
if (values.json) return printJson({ path: loaded.path, localPath: loaded.localPath, config: loaded.config, warnings: loaded.warnings });
|
|
3337
4451
|
writers.out(`${tr("\u043A\u043E\u043D\u0444\u0438\u0433", "config")}: ${loaded.path ?? tr("\u043D\u0435\u0442 (.revdeck.yml)", "none (.revdeck.yml)")}`);
|
|
4452
|
+
if (loaded.localPath) writers.out(`${tr("\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u043A\u043E\u043D\u0444\u0438\u0433", "local config")}: ${loaded.localPath}`);
|
|
4453
|
+
writers.out(`${tr("\u0440\u043E\u043B\u0438", "roles")}: ${loaded.config.review.agents} \xB7 ${loaded.config.review.roles.join(", ")}${loaded.config.review.readOnly ? tr(" \xB7 read-only", " \xB7 read-only") : ""}`);
|
|
3338
4454
|
writers.out(`${tr("\u043F\u0440\u0430\u0432\u0438\u043B\u0430", "rules")}: ${loaded.config.rules.sources.join(", ") || "\u2014"}`);
|
|
3339
4455
|
writers.out(`${tr("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438", "checks")}: ${loaded.config.checks.map((check) => check.id).join(", ") || "\u2014"}`);
|
|
3340
4456
|
writers.out(`${tr("\u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F", "publishing")}: requireApproval=${loaded.config.publish.requireApproval}, ${tr("\u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C", "max")} ${loaded.config.publish.maxComments}`);
|
|
@@ -3386,6 +4502,7 @@ async function doctor(root) {
|
|
|
3386
4502
|
const loaded = await loadConfig(root);
|
|
3387
4503
|
host = loaded.config.provider.host ?? (await gitRemote(root))?.host;
|
|
3388
4504
|
rows.push(["config", loaded.path ? "ok" : "warn", loaded.path ?? tr("\u043D\u0435\u0442 .revdeck.yml (\u0430\u0432\u0442\u043E\u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u0438\u0435)", "no .revdeck.yml (auto-discovery)")]);
|
|
4505
|
+
if (loaded.localPath) rows.push(["local config", "ok", loaded.localPath]);
|
|
3389
4506
|
for (const warning of loaded.warnings) rows.push(["warning", "warn", warning]);
|
|
3390
4507
|
} catch (error) {
|
|
3391
4508
|
rows.push(["config", "fail", redactLine(error)]);
|