revdeck 0.4.6 → 0.5.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 +23 -0
- package/README.md +38 -1
- package/README.ru.md +38 -1
- package/dist/cli.js +477 -81
- package/dist/cli.js.map +4 -4
- package/dist/daemon.js +525 -19
- package/dist/daemon.js.map +4 -4
- package/dist/mcp.js +208 -25
- package/dist/mcp.js.map +4 -4
- package/dist/ui/assets/{index-DZ9XSSBl.css → index-CcmcJhhu.css} +1 -1
- package/dist/ui/assets/index-CuvK5owY.js +10 -0
- package/dist/ui/index.html +2 -2
- package/docs/configuration.md +133 -1
- package/docs/ru/configuration.md +135 -1
- package/package.json +1 -1
- package/skills/revdeck/en/SKILL.md +20 -0
- package/skills/revdeck/ru/SKILL.md +20 -0
- package/dist/ui/assets/index-DP2dIReT.js +0 -10
package/dist/cli.js
CHANGED
|
@@ -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");
|
|
@@ -94,11 +101,12 @@ function packageRoot() {
|
|
|
94
101
|
dir = parent;
|
|
95
102
|
}
|
|
96
103
|
}
|
|
97
|
-
var CONFIG_FILES;
|
|
104
|
+
var CONFIG_FILES, LOCAL_CONFIG_FILES;
|
|
98
105
|
var init_paths = __esm({
|
|
99
106
|
"src/core/paths.ts"() {
|
|
100
107
|
"use strict";
|
|
101
108
|
CONFIG_FILES = [".revdeck.yml", ".revdeck.yaml"];
|
|
109
|
+
LOCAL_CONFIG_FILES = [".revdeck.local.yml", ".revdeck.local.yaml"];
|
|
102
110
|
}
|
|
103
111
|
});
|
|
104
112
|
|
|
@@ -133,6 +141,143 @@ var init_locale = __esm({
|
|
|
133
141
|
}
|
|
134
142
|
});
|
|
135
143
|
|
|
144
|
+
// src/core/review-roles.ts
|
|
145
|
+
function effectiveRoleIds(agents, roles) {
|
|
146
|
+
const base = roles.length ? roles : DEFAULT_REVIEW_ROLES;
|
|
147
|
+
return Array.from({ length: agents }, (_, index) => base[index % base.length]);
|
|
148
|
+
}
|
|
149
|
+
function resolveReviewRole(id, language, custom = {}) {
|
|
150
|
+
if (id in REVIEW_ROLES) {
|
|
151
|
+
const role2 = REVIEW_ROLES[id];
|
|
152
|
+
return {
|
|
153
|
+
id,
|
|
154
|
+
title: role2.title[language],
|
|
155
|
+
description: role2.focus[language],
|
|
156
|
+
criteria: role2.criteria,
|
|
157
|
+
instructions: ""
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const role = custom[id];
|
|
161
|
+
if (!role) return null;
|
|
162
|
+
return {
|
|
163
|
+
id,
|
|
164
|
+
title: role.title,
|
|
165
|
+
description: role.description,
|
|
166
|
+
criteria: role.criteria,
|
|
167
|
+
instructions: role.instructions ?? ""
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function roleCriteriaText(role) {
|
|
171
|
+
return role.criteria.length ? `\xA7${role.criteria.join(", \xA7")}` : "";
|
|
172
|
+
}
|
|
173
|
+
var REVIEW_ROLE_IDS, DEFAULT_REVIEW_ROLES, REVIEW_ROLES;
|
|
174
|
+
var init_review_roles = __esm({
|
|
175
|
+
"src/core/review-roles.ts"() {
|
|
176
|
+
"use strict";
|
|
177
|
+
REVIEW_ROLE_IDS = [
|
|
178
|
+
"correctness",
|
|
179
|
+
"architecture",
|
|
180
|
+
"tests",
|
|
181
|
+
"security",
|
|
182
|
+
"performance",
|
|
183
|
+
"compatibility",
|
|
184
|
+
"docs",
|
|
185
|
+
"concurrency",
|
|
186
|
+
"ux",
|
|
187
|
+
"data",
|
|
188
|
+
"api",
|
|
189
|
+
"dependencies",
|
|
190
|
+
"observability",
|
|
191
|
+
"build",
|
|
192
|
+
"privacy",
|
|
193
|
+
"general"
|
|
194
|
+
];
|
|
195
|
+
DEFAULT_REVIEW_ROLES = ["correctness", "architecture", "tests"];
|
|
196
|
+
REVIEW_ROLES = {
|
|
197
|
+
correctness: {
|
|
198
|
+
criteria: ["6", "10"],
|
|
199
|
+
title: { ru: "\u041A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u043E\u0441\u0442\u044C", en: "Correctness" },
|
|
200
|
+
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" }
|
|
201
|
+
},
|
|
202
|
+
architecture: {
|
|
203
|
+
criteria: ["3", "4", "5", "7"],
|
|
204
|
+
title: { ru: "\u0410\u0440\u0445\u0438\u0442\u0435\u043A\u0442\u0443\u0440\u0430", en: "Architecture" },
|
|
205
|
+
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" }
|
|
206
|
+
},
|
|
207
|
+
tests: {
|
|
208
|
+
criteria: ["8"],
|
|
209
|
+
title: { ru: "\u0422\u0435\u0441\u0442\u044B", en: "Tests" },
|
|
210
|
+
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" }
|
|
211
|
+
},
|
|
212
|
+
security: {
|
|
213
|
+
criteria: ["10"],
|
|
214
|
+
title: { ru: "\u0411\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0441\u0442\u044C", en: "Security" },
|
|
215
|
+
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" }
|
|
216
|
+
},
|
|
217
|
+
performance: {
|
|
218
|
+
criteria: ["10"],
|
|
219
|
+
title: { ru: "\u041F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C", en: "Performance" },
|
|
220
|
+
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" }
|
|
221
|
+
},
|
|
222
|
+
compatibility: {
|
|
223
|
+
criteria: ["6", "7"],
|
|
224
|
+
title: { ru: "\u0421\u043E\u0432\u043C\u0435\u0441\u0442\u0438\u043C\u043E\u0441\u0442\u044C", en: "Compatibility" },
|
|
225
|
+
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" }
|
|
226
|
+
},
|
|
227
|
+
docs: {
|
|
228
|
+
criteria: ["9"],
|
|
229
|
+
title: { ru: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u044F", en: "Documentation" },
|
|
230
|
+
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" }
|
|
231
|
+
},
|
|
232
|
+
concurrency: {
|
|
233
|
+
criteria: ["10"],
|
|
234
|
+
title: { ru: "\u041A\u043E\u043D\u043A\u0443\u0440\u0435\u043D\u0442\u043D\u043E\u0441\u0442\u044C", en: "Concurrency" },
|
|
235
|
+
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" }
|
|
236
|
+
},
|
|
237
|
+
ux: {
|
|
238
|
+
criteria: ["9", "10"],
|
|
239
|
+
title: { ru: "UX \u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0441\u0442\u044C", en: "UX and accessibility" },
|
|
240
|
+
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" }
|
|
241
|
+
},
|
|
242
|
+
data: {
|
|
243
|
+
criteria: ["3", "10"],
|
|
244
|
+
title: { ru: "\u0414\u0430\u043D\u043D\u044B\u0435 \u0438 \u043C\u0438\u0433\u0440\u0430\u0446\u0438\u0438", en: "Data and migrations" },
|
|
245
|
+
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" }
|
|
246
|
+
},
|
|
247
|
+
api: {
|
|
248
|
+
criteria: ["6", "7"],
|
|
249
|
+
title: { ru: "\u041F\u0443\u0431\u043B\u0438\u0447\u043D\u044B\u0439 API", en: "Public API" },
|
|
250
|
+
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" }
|
|
251
|
+
},
|
|
252
|
+
dependencies: {
|
|
253
|
+
criteria: ["3", "10"],
|
|
254
|
+
title: { ru: "\u0417\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438", en: "Dependencies" },
|
|
255
|
+
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" }
|
|
256
|
+
},
|
|
257
|
+
observability: {
|
|
258
|
+
criteria: ["9", "10"],
|
|
259
|
+
title: { ru: "\u041D\u0430\u0431\u043B\u044E\u0434\u0430\u0435\u043C\u043E\u0441\u0442\u044C", en: "Observability" },
|
|
260
|
+
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" }
|
|
261
|
+
},
|
|
262
|
+
build: {
|
|
263
|
+
criteria: ["8", "9"],
|
|
264
|
+
title: { ru: "\u0421\u0431\u043E\u0440\u043A\u0430 \u0438 CI", en: "Build and CI" },
|
|
265
|
+
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" }
|
|
266
|
+
},
|
|
267
|
+
privacy: {
|
|
268
|
+
criteria: ["9", "10"],
|
|
269
|
+
title: { ru: "\u041F\u0440\u0438\u0432\u0430\u0442\u043D\u043E\u0441\u0442\u044C", en: "Privacy" },
|
|
270
|
+
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" }
|
|
271
|
+
},
|
|
272
|
+
general: {
|
|
273
|
+
criteria: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
|
|
274
|
+
title: { ru: "\u041E\u0431\u0449\u0435\u0435 \u0440\u0435\u0432\u044C\u044E", en: "General review" },
|
|
275
|
+
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" }
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
136
281
|
// src/core/redact.ts
|
|
137
282
|
function redact(value) {
|
|
138
283
|
let text = String(value ?? "").replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, " ");
|
|
@@ -168,7 +313,7 @@ var VERSION;
|
|
|
168
313
|
var init_version = __esm({
|
|
169
314
|
"src/version.ts"() {
|
|
170
315
|
"use strict";
|
|
171
|
-
VERSION = "0.
|
|
316
|
+
VERSION = "0.5.0";
|
|
172
317
|
}
|
|
173
318
|
});
|
|
174
319
|
|
|
@@ -479,6 +624,17 @@ function renderContext(review, rules2, options = {}) {
|
|
|
479
624
|
const limit = maxBytes > 0 ? maxBytes : Number.POSITIVE_INFINITY;
|
|
480
625
|
const language = options.language ?? rules2.language ?? "en";
|
|
481
626
|
const t = (ru, en) => language === "ru" ? ru : en;
|
|
627
|
+
const agents = Math.max(1, options.agents ?? rules2.agents ?? 1);
|
|
628
|
+
const planRoles = options.roles ?? rules2.roles ?? effectiveRoleIds(agents, DEFAULT_REVIEW_ROLES);
|
|
629
|
+
const roles = Array.isArray(planRoles) && planRoles.length && typeof planRoles[0] === "object" ? planRoles : effectiveRoleIds(agents, planRoles).map((id) => resolveReviewRole(id, language)).filter((role) => Boolean(role));
|
|
630
|
+
const selectedRole = options.role ? roles.find((role) => role.id === options.role) : void 0;
|
|
631
|
+
if (options.role && !selectedRole) throw new Error(`unknown review role: ${options.role}`);
|
|
632
|
+
const shardCount = options.shard?.count ?? 1;
|
|
633
|
+
const shardIndex = options.shard?.index ?? 1;
|
|
634
|
+
const visibleFiles = shardCount > 1 ? review.files.filter((_, index) => index % shardCount === shardIndex - 1) : review.files;
|
|
635
|
+
const visiblePaths = new Set(visibleFiles.map((file) => file.path));
|
|
636
|
+
const visibleThreads = shardCount > 1 ? review.threads.filter((thread) => !thread.path || visiblePaths.has(thread.path)) : review.threads;
|
|
637
|
+
const visibleNotes = shardCount > 1 ? review.notes.filter((note) => visiblePaths.has(note.file)) : review.notes;
|
|
482
638
|
const lines = [];
|
|
483
639
|
const push = (line = "") => {
|
|
484
640
|
lines.push(line);
|
|
@@ -502,6 +658,34 @@ function renderContext(review, rules2, options = {}) {
|
|
|
502
658
|
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
659
|
}
|
|
504
660
|
push("");
|
|
661
|
+
if (agents > 1 || options.role || shardCount > 1) {
|
|
662
|
+
push(`## ${t("\u041C\u043D\u043E\u0433\u043E\u0430\u0433\u0435\u043D\u0442\u043D\u043E\u0435 \u0440\u0435\u0432\u044C\u044E", "Multi-agent review")}`);
|
|
663
|
+
push(`${t("\u0410\u0433\u0435\u043D\u0442\u043E\u0432", "Agents")}: ${agents}`);
|
|
664
|
+
push(`${t("\u0420\u043E\u043B\u0438", "Roles")}: ${roles.map((role) => role.title).join(", ")}`);
|
|
665
|
+
if (selectedRole) {
|
|
666
|
+
push(`### ${t("\u0420\u043E\u043B\u044C", "Role")}: ${selectedRole.title}`);
|
|
667
|
+
if (selectedRole.criteria.length) push(`${t("\u041A\u0440\u0438\u0442\u0435\u0440\u0438\u0438", "Criteria")}: Criteria.md ${roleCriteriaText(selectedRole)}`);
|
|
668
|
+
push(`${t("\u0424\u043E\u043A\u0443\u0441", "Focus")}: ${selectedRole.description}`);
|
|
669
|
+
if (selectedRole.instructions) push(`${t("\u0418\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u0438", "Instructions")}: ${selectedRole.instructions}`);
|
|
670
|
+
}
|
|
671
|
+
if (shardCount > 1) {
|
|
672
|
+
push(`### ${t("\u0428\u0430\u0440\u0434", "Shard")}: ${shardIndex}/${shardCount}`);
|
|
673
|
+
push(t("\u0424\u0430\u0439\u043B\u044B \u044D\u0442\u043E\u0433\u043E \u0448\u0430\u0440\u0434\u0430:", "Files in this shard:"));
|
|
674
|
+
for (const file of visibleFiles) push(`- ${file.path}`);
|
|
675
|
+
}
|
|
676
|
+
if (options.role || shardCount > 1) {
|
|
677
|
+
push(t(
|
|
678
|
+
"\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.",
|
|
679
|
+
"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."
|
|
680
|
+
));
|
|
681
|
+
} else {
|
|
682
|
+
push(t(
|
|
683
|
+
"\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.",
|
|
684
|
+
"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."
|
|
685
|
+
));
|
|
686
|
+
}
|
|
687
|
+
push("");
|
|
688
|
+
}
|
|
505
689
|
if (review.summary) {
|
|
506
690
|
push(`## ${t("\u0412\u044B\u0436\u0438\u043C\u043A\u0430", "Summary")}`);
|
|
507
691
|
if (review.summary.title) push(`**${review.summary.title}**`);
|
|
@@ -517,16 +701,23 @@ function renderContext(review, rules2, options = {}) {
|
|
|
517
701
|
}
|
|
518
702
|
push("");
|
|
519
703
|
}
|
|
520
|
-
push(`## ${t("\u0424\u0430\u0439\u043B\u044B", "Files")} (${review.files.length})`);
|
|
521
|
-
for (const file of
|
|
704
|
+
push(`## ${t("\u0424\u0430\u0439\u043B\u044B", "Files")} (${visibleFiles.length}${shardCount > 1 ? ` / ${review.files.length}` : ""})`);
|
|
705
|
+
for (const file of visibleFiles) {
|
|
522
706
|
push(`- ${file.path} (${file.status}, +${file.additions} \u2212${file.deletions})${file.binary ? " [binary]" : ""}`);
|
|
523
707
|
}
|
|
524
708
|
push("");
|
|
709
|
+
if (review.groups?.length) {
|
|
710
|
+
push(`## ${t("\u0413\u0440\u0443\u043F\u043F\u044B \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439", "Change groups")}`);
|
|
711
|
+
for (const group of review.groups) {
|
|
712
|
+
push(`- ${group.title}: ${group.files.length} ${t("\u0444\u0430\u0439\u043B(\u043E\u0432)", "file(s)")}, +${group.additions} \u2212${group.deletions}`);
|
|
713
|
+
}
|
|
714
|
+
push("");
|
|
715
|
+
}
|
|
525
716
|
push(rules2.markdown.trim());
|
|
526
717
|
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
|
|
718
|
+
const openThreads = visibleThreads.filter((thread) => !thread.resolved);
|
|
719
|
+
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})`);
|
|
720
|
+
for (const thread of visibleThreads) {
|
|
530
721
|
const place = thread.path ? `${thread.path}:${thread.line ?? "?"}` : t("\u043E\u0431\u0449\u0438\u0439", "general");
|
|
531
722
|
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
723
|
if (thread.snippet) {
|
|
@@ -554,9 +745,9 @@ function renderContext(review, rules2, options = {}) {
|
|
|
554
745
|
if (finding.agentNote) push(` \u2192 ${t("\u0430\u0433\u0435\u043D\u0442\u0443", "to agent")}: ${truncate(finding.agentNote, 500)}`);
|
|
555
746
|
}
|
|
556
747
|
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
|
|
748
|
+
if (visibleNotes.length) {
|
|
749
|
+
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})`);
|
|
750
|
+
for (const note of visibleNotes) {
|
|
560
751
|
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
752
|
push(` ${truncate(note.text, 500)}`);
|
|
562
753
|
if (note.agentReply) push(` \u2192 ${truncate(note.agentReply, 500)}`);
|
|
@@ -617,13 +808,18 @@ function contextPayload(review, rules2) {
|
|
|
617
808
|
syncedAt: review.syncedAt
|
|
618
809
|
},
|
|
619
810
|
rules: rules2,
|
|
620
|
-
language: rules2.language
|
|
811
|
+
language: rules2.language,
|
|
812
|
+
multiAgent: {
|
|
813
|
+
agents: rules2.agents ?? 1,
|
|
814
|
+
roles: rules2.roles ?? DEFAULT_REVIEW_ROLES.map((id) => resolveReviewRole(id, rules2.language)).filter(Boolean)
|
|
815
|
+
}
|
|
621
816
|
};
|
|
622
817
|
}
|
|
623
818
|
var init_context = __esm({
|
|
624
819
|
"src/context.ts"() {
|
|
625
820
|
"use strict";
|
|
626
821
|
init_format();
|
|
822
|
+
init_review_roles();
|
|
627
823
|
}
|
|
628
824
|
});
|
|
629
825
|
|
|
@@ -747,9 +943,9 @@ ${text}`, result);
|
|
|
747
943
|
"revdeck_open",
|
|
748
944
|
{
|
|
749
945
|
title: "Open review",
|
|
750
|
-
description: "Load
|
|
946
|
+
description: "Load one or more MR/PR by number or URL: description, diff, threads. Returns the id used by other tools.",
|
|
751
947
|
inputSchema: {
|
|
752
|
-
input: z2.string().min(1).describe("Number, URL, project!N
|
|
948
|
+
input: z2.union([z2.string().min(1), z2.array(z2.string().min(1)).min(1).max(8)]).describe("Number, URL, project!N, owner/repo#N, or an array of them"),
|
|
753
949
|
root: rootSchema,
|
|
754
950
|
platform: z2.enum(["gitlab", "github"]).optional(),
|
|
755
951
|
project: z2.string().optional(),
|
|
@@ -759,17 +955,23 @@ ${text}`, result);
|
|
|
759
955
|
},
|
|
760
956
|
async ({ input, root, platform, project, host, branch }) => {
|
|
761
957
|
try {
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
958
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
959
|
+
const reviews = [];
|
|
960
|
+
for (const value of inputs) {
|
|
961
|
+
const result = await call("reviews.open", {
|
|
962
|
+
root: root ?? defaultRoot,
|
|
963
|
+
input: value,
|
|
964
|
+
...platform ? { platform } : {},
|
|
965
|
+
...project ? { project } : {},
|
|
966
|
+
...host ? { host } : {},
|
|
967
|
+
...branch ? { branch } : {}
|
|
968
|
+
});
|
|
969
|
+
reviews.push(result.review);
|
|
970
|
+
}
|
|
971
|
+
const text = reviews.map((review) => `${summarize(review)}
|
|
972
|
+
Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
973
|
+
if (reviews.length === 1) return ok(text, { reviewId: reviews[0].id });
|
|
974
|
+
return ok(text, { reviewIds: reviews.map((review) => review.id) });
|
|
773
975
|
} catch (error) {
|
|
774
976
|
return failure(error);
|
|
775
977
|
}
|
|
@@ -785,14 +987,28 @@ Next: revdeck_context(review="${result.review.id}").`, { reviewId: result.review
|
|
|
785
987
|
refresh: z2.boolean().optional().describe("Fetch fresh diff and threads from the platform"),
|
|
786
988
|
file: z2.string().optional().describe("Append the diff of one file"),
|
|
787
989
|
max_bytes: z2.number().int().positive().max(5e5).optional(),
|
|
990
|
+
role: z2.string().max(64).optional().describe("Role for an independent shard reviewer"),
|
|
991
|
+
shard: z2.string().regex(/^\d+\/\d+$/).optional().describe("Shard as i/N, for example 1/3"),
|
|
788
992
|
root: rootSchema
|
|
789
993
|
}
|
|
790
994
|
},
|
|
791
|
-
async ({ review, refresh, file, max_bytes }) => {
|
|
995
|
+
async ({ review, refresh, file, max_bytes, role, shard }) => {
|
|
792
996
|
try {
|
|
793
997
|
const { review: view } = await call("reviews.get", { review, refresh: refresh === true });
|
|
794
998
|
const { rules: rules2 } = await call("rules.get", { review });
|
|
795
|
-
|
|
999
|
+
const parsedShard = shard ? (() => {
|
|
1000
|
+
const [index, count] = shard.split("/").map(Number);
|
|
1001
|
+
if (!Number.isInteger(index) || !Number.isInteger(count) || index < 1 || count < 1 || index > count) {
|
|
1002
|
+
throw new Error("shard must be i/N with 1 <= i <= N");
|
|
1003
|
+
}
|
|
1004
|
+
return { index, count };
|
|
1005
|
+
})() : void 0;
|
|
1006
|
+
let text = renderContext(view, rules2, {
|
|
1007
|
+
maxBytes: max_bytes ?? rules2.maxBytes ?? 2e5,
|
|
1008
|
+
language: rules2.language,
|
|
1009
|
+
...role ? { role } : {},
|
|
1010
|
+
...parsedShard ? { shard: parsedShard } : {}
|
|
1011
|
+
});
|
|
796
1012
|
if (file) {
|
|
797
1013
|
const { file: diff2 } = await call("diff.get", {
|
|
798
1014
|
review,
|
|
@@ -1227,7 +1443,15 @@ function classifyFile(path11) {
|
|
|
1227
1443
|
|
|
1228
1444
|
// src/core/config.ts
|
|
1229
1445
|
init_locale();
|
|
1446
|
+
init_review_roles();
|
|
1230
1447
|
var matchSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
1448
|
+
var customRoleSchema = z.object({
|
|
1449
|
+
title: z.string().min(1).max(120),
|
|
1450
|
+
description: z.string().min(1).max(2e3),
|
|
1451
|
+
criteria: z.array(z.string().min(1).max(20)).max(20).default([]),
|
|
1452
|
+
focus: z.string().max(2e3).optional(),
|
|
1453
|
+
instructions: z.string().max(8e3).optional()
|
|
1454
|
+
});
|
|
1231
1455
|
var reviewConfigSchema = z.object({
|
|
1232
1456
|
version: z.literal(1).default(1),
|
|
1233
1457
|
provider: z.object({
|
|
@@ -1242,6 +1466,48 @@ var reviewConfigSchema = z.object({
|
|
|
1242
1466
|
output: z.object({
|
|
1243
1467
|
language: z.enum(["auto", "ru", "en"]).default("auto")
|
|
1244
1468
|
}).prefault({}),
|
|
1469
|
+
review: z.object({
|
|
1470
|
+
/** Сколько независимых ревьюеров запускать. */
|
|
1471
|
+
agents: z.number().int().min(1).max(8).default(3),
|
|
1472
|
+
/** Роли агентов; встроенные id или ключи customRoles. */
|
|
1473
|
+
roles: z.array(z.string().min(1).max(64)).min(1).max(10).default([...DEFAULT_REVIEW_ROLES]),
|
|
1474
|
+
/** Пользовательские роли с описанием и инструкциями. */
|
|
1475
|
+
customRoles: z.record(z.string().min(1).max(64), customRoleSchema).default({}),
|
|
1476
|
+
/** Явные группы изменений; остальные группируются по типу и модулю. */
|
|
1477
|
+
groups: z.array(
|
|
1478
|
+
z.object({
|
|
1479
|
+
id: z.string().min(1).max(64),
|
|
1480
|
+
title: z.string().min(1).max(120),
|
|
1481
|
+
match: matchSchema
|
|
1482
|
+
})
|
|
1483
|
+
).max(100).default([]),
|
|
1484
|
+
/** Опциональный скан секретов; по умолчанию выключен. */
|
|
1485
|
+
secrets: z.object({
|
|
1486
|
+
enabled: z.boolean().default(false),
|
|
1487
|
+
scan: z.enum(["diff", "files", "both"]).default("diff"),
|
|
1488
|
+
includeTests: z.boolean().default(false),
|
|
1489
|
+
/** Glob-пути или id правила (`rule:generic-secret`). */
|
|
1490
|
+
allowlist: z.array(z.string().min(1)).default([])
|
|
1491
|
+
}).prefault({}),
|
|
1492
|
+
/** История версий ревью (снимки по commit SHA). */
|
|
1493
|
+
history: z.object({
|
|
1494
|
+
enabled: z.boolean().default(false),
|
|
1495
|
+
keep: z.number().int().min(1).max(100).default(20)
|
|
1496
|
+
}).prefault({}),
|
|
1497
|
+
/** Запрет любых изменений: drafts, findings, публикация. */
|
|
1498
|
+
readOnly: z.boolean().default(false)
|
|
1499
|
+
}).prefault({}).superRefine((value, ctx) => {
|
|
1500
|
+
for (const key of Object.keys(value.customRoles)) {
|
|
1501
|
+
if (REVIEW_ROLE_IDS.includes(key)) {
|
|
1502
|
+
ctx.addIssue({ code: "custom", path: ["customRoles", key], message: `role ${key} is built in and cannot be overridden` });
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
for (const role of value.roles) {
|
|
1506
|
+
if (!REVIEW_ROLE_IDS.includes(role) && !(role in value.customRoles)) {
|
|
1507
|
+
ctx.addIssue({ code: "custom", path: ["roles"], message: `unknown role: ${role}` });
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
}),
|
|
1245
1511
|
rules: z.object({
|
|
1246
1512
|
/** Общие документы, если ни одна строка map не подошла. Пусто — автообнаружение. */
|
|
1247
1513
|
sources: z.array(z.string().min(1)).default([]),
|
|
@@ -1287,31 +1553,39 @@ var DISCOVERED_SOURCES = [
|
|
|
1287
1553
|
"docs/Styleguide.md",
|
|
1288
1554
|
"docs/CONTRIBUTING.md"
|
|
1289
1555
|
];
|
|
1290
|
-
function
|
|
1291
|
-
|
|
1556
|
+
function isRecord(value) {
|
|
1557
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1558
|
+
}
|
|
1559
|
+
function parseYamlData(text, source) {
|
|
1292
1560
|
try {
|
|
1293
|
-
|
|
1561
|
+
return parseYaml(text);
|
|
1294
1562
|
} catch (error) {
|
|
1295
1563
|
throw new ConfigError(tr(`${source}: \u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 YAML: ${error.message}`, `${source}: invalid YAML: ${error.message}`));
|
|
1296
1564
|
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
if (!
|
|
1300
|
-
|
|
1301
|
-
|
|
1565
|
+
}
|
|
1566
|
+
function mergeConfigData(base, local) {
|
|
1567
|
+
if (!isRecord(base) || !isRecord(local)) return local;
|
|
1568
|
+
const result = { ...base };
|
|
1569
|
+
for (const [key, value] of Object.entries(local)) {
|
|
1570
|
+
const current2 = result[key];
|
|
1571
|
+
result[key] = isRecord(current2) && isRecord(value) ? mergeConfigData(current2, value) : value;
|
|
1302
1572
|
}
|
|
1303
|
-
return result
|
|
1573
|
+
return result;
|
|
1304
1574
|
}
|
|
1305
1575
|
async function loadConfig(root = findRepoRoot()) {
|
|
1306
1576
|
const warnings = [];
|
|
1307
1577
|
const file = findConfigFile(root);
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
config2 = reviewConfigSchema.parse({});
|
|
1578
|
+
const localFile = findLocalConfigFile(root);
|
|
1579
|
+
const baseData = file ? parseYamlData(await readTextNoFollow(file), path2.relative(root, file) || file) : {};
|
|
1580
|
+
const localData = localFile ? parseYamlData(await readTextNoFollow(localFile), path2.relative(root, localFile) || localFile) : {};
|
|
1581
|
+
if (!file && !localFile) {
|
|
1313
1582
|
warnings.push(tr("\u0444\u0430\u0439\u043B .revdeck.yml \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u043F\u0440\u0430\u0432\u0438\u043B\u0430 \u0432\u0437\u044F\u0442\u044B \u0438\u0437 \u0430\u0432\u0442\u043E\u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432", ".revdeck.yml not found: rules come from auto-discovered documents"));
|
|
1314
1583
|
}
|
|
1584
|
+
const merged = mergeConfigData(baseData, localData);
|
|
1585
|
+
const config2 = reviewConfigSchema.parse(merged);
|
|
1586
|
+
const baseReadOnly = isRecord(baseData) && isRecord(baseData.review) && baseData.review.readOnly === true;
|
|
1587
|
+
const localReadOnly = isRecord(localData) && isRecord(localData.review) && localData.review.readOnly === true;
|
|
1588
|
+
config2.review.readOnly = baseReadOnly || localReadOnly;
|
|
1315
1589
|
if (!config2.rules.sources.length && !config2.rules.map.length) {
|
|
1316
1590
|
const found = DISCOVERED_SOURCES.filter((item) => existsSync2(path2.join(root, item)));
|
|
1317
1591
|
config2.rules.sources = found;
|
|
@@ -1319,7 +1593,12 @@ async function loadConfig(root = findRepoRoot()) {
|
|
|
1319
1593
|
warnings.push(tr("\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u044B \u0441 \u043F\u0440\u0430\u0432\u0438\u043B\u0430\u043C\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B: \u0440\u0435\u0432\u044C\u044E \u0431\u0443\u0434\u0435\u0442 \u043E\u043F\u0438\u0440\u0430\u0442\u044C\u0441\u044F \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \u043A\u043E\u0434 \u0438 \u0437\u0434\u0440\u0430\u0432\u044B\u0439 \u0441\u043C\u044B\u0441\u043B", "no rule documents found: the review will rely on the code only"));
|
|
1320
1594
|
}
|
|
1321
1595
|
}
|
|
1322
|
-
return {
|
|
1596
|
+
return {
|
|
1597
|
+
config: config2,
|
|
1598
|
+
path: file,
|
|
1599
|
+
localPath: localFile,
|
|
1600
|
+
warnings
|
|
1601
|
+
};
|
|
1323
1602
|
}
|
|
1324
1603
|
function assertConfigPath(root, relative) {
|
|
1325
1604
|
const cleaned = relative.split("#")[0];
|
|
@@ -1679,7 +1958,7 @@ init_format();
|
|
|
1679
1958
|
// src/cli/init.ts
|
|
1680
1959
|
init_paths();
|
|
1681
1960
|
import { existsSync as existsSync5 } from "node:fs";
|
|
1682
|
-
import {
|
|
1961
|
+
import { cp, lstat as lstat2, mkdir as mkdir2, readdir, readFile as readFile3, rm, symlink, writeFile } from "node:fs/promises";
|
|
1683
1962
|
import path6 from "node:path";
|
|
1684
1963
|
init_redact();
|
|
1685
1964
|
init_locale();
|
|
@@ -1710,6 +1989,17 @@ async function runInit(rootInput, options) {
|
|
|
1710
1989
|
"output:",
|
|
1711
1990
|
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
1991
|
` language: ${options.outputLanguage}`,
|
|
1992
|
+
"review:",
|
|
1993
|
+
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."),
|
|
1994
|
+
" agents: 3",
|
|
1995
|
+
" roles:",
|
|
1996
|
+
" - correctness",
|
|
1997
|
+
" - architecture",
|
|
1998
|
+
" - tests",
|
|
1999
|
+
tr(" # customRoles:", " # customRoles:"),
|
|
2000
|
+
tr(" # accessibility:", " # accessibility:"),
|
|
2001
|
+
tr(' # title: "\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0441\u0442\u044C"', ' # title: "Accessibility"'),
|
|
2002
|
+
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
2003
|
"rules:",
|
|
1714
2004
|
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
2005
|
...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 +2210,18 @@ async function mergeMcpJson(file, root, mcp) {
|
|
|
1920
2210
|
}
|
|
1921
2211
|
async function ensureGitignore(root) {
|
|
1922
2212
|
const file = path6.join(root, ".gitignore");
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
2213
|
+
let current2 = existsSync5(file) ? await readFile3(file, "utf8") : "";
|
|
2214
|
+
const entries = [".revdeck/", ".revdeck.local.yml", ".revdeck.local.yaml"];
|
|
2215
|
+
const added = [];
|
|
2216
|
+
for (const entry of entries) {
|
|
2217
|
+
if (new RegExp(`(^|\\n)${entry.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$`, "m").test(current2)) continue;
|
|
2218
|
+
current2 += `${current2 && !current2.endsWith("\n") ? "\n" : ""}${entry}
|
|
2219
|
+
`;
|
|
2220
|
+
added.push(entry);
|
|
2221
|
+
}
|
|
2222
|
+
if (!added.length) return;
|
|
2223
|
+
await writeFile(file, current2);
|
|
2224
|
+
writers.out(tr(`\u2714 ${added.join(", ")} \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u044B \u0432 .gitignore`, `\u2714 ${added.join(", ")} added to .gitignore`));
|
|
1928
2225
|
}
|
|
1929
2226
|
async function installService(host) {
|
|
1930
2227
|
const glab = await resolveExecutable("glab");
|
|
@@ -2084,7 +2381,7 @@ function parseJsonc(text) {
|
|
|
2084
2381
|
}
|
|
2085
2382
|
return JSON.parse(cleaned);
|
|
2086
2383
|
}
|
|
2087
|
-
function
|
|
2384
|
+
function isRecord2(value) {
|
|
2088
2385
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2089
2386
|
}
|
|
2090
2387
|
|
|
@@ -2128,15 +2425,15 @@ function mergeDevcontainerConfig(existing, patch) {
|
|
|
2128
2425
|
const result = { ...existing };
|
|
2129
2426
|
const currentMounts = Array.isArray(existing.mounts) ? [...existing.mounts] : [];
|
|
2130
2427
|
for (const mount of patch.mounts) {
|
|
2131
|
-
const index = currentMounts.findIndex((item) =>
|
|
2428
|
+
const index = currentMounts.findIndex((item) => isRecord2(item) && item.target === mount.target);
|
|
2132
2429
|
if (index >= 0) currentMounts[index] = mount;
|
|
2133
2430
|
else currentMounts.push(mount);
|
|
2134
2431
|
}
|
|
2135
2432
|
result.mounts = currentMounts;
|
|
2136
|
-
const containerEnv =
|
|
2433
|
+
const containerEnv = isRecord2(existing.containerEnv) ? { ...existing.containerEnv } : {};
|
|
2137
2434
|
Object.assign(containerEnv, patch.containerEnv);
|
|
2138
2435
|
result.containerEnv = containerEnv;
|
|
2139
|
-
const remoteEnv =
|
|
2436
|
+
const remoteEnv = isRecord2(existing.remoteEnv) ? { ...existing.remoteEnv } : {};
|
|
2140
2437
|
Object.assign(remoteEnv, patch.remoteEnv);
|
|
2141
2438
|
result.remoteEnv = remoteEnv;
|
|
2142
2439
|
const runArgs = Array.isArray(existing.runArgs) ? existing.runArgs.filter((item) => typeof item === "string") : [];
|
|
@@ -2147,11 +2444,11 @@ function mergeDevcontainerConfig(existing, patch) {
|
|
|
2147
2444
|
function applyDevcontainerPatch(text, patch) {
|
|
2148
2445
|
let current2 = text;
|
|
2149
2446
|
const parsed = parseJsonc2(current2);
|
|
2150
|
-
if (!
|
|
2447
|
+
if (!isRecord2(parsed)) throw new Error("devcontainer.json: expected an object");
|
|
2151
2448
|
const formatting = { formattingOptions: { insertSpaces: true, tabSize: 2 } };
|
|
2152
2449
|
const mounts = Array.isArray(parsed.mounts) ? [...parsed.mounts] : [];
|
|
2153
2450
|
for (const mount of patch.mounts) {
|
|
2154
|
-
const index = mounts.findIndex((item) =>
|
|
2451
|
+
const index = mounts.findIndex((item) => isRecord2(item) && item.target === mount.target);
|
|
2155
2452
|
const path11 = ["mounts", index >= 0 ? index : mounts.length];
|
|
2156
2453
|
current2 = applyEdits(current2, modify(current2, path11, mount, formatting));
|
|
2157
2454
|
if (index >= 0) mounts[index] = mount;
|
|
@@ -2242,10 +2539,10 @@ async function mergeMcpEnv(root, env) {
|
|
|
2242
2539
|
if (!existsSync6(file)) continue;
|
|
2243
2540
|
try {
|
|
2244
2541
|
const data = JSON.parse(await readFile4(file, "utf8"));
|
|
2245
|
-
const servers =
|
|
2246
|
-
const server2 = servers &&
|
|
2542
|
+
const servers = isRecord2(data.mcpServers) ? data.mcpServers : null;
|
|
2543
|
+
const server2 = servers && isRecord2(servers.revdeck) ? servers.revdeck : null;
|
|
2247
2544
|
if (!server2) continue;
|
|
2248
|
-
server2.env = { ...
|
|
2545
|
+
server2.env = { ...isRecord2(server2.env) ? server2.env : {}, ...env };
|
|
2249
2546
|
await writeFile2(file, `${JSON.stringify(data, null, 2)}
|
|
2250
2547
|
`);
|
|
2251
2548
|
changed += 1;
|
|
@@ -2329,19 +2626,19 @@ async function runEject(rootInput, options) {
|
|
|
2329
2626
|
const text = await readFile5(devcontainer, "utf8");
|
|
2330
2627
|
try {
|
|
2331
2628
|
const parsed = parseJsonc(text);
|
|
2332
|
-
if (
|
|
2629
|
+
if (isRecord2(parsed)) {
|
|
2333
2630
|
const formatting = { formattingOptions: { insertSpaces: true, tabSize: 2 } };
|
|
2334
2631
|
let current2 = text;
|
|
2335
2632
|
let changed = false;
|
|
2336
2633
|
if (Array.isArray(parsed.mounts)) {
|
|
2337
|
-
const mounts = parsed.mounts.filter((item) => !(
|
|
2634
|
+
const mounts = parsed.mounts.filter((item) => !(isRecord2(item) && (item.target === CONTAINER_RUNTIME_DIR || item.target === CONTAINER_STATE_DIR)));
|
|
2338
2635
|
if (mounts.length !== parsed.mounts.length) {
|
|
2339
2636
|
current2 = applyEdits2(current2, modify2(current2, ["mounts"], mounts, formatting));
|
|
2340
2637
|
changed = true;
|
|
2341
2638
|
}
|
|
2342
2639
|
}
|
|
2343
2640
|
for (const key of ["containerEnv", "remoteEnv"]) {
|
|
2344
|
-
if (!
|
|
2641
|
+
if (!isRecord2(parsed[key])) continue;
|
|
2345
2642
|
const env = { ...parsed[key] };
|
|
2346
2643
|
for (const name of ["REVDECK_RUNTIME_DIR", "REVDECK_STATE_DIR", "REVDECK_DEV_CONTAINER", "REVDECK_UI_HOST"]) delete env[name];
|
|
2347
2644
|
if (Object.keys(env).length !== Object.keys(parsed[key]).length) {
|
|
@@ -2705,7 +3002,9 @@ var OPTIONS = {
|
|
|
2705
3002
|
id: { type: "string" },
|
|
2706
3003
|
toAgent: { type: "boolean", default: true },
|
|
2707
3004
|
all: { type: "boolean", default: false },
|
|
2708
|
-
lang: { type: "string" }
|
|
3005
|
+
lang: { type: "string" },
|
|
3006
|
+
role: { type: "string" },
|
|
3007
|
+
shard: { type: "string" }
|
|
2709
3008
|
};
|
|
2710
3009
|
function parse(argv) {
|
|
2711
3010
|
try {
|
|
@@ -2723,9 +3022,12 @@ var HELP_RU = `revdeck ${VERSION} \u2014 \u0440\u0435\u0432\u044C\u044E GitLab/G
|
|
|
2723
3022
|
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
3023
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
2725
3024
|
revdeck list \u043E\u0442\u043A\u0440\u044B\u0442\u044B\u0435 \u0440\u0435\u0432\u044C\u044E (\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u043A\u0435\u0448), --remote \u2014 \u0441 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B
|
|
2726
|
-
revdeck open <url|N
|
|
3025
|
+
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
3026
|
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
|
|
3027
|
+
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]
|
|
3028
|
+
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
|
|
3029
|
+
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)
|
|
3030
|
+
revdeck versions <N> \u0438\u0441\u0442\u043E\u0440\u0438\u044F \u0432\u0435\u0440\u0441\u0438\u0439 \u0440\u0435\u0432\u044C\u044E
|
|
2729
3031
|
revdeck threads <N> \u043E\u0431\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u044F
|
|
2730
3032
|
revdeck diff <N> [--file <\u043F\u0443\u0442\u044C>]
|
|
2731
3033
|
revdeck findings <N> [list|set --file <json>|decide --id <id> --decision accept|reject|discuss]
|
|
@@ -2752,9 +3054,12 @@ var HELP_EN = `revdeck ${VERSION} \u2014 code review for GitLab/GitHub, for huma
|
|
|
2752
3054
|
revdeck doctor check the environment and access
|
|
2753
3055
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
2754
3056
|
revdeck list open reviews (local cache), --remote \u2014 from the platform
|
|
2755
|
-
revdeck open <url|N
|
|
3057
|
+
revdeck open <url|N...> open one or more reviews
|
|
2756
3058
|
revdeck ui [N] link to the local UI
|
|
2757
|
-
revdeck context <N> agent context: rules, diff, threads
|
|
3059
|
+
revdeck context <N> agent context: rules, diff, threads [--role <role>] [--shard i/N]
|
|
3060
|
+
revdeck stats <N> review analytics: decisions, rejections, threads
|
|
3061
|
+
revdeck scan <N> secret scan (when review.secrets is enabled)
|
|
3062
|
+
revdeck versions <N> review version history
|
|
2758
3063
|
revdeck threads <N> discussions
|
|
2759
3064
|
revdeck diff <N> [--file <path>]
|
|
2760
3065
|
revdeck findings <N> [list|set --file <json>|decide --id <id> --decision accept|reject|discuss]
|
|
@@ -2808,7 +3113,7 @@ async function main2() {
|
|
|
2808
3113
|
case "list":
|
|
2809
3114
|
return list(root, values);
|
|
2810
3115
|
case "open":
|
|
2811
|
-
return openReview(root, positionals
|
|
3116
|
+
return openReview(root, positionals, values);
|
|
2812
3117
|
case "ui":
|
|
2813
3118
|
return ui(positionals[0], values);
|
|
2814
3119
|
case "status":
|
|
@@ -2816,6 +3121,14 @@ async function main2() {
|
|
|
2816
3121
|
case "context":
|
|
2817
3122
|
case "review":
|
|
2818
3123
|
return context(root, positionals[0], values);
|
|
3124
|
+
case "stats":
|
|
3125
|
+
case "analytics":
|
|
3126
|
+
return stats(positionals[0], values);
|
|
3127
|
+
case "scan":
|
|
3128
|
+
case "secrets":
|
|
3129
|
+
return secrets(positionals[0], values);
|
|
3130
|
+
case "versions":
|
|
3131
|
+
return versions(positionals[0], values);
|
|
2819
3132
|
case "threads":
|
|
2820
3133
|
return threads(positionals[0], values);
|
|
2821
3134
|
case "diff":
|
|
@@ -2919,23 +3232,36 @@ async function list(root, values) {
|
|
|
2919
3232
|
for (const item of reviews) writers.out(reviewLine(item));
|
|
2920
3233
|
});
|
|
2921
3234
|
}
|
|
2922
|
-
async function openReview(root,
|
|
2923
|
-
if (!
|
|
3235
|
+
async function openReview(root, args, values) {
|
|
3236
|
+
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"));
|
|
2924
3237
|
await withClient(async ({ client: client2 }) => {
|
|
2925
|
-
const
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3238
|
+
const requests = args.map(async (input) => {
|
|
3239
|
+
const result = await client2.request("reviews.open", {
|
|
3240
|
+
root,
|
|
3241
|
+
input,
|
|
3242
|
+
...values.platform ? { platform: values.platform } : {},
|
|
3243
|
+
...values.project ? { project: values.project } : {},
|
|
3244
|
+
...values.host ? { host: values.host } : {},
|
|
3245
|
+
...values.branch ? { branch: values.branch } : {}
|
|
3246
|
+
});
|
|
3247
|
+
return result.review;
|
|
2932
3248
|
});
|
|
2933
|
-
const
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
if (
|
|
3249
|
+
const settled = await Promise.allSettled(requests);
|
|
3250
|
+
const reviews = settled.flatMap((item) => item.status === "fulfilled" ? [item.value] : []);
|
|
3251
|
+
const failures = settled.flatMap((item) => item.status === "rejected" ? [item.reason] : []);
|
|
3252
|
+
if (values.json) {
|
|
3253
|
+
if (args.length === 1 && reviews[0]) return printJson(reviews[0]);
|
|
3254
|
+
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"));
|
|
3255
|
+
return printJson(reviews);
|
|
3256
|
+
}
|
|
3257
|
+
for (const review of reviews) {
|
|
3258
|
+
writers.out(formatInfo(review).join("\n"));
|
|
3259
|
+
if (review.errors.length) writers.err(`${tr("\u043F\u0440\u0435\u0434\u0443\u043F\u0440\u0435\u0436\u0434\u0435\u043D\u0438\u044F", "warnings")}:
|
|
2937
3260
|
${review.errors.map((item) => ` ${item}`).join("\n")}`);
|
|
2938
|
-
|
|
3261
|
+
}
|
|
3262
|
+
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}`));
|
|
3263
|
+
if (values.ui && reviews.length) printUi(reviews[reviews.length - 1].id, values);
|
|
3264
|
+
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
3265
|
});
|
|
2940
3266
|
}
|
|
2941
3267
|
async function ui(arg, values) {
|
|
@@ -3053,6 +3379,19 @@ async function status() {
|
|
|
3053
3379
|
for (const item of reviews) writers.out(reviewLine(item));
|
|
3054
3380
|
});
|
|
3055
3381
|
}
|
|
3382
|
+
function parseRole(value) {
|
|
3383
|
+
if (!value) return void 0;
|
|
3384
|
+
return value;
|
|
3385
|
+
}
|
|
3386
|
+
function parseShard(value) {
|
|
3387
|
+
if (!value) return void 0;
|
|
3388
|
+
const match = /^(\d+)\/(\d+)$/.exec(value);
|
|
3389
|
+
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"));
|
|
3390
|
+
const index = Number(match[1]);
|
|
3391
|
+
const count = Number(match[2]);
|
|
3392
|
+
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"));
|
|
3393
|
+
return { index, count };
|
|
3394
|
+
}
|
|
3056
3395
|
async function context(root, arg, values) {
|
|
3057
3396
|
await withClient(async ({ client: client2 }) => {
|
|
3058
3397
|
const { review } = await resolveReview(client2, root, reviewArg(values, arg), values);
|
|
@@ -3060,7 +3399,61 @@ async function context(root, arg, values) {
|
|
|
3060
3399
|
review: review.id
|
|
3061
3400
|
});
|
|
3062
3401
|
if (values.json) return printJson(contextPayload(review, rules2));
|
|
3063
|
-
|
|
3402
|
+
const role = parseRole(values.role);
|
|
3403
|
+
if (role && !rules2.roles.some((item) => item.id === role)) {
|
|
3404
|
+
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("|")}>`);
|
|
3405
|
+
}
|
|
3406
|
+
const shard = parseShard(values.shard);
|
|
3407
|
+
writers.out(renderContext(review, rules2, {
|
|
3408
|
+
language: rules2.language,
|
|
3409
|
+
...rules2.maxBytes !== void 0 ? { maxBytes: rules2.maxBytes } : {},
|
|
3410
|
+
...role ? { role } : {},
|
|
3411
|
+
...shard ? { shard } : {}
|
|
3412
|
+
}));
|
|
3413
|
+
});
|
|
3414
|
+
}
|
|
3415
|
+
async function versions(arg, values) {
|
|
3416
|
+
await withClient(async ({ client: client2 }) => {
|
|
3417
|
+
const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);
|
|
3418
|
+
const { versions: versions2 } = await client2.request("versions.list", { review: review.id });
|
|
3419
|
+
if (values.json) return printJson(versions2);
|
|
3420
|
+
if (!versions2.length) {
|
|
3421
|
+
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"));
|
|
3422
|
+
return;
|
|
3423
|
+
}
|
|
3424
|
+
for (const version of versions2) {
|
|
3425
|
+
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")}`);
|
|
3426
|
+
}
|
|
3427
|
+
});
|
|
3428
|
+
}
|
|
3429
|
+
async function secrets(arg, values) {
|
|
3430
|
+
await withClient(async ({ client: client2 }) => {
|
|
3431
|
+
const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);
|
|
3432
|
+
const result = await client2.request("secrets.get", { review: review.id });
|
|
3433
|
+
if (values.json) return printJson(result);
|
|
3434
|
+
if (!result.enabled) {
|
|
3435
|
+
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"));
|
|
3436
|
+
return;
|
|
3437
|
+
}
|
|
3438
|
+
writers.out(`${tr("\u0441\u043A\u0430\u043D", "scan")}: ${result.scan} \xB7 ${result.findings.length} ${tr("\u043D\u0430\u0445\u043E\u0434\u043E\u043A", "findings")}`);
|
|
3439
|
+
for (const finding of result.findings) writers.out(`\u2716 ${finding.rule} \xB7 ${finding.file}:${finding.line} \xB7 ${finding.preview}`);
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
3442
|
+
async function stats(arg, values) {
|
|
3443
|
+
await withClient(async ({ client: client2 }) => {
|
|
3444
|
+
const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);
|
|
3445
|
+
const { analytics } = await client2.request("analytics.get", { review: review.id });
|
|
3446
|
+
if (values.json) return printJson(analytics);
|
|
3447
|
+
const findings2 = analytics.findings;
|
|
3448
|
+
const threads2 = analytics.threads;
|
|
3449
|
+
const rate = analytics.acceptanceRate;
|
|
3450
|
+
writers.out(`#${review.info.ref.number} ${review.info.title}`);
|
|
3451
|
+
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}`);
|
|
3452
|
+
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}`);
|
|
3453
|
+
writers.out(`${tr("acceptance rate", "acceptance rate")}: ${rate == null ? "\u2014" : `${Math.round(rate * 100)}%`}`);
|
|
3454
|
+
for (const rejection of analytics.rejections) {
|
|
3455
|
+
writers.out(`\u2716 ${rejection.level} ${rejection.title} (${rejection.file}:${rejection.line ?? "\u2014"})${rejection.note ? ` \u2014 ${rejection.note}` : ""}`);
|
|
3456
|
+
}
|
|
3064
3457
|
});
|
|
3065
3458
|
}
|
|
3066
3459
|
async function threads(arg, values) {
|
|
@@ -3333,8 +3726,10 @@ async function checks(root, arg, values) {
|
|
|
3333
3726
|
}
|
|
3334
3727
|
async function config(root, values) {
|
|
3335
3728
|
const loaded = await loadConfig(root);
|
|
3336
|
-
if (values.json) return printJson({ path: loaded.path, config: loaded.config, warnings: loaded.warnings });
|
|
3729
|
+
if (values.json) return printJson({ path: loaded.path, localPath: loaded.localPath, config: loaded.config, warnings: loaded.warnings });
|
|
3337
3730
|
writers.out(`${tr("\u043A\u043E\u043D\u0444\u0438\u0433", "config")}: ${loaded.path ?? tr("\u043D\u0435\u0442 (.revdeck.yml)", "none (.revdeck.yml)")}`);
|
|
3731
|
+
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}`);
|
|
3732
|
+
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
3733
|
writers.out(`${tr("\u043F\u0440\u0430\u0432\u0438\u043B\u0430", "rules")}: ${loaded.config.rules.sources.join(", ") || "\u2014"}`);
|
|
3339
3734
|
writers.out(`${tr("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438", "checks")}: ${loaded.config.checks.map((check) => check.id).join(", ") || "\u2014"}`);
|
|
3340
3735
|
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 +3781,7 @@ async function doctor(root) {
|
|
|
3386
3781
|
const loaded = await loadConfig(root);
|
|
3387
3782
|
host = loaded.config.provider.host ?? (await gitRemote(root))?.host;
|
|
3388
3783
|
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)")]);
|
|
3784
|
+
if (loaded.localPath) rows.push(["local config", "ok", loaded.localPath]);
|
|
3389
3785
|
for (const warning of loaded.warnings) rows.push(["warning", "warn", warning]);
|
|
3390
3786
|
} catch (error) {
|
|
3391
3787
|
rows.push(["config", "fail", redactLine(error)]);
|