revdeck 0.5.0 → 0.7.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 +105 -2
- package/README.md +102 -22
- package/README.ru.md +105 -29
- package/SECURITY.md +1 -1
- package/dist/cli.js +1484 -593
- package/dist/cli.js.map +4 -4
- package/dist/daemon.js +1768 -283
- package/dist/daemon.js.map +4 -4
- package/dist/mcp.js +980 -117
- package/dist/mcp.js.map +4 -4
- package/dist/ui/assets/index-BIVPy49b.css +1 -0
- package/dist/ui/assets/index-BcvEWwhI.js +18 -0
- package/dist/ui/favicon.svg +8 -3
- package/dist/ui/icon-128.png +0 -0
- package/dist/ui/icon-32.png +0 -0
- package/dist/ui/index.html +4 -2
- package/docs/README.md +4 -1
- package/docs/architecture.md +60 -11
- package/docs/assets/brand/README.md +49 -0
- package/docs/assets/brand/icon-1024.png +0 -0
- package/docs/assets/brand/icon-128.png +0 -0
- package/docs/assets/brand/icon-256.png +0 -0
- package/docs/assets/brand/icon-32.png +0 -0
- package/docs/assets/brand/icon-512.png +0 -0
- package/docs/assets/brand/icon-64.png +0 -0
- package/docs/assets/brand/icon.svg +9 -0
- package/docs/assets/brand/logo-dark.png +0 -0
- package/docs/assets/brand/logo-dark.svg +13 -0
- package/docs/assets/brand/logo.png +0 -0
- package/docs/assets/brand/logo.svg +13 -0
- package/docs/capabilities.md +238 -0
- package/docs/configuration.md +87 -8
- package/docs/integrations.md +52 -14
- package/docs/protocol.md +85 -14
- package/docs/ru/README.md +4 -1
- package/docs/ru/architecture.md +60 -10
- package/docs/ru/capabilities.md +240 -0
- package/docs/ru/configuration.md +74 -6
- package/docs/ru/integrations.md +52 -14
- package/docs/ru/protocol.md +83 -13
- package/docs/ru/threat-model.md +34 -5
- package/docs/screenshot.png +0 -0
- package/docs/screenshot.ru.png +0 -0
- package/docs/threat-model.md +36 -5
- 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/Feedback.md +3 -2
- package/skills/revdeck/en/Review.md +3 -2
- package/skills/revdeck/en/SKILL.md +17 -1
- package/skills/revdeck/ru/Feature.md +61 -0
- package/skills/revdeck/ru/Feedback.md +3 -2
- package/skills/revdeck/ru/Review.md +2 -2
- package/skills/revdeck/ru/SKILL.md +18 -1
- package/dist/ui/assets/index-CcmcJhhu.css +0 -1
- package/dist/ui/assets/index-CuvK5owY.js +0 -10
- package/docs/adr/0001-daemon-first.md +0 -65
- package/docs/ru/adr/0001-daemon-first.md +0 -63
- package/examples/web-chat-core.yml +0 -45
package/dist/cli.js
CHANGED
|
@@ -10,8 +10,8 @@ var __esm = (fn, res, err) => function __init() {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/core/paths.ts
|
|
13
|
-
import { existsSync } from "node:fs";
|
|
14
|
-
import { lstat, mkdir, open, realpath, rename, unlink } from "node:fs/promises";
|
|
13
|
+
import { constants, existsSync } from "node:fs";
|
|
14
|
+
import { lstat, mkdir, open, realpath, rename, stat, unlink } from "node:fs/promises";
|
|
15
15
|
import path from "node:path";
|
|
16
16
|
import os from "node:os";
|
|
17
17
|
import { fileURLToPath } from "node:url";
|
|
@@ -79,18 +79,59 @@ async function ensureDir(dir, mode = 448) {
|
|
|
79
79
|
await chmod(dir, mode);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
function isInside(root, target) {
|
|
83
|
+
const relative = path.relative(path.resolve(root), path.resolve(target));
|
|
84
|
+
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
85
|
+
}
|
|
82
86
|
async function readTextNoFollow(file, maxBytes = 4 * 1024 * 1024) {
|
|
83
87
|
const info = await lstat(file);
|
|
84
88
|
if (info.isSymbolicLink()) throw new Error(`${path.basename(file)}: symbolic link, read refused`);
|
|
85
89
|
if (!info.isFile()) throw new Error(`${path.basename(file)}: not a regular file`);
|
|
86
90
|
if (info.size > maxBytes) throw new Error(`${path.basename(file)}: file is larger than ${Math.round(maxBytes / 1024)} KB`);
|
|
87
|
-
const
|
|
91
|
+
const flags = process.platform === "win32" ? "r" : constants.O_RDONLY | constants.O_NOFOLLOW;
|
|
92
|
+
const handle = await open(file, flags);
|
|
88
93
|
try {
|
|
89
94
|
return await handle.readFile({ encoding: "utf8" });
|
|
90
95
|
} finally {
|
|
91
96
|
await handle.close();
|
|
92
97
|
}
|
|
93
98
|
}
|
|
99
|
+
async function openInsideRoot(root, target) {
|
|
100
|
+
const resolvedTarget = path.resolve(target);
|
|
101
|
+
const realRoot = await realpath(path.resolve(root));
|
|
102
|
+
let handle;
|
|
103
|
+
try {
|
|
104
|
+
handle = await open(resolvedTarget, process.platform === "win32" ? "r" : constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (error.code === "ELOOP") {
|
|
107
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
108
|
+
}
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const info = await handle.stat();
|
|
113
|
+
if (!info.isFile()) throw new Error(`${path.basename(target)}: not a regular file`);
|
|
114
|
+
if (process.platform === "linux") {
|
|
115
|
+
const actual = await realpath(`/proc/self/fd/${handle.fd}`);
|
|
116
|
+
if (!isInside(realRoot, actual)) {
|
|
117
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
const actual = await realpath(resolvedTarget);
|
|
121
|
+
if (!isInside(realRoot, actual)) {
|
|
122
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
123
|
+
}
|
|
124
|
+
const onDisk = await stat(actual);
|
|
125
|
+
if (onDisk.dev !== info.dev || onDisk.ino !== info.ino) {
|
|
126
|
+
throw new Error(`${path.basename(target)}: path changed during read`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return handle;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
await handle.close();
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
94
135
|
function packageRoot() {
|
|
95
136
|
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
96
137
|
for (; ; ) {
|
|
@@ -110,6 +151,97 @@ var init_paths = __esm({
|
|
|
110
151
|
}
|
|
111
152
|
});
|
|
112
153
|
|
|
154
|
+
// src/core/errors.ts
|
|
155
|
+
var MrReviewError, ConfigError, ProviderError;
|
|
156
|
+
var init_errors = __esm({
|
|
157
|
+
"src/core/errors.ts"() {
|
|
158
|
+
"use strict";
|
|
159
|
+
MrReviewError = class extends Error {
|
|
160
|
+
code;
|
|
161
|
+
hint;
|
|
162
|
+
constructor(message, code = "REVDECK_ERROR", hint) {
|
|
163
|
+
super(message);
|
|
164
|
+
this.name = "MrReviewError";
|
|
165
|
+
this.code = code;
|
|
166
|
+
this.hint = hint;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
ConfigError = class extends MrReviewError {
|
|
170
|
+
constructor(message, hint) {
|
|
171
|
+
super(message, "CONFIG", hint);
|
|
172
|
+
this.name = "ConfigError";
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
ProviderError = class extends MrReviewError {
|
|
176
|
+
constructor(message, hint) {
|
|
177
|
+
super(message, "PROVIDER", hint);
|
|
178
|
+
this.name = "ProviderError";
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// src/core/glob.ts
|
|
185
|
+
function globToRegExp(glob) {
|
|
186
|
+
let source = "";
|
|
187
|
+
let index = 0;
|
|
188
|
+
const pattern = glob.replace(/^\.\//, "").replace(/^\/+/, "");
|
|
189
|
+
while (index < pattern.length) {
|
|
190
|
+
const char = pattern[index];
|
|
191
|
+
if (char === "*") {
|
|
192
|
+
if (pattern[index + 1] === "*") {
|
|
193
|
+
if (pattern[index + 2] === "/") {
|
|
194
|
+
source += "(?:[^/]+/)*";
|
|
195
|
+
index += 3;
|
|
196
|
+
} else {
|
|
197
|
+
source += ".*";
|
|
198
|
+
index += 2;
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
source += "[^/]*";
|
|
202
|
+
index += 1;
|
|
203
|
+
}
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (char === "?") {
|
|
207
|
+
source += "[^/]";
|
|
208
|
+
index += 1;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (char === "{") {
|
|
212
|
+
const end = pattern.indexOf("}", index);
|
|
213
|
+
if (end > index) {
|
|
214
|
+
const options = pattern.slice(index + 1, end).split(",").map((item) => escapeRegExp(item.trim()));
|
|
215
|
+
source += `(?:${options.join("|")})`;
|
|
216
|
+
index = end + 1;
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
source += escapeRegExp(char);
|
|
221
|
+
index += 1;
|
|
222
|
+
}
|
|
223
|
+
return new RegExp(`^${source}$`);
|
|
224
|
+
}
|
|
225
|
+
function escapeRegExp(value) {
|
|
226
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
227
|
+
}
|
|
228
|
+
function classifyFile(path12) {
|
|
229
|
+
const lower = path12.toLowerCase();
|
|
230
|
+
if (/(^|\/)(node_modules|dist|build|coverage|vendor)\//.test(lower)) return "generated";
|
|
231
|
+
if (/\.(md|mdx|rst|txt|adoc)$/.test(lower) || /(^|\/)(docs?|adr)\//.test(lower)) return "docs";
|
|
232
|
+
if (/(^|\/)(__tests__|tests?|spec|e2e)\//.test(lower) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /_test\.go$/.test(lower)) return "test";
|
|
233
|
+
if (/\.(css|scss|sass|less|styl)$/.test(lower)) return "style";
|
|
234
|
+
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";
|
|
235
|
+
if (/\.(generated|g)\.[cm]?[jt]s$|\.d\.ts$|(^|\/)generated\//.test(lower)) return "generated";
|
|
236
|
+
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";
|
|
237
|
+
return "other";
|
|
238
|
+
}
|
|
239
|
+
var init_glob = __esm({
|
|
240
|
+
"src/core/glob.ts"() {
|
|
241
|
+
"use strict";
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
113
245
|
// src/core/locale.ts
|
|
114
246
|
function detectLocale(explicit) {
|
|
115
247
|
const value = (explicit ?? process.env.REVDECK_LANG ?? process.env.LC_ALL ?? process.env.LANG ?? "").toLowerCase();
|
|
@@ -278,6 +410,352 @@ var init_review_roles = __esm({
|
|
|
278
410
|
}
|
|
279
411
|
});
|
|
280
412
|
|
|
413
|
+
// src/core/exec.ts
|
|
414
|
+
import { execFile } from "node:child_process";
|
|
415
|
+
import { access, constants as constants2 } from "node:fs/promises";
|
|
416
|
+
import os2 from "node:os";
|
|
417
|
+
import path2 from "node:path";
|
|
418
|
+
function scrubEnv(extra) {
|
|
419
|
+
const env = {};
|
|
420
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
421
|
+
if (SECRET_ENV.includes(key)) continue;
|
|
422
|
+
env[key] = value;
|
|
423
|
+
}
|
|
424
|
+
env.PAGER = "cat";
|
|
425
|
+
env.GIT_PAGER = "cat";
|
|
426
|
+
env.GIT_TERMINAL_PROMPT = "0";
|
|
427
|
+
env.NO_COLOR = "1";
|
|
428
|
+
env.CLICOLOR = "0";
|
|
429
|
+
env.FORCE_COLOR = "0";
|
|
430
|
+
env.TERM = "dumb";
|
|
431
|
+
return { ...env, ...extra };
|
|
432
|
+
}
|
|
433
|
+
async function resolveExecutable(command) {
|
|
434
|
+
if (command.includes("/") || command.includes("\\")) {
|
|
435
|
+
try {
|
|
436
|
+
await access(command, constants2.X_OK);
|
|
437
|
+
return command;
|
|
438
|
+
} catch {
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
const override = process.env[`REVDECK_${command.toUpperCase()}`];
|
|
443
|
+
if (override) return override;
|
|
444
|
+
const cached = RESOLVED.get(command);
|
|
445
|
+
if (cached) return cached;
|
|
446
|
+
const dirs = [
|
|
447
|
+
...(process.env.PATH ?? "").split(path2.delimiter),
|
|
448
|
+
path2.join(os2.homedir(), ".local", "bin"),
|
|
449
|
+
path2.join(os2.homedir(), ".local", "share", "mise", "shims"),
|
|
450
|
+
path2.join(os2.homedir(), ".asdf", "shims"),
|
|
451
|
+
path2.join(os2.homedir(), ".npm-global", "bin"),
|
|
452
|
+
"/opt/homebrew/bin",
|
|
453
|
+
"/usr/local/bin",
|
|
454
|
+
"/usr/bin",
|
|
455
|
+
"/bin"
|
|
456
|
+
].filter(Boolean);
|
|
457
|
+
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
458
|
+
for (const dir of [...new Set(dirs)]) {
|
|
459
|
+
for (const extension of extensions) {
|
|
460
|
+
const candidate = path2.join(dir, `${command}${extension}`);
|
|
461
|
+
try {
|
|
462
|
+
await access(candidate, constants2.X_OK);
|
|
463
|
+
RESOLVED.set(command, candidate);
|
|
464
|
+
return candidate;
|
|
465
|
+
} catch {
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
var SECRET_ENV, RESOLVED, run;
|
|
472
|
+
var init_exec = __esm({
|
|
473
|
+
"src/core/exec.ts"() {
|
|
474
|
+
"use strict";
|
|
475
|
+
SECRET_ENV = [
|
|
476
|
+
"GITLAB_TOKEN",
|
|
477
|
+
"GITLAB_PRIVATE_TOKEN",
|
|
478
|
+
"GLAB_TOKEN",
|
|
479
|
+
"CI_JOB_TOKEN",
|
|
480
|
+
"GH_TOKEN",
|
|
481
|
+
"GITHUB_TOKEN",
|
|
482
|
+
"GITHUB_ENTERPRISE_TOKEN",
|
|
483
|
+
"GIT_ASKPASS",
|
|
484
|
+
"SSH_ASKPASS",
|
|
485
|
+
"REVDECK_TOKEN"
|
|
486
|
+
];
|
|
487
|
+
RESOLVED = /* @__PURE__ */ new Map();
|
|
488
|
+
run = async (command, args, options = {}) => {
|
|
489
|
+
const executable = await resolveExecutable(command) ?? command;
|
|
490
|
+
return new Promise((resolve, reject) => {
|
|
491
|
+
const child = execFile(
|
|
492
|
+
executable,
|
|
493
|
+
args,
|
|
494
|
+
{
|
|
495
|
+
cwd: options.cwd,
|
|
496
|
+
env: scrubEnv(options.env),
|
|
497
|
+
timeout: options.timeoutMs ?? 12e4,
|
|
498
|
+
maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
|
|
499
|
+
encoding: "utf8",
|
|
500
|
+
windowsHide: true,
|
|
501
|
+
shell: false
|
|
502
|
+
},
|
|
503
|
+
(error, stdout, stderr) => {
|
|
504
|
+
const exitCode = error?.code;
|
|
505
|
+
const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
|
|
506
|
+
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
507
|
+
const reason = (stderr || stdout || error.message).trim();
|
|
508
|
+
reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
resolve({ stdout, stderr, code });
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
if (options.input !== void 0) {
|
|
515
|
+
child.stdin?.end(options.input);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
// src/core/git-files.ts
|
|
523
|
+
async function gitTrackState(root, relative) {
|
|
524
|
+
try {
|
|
525
|
+
const { stdout } = await run("git", ["-C", root, "ls-files", "--error-unmatch", "--", relative], {
|
|
526
|
+
timeoutMs: 1e4
|
|
527
|
+
});
|
|
528
|
+
return stdout.trim() ? "tracked" : "unknown";
|
|
529
|
+
} catch (error) {
|
|
530
|
+
return error.code === 1 ? "untracked" : "unknown";
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
var init_git_files = __esm({
|
|
534
|
+
"src/core/git-files.ts"() {
|
|
535
|
+
"use strict";
|
|
536
|
+
init_exec();
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
// src/core/config.ts
|
|
541
|
+
import { z } from "zod";
|
|
542
|
+
import { parse as parseYaml } from "yaml";
|
|
543
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
544
|
+
import path3 from "node:path";
|
|
545
|
+
function isRecord(value) {
|
|
546
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
547
|
+
}
|
|
548
|
+
function parseYamlData(text, source) {
|
|
549
|
+
try {
|
|
550
|
+
return parseYaml(text);
|
|
551
|
+
} catch (error) {
|
|
552
|
+
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}`));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function mergeConfigData(base, local) {
|
|
556
|
+
if (!isRecord(base) || !isRecord(local)) return local;
|
|
557
|
+
const result = { ...base };
|
|
558
|
+
for (const [key, value] of Object.entries(local)) {
|
|
559
|
+
const current2 = result[key];
|
|
560
|
+
result[key] = isRecord(current2) && isRecord(value) ? mergeConfigData(current2, value) : value;
|
|
561
|
+
}
|
|
562
|
+
return result;
|
|
563
|
+
}
|
|
564
|
+
async function loadConfig(root = findRepoRoot()) {
|
|
565
|
+
const warnings = [];
|
|
566
|
+
const file = findConfigFile(root);
|
|
567
|
+
let localFile = findLocalConfigFile(root);
|
|
568
|
+
if (localFile && existsSync2(path3.join(root, ".git"))) {
|
|
569
|
+
const state = await gitTrackState(root, path3.relative(root, localFile));
|
|
570
|
+
if (state !== "untracked") {
|
|
571
|
+
warnings.push(
|
|
572
|
+
tr(
|
|
573
|
+
".revdeck.local.yml \u043E\u0442\u0441\u043B\u0435\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F git: \u0444\u0430\u0439\u043B \u0438\u0437 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F \u0438\u0433\u043D\u043E\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044F \u043A\u0430\u043A \u043B\u0438\u0447\u043D\u044B\u0439",
|
|
574
|
+
".revdeck.local.yml is tracked by git: a repository file is ignored as personal overrides"
|
|
575
|
+
)
|
|
576
|
+
);
|
|
577
|
+
localFile = null;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const baseData = file ? parseYamlData(await readTextNoFollow(file), path3.relative(root, file) || file) : {};
|
|
581
|
+
const localData = localFile ? parseYamlData(await readTextNoFollow(localFile), path3.relative(root, localFile) || localFile) : {};
|
|
582
|
+
if (!file && !localFile) {
|
|
583
|
+
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"));
|
|
584
|
+
}
|
|
585
|
+
const merged = mergeConfigData(baseData, localData);
|
|
586
|
+
const config2 = reviewConfigSchema.parse(merged);
|
|
587
|
+
const baseReadOnly = isRecord(baseData) && isRecord(baseData.review) && baseData.review.readOnly === true;
|
|
588
|
+
const localReadOnly = isRecord(localData) && isRecord(localData.review) && localData.review.readOnly === true;
|
|
589
|
+
config2.review.readOnly = baseReadOnly || localReadOnly;
|
|
590
|
+
if (!config2.rules.sources.length && !config2.rules.map.length) {
|
|
591
|
+
const found = DISCOVERED_SOURCES.filter((item) => existsSync2(path3.join(root, item)));
|
|
592
|
+
config2.rules.sources = found;
|
|
593
|
+
if (!found.length) {
|
|
594
|
+
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"));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return {
|
|
598
|
+
config: config2,
|
|
599
|
+
path: file,
|
|
600
|
+
localPath: localFile,
|
|
601
|
+
warnings
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
function assertConfigPath(root, relative) {
|
|
605
|
+
const cleaned = relative.split("#")[0];
|
|
606
|
+
const resolved = path3.resolve(root, cleaned);
|
|
607
|
+
const rel = path3.relative(root, resolved);
|
|
608
|
+
if (rel.startsWith("..") || path3.isAbsolute(rel)) {
|
|
609
|
+
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`));
|
|
610
|
+
}
|
|
611
|
+
return resolved;
|
|
612
|
+
}
|
|
613
|
+
async function readConfigFile(root, relative, maxBytes = 4 * 1024 * 1024) {
|
|
614
|
+
const handle = await openInsideRoot(root, assertConfigPath(root, relative));
|
|
615
|
+
try {
|
|
616
|
+
const info = await handle.stat();
|
|
617
|
+
if (info.size > maxBytes) {
|
|
618
|
+
throw new Error(`${path3.basename(relative)}: file is larger than ${Math.round(maxBytes / 1024)} KB`);
|
|
619
|
+
}
|
|
620
|
+
return await handle.readFile({ encoding: "utf8" });
|
|
621
|
+
} finally {
|
|
622
|
+
await handle.close();
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
function checksForPaths(config2, paths) {
|
|
626
|
+
return config2.checks.map((check) => {
|
|
627
|
+
const matched = !check.when.length || paths.some((file) => check.when.some((pattern) => globToRegExp(pattern).test(file)));
|
|
628
|
+
return { id: check.id, name: check.name ?? check.id, argv: check.argv, consent: check.consent, matched };
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
var matchSchema, customRoleSchema, reviewConfigSchema, DISCOVERED_SOURCES;
|
|
632
|
+
var init_config = __esm({
|
|
633
|
+
"src/core/config.ts"() {
|
|
634
|
+
"use strict";
|
|
635
|
+
init_paths();
|
|
636
|
+
init_errors();
|
|
637
|
+
init_glob();
|
|
638
|
+
init_locale();
|
|
639
|
+
init_review_roles();
|
|
640
|
+
init_git_files();
|
|
641
|
+
matchSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
642
|
+
customRoleSchema = z.object({
|
|
643
|
+
title: z.string().min(1).max(120),
|
|
644
|
+
description: z.string().min(1).max(2e3),
|
|
645
|
+
criteria: z.array(z.string().min(1).max(20)).max(20).default([]),
|
|
646
|
+
focus: z.string().max(2e3).optional(),
|
|
647
|
+
instructions: z.string().max(8e3).optional()
|
|
648
|
+
});
|
|
649
|
+
reviewConfigSchema = z.object({
|
|
650
|
+
version: z.literal(1).default(1),
|
|
651
|
+
provider: z.object({
|
|
652
|
+
/** auto — по git remote; иначе явная платформа. */
|
|
653
|
+
type: z.enum(["auto", "gitlab", "github"]).default("auto"),
|
|
654
|
+
host: z.string().min(1).optional(),
|
|
655
|
+
/** GitLab: group/project. GitHub: owner/repo. */
|
|
656
|
+
project: z.string().min(1).optional(),
|
|
657
|
+
/** База для локального diff, когда ревью идёт по ветке. */
|
|
658
|
+
base: z.string().min(1).optional()
|
|
659
|
+
}).prefault({}),
|
|
660
|
+
output: z.object({
|
|
661
|
+
language: z.enum(["auto", "ru", "en"]).default("auto")
|
|
662
|
+
}).prefault({}),
|
|
663
|
+
context: z.object({
|
|
664
|
+
/** Документы о приложении: архитектура, интерфейсы, деплой. Не правила оценки. */
|
|
665
|
+
sources: z.array(z.string().min(1)).default([]),
|
|
666
|
+
/** 0 — использовать бюджет feature-контекста; иначе предел профиля проекта. */
|
|
667
|
+
maxBytes: z.number().int().nonnegative().default(0)
|
|
668
|
+
}).prefault({}),
|
|
669
|
+
review: z.object({
|
|
670
|
+
/** Сколько независимых ревьюеров запускать. */
|
|
671
|
+
agents: z.number().int().min(1).max(8).default(3),
|
|
672
|
+
/** Роли агентов; встроенные id или ключи customRoles. */
|
|
673
|
+
roles: z.array(z.string().min(1).max(64)).min(1).max(10).default([...DEFAULT_REVIEW_ROLES]),
|
|
674
|
+
/** Пользовательские роли с описанием и инструкциями. */
|
|
675
|
+
customRoles: z.record(z.string().min(1).max(64), customRoleSchema).default({}),
|
|
676
|
+
/** Явные группы изменений; остальные группируются по типу и модулю. */
|
|
677
|
+
groups: z.array(
|
|
678
|
+
z.object({
|
|
679
|
+
id: z.string().min(1).max(64),
|
|
680
|
+
title: z.string().min(1).max(120),
|
|
681
|
+
match: matchSchema
|
|
682
|
+
})
|
|
683
|
+
).max(100).default([]),
|
|
684
|
+
/** Опциональный скан секретов; по умолчанию выключен. */
|
|
685
|
+
secrets: z.object({
|
|
686
|
+
enabled: z.boolean().default(false),
|
|
687
|
+
scan: z.enum(["diff", "files", "both"]).default("diff"),
|
|
688
|
+
includeTests: z.boolean().default(false),
|
|
689
|
+
/** Glob-пути или id правила (`rule:generic-secret`). */
|
|
690
|
+
allowlist: z.array(z.string().min(1)).default([])
|
|
691
|
+
}).prefault({}),
|
|
692
|
+
/** История версий ревью (снимки по commit SHA). */
|
|
693
|
+
history: z.object({
|
|
694
|
+
enabled: z.boolean().default(false),
|
|
695
|
+
keep: z.number().int().min(1).max(100).default(20)
|
|
696
|
+
}).prefault({}),
|
|
697
|
+
/** Запрет любых изменений: drafts, findings, публикация. */
|
|
698
|
+
readOnly: z.boolean().default(false)
|
|
699
|
+
}).prefault({}).superRefine((value, ctx) => {
|
|
700
|
+
for (const key of Object.keys(value.customRoles)) {
|
|
701
|
+
if (REVIEW_ROLE_IDS.includes(key)) {
|
|
702
|
+
ctx.addIssue({ code: "custom", path: ["customRoles", key], message: `role ${key} is built in and cannot be overridden` });
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
for (const role of value.roles) {
|
|
706
|
+
if (!REVIEW_ROLE_IDS.includes(role) && !(role in value.customRoles)) {
|
|
707
|
+
ctx.addIssue({ code: "custom", path: ["roles"], message: `unknown role: ${role}` });
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}),
|
|
711
|
+
rules: z.object({
|
|
712
|
+
/** Общие документы, если ни одна строка map не подошла. Пусто — автообнаружение. */
|
|
713
|
+
sources: z.array(z.string().min(1)).default([]),
|
|
714
|
+
/** Привязка путей к документам: match — glob, docs — пути с необязательной секцией `#…`. */
|
|
715
|
+
map: z.array(
|
|
716
|
+
z.object({
|
|
717
|
+
match: matchSchema,
|
|
718
|
+
docs: z.array(z.string().min(1)).min(1),
|
|
719
|
+
note: z.string().optional()
|
|
720
|
+
})
|
|
721
|
+
).default([]),
|
|
722
|
+
/** Пути, которые не ревьюятся (сгенерированный код и т.п.). */
|
|
723
|
+
ignore: z.array(z.string().min(1)).default([]),
|
|
724
|
+
/** 0 — без ограничения; иначе документ обрезается до этого размера. */
|
|
725
|
+
maxDocumentBytes: z.number().int().nonnegative().default(0),
|
|
726
|
+
/** 0 — без ограничения; иначе общий контекст правил обрезается. */
|
|
727
|
+
maxTotalBytes: z.number().int().nonnegative().default(0)
|
|
728
|
+
}).prefault({}),
|
|
729
|
+
checks: z.array(
|
|
730
|
+
z.object({
|
|
731
|
+
id: z.string().min(1),
|
|
732
|
+
name: z.string().optional(),
|
|
733
|
+
/** argv без shell: первым идёт исполняемый файл. */
|
|
734
|
+
argv: z.array(z.string()).min(1),
|
|
735
|
+
/** Запускать, только если diff затронул эти glob-пути. */
|
|
736
|
+
when: z.array(z.string()).default([]),
|
|
737
|
+
consent: z.boolean().default(true),
|
|
738
|
+
timeoutMs: z.number().int().positive().max(36e5).default(3e5)
|
|
739
|
+
})
|
|
740
|
+
).default([]),
|
|
741
|
+
publish: z.object({
|
|
742
|
+
requireApproval: z.boolean().default(true),
|
|
743
|
+
maxComments: z.number().int().positive().max(200).default(50)
|
|
744
|
+
}).prefault({})
|
|
745
|
+
});
|
|
746
|
+
DISCOVERED_SOURCES = [
|
|
747
|
+
"AGENTS.md",
|
|
748
|
+
"CLAUDE.md",
|
|
749
|
+
"CONTRIBUTING.md",
|
|
750
|
+
"docs/ARCHITECTURE.md",
|
|
751
|
+
"docs/Architecture.md",
|
|
752
|
+
"docs/STYLEGUIDE.md",
|
|
753
|
+
"docs/Styleguide.md",
|
|
754
|
+
"docs/CONTRIBUTING.md"
|
|
755
|
+
];
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
|
|
281
759
|
// src/core/redact.ts
|
|
282
760
|
function redact(value) {
|
|
283
761
|
let text = String(value ?? "").replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, " ");
|
|
@@ -313,16 +791,16 @@ var VERSION;
|
|
|
313
791
|
var init_version = __esm({
|
|
314
792
|
"src/version.ts"() {
|
|
315
793
|
"use strict";
|
|
316
|
-
VERSION = "0.
|
|
794
|
+
VERSION = "0.7.0";
|
|
317
795
|
}
|
|
318
796
|
});
|
|
319
797
|
|
|
320
798
|
// src/client.ts
|
|
321
799
|
import net from "node:net";
|
|
322
800
|
import { spawn } from "node:child_process";
|
|
323
|
-
import { existsSync as
|
|
801
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
324
802
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
325
|
-
import
|
|
803
|
+
import path6 from "node:path";
|
|
326
804
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
327
805
|
async function connectSocket(file = socketPath(), timeoutMs = 1500) {
|
|
328
806
|
return new Promise((resolve, reject) => {
|
|
@@ -361,16 +839,17 @@ function devcontainerHint() {
|
|
|
361
839
|
return [
|
|
362
840
|
"\u0434\u0435\u043C\u043E\u043D revdeck \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u043D\u0430 \u0445\u043E\u0441\u0442\u0435",
|
|
363
841
|
"\u043D\u0430 \u0445\u043E\u0441\u0442\u0435: revdeck daemon start",
|
|
364
|
-
`\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435
|
|
842
|
+
`\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 mount \u0441\u043E\u043A\u0435\u0442\u0430 \u0438\u0437 revdeck devcontainer --write: ${runtime} (state: ${state})`,
|
|
843
|
+
"UI-\u0442\u043E\u043A\u0435\u043D \u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440 \u043D\u0435 \u043F\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044F; \u043C\u043E\u0441\u0442 \u0434\u0430\u0451\u0442 \u0442\u043E\u043B\u044C\u043A\u043E \u0430\u0433\u0435\u043D\u0442\u0441\u043A\u0438\u0435 \u043C\u0435\u0442\u043E\u0434\u044B",
|
|
365
844
|
"gh/glab \u0434\u043E\u043B\u0436\u043D\u044B \u043E\u0441\u0442\u0430\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 \u0445\u043E\u0441\u0442\u0435: \u0432\u043D\u0443\u0442\u0440\u0438 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0430 \u0438\u0445 \u0437\u0430\u043F\u0443\u0441\u043A\u0430\u0442\u044C \u043D\u0435 \u043D\u0443\u0436\u043D\u043E"
|
|
366
845
|
].join("; ");
|
|
367
846
|
}
|
|
368
847
|
async function devcontainerHttpClient() {
|
|
369
848
|
const { info, error } = await daemonInfoRead();
|
|
370
849
|
if (!info) return { client: null, error: `${daemonInfoPath()}: ${error}` };
|
|
371
|
-
if (!info.port || !info.
|
|
850
|
+
if (!info.port || !info.agentToken) return { client: null, error: `${daemonInfoPath()}: \u043D\u0435\u0442 port/agentToken` };
|
|
372
851
|
const host = process.env.REVDECK_UI_HOST ?? "host.docker.internal";
|
|
373
|
-
return { client: new HttpClient(`http://${host}:${info.port}`, info.
|
|
852
|
+
return { client: new HttpClient(`http://${host}:${info.port}`, info.agentToken), error: "" };
|
|
374
853
|
}
|
|
375
854
|
async function ensureDaemon(options = {}) {
|
|
376
855
|
const url = process.env.REVDECK_URL;
|
|
@@ -392,11 +871,11 @@ async function ensureDaemon(options = {}) {
|
|
|
392
871
|
throw new RpcError(
|
|
393
872
|
`devcontainer HTTP: ${httpError.message}`,
|
|
394
873
|
"DEVCONTAINER",
|
|
395
|
-
"\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435, \u0447\u0442\u043E \u0434\u0435\u043C\u043E\u043D \u043D\u0430 \u0445\u043E\u0441\u0442\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D; \
|
|
874
|
+
"\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435, \u0447\u0442\u043E \u0434\u0435\u043C\u043E\u043D \u043D\u0430 \u0445\u043E\u0441\u0442\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D; \u0434\u043B\u044F HTTP-\u043F\u0440\u043E\u0431\u0440\u043E\u0441\u0430 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 REVDECK_URL + REVDECK_TOKEN"
|
|
396
875
|
);
|
|
397
876
|
}
|
|
398
877
|
}
|
|
399
|
-
throw new RpcError(`devcontainer: ${http.error || devcontainerHint()}`, "DEVCONTAINER", "\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \
|
|
878
|
+
throw new RpcError(`devcontainer: ${http.error || devcontainerHint()}`, "DEVCONTAINER", "\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 mount \u0441\u043E\u043A\u0435\u0442\u0430 /run/revdeck");
|
|
400
879
|
}
|
|
401
880
|
if (options.autoStart === false) throw error;
|
|
402
881
|
}
|
|
@@ -429,15 +908,15 @@ async function spawnDaemon(extraArgs = []) {
|
|
|
429
908
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
430
909
|
}
|
|
431
910
|
function daemonEntry() {
|
|
432
|
-
const here =
|
|
433
|
-
const built =
|
|
434
|
-
if (
|
|
435
|
-
const source =
|
|
436
|
-
if (
|
|
911
|
+
const here = path6.dirname(fileURLToPath2(import.meta.url));
|
|
912
|
+
const built = path6.join(here, "daemon.js");
|
|
913
|
+
if (existsSync5(built)) return { command: process.execPath, args: [built] };
|
|
914
|
+
const source = path6.join(here, "daemon", "main.ts");
|
|
915
|
+
if (existsSync5(source)) {
|
|
437
916
|
return { command: process.execPath, args: ["--import", "tsx", source] };
|
|
438
917
|
}
|
|
439
|
-
const sibling =
|
|
440
|
-
if (
|
|
918
|
+
const sibling = path6.join(here, "..", "dist", "daemon.js");
|
|
919
|
+
if (existsSync5(sibling)) return { command: process.execPath, args: [sibling] };
|
|
441
920
|
throw new RpcError("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0432\u0445\u043E\u0434 \u0434\u0435\u043C\u043E\u043D\u0430 (dist/daemon.js)", "DAEMON");
|
|
442
921
|
}
|
|
443
922
|
function uiBaseUrl(info) {
|
|
@@ -563,6 +1042,103 @@ var init_client = __esm({
|
|
|
563
1042
|
}
|
|
564
1043
|
});
|
|
565
1044
|
|
|
1045
|
+
// src/core/git.ts
|
|
1046
|
+
function parseRemote(url) {
|
|
1047
|
+
const value = url.trim();
|
|
1048
|
+
if (!value) return null;
|
|
1049
|
+
let host = "";
|
|
1050
|
+
let projectPath = "";
|
|
1051
|
+
const http = /^(?:https?|git|ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+?)(?:\.git)?\/?$/.exec(value);
|
|
1052
|
+
if (http) {
|
|
1053
|
+
host = http[1];
|
|
1054
|
+
projectPath = http[2];
|
|
1055
|
+
} else {
|
|
1056
|
+
const scp = SSH_SCP.exec(value);
|
|
1057
|
+
if (!scp) return null;
|
|
1058
|
+
host = scp[1];
|
|
1059
|
+
projectPath = scp[3];
|
|
1060
|
+
}
|
|
1061
|
+
projectPath = projectPath.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
1062
|
+
if (!host || !projectPath || !projectPath.includes("/")) return null;
|
|
1063
|
+
return { host, project: projectPath, platform: detectPlatform(host), url: value };
|
|
1064
|
+
}
|
|
1065
|
+
function detectPlatform(host) {
|
|
1066
|
+
const lower = host.toLowerCase();
|
|
1067
|
+
if (lower === "github.com" || lower.endsWith(".github.com") || lower.includes("github")) return "github";
|
|
1068
|
+
if (lower === "gitlab.com" || lower.endsWith(".gitlab.com") || lower.includes("gitlab")) return "gitlab";
|
|
1069
|
+
return null;
|
|
1070
|
+
}
|
|
1071
|
+
async function gitRemote(root, remote = "origin") {
|
|
1072
|
+
try {
|
|
1073
|
+
const { stdout } = await run("git", ["config", "--get", `remote.${remote}.url`], { cwd: root, timeoutMs: 1e4 });
|
|
1074
|
+
return parseRemote(stdout.trim());
|
|
1075
|
+
} catch {
|
|
1076
|
+
return null;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
var SSH_SCP;
|
|
1080
|
+
var init_git = __esm({
|
|
1081
|
+
"src/core/git.ts"() {
|
|
1082
|
+
"use strict";
|
|
1083
|
+
init_exec();
|
|
1084
|
+
SSH_SCP = /^(?:ssh:\/\/)?(?:[^@/]+@)?([^:/]+)(?::(\d+))?[:/](.+?)(?:\.git)?\/?$/;
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
// src/core/types.ts
|
|
1089
|
+
var init_types = __esm({
|
|
1090
|
+
"src/core/types.ts"() {
|
|
1091
|
+
"use strict";
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
|
|
1095
|
+
// src/core/refs.ts
|
|
1096
|
+
function reviewId(ref) {
|
|
1097
|
+
return `${ref.platform}:${ref.host}/${ref.project}!${ref.number}`;
|
|
1098
|
+
}
|
|
1099
|
+
function parseReviewId(id) {
|
|
1100
|
+
const match = /^(gitlab|github):([^/]+)\/(.+)!(\d+)$/.exec(id);
|
|
1101
|
+
if (!match) throw new Error(`invalid review id: ${id}`);
|
|
1102
|
+
return {
|
|
1103
|
+
platform: match[1],
|
|
1104
|
+
host: match[2],
|
|
1105
|
+
project: match[3],
|
|
1106
|
+
number: Number(match[4])
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
function parseReviewUrl(input) {
|
|
1110
|
+
const value = input.trim();
|
|
1111
|
+
const gitlab = GITLAB_URL.exec(value);
|
|
1112
|
+
if (gitlab) {
|
|
1113
|
+
return { platform: "gitlab", host: gitlab[1], project: gitlab[2], number: Number(gitlab[3]) };
|
|
1114
|
+
}
|
|
1115
|
+
const github = GITHUB_URL.exec(value);
|
|
1116
|
+
if (github) {
|
|
1117
|
+
return { platform: "github", host: github[1], project: github[2], number: Number(github[3]) };
|
|
1118
|
+
}
|
|
1119
|
+
const short = /^(.+?)([#!])(\d+)$/.exec(value);
|
|
1120
|
+
if (short) {
|
|
1121
|
+
return {
|
|
1122
|
+
platform: short[2] === "!" ? "gitlab" : "github",
|
|
1123
|
+
host: short[2] === "!" ? "gitlab.com" : "github.com",
|
|
1124
|
+
project: short[1],
|
|
1125
|
+
number: Number(short[3])
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
throw new Error(
|
|
1129
|
+
"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"
|
|
1130
|
+
);
|
|
1131
|
+
}
|
|
1132
|
+
var GITLAB_URL, GITHUB_URL;
|
|
1133
|
+
var init_refs = __esm({
|
|
1134
|
+
"src/core/refs.ts"() {
|
|
1135
|
+
"use strict";
|
|
1136
|
+
init_types();
|
|
1137
|
+
GITLAB_URL = /^(?:https?:\/\/)?([^/]+)\/(.+?)\/-\/merge_requests\/(\d+)(?:[/?#].*)?$/;
|
|
1138
|
+
GITHUB_URL = /^(?:https?:\/\/)?([^/]+)\/([^/]+\/[^/]+)\/pull\/(\d+)(?:[/?#].*)?$/;
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
|
|
566
1142
|
// src/cli/format.ts
|
|
567
1143
|
function printJson(value) {
|
|
568
1144
|
writers.out(JSON.stringify(value, null, 2));
|
|
@@ -823,6 +1399,146 @@ var init_context = __esm({
|
|
|
823
1399
|
}
|
|
824
1400
|
});
|
|
825
1401
|
|
|
1402
|
+
// src/core/projects.ts
|
|
1403
|
+
function projectKey(ref) {
|
|
1404
|
+
return `${ref.platform}:${ref.host.trim().toLowerCase()}/${ref.project.trim().toLowerCase()}`;
|
|
1405
|
+
}
|
|
1406
|
+
function projectTitle(project) {
|
|
1407
|
+
const parts = project.split("/").filter(Boolean);
|
|
1408
|
+
return parts[parts.length - 1] ?? project;
|
|
1409
|
+
}
|
|
1410
|
+
var init_projects = __esm({
|
|
1411
|
+
"src/core/projects.ts"() {
|
|
1412
|
+
"use strict";
|
|
1413
|
+
}
|
|
1414
|
+
});
|
|
1415
|
+
|
|
1416
|
+
// src/providers/provider.ts
|
|
1417
|
+
async function projectContext(root, config2, overrides = {}) {
|
|
1418
|
+
const remote = await gitRemote(root);
|
|
1419
|
+
const platform = overrides.platform ?? (config2.provider.type !== "auto" ? config2.provider.type : remote?.platform ?? void 0);
|
|
1420
|
+
const host = overrides.host ?? config2.provider.host ?? remote?.host;
|
|
1421
|
+
const project = overrides.project ?? config2.provider.project ?? remote?.project;
|
|
1422
|
+
if (!platform) {
|
|
1423
|
+
throw new ProviderError(
|
|
1424
|
+
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"),
|
|
1425
|
+
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)")
|
|
1426
|
+
);
|
|
1427
|
+
}
|
|
1428
|
+
if (!host || !project) {
|
|
1429
|
+
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"));
|
|
1430
|
+
}
|
|
1431
|
+
return { platform, host, project };
|
|
1432
|
+
}
|
|
1433
|
+
var init_provider = __esm({
|
|
1434
|
+
"src/providers/provider.ts"() {
|
|
1435
|
+
"use strict";
|
|
1436
|
+
init_git();
|
|
1437
|
+
init_errors();
|
|
1438
|
+
init_refs();
|
|
1439
|
+
init_locale();
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
|
|
1443
|
+
// src/mcp/scope.ts
|
|
1444
|
+
async function resolveScope(rootInput) {
|
|
1445
|
+
const root = findRepoRoot(rootInput);
|
|
1446
|
+
const loaded = await loadConfig(root);
|
|
1447
|
+
const context2 = await projectContext(root, loaded.config);
|
|
1448
|
+
return {
|
|
1449
|
+
root,
|
|
1450
|
+
...context2,
|
|
1451
|
+
key: projectKey(context2),
|
|
1452
|
+
title: projectTitle(context2.project)
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
function reviewRefFromInput(input) {
|
|
1456
|
+
const value = input.trim();
|
|
1457
|
+
if (!value || /^\d+$/.test(value)) return null;
|
|
1458
|
+
if (/^(gitlab|github):/.test(value)) {
|
|
1459
|
+
try {
|
|
1460
|
+
return parseReviewId(value);
|
|
1461
|
+
} catch {
|
|
1462
|
+
return null;
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
if (value.includes("/") || /[#!]\d+$/.test(value)) {
|
|
1466
|
+
try {
|
|
1467
|
+
return parseReviewUrl(value);
|
|
1468
|
+
} catch {
|
|
1469
|
+
return null;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
return null;
|
|
1473
|
+
}
|
|
1474
|
+
function featureReviewId(ref, scope2) {
|
|
1475
|
+
if (!scope2.feature) return null;
|
|
1476
|
+
for (const id of scope2.feature.reviewIds) {
|
|
1477
|
+
try {
|
|
1478
|
+
const member = parseReviewId(id);
|
|
1479
|
+
if (projectKey(member) === projectKey(ref) && member.number === ref.number) return id;
|
|
1480
|
+
} catch {
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
return null;
|
|
1484
|
+
}
|
|
1485
|
+
function assertReviewInScope(review, scope2) {
|
|
1486
|
+
const ref = reviewRefFromInput(review);
|
|
1487
|
+
if (scope2.feature) {
|
|
1488
|
+
if (!ref) {
|
|
1489
|
+
const error3 = new Error(
|
|
1490
|
+
tr(
|
|
1491
|
+
"\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",
|
|
1492
|
+
"in a feature session pass a full review id or URL, not a number"
|
|
1493
|
+
)
|
|
1494
|
+
);
|
|
1495
|
+
error3.hint = tr(
|
|
1496
|
+
"\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 id \u0438\u0437 revdeck_feature \u0438\u043B\u0438 revdeck_status.",
|
|
1497
|
+
"Use an id from revdeck_feature or revdeck_status."
|
|
1498
|
+
);
|
|
1499
|
+
throw error3;
|
|
1500
|
+
}
|
|
1501
|
+
const id = featureReviewId(ref, scope2) ?? reviewId(ref);
|
|
1502
|
+
if (featureReviewId(ref, scope2)) return;
|
|
1503
|
+
const error2 = new Error(
|
|
1504
|
+
tr(
|
|
1505
|
+
`\u0440\u0435\u0432\u044C\u044E ${id} \u043D\u0435 \u0432\u0445\u043E\u0434\u0438\u0442 \u0432 \u0444\u0438\u0447\u0443 ${scope2.feature.id}`,
|
|
1506
|
+
`review ${id} is not a member of feature ${scope2.feature.id}`
|
|
1507
|
+
)
|
|
1508
|
+
);
|
|
1509
|
+
error2.hint = tr(
|
|
1510
|
+
"\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.",
|
|
1511
|
+
"A feature session is limited to its reviews. Add the review in the UI or CLI."
|
|
1512
|
+
);
|
|
1513
|
+
throw error2;
|
|
1514
|
+
}
|
|
1515
|
+
if (!ref) return;
|
|
1516
|
+
if (projectKey(ref) === scope2.key) return;
|
|
1517
|
+
const error = new Error(
|
|
1518
|
+
tr(
|
|
1519
|
+
`\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}`,
|
|
1520
|
+
`review ${ref.project}#${ref.number} belongs to project ${projectKey(ref)}, but this session is scoped to ${scope2.key}`
|
|
1521
|
+
)
|
|
1522
|
+
);
|
|
1523
|
+
error.hint = tr(
|
|
1524
|
+
"\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.",
|
|
1525
|
+
"Open a separate session in that repository. Cross-project access will only be available through an explicit feature."
|
|
1526
|
+
);
|
|
1527
|
+
throw error;
|
|
1528
|
+
}
|
|
1529
|
+
var init_scope = __esm({
|
|
1530
|
+
"src/mcp/scope.ts"() {
|
|
1531
|
+
"use strict";
|
|
1532
|
+
init_config();
|
|
1533
|
+
init_paths();
|
|
1534
|
+
init_projects();
|
|
1535
|
+
init_refs();
|
|
1536
|
+
init_refs();
|
|
1537
|
+
init_locale();
|
|
1538
|
+
init_provider();
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
|
|
826
1542
|
// src/mcp/main.ts
|
|
827
1543
|
var main_exports = {};
|
|
828
1544
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -832,6 +1548,48 @@ async function client() {
|
|
|
832
1548
|
if (!clientPromise) clientPromise = ensureDaemon().then((result) => result.client);
|
|
833
1549
|
return clientPromise;
|
|
834
1550
|
}
|
|
1551
|
+
async function scope() {
|
|
1552
|
+
if (!scopePromise) {
|
|
1553
|
+
scopePromise = (async () => {
|
|
1554
|
+
const base = await resolveScope(defaultRoot);
|
|
1555
|
+
if (!featureId) return base;
|
|
1556
|
+
const { feature: feature2 } = await call("features.get", { feature: featureId });
|
|
1557
|
+
if (!feature2.members.some((member) => member.review.projectKey === base.key)) {
|
|
1558
|
+
const error = new Error(
|
|
1559
|
+
tr(
|
|
1560
|
+
`\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}`,
|
|
1561
|
+
`the current project ${base.key} is not a member of feature ${feature2.id}`
|
|
1562
|
+
)
|
|
1563
|
+
);
|
|
1564
|
+
error.hint = tr(
|
|
1565
|
+
"\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.",
|
|
1566
|
+
"Start the feature session from a repository that is part of the feature."
|
|
1567
|
+
);
|
|
1568
|
+
throw error;
|
|
1569
|
+
}
|
|
1570
|
+
return {
|
|
1571
|
+
...base,
|
|
1572
|
+
feature: { id: feature2.id, title: feature2.title, reviewIds: feature2.members.map((member) => member.review.id) }
|
|
1573
|
+
};
|
|
1574
|
+
})();
|
|
1575
|
+
}
|
|
1576
|
+
return scopePromise;
|
|
1577
|
+
}
|
|
1578
|
+
async function refreshFeatureScope(current2) {
|
|
1579
|
+
if (!current2.feature) return;
|
|
1580
|
+
const { feature: feature2 } = await call("features.get", {
|
|
1581
|
+
feature: current2.feature.id
|
|
1582
|
+
});
|
|
1583
|
+
if (!feature2.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1584
|
+
throw new Error(`the current project ${current2.key} is no longer a member of feature ${current2.feature.id}`);
|
|
1585
|
+
}
|
|
1586
|
+
current2.feature.reviewIds = feature2.members.map((member) => member.review.id);
|
|
1587
|
+
}
|
|
1588
|
+
async function scopedReview(review) {
|
|
1589
|
+
const current2 = await scope();
|
|
1590
|
+
await refreshFeatureScope(current2);
|
|
1591
|
+
assertReviewInScope(review, current2);
|
|
1592
|
+
}
|
|
835
1593
|
async function call(method, params = {}) {
|
|
836
1594
|
const current2 = await client();
|
|
837
1595
|
try {
|
|
@@ -878,33 +1636,66 @@ async function main() {
|
|
|
878
1636
|
process.stderr.write(`revdeck MCP ${VERSION} ${tr("\u0433\u043E\u0442\u043E\u0432", "ready")} (root: ${defaultRoot})
|
|
879
1637
|
`);
|
|
880
1638
|
}
|
|
881
|
-
var server, defaultRoot, clientPromise,
|
|
1639
|
+
var server, defaultRoot, featureId, clientPromise, scopePromise, reviewSchema;
|
|
882
1640
|
var init_main = __esm({
|
|
883
1641
|
"src/mcp/main.ts"() {
|
|
884
1642
|
"use strict";
|
|
885
1643
|
init_client();
|
|
886
1644
|
init_context();
|
|
887
1645
|
init_redact();
|
|
1646
|
+
init_paths();
|
|
888
1647
|
init_version();
|
|
889
1648
|
init_locale();
|
|
1649
|
+
init_scope();
|
|
1650
|
+
init_refs();
|
|
890
1651
|
setLocale(detectLocale());
|
|
891
1652
|
server = new McpServer({ name: "revdeck", version: VERSION });
|
|
892
|
-
defaultRoot = process.env.REVDECK_ROOT ?? process.cwd();
|
|
1653
|
+
defaultRoot = findRepoRoot(process.env.REVDECK_ROOT ?? process.cwd());
|
|
1654
|
+
featureId = process.env.REVDECK_FEATURE?.trim() || null;
|
|
893
1655
|
clientPromise = null;
|
|
894
|
-
|
|
895
|
-
|
|
1656
|
+
scopePromise = null;
|
|
1657
|
+
reviewSchema = z2.string().min(1).describe("Review: id (gitlab:host/project!42) or MR/PR URL; a bare number is accepted only in a project session");
|
|
896
1658
|
server.registerTool(
|
|
897
1659
|
"revdeck_status",
|
|
898
1660
|
{
|
|
899
1661
|
title: "revdeck status",
|
|
900
|
-
description: "Check that the daemon and provider are available, and list open reviews. Start here if you do not know a review id.",
|
|
1662
|
+
description: "Check that the daemon and provider are available, and list open reviews in the repository project this server is scoped to. Start here if you do not know a review id.",
|
|
901
1663
|
inputSchema: {}
|
|
902
1664
|
},
|
|
903
1665
|
async () => {
|
|
904
1666
|
try {
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
|
|
1667
|
+
const current2 = await scope();
|
|
1668
|
+
if (current2.feature) {
|
|
1669
|
+
const { feature: feature2 } = await call("features.get", { feature: current2.feature.id });
|
|
1670
|
+
if (!feature2.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1671
|
+
throw new Error(`the current project ${current2.key} is no longer a member of feature ${current2.feature.id}`);
|
|
1672
|
+
}
|
|
1673
|
+
const lines2 = feature2.members.map(
|
|
1674
|
+
(member) => `- ${member.review.id} \u2014 #${member.review.number} ${member.review.title} (${member.review.project}${member.role ? `, ${member.role}` : ""})`
|
|
1675
|
+
);
|
|
1676
|
+
return ok(
|
|
1677
|
+
[`revdeck daemon ${VERSION} is available.`, `Feature: ${feature2.title} (${feature2.id})`, ...lines2].join("\n"),
|
|
1678
|
+
{ feature: feature2.id, reviews: feature2.members.map((member) => member.review) }
|
|
1679
|
+
);
|
|
1680
|
+
}
|
|
1681
|
+
const { reviews } = await call(
|
|
1682
|
+
"reviews.list",
|
|
1683
|
+
{ project: current2.key }
|
|
1684
|
+
);
|
|
1685
|
+
const { features } = await call("features.list", { project: current2.key });
|
|
1686
|
+
const lines = reviews.length ? reviews.map((item) => `- ${item.id} \u2014 #${item.number} ${item.title} (${item.author})`) : ["No open reviews in this project."];
|
|
1687
|
+
const featureLines = features.length ? ["", "Features:", ...features.map((feature2) => `- ${feature2.id} \u2014 ${feature2.title} (${feature2.reviews} reviews)`)].join("\n") : "";
|
|
1688
|
+
return ok(
|
|
1689
|
+
[
|
|
1690
|
+
`revdeck daemon ${VERSION} is available.`,
|
|
1691
|
+
`Project: ${current2.key}`,
|
|
1692
|
+
...lines,
|
|
1693
|
+
featureLines,
|
|
1694
|
+
"",
|
|
1695
|
+
"Open one with revdeck_open and a number or URL."
|
|
1696
|
+
].join("\n"),
|
|
1697
|
+
{ project: current2.key, reviews, features }
|
|
1698
|
+
);
|
|
908
1699
|
} catch (error) {
|
|
909
1700
|
return failure(error);
|
|
910
1701
|
}
|
|
@@ -914,22 +1705,35 @@ var init_main = __esm({
|
|
|
914
1705
|
"revdeck_list",
|
|
915
1706
|
{
|
|
916
1707
|
title: "Review list",
|
|
917
|
-
description: "List reviews. scope=tracked \u2014 already opened locally; open/mine/reviewing query the platform
|
|
1708
|
+
description: "List reviews in the current repository project. scope=tracked \u2014 already opened locally; open/mine/reviewing query the platform for this project.",
|
|
918
1709
|
inputSchema: {
|
|
919
1710
|
scope: z2.enum(["tracked", "open", "mine", "reviewing"]).optional().describe("Defaults to tracked; open/mine/reviewing require platform access"),
|
|
920
|
-
limit: z2.number().int().positive().max(100).optional()
|
|
921
|
-
root: rootSchema
|
|
1711
|
+
limit: z2.number().int().positive().max(100).optional()
|
|
922
1712
|
}
|
|
923
1713
|
},
|
|
924
|
-
async ({ scope, limit
|
|
1714
|
+
async ({ scope: listScope, limit }) => {
|
|
925
1715
|
try {
|
|
926
|
-
|
|
927
|
-
|
|
1716
|
+
const current2 = await scope();
|
|
1717
|
+
if (current2.feature) {
|
|
1718
|
+
if (listScope && listScope !== "tracked") {
|
|
1719
|
+
return failure(new Error("remote review list is not available in a feature session"));
|
|
1720
|
+
}
|
|
1721
|
+
const { feature: feature2 } = await call("features.get", {
|
|
1722
|
+
feature: current2.feature.id
|
|
1723
|
+
});
|
|
1724
|
+
if (!feature2.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1725
|
+
throw new Error(`the current project ${current2.key} is no longer a member of feature ${current2.feature.id}`);
|
|
1726
|
+
}
|
|
1727
|
+
const reviews = feature2.members.map((member) => member.review);
|
|
1728
|
+
return ok(JSON.stringify(reviews, null, 2), { reviews });
|
|
1729
|
+
}
|
|
1730
|
+
if (!listScope || listScope === "tracked") {
|
|
1731
|
+
const { reviews } = await call("reviews.list", { project: current2.key });
|
|
928
1732
|
return ok(JSON.stringify(reviews, null, 2), { reviews });
|
|
929
1733
|
}
|
|
930
1734
|
const result = await call(
|
|
931
1735
|
"reviews.remoteList",
|
|
932
|
-
{ root: root
|
|
1736
|
+
{ root: current2.root, scope: listScope, limit: limit ?? 50 }
|
|
933
1737
|
);
|
|
934
1738
|
const text = result.items.map((item) => `#${item.ref.number} ${item.title} \xB7 ${item.author} \xB7 ${item.updatedAt}`).join("\n") || "Empty.";
|
|
935
1739
|
return ok(`${result.platform}:${result.project}
|
|
@@ -943,28 +1747,31 @@ ${text}`, result);
|
|
|
943
1747
|
"revdeck_open",
|
|
944
1748
|
{
|
|
945
1749
|
title: "Open review",
|
|
946
|
-
description: "Load one or more MR/PR by number or URL: description, diff, threads. Returns the id used by other tools.",
|
|
1750
|
+
description: "Load one or more MR/PR in the current repository project by number or URL: description, diff, threads. Returns the id used by other tools. A review from another project is rejected.",
|
|
947
1751
|
inputSchema: {
|
|
948
|
-
input: z2.union([z2.string().min(1), z2.array(z2.string().min(1)).min(1).max(8)]).describe("Number, URL, project!N, owner/repo#N, or an array of them")
|
|
949
|
-
root: rootSchema,
|
|
950
|
-
platform: z2.enum(["gitlab", "github"]).optional(),
|
|
951
|
-
project: z2.string().optional(),
|
|
952
|
-
host: z2.string().optional(),
|
|
953
|
-
branch: z2.string().optional()
|
|
1752
|
+
input: z2.union([z2.string().min(1), z2.array(z2.string().min(1)).min(1).max(8)]).describe("Number, URL, project!N, owner/repo#N, or an array of them; must belong to the current project")
|
|
954
1753
|
}
|
|
955
1754
|
},
|
|
956
|
-
async ({ input
|
|
1755
|
+
async ({ input }) => {
|
|
957
1756
|
try {
|
|
1757
|
+
const current2 = await scope();
|
|
1758
|
+
await refreshFeatureScope(current2);
|
|
958
1759
|
const inputs = Array.isArray(input) ? input : [input];
|
|
1760
|
+
for (const value of inputs) assertReviewInScope(value, current2);
|
|
959
1761
|
const reviews = [];
|
|
960
1762
|
for (const value of inputs) {
|
|
1763
|
+
if (current2.feature) {
|
|
1764
|
+
const ref = reviewRefFromInput(value);
|
|
1765
|
+
if (!ref) throw new Error("feature session requires a full review id or URL");
|
|
1766
|
+
const id = featureReviewId(ref, current2);
|
|
1767
|
+
if (!id) throw new Error(`review ${reviewId(ref)} is not a member of feature ${current2.feature.id}`);
|
|
1768
|
+
const result2 = await call("reviews.get", { review: id });
|
|
1769
|
+
reviews.push(result2.review);
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
961
1772
|
const result = await call("reviews.open", {
|
|
962
|
-
root: root
|
|
963
|
-
input: value
|
|
964
|
-
...platform ? { platform } : {},
|
|
965
|
-
...project ? { project } : {},
|
|
966
|
-
...host ? { host } : {},
|
|
967
|
-
...branch ? { branch } : {}
|
|
1773
|
+
root: current2.root,
|
|
1774
|
+
input: value
|
|
968
1775
|
});
|
|
969
1776
|
reviews.push(result.review);
|
|
970
1777
|
}
|
|
@@ -977,6 +1784,106 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
977
1784
|
}
|
|
978
1785
|
}
|
|
979
1786
|
);
|
|
1787
|
+
server.registerTool(
|
|
1788
|
+
"revdeck_feature",
|
|
1789
|
+
{
|
|
1790
|
+
title: "Feature context",
|
|
1791
|
+
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.",
|
|
1792
|
+
inputSchema: {
|
|
1793
|
+
action: z2.enum(["list", "get", "context", "notes"]).default("list"),
|
|
1794
|
+
feature: z2.string().optional().describe("Feature id; optional in a feature session"),
|
|
1795
|
+
max_bytes: z2.number().int().positive().max(5e5).optional()
|
|
1796
|
+
}
|
|
1797
|
+
},
|
|
1798
|
+
async ({ action, feature: requested, max_bytes }) => {
|
|
1799
|
+
try {
|
|
1800
|
+
const current2 = await scope();
|
|
1801
|
+
if (action === "list") {
|
|
1802
|
+
if (current2.feature) {
|
|
1803
|
+
const { feature: feature3 } = await call("features.get", { feature: current2.feature.id });
|
|
1804
|
+
if (!feature3.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1805
|
+
throw new Error(`the current project ${current2.key} is no longer a member of feature ${current2.feature.id}`);
|
|
1806
|
+
}
|
|
1807
|
+
return ok(JSON.stringify(feature3, null, 2), { feature: feature3 });
|
|
1808
|
+
}
|
|
1809
|
+
const { features } = await call("features.list", { project: current2.key });
|
|
1810
|
+
return ok(JSON.stringify(features, null, 2), { features });
|
|
1811
|
+
}
|
|
1812
|
+
const id = current2.feature?.id ?? requested;
|
|
1813
|
+
if (!id) throw new Error("feature id is required");
|
|
1814
|
+
if (current2.feature && id !== current2.feature.id) throw new Error(`this session is scoped to feature ${current2.feature.id}`);
|
|
1815
|
+
const { feature: feature2 } = await call("features.get", { feature: id });
|
|
1816
|
+
if (!feature2.members.some((member) => member.review.projectKey === current2.key)) {
|
|
1817
|
+
throw new Error(`feature ${id} does not include project ${current2.key}`);
|
|
1818
|
+
}
|
|
1819
|
+
if (action === "get") return ok(JSON.stringify(feature2, null, 2), { feature: feature2 });
|
|
1820
|
+
if (action === "notes") return ok(JSON.stringify(feature2.notes, null, 2), { notes: feature2.notes });
|
|
1821
|
+
const result = await call("features.context", {
|
|
1822
|
+
feature: id,
|
|
1823
|
+
...max_bytes ? { maxBytes: max_bytes } : {}
|
|
1824
|
+
});
|
|
1825
|
+
return ok(result.markdown, { feature: result.feature, markdown: result.markdown });
|
|
1826
|
+
} catch (error) {
|
|
1827
|
+
return failure(error);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
);
|
|
1831
|
+
server.registerTool(
|
|
1832
|
+
"revdeck_feature_note",
|
|
1833
|
+
{
|
|
1834
|
+
title: "Feature note",
|
|
1835
|
+
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.",
|
|
1836
|
+
inputSchema: {
|
|
1837
|
+
action: z2.enum(["add", "update", "delete"]).default("add"),
|
|
1838
|
+
note_id: z2.string().optional().describe("Note id for update/delete"),
|
|
1839
|
+
kind: z2.enum(["note", "finding"]).optional(),
|
|
1840
|
+
level: z2.enum(["blocker", "major", "minor", "question"]).optional(),
|
|
1841
|
+
title: z2.string().min(1).max(300).optional(),
|
|
1842
|
+
body: z2.string().max(2e4).optional()
|
|
1843
|
+
}
|
|
1844
|
+
},
|
|
1845
|
+
async ({ action, note_id, kind, level, title, body }) => {
|
|
1846
|
+
try {
|
|
1847
|
+
const current2 = await scope();
|
|
1848
|
+
if (!current2.feature) throw new Error("feature notes can only be written in a feature session (REVDECK_FEATURE)");
|
|
1849
|
+
await refreshFeatureScope(current2);
|
|
1850
|
+
if (action === "add") {
|
|
1851
|
+
if (!title) throw new Error("title is required");
|
|
1852
|
+
const { note: note2 } = await call("features.addNote", {
|
|
1853
|
+
feature: current2.feature.id,
|
|
1854
|
+
kind: kind ?? "note",
|
|
1855
|
+
...level ? { level } : {},
|
|
1856
|
+
title,
|
|
1857
|
+
body: body ?? "",
|
|
1858
|
+
author: "agent"
|
|
1859
|
+
});
|
|
1860
|
+
return ok(`Feature note saved: ${note2.id}. It is not published.`, { note: note2 });
|
|
1861
|
+
}
|
|
1862
|
+
if (!note_id) throw new Error("note_id is required");
|
|
1863
|
+
const { feature: feature2 } = await call("features.get", { feature: current2.feature.id });
|
|
1864
|
+
const existing = feature2.notes.find((note2) => note2.id === note_id);
|
|
1865
|
+
if (!existing) throw new Error(`feature note ${note_id} not found`);
|
|
1866
|
+
if (existing.author !== "agent") {
|
|
1867
|
+
throw new Error("only feature notes authored by an agent can be changed; ask the human to edit or delete their note");
|
|
1868
|
+
}
|
|
1869
|
+
if (action === "delete") {
|
|
1870
|
+
await call("features.deleteNote", { feature: current2.feature.id, note: note_id });
|
|
1871
|
+
return ok("Feature note deleted.");
|
|
1872
|
+
}
|
|
1873
|
+
const { note } = await call("features.updateNote", {
|
|
1874
|
+
feature: current2.feature.id,
|
|
1875
|
+
note: note_id,
|
|
1876
|
+
...kind ? { kind } : {},
|
|
1877
|
+
...level ? { level } : {},
|
|
1878
|
+
...title ? { title } : {},
|
|
1879
|
+
...body !== void 0 ? { body } : {}
|
|
1880
|
+
});
|
|
1881
|
+
return ok("Feature note updated. It is not published.", { note });
|
|
1882
|
+
} catch (error) {
|
|
1883
|
+
return failure(error);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
);
|
|
980
1887
|
server.registerTool(
|
|
981
1888
|
"revdeck_context",
|
|
982
1889
|
{
|
|
@@ -988,12 +1895,12 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
988
1895
|
file: z2.string().optional().describe("Append the diff of one file"),
|
|
989
1896
|
max_bytes: z2.number().int().positive().max(5e5).optional(),
|
|
990
1897
|
role: z2.string().max(64).optional().describe("Role for an independent shard reviewer"),
|
|
991
|
-
shard: z2.string().regex(/^\d+\/\d+$/).optional().describe("Shard as i/N, for example 1/3")
|
|
992
|
-
root: rootSchema
|
|
1898
|
+
shard: z2.string().regex(/^\d+\/\d+$/).optional().describe("Shard as i/N, for example 1/3")
|
|
993
1899
|
}
|
|
994
1900
|
},
|
|
995
1901
|
async ({ review, refresh, file, max_bytes, role, shard }) => {
|
|
996
1902
|
try {
|
|
1903
|
+
await scopedReview(review);
|
|
997
1904
|
const { review: view } = await call("reviews.get", { review, refresh: refresh === true });
|
|
998
1905
|
const { rules: rules2 } = await call("rules.get", { review });
|
|
999
1906
|
const parsedShard = shard ? (() => {
|
|
@@ -1045,6 +1952,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1045
1952
|
},
|
|
1046
1953
|
async ({ review }) => {
|
|
1047
1954
|
try {
|
|
1955
|
+
await scopedReview(review);
|
|
1048
1956
|
const { review: view } = await call("reviews.get", { review });
|
|
1049
1957
|
return ok(JSON.stringify(view.threads, null, 2), { threads: view.threads });
|
|
1050
1958
|
} catch (error) {
|
|
@@ -1065,6 +1973,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1065
1973
|
},
|
|
1066
1974
|
async ({ review, file, max_lines }) => {
|
|
1067
1975
|
try {
|
|
1976
|
+
await scopedReview(review);
|
|
1068
1977
|
if (!file) {
|
|
1069
1978
|
const { review: view } = await call("reviews.get", { review });
|
|
1070
1979
|
const text = view.files.map((item) => `${item.status} +${item.additions} -${item.deletions} ${item.path}`).join("\n");
|
|
@@ -1106,6 +2015,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1106
2015
|
},
|
|
1107
2016
|
async ({ review, thread_id, body, resolve }) => {
|
|
1108
2017
|
try {
|
|
2018
|
+
await scopedReview(review);
|
|
1109
2019
|
const { draft } = await call("drafts.put", {
|
|
1110
2020
|
review,
|
|
1111
2021
|
threadId: thread_id,
|
|
@@ -1141,6 +2051,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1141
2051
|
},
|
|
1142
2052
|
async ({ review, findings: findings2 }) => {
|
|
1143
2053
|
try {
|
|
2054
|
+
await scopedReview(review);
|
|
1144
2055
|
const { findings: saved } = await call("findings.put", { review, findings: findings2 });
|
|
1145
2056
|
return ok(`Findings saved: ${saved.length}.`, { findings: saved });
|
|
1146
2057
|
} catch (error) {
|
|
@@ -1162,11 +2073,12 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1162
2073
|
focus: z2.array(z2.string()).optional()
|
|
1163
2074
|
}
|
|
1164
2075
|
},
|
|
1165
|
-
async ({ review, title, scope, summary: summary2, changes, focus }) => {
|
|
2076
|
+
async ({ review, title, scope: scope2, summary: summary2, changes, focus }) => {
|
|
1166
2077
|
try {
|
|
2078
|
+
await scopedReview(review);
|
|
1167
2079
|
const { summary: saved } = await call("summary.put", {
|
|
1168
2080
|
review,
|
|
1169
|
-
summary: { title: title ?? "", scope:
|
|
2081
|
+
summary: { title: title ?? "", scope: scope2 ?? "", summary: summary2 ?? "", changes: changes ?? [], focus: focus ?? [] }
|
|
1170
2082
|
});
|
|
1171
2083
|
return ok("Summary saved.", { summary: saved });
|
|
1172
2084
|
} catch (error) {
|
|
@@ -1188,6 +2100,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1188
2100
|
},
|
|
1189
2101
|
async ({ review, action, note_id, text }) => {
|
|
1190
2102
|
try {
|
|
2103
|
+
await scopedReview(review);
|
|
1191
2104
|
if (action === "reply") {
|
|
1192
2105
|
if (!note_id || !text) return ok("reply requires note_id and text.");
|
|
1193
2106
|
const { note } = await call("notes.update", { review, noteId: note_id, patch: { agentReply: text } });
|
|
@@ -1209,6 +2122,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1209
2122
|
},
|
|
1210
2123
|
async ({ review }) => {
|
|
1211
2124
|
try {
|
|
2125
|
+
await scopedReview(review);
|
|
1212
2126
|
const { rules: rules2 } = await call("rules.get", { review });
|
|
1213
2127
|
return ok(rules2.markdown, rules2);
|
|
1214
2128
|
} catch (error) {
|
|
@@ -1229,6 +2143,7 @@ Next: revdeck_context(review="${review.id}").`).join("\n\n");
|
|
|
1229
2143
|
},
|
|
1230
2144
|
async ({ review, kind, ids }) => {
|
|
1231
2145
|
try {
|
|
2146
|
+
await scopedReview(review);
|
|
1232
2147
|
const { review: view } = await call("reviews.get", { review });
|
|
1233
2148
|
const selected = ids ?? defaultSelection(view, kind);
|
|
1234
2149
|
const { preview } = await call("publish.preview", { review, kind, ids: selected });
|
|
@@ -1253,6 +2168,7 @@ ${preview.warnings.join("\n")}` : ""), { preview });
|
|
|
1253
2168
|
},
|
|
1254
2169
|
async ({ review, approval_id }) => {
|
|
1255
2170
|
try {
|
|
2171
|
+
await scopedReview(review);
|
|
1256
2172
|
const { result } = await call("publish.commit", {
|
|
1257
2173
|
review,
|
|
1258
2174
|
approvalId: approval_id
|
|
@@ -1305,6 +2221,46 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
|
|
|
1305
2221
|
]
|
|
1306
2222
|
})
|
|
1307
2223
|
);
|
|
2224
|
+
server.registerPrompt(
|
|
2225
|
+
"review-feature",
|
|
2226
|
+
{
|
|
2227
|
+
title: "Review a cross-project feature",
|
|
2228
|
+
description: "A full feature pass: brief and contract, every member review, cross-project integration checks.",
|
|
2229
|
+
argsSchema: { feature: z2.string().describe("Feature id, for example ft-a1b2c3") }
|
|
2230
|
+
},
|
|
2231
|
+
({ feature: feature2 }) => ({
|
|
2232
|
+
messages: [
|
|
2233
|
+
{
|
|
2234
|
+
role: "user",
|
|
2235
|
+
content: {
|
|
2236
|
+
type: "text",
|
|
2237
|
+
text: [
|
|
2238
|
+
tr(
|
|
2239
|
+
[
|
|
2240
|
+
`\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.`,
|
|
2241
|
+
"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.",
|
|
2242
|
+
"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.",
|
|
2243
|
+
"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.",
|
|
2244
|
+
"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.",
|
|
2245
|
+
"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.",
|
|
2246
|
+
"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."
|
|
2247
|
+
].join("\n"),
|
|
2248
|
+
[
|
|
2249
|
+
`Review feature ${feature2} with revdeck.`,
|
|
2250
|
+
"1. Call revdeck_feature action=context: read the brief, contract and rollout order.",
|
|
2251
|
+
"2. For every member MR read its own revdeck_context and its own project rules.",
|
|
2252
|
+
"3. Do a separate integration pass: API contract, compatibility, auth, data, retries, rollout order.",
|
|
2253
|
+
"4. Never mix project rules. Put each finding on its owning review and reference the other MR in the text.",
|
|
2254
|
+
"5. If the contract or context is missing, ask; do not invent it.",
|
|
2255
|
+
"6. Publishing is done only by a human, per review."
|
|
2256
|
+
].join("\n")
|
|
2257
|
+
)
|
|
2258
|
+
].join("\n")
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
]
|
|
2262
|
+
})
|
|
2263
|
+
);
|
|
1308
2264
|
server.registerPrompt(
|
|
1309
2265
|
"close-feedback",
|
|
1310
2266
|
{
|
|
@@ -1334,292 +2290,71 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
|
|
|
1334
2290
|
"2. Check the code for each thread and classify it: fix, reply, disagree, unclear, out of scope.",
|
|
1335
2291
|
"3. Draft replies with revdeck_draft_reply; show code changes to the human.",
|
|
1336
2292
|
"4. Use revdeck_notes to answer the human comments on lines.",
|
|
1337
|
-
"Publishing is done only by a human after confirmation."
|
|
1338
|
-
].join("\n")
|
|
1339
|
-
)
|
|
1340
|
-
].join("\n")
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
]
|
|
1344
|
-
})
|
|
1345
|
-
);
|
|
1346
|
-
main().catch((error) => {
|
|
1347
|
-
process.stderr.write(`revdeck MCP: ${redact(error instanceof Error ? error.message : error)}
|
|
1348
|
-
`);
|
|
1349
|
-
process.exit(1);
|
|
1350
|
-
});
|
|
1351
|
-
}
|
|
1352
|
-
});
|
|
1353
|
-
|
|
1354
|
-
// src/cli/main.ts
|
|
1355
|
-
init_paths();
|
|
1356
|
-
import { readFile as readFile7, stat } from "node:fs/promises";
|
|
1357
|
-
import { readFileSync } from "node:fs";
|
|
1358
|
-
import { parseArgs } from "node:util";
|
|
1359
|
-
import path10 from "node:path";
|
|
1360
|
-
|
|
1361
|
-
// src/core/config.ts
|
|
1362
|
-
init_paths();
|
|
1363
|
-
import { z } from "zod";
|
|
1364
|
-
|
|
1365
|
-
// src/core/errors.ts
|
|
1366
|
-
var MrReviewError = class extends Error {
|
|
1367
|
-
code;
|
|
1368
|
-
hint;
|
|
1369
|
-
constructor(message, code = "REVDECK_ERROR", hint) {
|
|
1370
|
-
super(message);
|
|
1371
|
-
this.name = "MrReviewError";
|
|
1372
|
-
this.code = code;
|
|
1373
|
-
this.hint = hint;
|
|
1374
|
-
}
|
|
1375
|
-
};
|
|
1376
|
-
var ConfigError = class extends MrReviewError {
|
|
1377
|
-
constructor(message, hint) {
|
|
1378
|
-
super(message, "CONFIG", hint);
|
|
1379
|
-
this.name = "ConfigError";
|
|
1380
|
-
}
|
|
1381
|
-
};
|
|
1382
|
-
|
|
1383
|
-
// src/core/config.ts
|
|
1384
|
-
import { parse as parseYaml } from "yaml";
|
|
1385
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
1386
|
-
import path2 from "node:path";
|
|
1387
|
-
|
|
1388
|
-
// src/core/glob.ts
|
|
1389
|
-
function globToRegExp(glob) {
|
|
1390
|
-
let source = "";
|
|
1391
|
-
let index = 0;
|
|
1392
|
-
const pattern = glob.replace(/^\.\//, "").replace(/^\/+/, "");
|
|
1393
|
-
while (index < pattern.length) {
|
|
1394
|
-
const char = pattern[index];
|
|
1395
|
-
if (char === "*") {
|
|
1396
|
-
if (pattern[index + 1] === "*") {
|
|
1397
|
-
if (pattern[index + 2] === "/") {
|
|
1398
|
-
source += "(?:[^/]+/)*";
|
|
1399
|
-
index += 3;
|
|
1400
|
-
} else {
|
|
1401
|
-
source += ".*";
|
|
1402
|
-
index += 2;
|
|
1403
|
-
}
|
|
1404
|
-
} else {
|
|
1405
|
-
source += "[^/]*";
|
|
1406
|
-
index += 1;
|
|
1407
|
-
}
|
|
1408
|
-
continue;
|
|
1409
|
-
}
|
|
1410
|
-
if (char === "?") {
|
|
1411
|
-
source += "[^/]";
|
|
1412
|
-
index += 1;
|
|
1413
|
-
continue;
|
|
1414
|
-
}
|
|
1415
|
-
if (char === "{") {
|
|
1416
|
-
const end = pattern.indexOf("}", index);
|
|
1417
|
-
if (end > index) {
|
|
1418
|
-
const options = pattern.slice(index + 1, end).split(",").map((item) => escapeRegExp(item.trim()));
|
|
1419
|
-
source += `(?:${options.join("|")})`;
|
|
1420
|
-
index = end + 1;
|
|
1421
|
-
continue;
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
source += escapeRegExp(char);
|
|
1425
|
-
index += 1;
|
|
1426
|
-
}
|
|
1427
|
-
return new RegExp(`^${source}$`);
|
|
1428
|
-
}
|
|
1429
|
-
function escapeRegExp(value) {
|
|
1430
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1431
|
-
}
|
|
1432
|
-
function classifyFile(path11) {
|
|
1433
|
-
const lower = path11.toLowerCase();
|
|
1434
|
-
if (/(^|\/)(node_modules|dist|build|coverage|vendor)\//.test(lower)) return "generated";
|
|
1435
|
-
if (/\.(md|mdx|rst|txt|adoc)$/.test(lower) || /(^|\/)(docs?|adr)\//.test(lower)) return "docs";
|
|
1436
|
-
if (/(^|\/)(__tests__|tests?|spec|e2e)\//.test(lower) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /_test\.go$/.test(lower)) return "test";
|
|
1437
|
-
if (/\.(css|scss|sass|less|styl)$/.test(lower)) return "style";
|
|
1438
|
-
if (/(^|\/)(package(-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|tsconfig[^/]*\.json|[^/]*\.config\.[cm]?[jt]s|\.eslintrc[^/]*|\.prettierrc[^/]*|Dockerfile|Makefile|\.github\/workflows\/|\.gitlab-ci\.yml)/.test(lower)) return "config";
|
|
1439
|
-
if (/\.(generated|g)\.[cm]?[jt]s$|\.d\.ts$|(^|\/)generated\//.test(lower)) return "generated";
|
|
1440
|
-
if (/\.(ts|tsx|js|jsx|mjs|cjs|vue|svelte|py|go|rs|java|kt|rb|php|cs|c|cpp|h|hpp|swift|scala|ex|exs)$/.test(lower)) return "app";
|
|
1441
|
-
return "other";
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
// src/core/config.ts
|
|
1445
|
-
init_locale();
|
|
1446
|
-
init_review_roles();
|
|
1447
|
-
var matchSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
1448
|
-
var customRoleSchema = z.object({
|
|
1449
|
-
title: z.string().min(1).max(120),
|
|
1450
|
-
description: z.string().min(1).max(2e3),
|
|
1451
|
-
criteria: z.array(z.string().min(1).max(20)).max(20).default([]),
|
|
1452
|
-
focus: z.string().max(2e3).optional(),
|
|
1453
|
-
instructions: z.string().max(8e3).optional()
|
|
1454
|
-
});
|
|
1455
|
-
var reviewConfigSchema = z.object({
|
|
1456
|
-
version: z.literal(1).default(1),
|
|
1457
|
-
provider: z.object({
|
|
1458
|
-
/** auto — по git remote; иначе явная платформа. */
|
|
1459
|
-
type: z.enum(["auto", "gitlab", "github"]).default("auto"),
|
|
1460
|
-
host: z.string().min(1).optional(),
|
|
1461
|
-
/** GitLab: group/project. GitHub: owner/repo. */
|
|
1462
|
-
project: z.string().min(1).optional(),
|
|
1463
|
-
/** База для локального diff, когда ревью идёт по ветке. */
|
|
1464
|
-
base: z.string().min(1).optional()
|
|
1465
|
-
}).prefault({}),
|
|
1466
|
-
output: z.object({
|
|
1467
|
-
language: z.enum(["auto", "ru", "en"]).default("auto")
|
|
1468
|
-
}).prefault({}),
|
|
1469
|
-
review: z.object({
|
|
1470
|
-
/** Сколько независимых ревьюеров запускать. */
|
|
1471
|
-
agents: z.number().int().min(1).max(8).default(3),
|
|
1472
|
-
/** Роли агентов; встроенные id или ключи customRoles. */
|
|
1473
|
-
roles: z.array(z.string().min(1).max(64)).min(1).max(10).default([...DEFAULT_REVIEW_ROLES]),
|
|
1474
|
-
/** Пользовательские роли с описанием и инструкциями. */
|
|
1475
|
-
customRoles: z.record(z.string().min(1).max(64), customRoleSchema).default({}),
|
|
1476
|
-
/** Явные группы изменений; остальные группируются по типу и модулю. */
|
|
1477
|
-
groups: z.array(
|
|
1478
|
-
z.object({
|
|
1479
|
-
id: z.string().min(1).max(64),
|
|
1480
|
-
title: z.string().min(1).max(120),
|
|
1481
|
-
match: matchSchema
|
|
1482
|
-
})
|
|
1483
|
-
).max(100).default([]),
|
|
1484
|
-
/** Опциональный скан секретов; по умолчанию выключен. */
|
|
1485
|
-
secrets: z.object({
|
|
1486
|
-
enabled: z.boolean().default(false),
|
|
1487
|
-
scan: z.enum(["diff", "files", "both"]).default("diff"),
|
|
1488
|
-
includeTests: z.boolean().default(false),
|
|
1489
|
-
/** Glob-пути или id правила (`rule:generic-secret`). */
|
|
1490
|
-
allowlist: z.array(z.string().min(1)).default([])
|
|
1491
|
-
}).prefault({}),
|
|
1492
|
-
/** История версий ревью (снимки по commit SHA). */
|
|
1493
|
-
history: z.object({
|
|
1494
|
-
enabled: z.boolean().default(false),
|
|
1495
|
-
keep: z.number().int().min(1).max(100).default(20)
|
|
1496
|
-
}).prefault({}),
|
|
1497
|
-
/** Запрет любых изменений: drafts, findings, публикация. */
|
|
1498
|
-
readOnly: z.boolean().default(false)
|
|
1499
|
-
}).prefault({}).superRefine((value, ctx) => {
|
|
1500
|
-
for (const key of Object.keys(value.customRoles)) {
|
|
1501
|
-
if (REVIEW_ROLE_IDS.includes(key)) {
|
|
1502
|
-
ctx.addIssue({ code: "custom", path: ["customRoles", key], message: `role ${key} is built in and cannot be overridden` });
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
for (const role of value.roles) {
|
|
1506
|
-
if (!REVIEW_ROLE_IDS.includes(role) && !(role in value.customRoles)) {
|
|
1507
|
-
ctx.addIssue({ code: "custom", path: ["roles"], message: `unknown role: ${role}` });
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
}),
|
|
1511
|
-
rules: z.object({
|
|
1512
|
-
/** Общие документы, если ни одна строка map не подошла. Пусто — автообнаружение. */
|
|
1513
|
-
sources: z.array(z.string().min(1)).default([]),
|
|
1514
|
-
/** Привязка путей к документам: match — glob, docs — пути с необязательной секцией `#…`. */
|
|
1515
|
-
map: z.array(
|
|
1516
|
-
z.object({
|
|
1517
|
-
match: matchSchema,
|
|
1518
|
-
docs: z.array(z.string().min(1)).min(1),
|
|
1519
|
-
note: z.string().optional()
|
|
1520
|
-
})
|
|
1521
|
-
).default([]),
|
|
1522
|
-
/** Пути, которые не ревьюятся (сгенерированный код и т.п.). */
|
|
1523
|
-
ignore: z.array(z.string().min(1)).default([]),
|
|
1524
|
-
/** 0 — без ограничения; иначе документ обрезается до этого размера. */
|
|
1525
|
-
maxDocumentBytes: z.number().int().nonnegative().default(0),
|
|
1526
|
-
/** 0 — без ограничения; иначе общий контекст правил обрезается. */
|
|
1527
|
-
maxTotalBytes: z.number().int().nonnegative().default(0)
|
|
1528
|
-
}).prefault({}),
|
|
1529
|
-
checks: z.array(
|
|
1530
|
-
z.object({
|
|
1531
|
-
id: z.string().min(1),
|
|
1532
|
-
name: z.string().optional(),
|
|
1533
|
-
/** argv без shell: первым идёт исполняемый файл. */
|
|
1534
|
-
argv: z.array(z.string()).min(1),
|
|
1535
|
-
/** Запускать, только если diff затронул эти glob-пути. */
|
|
1536
|
-
when: z.array(z.string()).default([]),
|
|
1537
|
-
consent: z.boolean().default(true),
|
|
1538
|
-
timeoutMs: z.number().int().positive().max(36e5).default(3e5)
|
|
1539
|
-
})
|
|
1540
|
-
).default([]),
|
|
1541
|
-
publish: z.object({
|
|
1542
|
-
requireApproval: z.boolean().default(true),
|
|
1543
|
-
maxComments: z.number().int().positive().max(200).default(50)
|
|
1544
|
-
}).prefault({})
|
|
1545
|
-
});
|
|
1546
|
-
var DISCOVERED_SOURCES = [
|
|
1547
|
-
"AGENTS.md",
|
|
1548
|
-
"CLAUDE.md",
|
|
1549
|
-
"CONTRIBUTING.md",
|
|
1550
|
-
"docs/ARCHITECTURE.md",
|
|
1551
|
-
"docs/Architecture.md",
|
|
1552
|
-
"docs/STYLEGUIDE.md",
|
|
1553
|
-
"docs/Styleguide.md",
|
|
1554
|
-
"docs/CONTRIBUTING.md"
|
|
1555
|
-
];
|
|
1556
|
-
function isRecord(value) {
|
|
1557
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1558
|
-
}
|
|
1559
|
-
function parseYamlData(text, source) {
|
|
1560
|
-
try {
|
|
1561
|
-
return parseYaml(text);
|
|
1562
|
-
} catch (error) {
|
|
1563
|
-
throw new ConfigError(tr(`${source}: \u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 YAML: ${error.message}`, `${source}: invalid YAML: ${error.message}`));
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
function mergeConfigData(base, local) {
|
|
1567
|
-
if (!isRecord(base) || !isRecord(local)) return local;
|
|
1568
|
-
const result = { ...base };
|
|
1569
|
-
for (const [key, value] of Object.entries(local)) {
|
|
1570
|
-
const current2 = result[key];
|
|
1571
|
-
result[key] = isRecord(current2) && isRecord(value) ? mergeConfigData(current2, value) : value;
|
|
1572
|
-
}
|
|
1573
|
-
return result;
|
|
1574
|
-
}
|
|
1575
|
-
async function loadConfig(root = findRepoRoot()) {
|
|
1576
|
-
const warnings = [];
|
|
1577
|
-
const file = findConfigFile(root);
|
|
1578
|
-
const localFile = findLocalConfigFile(root);
|
|
1579
|
-
const baseData = file ? parseYamlData(await readTextNoFollow(file), path2.relative(root, file) || file) : {};
|
|
1580
|
-
const localData = localFile ? parseYamlData(await readTextNoFollow(localFile), path2.relative(root, localFile) || localFile) : {};
|
|
1581
|
-
if (!file && !localFile) {
|
|
1582
|
-
warnings.push(tr("\u0444\u0430\u0439\u043B .revdeck.yml \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u043F\u0440\u0430\u0432\u0438\u043B\u0430 \u0432\u0437\u044F\u0442\u044B \u0438\u0437 \u0430\u0432\u0442\u043E\u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432", ".revdeck.yml not found: rules come from auto-discovered documents"));
|
|
2293
|
+
"Publishing is done only by a human after confirmation."
|
|
2294
|
+
].join("\n")
|
|
2295
|
+
)
|
|
2296
|
+
].join("\n")
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
]
|
|
2300
|
+
})
|
|
2301
|
+
);
|
|
2302
|
+
main().catch((error) => {
|
|
2303
|
+
process.stderr.write(`revdeck MCP: ${redact(error instanceof Error ? error.message : error)}
|
|
2304
|
+
`);
|
|
2305
|
+
process.exit(1);
|
|
2306
|
+
});
|
|
1583
2307
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
2308
|
+
});
|
|
2309
|
+
|
|
2310
|
+
// src/cli/main.ts
|
|
2311
|
+
init_paths();
|
|
2312
|
+
init_config();
|
|
2313
|
+
import { readFile as readFile7, stat as stat2 } from "node:fs/promises";
|
|
2314
|
+
import { readFileSync } from "node:fs";
|
|
2315
|
+
import { parseArgs } from "node:util";
|
|
2316
|
+
import path11 from "node:path";
|
|
2317
|
+
|
|
2318
|
+
// src/core/rules.ts
|
|
2319
|
+
init_config();
|
|
2320
|
+
import path5 from "node:path";
|
|
2321
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
2322
|
+
|
|
2323
|
+
// src/core/doc-policy.ts
|
|
2324
|
+
init_config();
|
|
2325
|
+
init_errors();
|
|
2326
|
+
init_git_files();
|
|
2327
|
+
init_locale();
|
|
2328
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
2329
|
+
import path4 from "node:path";
|
|
2330
|
+
var DOC_EXTENSION = /\.(md|mdx|rst|txt|adoc)$/i;
|
|
2331
|
+
var PROFILE_EXTENSION = /\.(md|mdx|rst|txt|adoc|ya?ml|json)$/i;
|
|
2332
|
+
var SECRET_PATH = /(^|\/)(\.env(\..*)?|\.npmrc|\.git(\/.*)?|\.revdeck\.local\.(ya?ml)|id_(rsa|ed25519|ecdsa)(\.pub)?|.*\.(pem|key|p12|pfx|jks|keystore|tfvars|tfstate))$/i;
|
|
2333
|
+
async function assertSafeDocument(root, relative, kind = "rules") {
|
|
2334
|
+
const clean = relative.split("#")[0];
|
|
2335
|
+
const resolved = assertConfigPath(root, clean);
|
|
2336
|
+
if (SECRET_PATH.test(clean)) {
|
|
2337
|
+
throw new ConfigError(tr(`${relative}: \u0441\u0435\u043A\u0440\u0435\u0442\u043D\u044B\u0439 \u0444\u0430\u0439\u043B \u043D\u0435\u043B\u044C\u0437\u044F \u0447\u0438\u0442\u0430\u0442\u044C \u043A\u0430\u043A \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442`, `${relative}: secret files cannot be read as documents`));
|
|
2338
|
+
}
|
|
2339
|
+
if (!(kind === "profile" ? PROFILE_EXTENSION : DOC_EXTENSION).test(clean)) {
|
|
2340
|
+
throw new ConfigError(tr(`${relative}: \u043D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0439 \u0442\u0438\u043F \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430`, `${relative}: unsupported document type`));
|
|
2341
|
+
}
|
|
2342
|
+
if (existsSync3(path4.join(root, ".git"))) {
|
|
2343
|
+
const state = await gitTrackState(root, clean);
|
|
2344
|
+
if (state !== "tracked") {
|
|
2345
|
+
throw new ConfigError(
|
|
2346
|
+
tr(
|
|
2347
|
+
`${relative}: \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442 \u043D\u0435 \u043E\u0442\u0441\u043B\u0435\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F git (\u0438\u043B\u0438 git \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D)`,
|
|
2348
|
+
`${relative}: document is not tracked by git (or git is unavailable)`
|
|
2349
|
+
)
|
|
2350
|
+
);
|
|
1594
2351
|
}
|
|
1595
2352
|
}
|
|
1596
|
-
return {
|
|
1597
|
-
config: config2,
|
|
1598
|
-
path: file,
|
|
1599
|
-
localPath: localFile,
|
|
1600
|
-
warnings
|
|
1601
|
-
};
|
|
1602
|
-
}
|
|
1603
|
-
function assertConfigPath(root, relative) {
|
|
1604
|
-
const cleaned = relative.split("#")[0];
|
|
1605
|
-
const resolved = path2.resolve(root, cleaned);
|
|
1606
|
-
const rel = path2.relative(root, resolved);
|
|
1607
|
-
if (rel.startsWith("..") || path2.isAbsolute(rel)) {
|
|
1608
|
-
throw new ConfigError(tr(`\u043F\u0443\u0442\u044C ${relative} \u0432\u044B\u0445\u043E\u0434\u0438\u0442 \u0437\u0430 \u043F\u0440\u0435\u0434\u0435\u043B\u044B \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F`, `path ${relative} escapes the repository`));
|
|
1609
|
-
}
|
|
1610
2353
|
return resolved;
|
|
1611
2354
|
}
|
|
1612
|
-
function checksForPaths(config2, paths) {
|
|
1613
|
-
return config2.checks.map((check) => {
|
|
1614
|
-
const matched = !check.when.length || paths.some((file) => check.when.some((pattern) => globToRegExp(pattern).test(file)));
|
|
1615
|
-
return { id: check.id, name: check.name ?? check.id, argv: check.argv, consent: check.consent, matched };
|
|
1616
|
-
});
|
|
1617
|
-
}
|
|
1618
2355
|
|
|
1619
2356
|
// src/core/rules.ts
|
|
1620
|
-
|
|
1621
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
1622
|
-
init_paths();
|
|
2357
|
+
init_glob();
|
|
1623
2358
|
init_redact();
|
|
1624
2359
|
var MAX_READ_BYTES = 16 * 1024 * 1024;
|
|
1625
2360
|
async function buildEffectiveRules(options) {
|
|
@@ -1639,20 +2374,20 @@ async function buildEffectiveRules(options) {
|
|
|
1639
2374
|
const relative = rawPath;
|
|
1640
2375
|
let resolved;
|
|
1641
2376
|
try {
|
|
1642
|
-
resolved =
|
|
2377
|
+
resolved = await assertSafeDocument(root, relative, "rules");
|
|
1643
2378
|
} catch (error) {
|
|
1644
|
-
warnings.push(
|
|
2379
|
+
warnings.push(error.message);
|
|
1645
2380
|
return { path: relative, exists: false, sections: [], excerpt: "", truncated: false };
|
|
1646
2381
|
}
|
|
1647
2382
|
let cached = cache.get(resolved);
|
|
1648
2383
|
if (!cached) {
|
|
1649
|
-
if (!
|
|
2384
|
+
if (!existsSync4(resolved)) {
|
|
1650
2385
|
cached = { exists: false, text: "", truncated: false };
|
|
1651
2386
|
warnings.push(`${t("\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442", "document")} ${relative} ${t("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D", "not found")}`);
|
|
1652
2387
|
} else {
|
|
1653
2388
|
try {
|
|
1654
2389
|
const readLimit = Number.isFinite(documentLimit) ? Math.max(documentLimit * 2, 4096) : MAX_READ_BYTES;
|
|
1655
|
-
const raw = await
|
|
2390
|
+
const raw = await readConfigFile(root, relative, readLimit);
|
|
1656
2391
|
const truncated = Number.isFinite(documentLimit) && raw.length > documentLimit;
|
|
1657
2392
|
cached = { exists: true, text: truncated ? raw.slice(0, documentLimit) : raw, truncated };
|
|
1658
2393
|
} catch (error) {
|
|
@@ -1699,7 +2434,7 @@ async function buildEffectiveRules(options) {
|
|
|
1699
2434
|
scopes.push({ file: "", kind: "other", documents });
|
|
1700
2435
|
}
|
|
1701
2436
|
return {
|
|
1702
|
-
configPath: configPath ?
|
|
2437
|
+
configPath: configPath ? path5.relative(root, configPath) : null,
|
|
1703
2438
|
scopes,
|
|
1704
2439
|
checks: checksForPaths(config2, files),
|
|
1705
2440
|
warnings: [...new Set(warnings)]
|
|
@@ -1772,10 +2507,10 @@ function renderRules(rules2, options = {}) {
|
|
|
1772
2507
|
if (rules2.warnings.length) out.push(`${t("\u041F\u0440\u0435\u0434\u0443\u043F\u0440\u0435\u0436\u0434\u0435\u043D\u0438\u044F", "Warnings")}:
|
|
1773
2508
|
${rules2.warnings.map((item) => `- ${item}`).join("\n")}`);
|
|
1774
2509
|
const seen = /* @__PURE__ */ new Set();
|
|
1775
|
-
for (const
|
|
2510
|
+
for (const scope2 of rules2.scopes) {
|
|
1776
2511
|
out.push(`
|
|
1777
|
-
## ${
|
|
1778
|
-
for (const doc of
|
|
2512
|
+
## ${scope2.file || `(${t("\u043E\u0431\u0449\u0438\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u0430", "general rules")})`} \u2014 ${scope2.kind}`);
|
|
2513
|
+
for (const doc of scope2.documents) {
|
|
1779
2514
|
const key = `${doc.path}#${doc.sections.join(",")}`;
|
|
1780
2515
|
const label = `${doc.path}${doc.sections.length ? `#${doc.sections.join(", ")}` : ""}`;
|
|
1781
2516
|
out.push(`- ${label}${doc.exists ? "" : ` (${t("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D", "not found")})`}`);
|
|
@@ -1807,172 +2542,39 @@ ${doc.excerpt}${doc.truncated ? `
|
|
|
1807
2542
|
|
|
1808
2543
|
// src/cli/main.ts
|
|
1809
2544
|
init_client();
|
|
1810
|
-
|
|
1811
|
-
// src/core/exec.ts
|
|
1812
|
-
import { execFile } from "node:child_process";
|
|
1813
|
-
import { access, constants } from "node:fs/promises";
|
|
1814
|
-
import os2 from "node:os";
|
|
1815
|
-
import path5 from "node:path";
|
|
1816
|
-
var SECRET_ENV = [
|
|
1817
|
-
"GITLAB_TOKEN",
|
|
1818
|
-
"GITLAB_PRIVATE_TOKEN",
|
|
1819
|
-
"GLAB_TOKEN",
|
|
1820
|
-
"CI_JOB_TOKEN",
|
|
1821
|
-
"GH_TOKEN",
|
|
1822
|
-
"GITHUB_TOKEN",
|
|
1823
|
-
"GITHUB_ENTERPRISE_TOKEN",
|
|
1824
|
-
"GIT_ASKPASS",
|
|
1825
|
-
"SSH_ASKPASS",
|
|
1826
|
-
"REVDECK_TOKEN"
|
|
1827
|
-
];
|
|
1828
|
-
function scrubEnv(extra) {
|
|
1829
|
-
const env = {};
|
|
1830
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
1831
|
-
if (SECRET_ENV.includes(key)) continue;
|
|
1832
|
-
env[key] = value;
|
|
1833
|
-
}
|
|
1834
|
-
env.PAGER = "cat";
|
|
1835
|
-
env.GIT_PAGER = "cat";
|
|
1836
|
-
env.GIT_TERMINAL_PROMPT = "0";
|
|
1837
|
-
env.NO_COLOR = "1";
|
|
1838
|
-
env.CLICOLOR = "0";
|
|
1839
|
-
env.FORCE_COLOR = "0";
|
|
1840
|
-
env.TERM = "dumb";
|
|
1841
|
-
return { ...env, ...extra };
|
|
1842
|
-
}
|
|
1843
|
-
var RESOLVED = /* @__PURE__ */ new Map();
|
|
1844
|
-
async function resolveExecutable(command) {
|
|
1845
|
-
if (command.includes("/") || command.includes("\\")) {
|
|
1846
|
-
try {
|
|
1847
|
-
await access(command, constants.X_OK);
|
|
1848
|
-
return command;
|
|
1849
|
-
} catch {
|
|
1850
|
-
return null;
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
const override = process.env[`REVDECK_${command.toUpperCase()}`];
|
|
1854
|
-
if (override) return override;
|
|
1855
|
-
const cached = RESOLVED.get(command);
|
|
1856
|
-
if (cached) return cached;
|
|
1857
|
-
const dirs = [
|
|
1858
|
-
...(process.env.PATH ?? "").split(path5.delimiter),
|
|
1859
|
-
path5.join(os2.homedir(), ".local", "bin"),
|
|
1860
|
-
path5.join(os2.homedir(), ".local", "share", "mise", "shims"),
|
|
1861
|
-
path5.join(os2.homedir(), ".asdf", "shims"),
|
|
1862
|
-
path5.join(os2.homedir(), ".npm-global", "bin"),
|
|
1863
|
-
"/opt/homebrew/bin",
|
|
1864
|
-
"/usr/local/bin",
|
|
1865
|
-
"/usr/bin",
|
|
1866
|
-
"/bin"
|
|
1867
|
-
].filter(Boolean);
|
|
1868
|
-
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
1869
|
-
for (const dir of [...new Set(dirs)]) {
|
|
1870
|
-
for (const extension of extensions) {
|
|
1871
|
-
const candidate = path5.join(dir, `${command}${extension}`);
|
|
1872
|
-
try {
|
|
1873
|
-
await access(candidate, constants.X_OK);
|
|
1874
|
-
RESOLVED.set(command, candidate);
|
|
1875
|
-
return candidate;
|
|
1876
|
-
} catch {
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
1879
|
-
}
|
|
1880
|
-
return null;
|
|
1881
|
-
}
|
|
1882
|
-
var run = async (command, args, options = {}) => {
|
|
1883
|
-
const executable = await resolveExecutable(command) ?? command;
|
|
1884
|
-
return new Promise((resolve, reject) => {
|
|
1885
|
-
const child = execFile(
|
|
1886
|
-
executable,
|
|
1887
|
-
args,
|
|
1888
|
-
{
|
|
1889
|
-
cwd: options.cwd,
|
|
1890
|
-
env: scrubEnv(options.env),
|
|
1891
|
-
timeout: options.timeoutMs ?? 12e4,
|
|
1892
|
-
maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
|
|
1893
|
-
encoding: "utf8",
|
|
1894
|
-
windowsHide: true,
|
|
1895
|
-
shell: false
|
|
1896
|
-
},
|
|
1897
|
-
(error, stdout, stderr) => {
|
|
1898
|
-
const exitCode = error?.code;
|
|
1899
|
-
const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
|
|
1900
|
-
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
1901
|
-
const reason = (stderr || stdout || error.message).trim();
|
|
1902
|
-
reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
|
|
1903
|
-
return;
|
|
1904
|
-
}
|
|
1905
|
-
resolve({ stdout, stderr, code });
|
|
1906
|
-
}
|
|
1907
|
-
);
|
|
1908
|
-
if (options.input !== void 0) {
|
|
1909
|
-
child.stdin?.end(options.input);
|
|
1910
|
-
}
|
|
1911
|
-
});
|
|
1912
|
-
};
|
|
1913
|
-
|
|
1914
|
-
// src/cli/main.ts
|
|
2545
|
+
init_exec();
|
|
1915
2546
|
init_redact();
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
var SSH_SCP = /^(?:ssh:\/\/)?(?:[^@/]+@)?([^:/]+)(?::(\d+))?[:/](.+?)(?:\.git)?\/?$/;
|
|
1919
|
-
function parseRemote(url) {
|
|
1920
|
-
const value = url.trim();
|
|
1921
|
-
if (!value) return null;
|
|
1922
|
-
let host = "";
|
|
1923
|
-
let projectPath = "";
|
|
1924
|
-
const http = /^(?:https?|git|ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+?)(?:\.git)?\/?$/.exec(value);
|
|
1925
|
-
if (http) {
|
|
1926
|
-
host = http[1];
|
|
1927
|
-
projectPath = http[2];
|
|
1928
|
-
} else {
|
|
1929
|
-
const scp = SSH_SCP.exec(value);
|
|
1930
|
-
if (!scp) return null;
|
|
1931
|
-
host = scp[1];
|
|
1932
|
-
projectPath = scp[3];
|
|
1933
|
-
}
|
|
1934
|
-
projectPath = projectPath.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
1935
|
-
if (!host || !projectPath || !projectPath.includes("/")) return null;
|
|
1936
|
-
return { host, project: projectPath, platform: detectPlatform(host), url: value };
|
|
1937
|
-
}
|
|
1938
|
-
function detectPlatform(host) {
|
|
1939
|
-
const lower = host.toLowerCase();
|
|
1940
|
-
if (lower === "github.com" || lower.endsWith(".github.com") || lower.includes("github")) return "github";
|
|
1941
|
-
if (lower === "gitlab.com" || lower.endsWith(".gitlab.com") || lower.includes("gitlab")) return "gitlab";
|
|
1942
|
-
return null;
|
|
1943
|
-
}
|
|
1944
|
-
async function gitRemote(root, remote = "origin") {
|
|
1945
|
-
try {
|
|
1946
|
-
const { stdout } = await run("git", ["config", "--get", `remote.${remote}.url`], { cwd: root, timeoutMs: 1e4 });
|
|
1947
|
-
return parseRemote(stdout.trim());
|
|
1948
|
-
} catch {
|
|
1949
|
-
return null;
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
// src/cli/main.ts
|
|
2547
|
+
init_git();
|
|
2548
|
+
init_refs();
|
|
1954
2549
|
init_version();
|
|
1955
2550
|
init_locale();
|
|
1956
2551
|
init_format();
|
|
1957
2552
|
|
|
1958
2553
|
// src/cli/init.ts
|
|
1959
2554
|
init_paths();
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
import path6 from "node:path";
|
|
2555
|
+
init_git();
|
|
2556
|
+
init_config();
|
|
1963
2557
|
init_redact();
|
|
1964
2558
|
init_locale();
|
|
2559
|
+
init_exec();
|
|
1965
2560
|
init_format();
|
|
2561
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
2562
|
+
import { cp, lstat as lstat2, mkdir as mkdir2, readdir, readFile as readFile3, rm, symlink, writeFile } from "node:fs/promises";
|
|
2563
|
+
import path7 from "node:path";
|
|
1966
2564
|
function mcpServer(locale2) {
|
|
1967
2565
|
return { command: "npx", args: ["-y", "revdeck", "mcp"], env: { REVDECK_LANG: locale2 } };
|
|
1968
2566
|
}
|
|
2567
|
+
function initProvider(remote, requested) {
|
|
2568
|
+
if (requested && requested !== "auto") return requested;
|
|
2569
|
+
return remote ?? "gitlab";
|
|
2570
|
+
}
|
|
1969
2571
|
async function runInit(rootInput, options) {
|
|
1970
2572
|
const root = findRepoRoot(rootInput);
|
|
1971
2573
|
writers.out(`${tr("\u043F\u0440\u043E\u0435\u043A\u0442", "project")}: ${root}`);
|
|
1972
2574
|
const remote = await gitRemote(root);
|
|
1973
|
-
const configFile =
|
|
1974
|
-
if (
|
|
1975
|
-
writers.out(`\u2714 ${tr("\u043A\u043E\u043D\u0444\u0438\u0433 \u0443\u0436\u0435 \u0435\u0441\u0442\u044C", "config already exists")}: ${
|
|
2575
|
+
const configFile = path7.join(root, ".revdeck.yml");
|
|
2576
|
+
if (existsSync6(configFile) && !options.force) {
|
|
2577
|
+
writers.out(`\u2714 ${tr("\u043A\u043E\u043D\u0444\u0438\u0433 \u0443\u0436\u0435 \u0435\u0441\u0442\u044C", "config already exists")}: ${path7.relative(root, configFile)}`);
|
|
1976
2578
|
} else {
|
|
1977
2579
|
let sources = [];
|
|
1978
2580
|
try {
|
|
@@ -1984,7 +2586,7 @@ async function runInit(rootInput, options) {
|
|
|
1984
2586
|
tr("# \u041A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044F revdeck. \u0421\u0445\u0435\u043C\u0430: docs/configuration.md", "# revdeck configuration. Schema: docs/configuration.md"),
|
|
1985
2587
|
"version: 1",
|
|
1986
2588
|
"provider:",
|
|
1987
|
-
` type: ${remote?.platform ??
|
|
2589
|
+
` type: ${initProvider(remote?.platform ?? null, options.provider)}`,
|
|
1988
2590
|
...remote ? [` host: ${remote.host}`, ` project: ${remote.project}`] : [" # host: gitlab.example.com", " # project: group/project"],
|
|
1989
2591
|
"output:",
|
|
1990
2592
|
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"),
|
|
@@ -2012,7 +2614,7 @@ async function runInit(rootInput, options) {
|
|
|
2012
2614
|
""
|
|
2013
2615
|
];
|
|
2014
2616
|
await writeFile(configFile, lines.join("\n"), { mode: 420 });
|
|
2015
|
-
writers.out(`\u2714 ${tr("\u0441\u043E\u0437\u0434\u0430\u043D", "created")} ${
|
|
2617
|
+
writers.out(`\u2714 ${tr("\u0441\u043E\u0437\u0434\u0430\u043D", "created")} ${path7.relative(root, configFile)}`);
|
|
2016
2618
|
}
|
|
2017
2619
|
await ensureGitignore(root);
|
|
2018
2620
|
const adapters = options.adapters.length ? options.adapters : detectAdapters(root);
|
|
@@ -2076,13 +2678,13 @@ var SPECS = {
|
|
|
2076
2678
|
};
|
|
2077
2679
|
function detectAdapters(root) {
|
|
2078
2680
|
const adapters = /* @__PURE__ */ new Set(["agents"]);
|
|
2079
|
-
if (
|
|
2080
|
-
if (
|
|
2081
|
-
if (
|
|
2082
|
-
if (
|
|
2083
|
-
if (
|
|
2084
|
-
if (
|
|
2085
|
-
if (
|
|
2681
|
+
if (existsSync6(path7.join(root, ".claude")) || existsSync6(path7.join(root, "CLAUDE.md"))) adapters.add("claude");
|
|
2682
|
+
if (existsSync6(path7.join(root, ".cursor"))) adapters.add("cursor");
|
|
2683
|
+
if (existsSync6(path7.join(root, ".codex")) || existsSync6(path7.join(root, "AGENTS.md"))) adapters.add("codex");
|
|
2684
|
+
if (existsSync6(path7.join(root, ".github"))) adapters.add("copilot");
|
|
2685
|
+
if (existsSync6(path7.join(root, ".dsh")) || existsSync6(path7.join(root, "dsh.yml"))) adapters.add("dsh");
|
|
2686
|
+
if (existsSync6(path7.join(root, ".gemini")) || existsSync6(path7.join(root, "GEMINI.md"))) adapters.add("gemini");
|
|
2687
|
+
if (existsSync6(path7.join(root, ".opencode"))) adapters.add("opencode");
|
|
2086
2688
|
return [...adapters];
|
|
2087
2689
|
}
|
|
2088
2690
|
async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
|
|
@@ -2092,16 +2694,16 @@ async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
|
|
|
2092
2694
|
return;
|
|
2093
2695
|
}
|
|
2094
2696
|
if (spec.linkSkill && canonicalSkill) await linkSkill(root, canonicalSkill, locale2);
|
|
2095
|
-
if (spec.mcp) await mergeMcpJson(
|
|
2697
|
+
if (spec.mcp) await mergeMcpJson(path7.join(root, spec.mcp), root, mcp);
|
|
2096
2698
|
for (const file of spec.files ?? []) {
|
|
2097
|
-
const target =
|
|
2098
|
-
if (
|
|
2099
|
-
writers.out(`! ${
|
|
2699
|
+
const target = path7.join(root, file.path);
|
|
2700
|
+
if (existsSync6(target)) {
|
|
2701
|
+
writers.out(`! ${path7.relative(root, target)} ${tr("\u0443\u0436\u0435 \u0435\u0441\u0442\u044C: \u043D\u0435 \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0438\u0441\u044B\u0432\u0430\u044E", "already exists: not overwriting")}`);
|
|
2100
2702
|
continue;
|
|
2101
2703
|
}
|
|
2102
|
-
await mkdir2(
|
|
2704
|
+
await mkdir2(path7.dirname(target), { recursive: true });
|
|
2103
2705
|
await writeFile(target, typeof file.content === "string" ? file.content : file.content(locale2));
|
|
2104
|
-
writers.out(`\u2714 ${
|
|
2706
|
+
writers.out(`\u2714 ${path7.relative(root, target)}`);
|
|
2105
2707
|
}
|
|
2106
2708
|
if (adapter === "dsh") {
|
|
2107
2709
|
writers.out(` ${tr("DSH: \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0435 MCP \u0432 \u043F\u0440\u043E\u0444\u0438\u043B\u0435 (Cordis YAML):", "DSH: add the MCP server to your profile (Cordis YAML):")}`);
|
|
@@ -2118,12 +2720,12 @@ async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
|
|
|
2118
2720
|
}
|
|
2119
2721
|
}
|
|
2120
2722
|
async function installSkill(root, locale2) {
|
|
2121
|
-
const source =
|
|
2122
|
-
if (!
|
|
2723
|
+
const source = path7.join(packageRoot(), "skills", "revdeck", locale2);
|
|
2724
|
+
if (!existsSync6(source)) {
|
|
2123
2725
|
writers.err(`! ${tr("\u043A\u0430\u0442\u0430\u043B\u043E\u0433 skills/revdeck \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u043F\u0430\u043A\u0435\u0442 \u0441\u043E\u0431\u0440\u0430\u043D \u043D\u0435 \u043F\u043E\u043B\u043D\u043E\u0441\u0442\u044C\u044E", "skills/revdeck not found: the package is incomplete")}`);
|
|
2124
2726
|
return null;
|
|
2125
2727
|
}
|
|
2126
|
-
const target =
|
|
2728
|
+
const target = path7.join(root, CANONICAL_SKILL);
|
|
2127
2729
|
await copySkill(source, target);
|
|
2128
2730
|
writers.out(`\u2714 ${tr("\u0441\u043A\u0438\u043B\u043B", "skill")}: ${CANONICAL_SKILL}`);
|
|
2129
2731
|
return target;
|
|
@@ -2131,16 +2733,16 @@ async function installSkill(root, locale2) {
|
|
|
2131
2733
|
async function copySkill(source, target) {
|
|
2132
2734
|
await mkdir2(target, { recursive: true });
|
|
2133
2735
|
for (const entry of await skillFiles(source)) {
|
|
2134
|
-
const file =
|
|
2135
|
-
await mkdir2(
|
|
2136
|
-
await cp(
|
|
2736
|
+
const file = path7.join(target, entry);
|
|
2737
|
+
await mkdir2(path7.dirname(file), { recursive: true });
|
|
2738
|
+
await cp(path7.join(source, entry), file, { force: true });
|
|
2137
2739
|
}
|
|
2138
2740
|
}
|
|
2139
2741
|
async function linkSkill(root, canonicalSkill, locale2) {
|
|
2140
|
-
const target =
|
|
2141
|
-
const source =
|
|
2142
|
-
const skillTarget =
|
|
2143
|
-
await mkdir2(
|
|
2742
|
+
const target = path7.join(root, ".claude", "skills", "revdeck");
|
|
2743
|
+
const source = path7.join(canonicalSkill, "SKILL.md");
|
|
2744
|
+
const skillTarget = path7.join(target, "SKILL.md");
|
|
2745
|
+
await mkdir2(path7.dirname(target), { recursive: true });
|
|
2144
2746
|
const existing = await lstat2(target).catch(() => null);
|
|
2145
2747
|
if (existing) {
|
|
2146
2748
|
if (existing.isSymbolicLink()) {
|
|
@@ -2169,18 +2771,18 @@ This file is a shim. The full procedure is \`.agents/skills/revdeck/SKILL.md\`;
|
|
|
2169
2771
|
`;
|
|
2170
2772
|
await writeFile(skillTarget, shim);
|
|
2171
2773
|
} else {
|
|
2172
|
-
await symlink(
|
|
2774
|
+
await symlink(path7.relative(target, source), skillTarget, "file");
|
|
2173
2775
|
}
|
|
2174
2776
|
writers.out(`\u2714 ${tr("\u0441\u043A\u0438\u043B\u043B", "skill")}: .claude/skills/revdeck/SKILL.md -> ${CANONICAL_SKILL}/SKILL.md`);
|
|
2175
2777
|
}
|
|
2176
2778
|
async function isManagedSkillDir(dir) {
|
|
2177
|
-
const skill =
|
|
2178
|
-
if (!
|
|
2779
|
+
const skill = path7.join(dir, "SKILL.md");
|
|
2780
|
+
if (!existsSync6(skill)) return false;
|
|
2179
2781
|
const text = await readFile3(skill, "utf8").catch(() => "");
|
|
2180
2782
|
return /^name:\s*revdeck\s*$/m.test(text);
|
|
2181
2783
|
}
|
|
2182
2784
|
async function skillFiles(dir, prefix = "") {
|
|
2183
|
-
const entries = await readdir(
|
|
2785
|
+
const entries = await readdir(path7.join(dir, prefix), { withFileTypes: true });
|
|
2184
2786
|
const files = [];
|
|
2185
2787
|
for (const entry of entries) {
|
|
2186
2788
|
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
@@ -2191,11 +2793,11 @@ async function skillFiles(dir, prefix = "") {
|
|
|
2191
2793
|
}
|
|
2192
2794
|
async function mergeMcpJson(file, root, mcp) {
|
|
2193
2795
|
let data = {};
|
|
2194
|
-
if (
|
|
2796
|
+
if (existsSync6(file)) {
|
|
2195
2797
|
try {
|
|
2196
2798
|
data = JSON.parse(await readFile3(file, "utf8"));
|
|
2197
2799
|
} catch {
|
|
2198
|
-
writers.err(`! ${
|
|
2800
|
+
writers.err(`! ${path7.relative(root, file)} ${tr("\u043F\u043E\u0432\u0440\u0435\u0436\u0434\u0451\u043D: \u043D\u0435 \u0442\u0440\u043E\u0433\u0430\u044E", "is broken: leaving it untouched")}`);
|
|
2199
2801
|
return;
|
|
2200
2802
|
}
|
|
2201
2803
|
}
|
|
@@ -2206,11 +2808,11 @@ async function mergeMcpJson(file, root, mcp) {
|
|
|
2206
2808
|
data.mcpServers = servers;
|
|
2207
2809
|
await writeFile(file, `${JSON.stringify(data, null, 2)}
|
|
2208
2810
|
`);
|
|
2209
|
-
writers.out(`\u2714 MCP: ${
|
|
2811
|
+
writers.out(`\u2714 MCP: ${path7.relative(root, file)}`);
|
|
2210
2812
|
}
|
|
2211
2813
|
async function ensureGitignore(root) {
|
|
2212
|
-
const file =
|
|
2213
|
-
let current2 =
|
|
2814
|
+
const file = path7.join(root, ".gitignore");
|
|
2815
|
+
let current2 = existsSync6(file) ? await readFile3(file, "utf8") : "";
|
|
2214
2816
|
const entries = [".revdeck/", ".revdeck.local.yml", ".revdeck.local.yaml"];
|
|
2215
2817
|
const added = [];
|
|
2216
2818
|
for (const entry of entries) {
|
|
@@ -2232,17 +2834,17 @@ async function installService(host) {
|
|
|
2232
2834
|
...gh ? [`REVDECK_GH=${gh}`] : []
|
|
2233
2835
|
];
|
|
2234
2836
|
const root = packageRoot();
|
|
2235
|
-
const daemon2 =
|
|
2837
|
+
const daemon2 = path7.join(root, "dist", "daemon.js");
|
|
2236
2838
|
const hostArgs = host ? ` --host ${host}` : "";
|
|
2237
|
-
if (!
|
|
2238
|
-
if (daemon2.includes(`${
|
|
2839
|
+
if (!existsSync6(daemon2)) throw new Error(tr("\u043D\u0435\u0442 dist/daemon.js: \u0441\u043D\u0430\u0447\u0430\u043B\u0430 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 npm run build", "dist/daemon.js is missing: run npm run build first"));
|
|
2840
|
+
if (daemon2.includes(`${path7.sep}_npx${path7.sep}`)) {
|
|
2239
2841
|
writers.err(tr("! \u043F\u0430\u043A\u0435\u0442 \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0447\u0435\u0440\u0435\u0437 npx: \u043F\u0443\u0442\u044C \u043A \u0434\u0435\u043C\u043E\u043D\u0443 \u043C\u043E\u0436\u0435\u0442 \u0438\u0441\u0447\u0435\u0437\u043D\u0443\u0442\u044C \u043F\u0440\u0438 \u043E\u0447\u0438\u0441\u0442\u043A\u0435 \u043A\u0435\u0448\u0430.", "! running from an npx cache: the daemon path can be evicted."));
|
|
2240
2842
|
writers.err(tr(" \u0434\u043B\u044F \u0430\u0432\u0442\u043E\u0437\u0430\u043F\u0443\u0441\u043A\u0430 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435 \u0433\u043B\u043E\u0431\u0430\u043B\u044C\u043D\u043E: npm install -g revdeck", " install globally for auto-start: npm install -g revdeck"));
|
|
2241
2843
|
}
|
|
2242
2844
|
if (process.platform === "linux") {
|
|
2243
|
-
const dir =
|
|
2845
|
+
const dir = path7.join(process.env.XDG_CONFIG_HOME || path7.join(process.env.HOME || "", ".config"), "systemd", "user");
|
|
2244
2846
|
await mkdir2(dir, { recursive: true });
|
|
2245
|
-
const unit =
|
|
2847
|
+
const unit = path7.join(dir, "revdeck.service");
|
|
2246
2848
|
await writeFile(
|
|
2247
2849
|
unit,
|
|
2248
2850
|
[
|
|
@@ -2266,9 +2868,9 @@ async function installService(host) {
|
|
|
2266
2868
|
return unit;
|
|
2267
2869
|
}
|
|
2268
2870
|
if (process.platform === "darwin") {
|
|
2269
|
-
const dir =
|
|
2871
|
+
const dir = path7.join(process.env.HOME || "", "Library", "LaunchAgents");
|
|
2270
2872
|
await mkdir2(dir, { recursive: true });
|
|
2271
|
-
const file =
|
|
2873
|
+
const file = path7.join(dir, "io.revdeck.daemon.plist");
|
|
2272
2874
|
await writeFile(
|
|
2273
2875
|
file,
|
|
2274
2876
|
`<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -2300,9 +2902,9 @@ function xmlEscape(value) {
|
|
|
2300
2902
|
|
|
2301
2903
|
// src/cli/eject.ts
|
|
2302
2904
|
init_paths();
|
|
2303
|
-
import { existsSync as
|
|
2905
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
2304
2906
|
import { lstat as lstat3, readFile as readFile5, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
|
|
2305
|
-
import
|
|
2907
|
+
import path9 from "node:path";
|
|
2306
2908
|
|
|
2307
2909
|
// src/core/jsonc.ts
|
|
2308
2910
|
function parseJsonc(text) {
|
|
@@ -2390,9 +2992,9 @@ import { applyEdits as applyEdits2, modify as modify2 } from "jsonc-parser";
|
|
|
2390
2992
|
|
|
2391
2993
|
// src/cli/devcontainer.ts
|
|
2392
2994
|
init_paths();
|
|
2393
|
-
import { existsSync as
|
|
2995
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
2394
2996
|
import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
|
|
2395
|
-
import
|
|
2997
|
+
import path8 from "node:path";
|
|
2396
2998
|
import { applyEdits, modify, parse as parseJsonc2 } from "jsonc-parser";
|
|
2397
2999
|
init_locale();
|
|
2398
3000
|
init_format();
|
|
@@ -2449,8 +3051,8 @@ function applyDevcontainerPatch(text, patch) {
|
|
|
2449
3051
|
const mounts = Array.isArray(parsed.mounts) ? [...parsed.mounts] : [];
|
|
2450
3052
|
for (const mount of patch.mounts) {
|
|
2451
3053
|
const index = mounts.findIndex((item) => isRecord2(item) && item.target === mount.target);
|
|
2452
|
-
const
|
|
2453
|
-
current2 = applyEdits(current2, modify(current2,
|
|
3054
|
+
const path12 = ["mounts", index >= 0 ? index : mounts.length];
|
|
3055
|
+
current2 = applyEdits(current2, modify(current2, path12, mount, formatting));
|
|
2454
3056
|
if (index >= 0) mounts[index] = mount;
|
|
2455
3057
|
else mounts.push(mount);
|
|
2456
3058
|
}
|
|
@@ -2476,12 +3078,12 @@ async function runDevcontainer(rootInput, options) {
|
|
|
2476
3078
|
const patch = devcontainerPatch();
|
|
2477
3079
|
await ensureDir(devcontainerRunDir());
|
|
2478
3080
|
await ensureDir(devcontainerStateDir());
|
|
2479
|
-
const dir =
|
|
2480
|
-
const file =
|
|
3081
|
+
const dir = path8.join(root, ".devcontainer");
|
|
3082
|
+
const file = path8.join(dir, "devcontainer.json");
|
|
2481
3083
|
writers.out(tr("\u041C\u043E\u0441\u0442 revdeck \u0434\u043B\u044F \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0430:", "revdeck bridge for the container:"));
|
|
2482
3084
|
writers.out(` ${tr("\u0441\u043E\u043A\u0435\u0442", "socket")}: ${devcontainerRunDir()} -> ${CONTAINER_RUNTIME_DIR}`);
|
|
2483
3085
|
writers.out(` ${tr("\u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435", "state")}: ${devcontainerStateDir()} -> ${CONTAINER_STATE_DIR} (${tr("\u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0442\u0435\u043D\u0438\u0435", "read-only")})`);
|
|
2484
|
-
if (!
|
|
3086
|
+
if (!existsSync7(devcontainerSocketPath())) {
|
|
2485
3087
|
writers.err(
|
|
2486
3088
|
tr(
|
|
2487
3089
|
"! \u0441\u043E\u043A\u0435\u0442 \u043C\u043E\u0441\u0442\u0430 \u0435\u0449\u0451 \u043D\u0435 \u0441\u043E\u0437\u0434\u0430\u043D: \u043D\u0430 \u0445\u043E\u0441\u0442\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 revdeck daemon restart",
|
|
@@ -2499,7 +3101,7 @@ async function runDevcontainer(rootInput, options) {
|
|
|
2499
3101
|
return;
|
|
2500
3102
|
}
|
|
2501
3103
|
await mkdir3(dir, { recursive: true });
|
|
2502
|
-
const existed =
|
|
3104
|
+
const existed = existsSync7(file);
|
|
2503
3105
|
let output;
|
|
2504
3106
|
if (existed) {
|
|
2505
3107
|
const text = await readFile4(file, "utf8");
|
|
@@ -2508,8 +3110,8 @@ async function runDevcontainer(rootInput, options) {
|
|
|
2508
3110
|
} catch (error) {
|
|
2509
3111
|
throw new Error(
|
|
2510
3112
|
tr(
|
|
2511
|
-
`${
|
|
2512
|
-
`${
|
|
3113
|
+
`${path8.relative(root, file)}: \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C JSONC (${error.message}); \u0434\u043E\u0431\u0430\u0432\u044C\u0442\u0435 mounts \u0432\u0440\u0443\u0447\u043D\u0443\u044E`,
|
|
3114
|
+
`${path8.relative(root, file)}: could not parse JSONC (${error.message}); add the mounts manually`
|
|
2513
3115
|
)
|
|
2514
3116
|
);
|
|
2515
3117
|
}
|
|
@@ -2519,7 +3121,7 @@ async function runDevcontainer(rootInput, options) {
|
|
|
2519
3121
|
`;
|
|
2520
3122
|
}
|
|
2521
3123
|
await writeFile2(file, output);
|
|
2522
|
-
writers.out(`\u2714 ${
|
|
3124
|
+
writers.out(`\u2714 ${path8.relative(root, file)}`);
|
|
2523
3125
|
const mcpFiles = await mergeMcpEnv(root, patch.containerEnv);
|
|
2524
3126
|
if (!mcpFiles) {
|
|
2525
3127
|
writers.out(tr(" MCP-\u043A\u043E\u043D\u0444\u0438\u0433 \u0432 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u0434\u043B\u044F \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C\u0441\u043A\u043E\u0433\u043E MCP \u0434\u043E\u0431\u0430\u0432\u044C\u0442\u0435 REVDECK_* \u0432\u0440\u0443\u0447\u043D\u0443\u044E.", " No MCP config in the repository: add the REVDECK_* variables to a user-level MCP manually."));
|
|
@@ -2535,8 +3137,8 @@ async function runDevcontainer(rootInput, options) {
|
|
|
2535
3137
|
async function mergeMcpEnv(root, env) {
|
|
2536
3138
|
let changed = 0;
|
|
2537
3139
|
for (const relative of [".mcp.json", ".cursor/mcp.json"]) {
|
|
2538
|
-
const file =
|
|
2539
|
-
if (!
|
|
3140
|
+
const file = path8.join(root, relative);
|
|
3141
|
+
if (!existsSync7(file)) continue;
|
|
2540
3142
|
try {
|
|
2541
3143
|
const data = JSON.parse(await readFile4(file, "utf8"));
|
|
2542
3144
|
const servers = isRecord2(data.mcpServers) ? data.mcpServers : null;
|
|
@@ -2574,13 +3176,13 @@ async function runEject(rootInput, options) {
|
|
|
2574
3176
|
const warnings = [];
|
|
2575
3177
|
if (!options.keepConfig) {
|
|
2576
3178
|
for (const name of CONFIG_FILES2) {
|
|
2577
|
-
const file =
|
|
2578
|
-
if (
|
|
3179
|
+
const file = path9.join(root, name);
|
|
3180
|
+
if (existsSync8(file)) changes.push({ path: name, action: tr("\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043A\u043E\u043D\u0444\u0438\u0433", "remove config"), remove: () => rm2(file, { force: true }) });
|
|
2579
3181
|
}
|
|
2580
3182
|
}
|
|
2581
3183
|
for (const name of SKILL_DIRS) {
|
|
2582
|
-
const target =
|
|
2583
|
-
if (!
|
|
3184
|
+
const target = path9.join(root, name);
|
|
3185
|
+
if (!existsSync8(target)) continue;
|
|
2584
3186
|
const managed = await isManagedSkill(target);
|
|
2585
3187
|
if (!managed) {
|
|
2586
3188
|
warnings.push(`${name}: ${tr("\u0441\u043A\u0438\u043B\u043B \u043D\u0435 \u043F\u043E\u0445\u043E\u0436 \u043D\u0430 revdeck \u2014 \u043E\u0441\u0442\u0430\u0432\u043B\u044F\u044E", "does not look like the revdeck skill \u2014 leaving it")}`);
|
|
@@ -2589,8 +3191,8 @@ async function runEject(rootInput, options) {
|
|
|
2589
3191
|
changes.push({ path: name, action: tr("\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u043A\u0438\u043B\u043B", "remove skill"), remove: () => rm2(target, { recursive: true, force: true }) });
|
|
2590
3192
|
}
|
|
2591
3193
|
for (const name of COMMAND_FILES) {
|
|
2592
|
-
const file =
|
|
2593
|
-
if (!
|
|
3194
|
+
const file = path9.join(root, name);
|
|
3195
|
+
if (!existsSync8(file)) continue;
|
|
2594
3196
|
const text = await readFile5(file, "utf8").catch(() => "");
|
|
2595
3197
|
if (!/revdeck/i.test(text)) {
|
|
2596
3198
|
warnings.push(`${name}: ${tr("\u0444\u0430\u0439\u043B \u043D\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 revdeck \u2014 \u043E\u0441\u0442\u0430\u0432\u043B\u044F\u044E", "file does not mention revdeck \u2014 leaving it")}`);
|
|
@@ -2599,8 +3201,8 @@ async function runEject(rootInput, options) {
|
|
|
2599
3201
|
changes.push({ path: name, action: tr("\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043A\u043E\u043C\u0430\u043D\u0434\u0443", "remove command"), remove: () => rm2(file, { force: true }) });
|
|
2600
3202
|
}
|
|
2601
3203
|
for (const name of MCP_FILES) {
|
|
2602
|
-
const file =
|
|
2603
|
-
if (!
|
|
3204
|
+
const file = path9.join(root, name);
|
|
3205
|
+
if (!existsSync8(file)) continue;
|
|
2604
3206
|
const text = await readFile5(file, "utf8").catch(() => "");
|
|
2605
3207
|
let data;
|
|
2606
3208
|
try {
|
|
@@ -2621,8 +3223,8 @@ async function runEject(rootInput, options) {
|
|
|
2621
3223
|
}
|
|
2622
3224
|
});
|
|
2623
3225
|
}
|
|
2624
|
-
const devcontainer =
|
|
2625
|
-
if (
|
|
3226
|
+
const devcontainer = path9.join(root, ".devcontainer", "devcontainer.json");
|
|
3227
|
+
if (existsSync8(devcontainer)) {
|
|
2626
3228
|
const text = await readFile5(devcontainer, "utf8");
|
|
2627
3229
|
try {
|
|
2628
3230
|
const parsed = parseJsonc(text);
|
|
@@ -2667,12 +3269,12 @@ async function runEject(rootInput, options) {
|
|
|
2667
3269
|
warnings.push(`.devcontainer/devcontainer.json: ${tr("\u043D\u0435 JSONC \u2014 \u043D\u0435 \u0442\u0440\u043E\u0433\u0430\u044E", "not JSONC \u2014 leaving it untouched")}`);
|
|
2668
3270
|
}
|
|
2669
3271
|
}
|
|
2670
|
-
const cache =
|
|
2671
|
-
if (
|
|
3272
|
+
const cache = path9.join(root, ".revdeck");
|
|
3273
|
+
if (existsSync8(cache)) {
|
|
2672
3274
|
changes.push({ path: ".revdeck/", action: tr("\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u043A\u0435\u0448", "remove local cache"), remove: () => rm2(cache, { recursive: true, force: true }) });
|
|
2673
3275
|
}
|
|
2674
|
-
const gitignore =
|
|
2675
|
-
if (
|
|
3276
|
+
const gitignore = path9.join(root, ".gitignore");
|
|
3277
|
+
if (existsSync8(gitignore)) {
|
|
2676
3278
|
const text = await readFile5(gitignore, "utf8");
|
|
2677
3279
|
if (/(^|\n)\.revdeck\/?\s*(\n|$)/.test(text)) {
|
|
2678
3280
|
changes.push({
|
|
@@ -2709,8 +3311,8 @@ async function isManagedSkill(target) {
|
|
|
2709
3311
|
const info = await lstat3(target);
|
|
2710
3312
|
if (info.isSymbolicLink()) return true;
|
|
2711
3313
|
if (!info.isDirectory()) return false;
|
|
2712
|
-
const skill =
|
|
2713
|
-
if (!
|
|
3314
|
+
const skill = path9.join(target, "SKILL.md");
|
|
3315
|
+
if (!existsSync8(skill)) return false;
|
|
2714
3316
|
const text = await readFile5(skill, "utf8");
|
|
2715
3317
|
return /^name:\s*revdeck\s*$/m.test(text) || /revdeck/i.test(text.slice(0, 2e3));
|
|
2716
3318
|
} catch {
|
|
@@ -2723,7 +3325,7 @@ init_client();
|
|
|
2723
3325
|
init_format();
|
|
2724
3326
|
init_locale();
|
|
2725
3327
|
import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile4 } from "node:fs/promises";
|
|
2726
|
-
import
|
|
3328
|
+
import path10 from "node:path";
|
|
2727
3329
|
async function reviewFor(client2, root, arg) {
|
|
2728
3330
|
if (arg && /^(gitlab|github):/.test(arg)) {
|
|
2729
3331
|
const { review } = await client2.request("reviews.get", { review: arg });
|
|
@@ -2779,12 +3381,12 @@ async function exportReview(root, arg, dir) {
|
|
|
2779
3381
|
const { client: client2 } = await ensureDaemon();
|
|
2780
3382
|
try {
|
|
2781
3383
|
const review = await reviewFor(client2, root, arg);
|
|
2782
|
-
const target =
|
|
3384
|
+
const target = path10.resolve(root, dir);
|
|
2783
3385
|
await mkdir4(target, { recursive: true });
|
|
2784
3386
|
const base = `mr-${review.info.ref.number}`;
|
|
2785
3387
|
const files = [];
|
|
2786
3388
|
const write = async (name, data) => {
|
|
2787
|
-
const file =
|
|
3389
|
+
const file = path10.join(target, name);
|
|
2788
3390
|
await writeFile4(file, `${JSON.stringify(data, null, 2)}
|
|
2789
3391
|
`, { mode: 420 });
|
|
2790
3392
|
files.push(name);
|
|
@@ -2850,9 +3452,9 @@ async function exportReview(root, arg, dir) {
|
|
|
2850
3452
|
}
|
|
2851
3453
|
}
|
|
2852
3454
|
await write(`${base}-published.json`, published);
|
|
2853
|
-
await writeFile4(
|
|
3455
|
+
await writeFile4(path10.join(target, `${base}.diff`), await serializeDiff(client2, review), { mode: 420 });
|
|
2854
3456
|
files.push(`${base}.diff`);
|
|
2855
|
-
writers.out(`${tr("\u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043E \u0432", "exported to")} ${
|
|
3457
|
+
writers.out(`${tr("\u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043E \u0432", "exported to")} ${path10.relative(root, target)}: ${files.join(", ")}`);
|
|
2856
3458
|
} finally {
|
|
2857
3459
|
client2.close();
|
|
2858
3460
|
}
|
|
@@ -2861,11 +3463,11 @@ async function importReview(root, arg, dir) {
|
|
|
2861
3463
|
const { client: client2 } = await ensureDaemon();
|
|
2862
3464
|
try {
|
|
2863
3465
|
const review = await reviewFor(client2, root, arg);
|
|
2864
|
-
const target =
|
|
3466
|
+
const target = path10.resolve(root, dir);
|
|
2865
3467
|
const base = `mr-${review.info.ref.number}`;
|
|
2866
3468
|
const read = async (name) => {
|
|
2867
3469
|
try {
|
|
2868
|
-
return JSON.parse(await readFile6(
|
|
3470
|
+
return JSON.parse(await readFile6(path10.join(target, name), "utf8"));
|
|
2869
3471
|
} catch {
|
|
2870
3472
|
return null;
|
|
2871
3473
|
}
|
|
@@ -2970,6 +3572,7 @@ var OPTIONS = {
|
|
|
2970
3572
|
review: { type: "string" },
|
|
2971
3573
|
root: { type: "string" },
|
|
2972
3574
|
platform: { type: "string" },
|
|
3575
|
+
provider: { type: "string" },
|
|
2973
3576
|
project: { type: "string" },
|
|
2974
3577
|
host: { type: "string" },
|
|
2975
3578
|
branch: { type: "string" },
|
|
@@ -2996,6 +3599,7 @@ var OPTIONS = {
|
|
|
2996
3599
|
limit: { type: "string" },
|
|
2997
3600
|
decision: { type: "string" },
|
|
2998
3601
|
note: { type: "string" },
|
|
3602
|
+
level: { type: "string" },
|
|
2999
3603
|
emoji: { type: "string" },
|
|
3000
3604
|
text: { type: "string" },
|
|
3001
3605
|
line: { type: "string" },
|
|
@@ -3004,7 +3608,14 @@ var OPTIONS = {
|
|
|
3004
3608
|
all: { type: "boolean", default: false },
|
|
3005
3609
|
lang: { type: "string" },
|
|
3006
3610
|
role: { type: "string" },
|
|
3007
|
-
shard: { type: "string" }
|
|
3611
|
+
shard: { type: "string" },
|
|
3612
|
+
title: { type: "string" },
|
|
3613
|
+
brief: { type: "string" },
|
|
3614
|
+
contract: { type: "string" },
|
|
3615
|
+
status: { type: "string" },
|
|
3616
|
+
"max-bytes": { type: "string" },
|
|
3617
|
+
feature: { type: "string" },
|
|
3618
|
+
archived: { type: "boolean", default: false }
|
|
3008
3619
|
};
|
|
3009
3620
|
function parse(argv) {
|
|
3010
3621
|
try {
|
|
@@ -3016,12 +3627,14 @@ function parse(argv) {
|
|
|
3016
3627
|
}
|
|
3017
3628
|
var HELP_RU = `revdeck ${VERSION} \u2014 \u0440\u0435\u0432\u044C\u044E GitLab/GitHub \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439 \u0438 \u0430\u0433\u0435\u043D\u0442\u043E\u0432
|
|
3018
3629
|
|
|
3019
|
-
revdeck init \u043D\u0430\u0441\u0442\u0440\u043E\u0438\u0442\u044C \u043F\u0440\u043E\u0435\u043A\u0442: .revdeck.yml, \u0430\u0434\u0430\u043F\u0442\u0435\u0440\u044B, MCP
|
|
3630
|
+
revdeck init \u043D\u0430\u0441\u0442\u0440\u043E\u0438\u0442\u044C \u043F\u0440\u043E\u0435\u043A\u0442: .revdeck.yml, \u0430\u0434\u0430\u043F\u0442\u0435\u0440\u044B, MCP [--provider gitlab|github|auto]
|
|
3020
3631
|
revdeck eject \u0443\u0434\u0430\u043B\u0438\u0442\u044C revdeck \u0438\u0437 \u043F\u0440\u043E\u0435\u043A\u0442\u0430 (--yes; --keep-config)
|
|
3021
3632
|
revdeck devcontainer \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C devcontainer \u043A \u0434\u0435\u043C\u043E\u043D\u0443 \u0445\u043E\u0441\u0442\u0430 (--write)
|
|
3022
3633
|
revdeck doctor \u043F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u0435 \u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u044B
|
|
3023
3634
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
3024
|
-
revdeck
|
|
3635
|
+
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)
|
|
3636
|
+
revdeck feature \u0444\u0438\u0447\u0438: list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete
|
|
3637
|
+
revdeck list \u0440\u0435\u0432\u044C\u044E \u0442\u0435\u043A\u0443\u0449\u0435\u0433\u043E \u043F\u0440\u043E\u0435\u043A\u0442\u0430 (--all \u2014 \u0432\u0441\u0435 \u043F\u0440\u043E\u0435\u043A\u0442\u044B; --remote \u2014 \u0441 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B)
|
|
3025
3638
|
revdeck open <url|N...> \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u043E\u0434\u043D\u043E \u0438\u043B\u0438 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0440\u0435\u0432\u044C\u044E
|
|
3026
3639
|
revdeck ui [N] \u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441
|
|
3027
3640
|
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]
|
|
@@ -3038,22 +3651,25 @@ var HELP_RU = `revdeck ${VERSION} \u2014 \u0440\u0435\u0432\u044C\u044E GitLab/G
|
|
|
3038
3651
|
revdeck attach <N> --file <\u043F\u0443\u0442\u044C> \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0443/\u0432\u0438\u0434\u0435\u043E \u0432 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0443
|
|
3039
3652
|
revdeck publish <N> [--kind reply|finding|note] [--ids a,b] [--yes]
|
|
3040
3653
|
revdeck rules [<N>] [--explain <\u043F\u0443\u0442\u044C>]
|
|
3041
|
-
revdeck checks <N> [--run --yes]
|
|
3654
|
+
revdeck checks <N> [--run --yes] \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438: \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0435\u043B\u043E\u0432\u0435\u043A \u043D\u0430 \u0445\u043E\u0441\u0442\u0435/\u0432 UI
|
|
3042
3655
|
revdeck export <N> [--dir .revdeck] \u0432\u044B\u0433\u0440\u0443\u0437\u043A\u0430 \u0432 \u0441\u0442\u0430\u0440\u044B\u0439 \u0444\u0430\u0439\u043B\u043E\u0432\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442
|
|
3043
3656
|
revdeck import <N> [--dir .revdeck] \u0438\u043C\u043F\u043E\u0440\u0442 \u0438\u0437 \u0441\u0442\u0430\u0440\u043E\u0433\u043E \u0444\u043E\u0440\u043C\u0430\u0442\u0430
|
|
3044
3657
|
revdeck config [--json] \u044D\u0444\u0444\u0435\u043A\u0442\u0438\u0432\u043D\u044B\u0439 \u043A\u043E\u043D\u0444\u0438\u0433 \u043F\u0440\u043E\u0435\u043A\u0442\u0430
|
|
3045
3658
|
revdeck mcp \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C MCP-\u0441\u0435\u0440\u0432\u0435\u0440 (stdio)
|
|
3046
3659
|
|
|
3047
3660
|
\u041E\u0431\u0449\u0438\u0435 \u0444\u043B\u0430\u0433\u0438: --json, --root <\u043F\u0443\u0442\u044C>, --review <id>, --lang ru|en, --help.
|
|
3048
|
-
\u041F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F \
|
|
3661
|
+
\u041F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F, checks \u0438 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u2014 human-only: \u043C\u043E\u0441\u0442 \u0430\u0433\u0435\u043D\u0442\u0430 \u043F\u043E\u043B\u0443\u0447\u0430\u0435\u0442 CAPABILITY, CLI \u0432
|
|
3662
|
+
\u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435 \u043E\u0442\u043A\u0430\u0437\u044B\u0432\u0430\u0435\u0442 --run/--yes. \u041F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F \u0431\u0435\u0437 --yes \u043D\u0438\u043A\u043E\u0433\u0434\u0430 \u043D\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u044F\u0435\u0442\u0441\u044F.`;
|
|
3049
3663
|
var HELP_EN = `revdeck ${VERSION} \u2014 code review for GitLab/GitHub, for humans and agents
|
|
3050
3664
|
|
|
3051
|
-
revdeck init set up a project: .revdeck.yml, adapters, MCP
|
|
3665
|
+
revdeck init set up a project: .revdeck.yml, adapters, MCP [--provider gitlab|github|auto]
|
|
3052
3666
|
revdeck eject remove revdeck from the project (--yes; --keep-config)
|
|
3053
3667
|
revdeck devcontainer connect a devcontainer to the host daemon (--write)
|
|
3054
3668
|
revdeck doctor check the environment and access
|
|
3055
3669
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
3056
|
-
revdeck
|
|
3670
|
+
revdeck projects projects and their working copies (add <path> \u2014 register)
|
|
3671
|
+
revdeck feature features: list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete
|
|
3672
|
+
revdeck list reviews of the current project (--all \u2014 all projects; --remote \u2014 from the platform)
|
|
3057
3673
|
revdeck open <url|N...> open one or more reviews
|
|
3058
3674
|
revdeck ui [N] link to the local UI
|
|
3059
3675
|
revdeck context <N> agent context: rules, diff, threads [--role <role>] [--shard i/N]
|
|
@@ -3070,14 +3686,15 @@ var HELP_EN = `revdeck ${VERSION} \u2014 code review for GitLab/GitHub, for huma
|
|
|
3070
3686
|
revdeck attach <N> --file <path> upload an image/video to the platform
|
|
3071
3687
|
revdeck publish <N> [--kind reply|finding|note] [--ids a,b] [--yes]
|
|
3072
3688
|
revdeck rules [<N>] [--explain <path>]
|
|
3073
|
-
revdeck checks <N> [--run --yes]
|
|
3689
|
+
revdeck checks <N> [--run --yes] checks run by a human on the host/UI only
|
|
3074
3690
|
revdeck export <N> [--dir .revdeck] export to the legacy file format
|
|
3075
3691
|
revdeck import <N> [--dir .revdeck] import from the legacy format
|
|
3076
3692
|
revdeck config [--json] effective project config
|
|
3077
3693
|
revdeck mcp start the MCP server (stdio)
|
|
3078
3694
|
|
|
3079
3695
|
Common flags: --json, --root <path>, --review <id>, --lang ru|en, --help.
|
|
3080
|
-
Publishing
|
|
3696
|
+
Publishing, checks and administration are human-only: the agent bridge gets CAPABILITY and the
|
|
3697
|
+
container CLI refuses --run/--yes. Publishing never happens without --yes.`;
|
|
3081
3698
|
var helpText = () => tr(HELP_RU, HELP_EN);
|
|
3082
3699
|
async function main2() {
|
|
3083
3700
|
const argv = process.argv.slice(2);
|
|
@@ -3099,9 +3716,49 @@ async function main2() {
|
|
|
3099
3716
|
return;
|
|
3100
3717
|
}
|
|
3101
3718
|
const root = String(values.root ?? findRepoRoot());
|
|
3719
|
+
if (isDevContainer()) {
|
|
3720
|
+
const featureAction = command === "feature" ? positionals[0] ?? "list" : "";
|
|
3721
|
+
const projectAction = command === "projects" ? positionals[0] ?? "list" : "";
|
|
3722
|
+
if (command === "checks" && values.run === true) {
|
|
3723
|
+
fail(
|
|
3724
|
+
tr("checks \u0437\u0430\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u0447\u0435\u043B\u043E\u0432\u0435\u043A \u043D\u0430 \u0445\u043E\u0441\u0442\u0435 \u0438\u043B\u0438 \u0432 UI: \u0430\u0433\u0435\u043D\u0442 \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C \u0437\u0430\u043F\u0443\u0441\u043A", "checks are run by a human on the host or in the UI: an agent cannot confirm execution"),
|
|
3725
|
+
tr("\u043F\u043E\u043A\u0430\u0436\u0438\u0442\u0435 \u043F\u043B\u0430\u043D \u043F\u0440\u043E\u0432\u0435\u0440\u043E\u043A \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u0443; \u0437\u0430\u043F\u0443\u0441\u043A \u2014 \u0432 UI \u0438\u043B\u0438 `revdeck checks --run --yes` \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "show the checks plan to the human; run it in the UI or `revdeck checks --run --yes` on the host")
|
|
3726
|
+
);
|
|
3727
|
+
}
|
|
3728
|
+
if ((command === "publish" || command === "reply") && values.yes === true && values["dry-run"] !== true) {
|
|
3729
|
+
fail(
|
|
3730
|
+
tr("\u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F \u2014 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u0430: \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 UI \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "publishing is a human action: use the UI on the host"),
|
|
3731
|
+
tr("\u0438\u0437 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0430 \u0430\u0433\u0435\u043D\u0442 \u043C\u043E\u0436\u0435\u0442 \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u043F\u043B\u0430\u043D (--dry-run)", "from a container an agent can only show the plan (--dry-run)")
|
|
3732
|
+
);
|
|
3733
|
+
}
|
|
3734
|
+
if (command === "feature" && ["create", "update", "archive", "delete", "add", "remove", "reorder", "note", "note-delete"].includes(featureAction)) {
|
|
3735
|
+
fail(
|
|
3736
|
+
tr("\u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0444\u0438\u0447 \u2014 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u0430 \u043D\u0430 \u0445\u043E\u0441\u0442\u0435/\u0432 UI", "feature administration is a human action on the host/UI"),
|
|
3737
|
+
tr("\u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0442\u0435\u043D\u0438\u0435 \u0444\u0438\u0447 \u0438 feature-\u0437\u0430\u043C\u0435\u0442\u043A\u0438 \u0447\u0435\u0440\u0435\u0437 MCP", "in a container only feature reading and feature notes via MCP are available")
|
|
3738
|
+
);
|
|
3739
|
+
}
|
|
3740
|
+
if (command === "projects" && ["update", "remove", "delete"].includes(projectAction)) {
|
|
3741
|
+
fail(
|
|
3742
|
+
tr("\u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432 \u2014 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u0430 \u043D\u0430 \u0445\u043E\u0441\u0442\u0435/\u0432 UI", "project administration is a human action on the host/UI"),
|
|
3743
|
+
tr("\u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0441\u043F\u0438\u0441\u043E\u043A \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432", "in a container only the project list is available")
|
|
3744
|
+
);
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3102
3747
|
switch (command) {
|
|
3103
|
-
case "init":
|
|
3104
|
-
|
|
3748
|
+
case "init": {
|
|
3749
|
+
const provider = values.provider === void 0 ? void 0 : String(values.provider);
|
|
3750
|
+
if (provider && provider !== "auto" && provider !== "gitlab" && provider !== "github") {
|
|
3751
|
+
fail(tr(`\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440: ${provider}`, `unknown provider: ${provider}`), tr("\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E: auto, gitlab, github", "allowed: auto, gitlab, github"));
|
|
3752
|
+
}
|
|
3753
|
+
return runInit(root, {
|
|
3754
|
+
force: values.force === true,
|
|
3755
|
+
adapters: parseList(values.adapters),
|
|
3756
|
+
noService: values["no-service"] === true,
|
|
3757
|
+
locale: values.lang === "ru" || values.lang === "en" ? values.lang : detectLocale(),
|
|
3758
|
+
outputLanguage: values.lang === "ru" || values.lang === "en" ? values.lang : "auto",
|
|
3759
|
+
...provider ? { provider } : {}
|
|
3760
|
+
});
|
|
3761
|
+
}
|
|
3105
3762
|
case "eject":
|
|
3106
3763
|
return runEject(root, { yes: values.yes === true && values["dry-run"] !== true, keepConfig: values["keep-config"] === true });
|
|
3107
3764
|
case "devcontainer":
|
|
@@ -3110,6 +3767,10 @@ async function main2() {
|
|
|
3110
3767
|
return doctor(root);
|
|
3111
3768
|
case "daemon":
|
|
3112
3769
|
return daemon(positionals[0] ?? "status", values);
|
|
3770
|
+
case "projects":
|
|
3771
|
+
return projects(root, positionals, values);
|
|
3772
|
+
case "feature":
|
|
3773
|
+
return feature(root, positionals, values);
|
|
3113
3774
|
case "list":
|
|
3114
3775
|
return list(root, values);
|
|
3115
3776
|
case "open":
|
|
@@ -3117,7 +3778,7 @@ async function main2() {
|
|
|
3117
3778
|
case "ui":
|
|
3118
3779
|
return ui(positionals[0], values);
|
|
3119
3780
|
case "status":
|
|
3120
|
-
return status();
|
|
3781
|
+
return status(root, values);
|
|
3121
3782
|
case "context":
|
|
3122
3783
|
case "review":
|
|
3123
3784
|
return context(root, positionals[0], values);
|
|
@@ -3226,12 +3887,220 @@ async function list(root, values) {
|
|
|
3226
3887
|
return;
|
|
3227
3888
|
}
|
|
3228
3889
|
await withClient(async ({ client: client2 }) => {
|
|
3229
|
-
const
|
|
3890
|
+
const project = typeof values.project === "string" && values.project.trim() ? values.project.trim() : void 0;
|
|
3891
|
+
const params = values.all === true ? {} : project ? { project } : { root };
|
|
3892
|
+
const { reviews } = await client2.request("reviews.list", params);
|
|
3230
3893
|
if (values.json) return printJson({ reviews });
|
|
3231
|
-
if (!reviews.length) return writers.out(tr("\u0440\u0435\u0432\u044C\u044E \u0435\u0449\u0451 \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0438\u0441\u044C: revdeck open <N>", "no reviews opened yet: revdeck open <N>"));
|
|
3894
|
+
if (!reviews.length) return writers.out(tr("\u0432 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0435 \u0440\u0435\u0432\u044C\u044E \u0435\u0449\u0451 \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0438\u0441\u044C: revdeck open <N>", "no reviews opened in this project yet: revdeck open <N>"));
|
|
3232
3895
|
for (const item of reviews) writers.out(reviewLine(item));
|
|
3233
3896
|
});
|
|
3234
3897
|
}
|
|
3898
|
+
async function projects(root, args, values) {
|
|
3899
|
+
const action = args[0] ?? "list";
|
|
3900
|
+
await withClient(async ({ client: client2 }) => {
|
|
3901
|
+
if (action === "add") {
|
|
3902
|
+
const target = args[1] ?? values.root ?? root;
|
|
3903
|
+
const result = await client2.request("projects.register", { root: target });
|
|
3904
|
+
if (values.json) return printJson(result);
|
|
3905
|
+
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"));
|
|
3906
|
+
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}`);
|
|
3907
|
+
return;
|
|
3908
|
+
}
|
|
3909
|
+
if (action !== "list") usage([tr("revdeck projects [add <path>]", "revdeck projects [add <path>]")]);
|
|
3910
|
+
const { projects: projects2 } = await client2.request("projects.list");
|
|
3911
|
+
if (values.json) return printJson({ projects: projects2 });
|
|
3912
|
+
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>"));
|
|
3913
|
+
for (const item of projects2) {
|
|
3914
|
+
writers.out(`${item.key} ${item.title} ${item.reviews} ${tr("\u0440\u0435\u0432\u044C\u044E", "reviews")} ${item.roots[0] ?? ""}`);
|
|
3915
|
+
}
|
|
3916
|
+
});
|
|
3917
|
+
}
|
|
3918
|
+
function featureRef(value) {
|
|
3919
|
+
const input = value.trim();
|
|
3920
|
+
if (/^(gitlab|github):/.test(input)) return input;
|
|
3921
|
+
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"));
|
|
3922
|
+
try {
|
|
3923
|
+
return reviewId(parseReviewUrl(input));
|
|
3924
|
+
} catch {
|
|
3925
|
+
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"));
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
async function textFromFile(file, label) {
|
|
3929
|
+
if (typeof file !== "string" || !file.trim()) return void 0;
|
|
3930
|
+
try {
|
|
3931
|
+
return await readFile7(file, "utf8");
|
|
3932
|
+
} catch (error) {
|
|
3933
|
+
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}`));
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
async function briefFrom(values) {
|
|
3937
|
+
return textFromFile(typeof values.brief === "string" ? values.brief : void 0, tr("\u0431\u0440\u0438\u0444", "brief"));
|
|
3938
|
+
}
|
|
3939
|
+
function printFeature(feature2) {
|
|
3940
|
+
writers.out(`${feature2.id} ${feature2.status} ${feature2.reviews} ${tr("\u0440\u0435\u0432\u044C\u044E", "reviews")} ${feature2.title}`);
|
|
3941
|
+
for (const project of feature2.projects) writers.out(` ${project.key}`);
|
|
3942
|
+
for (const member of feature2.members ?? []) {
|
|
3943
|
+
writers.out(` ${member.review.id} ${member.role || "\u2014"} #${member.review.number} ${member.review.title} (${member.review.state})`);
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
async function feature(_root, args, values) {
|
|
3947
|
+
const action = args[0] ?? "list";
|
|
3948
|
+
await withClient(async ({ client: client2 }) => {
|
|
3949
|
+
if (action === "list") {
|
|
3950
|
+
const project = typeof values.project === "string" && values.project.trim() ? values.project.trim() : void 0;
|
|
3951
|
+
const includeArchived = values.all === true || values.archived === true;
|
|
3952
|
+
const { features } = await client2.request("features.list", {
|
|
3953
|
+
...project ? { project } : {},
|
|
3954
|
+
includeArchived
|
|
3955
|
+
});
|
|
3956
|
+
if (values.json) return printJson({ features });
|
|
3957
|
+
if (!features.length) return writers.out(tr("\u0444\u0438\u0447 \u043F\u043E\u043A\u0430 \u043D\u0435\u0442", "no features yet"));
|
|
3958
|
+
for (const item of features) {
|
|
3959
|
+
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}`);
|
|
3960
|
+
}
|
|
3961
|
+
return;
|
|
3962
|
+
}
|
|
3963
|
+
if (action === "get") {
|
|
3964
|
+
const id = args[1];
|
|
3965
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3966
|
+
const { feature: feature2 } = await client2.request("features.get", { feature: id });
|
|
3967
|
+
if (values.json) return printJson(feature2);
|
|
3968
|
+
printFeature(feature2);
|
|
3969
|
+
if (feature2.brief.trim()) writers.out(`
|
|
3970
|
+
${feature2.brief}`);
|
|
3971
|
+
if (feature2.contract.trim()) writers.out(`
|
|
3972
|
+
${feature2.contract}`);
|
|
3973
|
+
return;
|
|
3974
|
+
}
|
|
3975
|
+
if (action === "create") {
|
|
3976
|
+
const title = args[1] ?? (typeof values.title === "string" ? values.title : "");
|
|
3977
|
+
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"));
|
|
3978
|
+
const reviews = args.slice(2).map((value) => ({ review: featureRef(value), ...values.role ? { role: String(values.role) } : {} }));
|
|
3979
|
+
const brief = await briefFrom(values);
|
|
3980
|
+
const contract = await textFromFile(typeof values.contract === "string" ? values.contract : void 0, tr("\u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442", "contract"));
|
|
3981
|
+
const { feature: feature2 } = await client2.request("features.create", {
|
|
3982
|
+
title,
|
|
3983
|
+
...brief !== void 0 ? { brief } : {},
|
|
3984
|
+
...contract !== void 0 ? { contract } : {},
|
|
3985
|
+
...reviews.length ? { reviews } : {}
|
|
3986
|
+
});
|
|
3987
|
+
if (values.json) return printJson(feature2);
|
|
3988
|
+
writers.out(`${tr("\u0444\u0438\u0447\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0430", "feature created")}: ${feature2.id}`);
|
|
3989
|
+
printFeature(feature2);
|
|
3990
|
+
return;
|
|
3991
|
+
}
|
|
3992
|
+
if (action === "add") {
|
|
3993
|
+
const id = args[1];
|
|
3994
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
3995
|
+
const reviews = args.slice(2).map((value) => ({ review: featureRef(value), ...values.role ? { role: String(values.role) } : {} }));
|
|
3996
|
+
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"));
|
|
3997
|
+
const { feature: feature2 } = await client2.request("features.addReviews", { feature: id, reviews });
|
|
3998
|
+
if (values.json) return printJson(feature2);
|
|
3999
|
+
printFeature(feature2);
|
|
4000
|
+
return;
|
|
4001
|
+
}
|
|
4002
|
+
if (action === "reorder") {
|
|
4003
|
+
const id = args[1];
|
|
4004
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
4005
|
+
const reviews = args.slice(2).map(featureRef);
|
|
4006
|
+
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"));
|
|
4007
|
+
const { feature: feature2 } = await client2.request("features.reorder", { feature: id, reviews });
|
|
4008
|
+
if (values.json) return printJson(feature2);
|
|
4009
|
+
printFeature(feature2);
|
|
4010
|
+
return;
|
|
4011
|
+
}
|
|
4012
|
+
if (action === "notes") {
|
|
4013
|
+
const id = args[1];
|
|
4014
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
4015
|
+
const { feature: feature2 } = await client2.request("features.get", { feature: id });
|
|
4016
|
+
if (values.json) return printJson(feature2.notes ?? []);
|
|
4017
|
+
for (const note of feature2.notes ?? []) {
|
|
4018
|
+
writers.out(`${note.id} ${note.kind}${note.level ? `/${note.level}` : ""} ${note.author} ${note.title}`);
|
|
4019
|
+
if (note.body) writers.out(` ${note.body}`);
|
|
4020
|
+
}
|
|
4021
|
+
return;
|
|
4022
|
+
}
|
|
4023
|
+
if (action === "note") {
|
|
4024
|
+
const id = args[1];
|
|
4025
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
4026
|
+
const title = typeof values.title === "string" ? values.title : "";
|
|
4027
|
+
const body = typeof values.body === "string" ? values.body : "";
|
|
4028
|
+
if (!title.trim()) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 --title", "pass --title"));
|
|
4029
|
+
const { note } = await client2.request("features.addNote", {
|
|
4030
|
+
feature: id,
|
|
4031
|
+
kind: values.kind === "finding" ? "finding" : "note",
|
|
4032
|
+
...values.level ? { level: String(values.level) } : {},
|
|
4033
|
+
title,
|
|
4034
|
+
body
|
|
4035
|
+
});
|
|
4036
|
+
if (values.json) return printJson(note);
|
|
4037
|
+
writers.out(`${tr("\u0437\u0430\u043C\u0435\u0442\u043A\u0430 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0430", "note added")}: ${note.id}`);
|
|
4038
|
+
return;
|
|
4039
|
+
}
|
|
4040
|
+
if (action === "note-delete") {
|
|
4041
|
+
const id = args[1];
|
|
4042
|
+
const note = args[2];
|
|
4043
|
+
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"));
|
|
4044
|
+
await client2.request("features.deleteNote", { feature: id, note });
|
|
4045
|
+
writers.out(tr("\u0437\u0430\u043C\u0435\u0442\u043A\u0430 \u0443\u0434\u0430\u043B\u0435\u043D\u0430", "note deleted"));
|
|
4046
|
+
return;
|
|
4047
|
+
}
|
|
4048
|
+
if (action === "remove") {
|
|
4049
|
+
const id = args[1];
|
|
4050
|
+
const review = args[2];
|
|
4051
|
+
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"));
|
|
4052
|
+
const { feature: feature2 } = await client2.request("features.removeReview", { feature: id, review: featureRef(review) });
|
|
4053
|
+
if (values.json) return printJson(feature2);
|
|
4054
|
+
printFeature(feature2);
|
|
4055
|
+
return;
|
|
4056
|
+
}
|
|
4057
|
+
if (action === "context") {
|
|
4058
|
+
const id = args[1];
|
|
4059
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
4060
|
+
const result = await client2.request("features.context", {
|
|
4061
|
+
feature: id,
|
|
4062
|
+
...values["max-bytes"] ? { maxBytes: Number(values["max-bytes"]) } : {}
|
|
4063
|
+
});
|
|
4064
|
+
if (values.json) return printJson(result);
|
|
4065
|
+
writers.out(result.markdown);
|
|
4066
|
+
return;
|
|
4067
|
+
}
|
|
4068
|
+
if (action === "update") {
|
|
4069
|
+
const id = args[1];
|
|
4070
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
4071
|
+
const brief = await briefFrom(values);
|
|
4072
|
+
const contract = await textFromFile(typeof values.contract === "string" ? values.contract : void 0, tr("\u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442", "contract"));
|
|
4073
|
+
const patch = {
|
|
4074
|
+
...typeof values.title === "string" ? { title: values.title } : {},
|
|
4075
|
+
...brief !== void 0 ? { brief } : {},
|
|
4076
|
+
...contract !== void 0 ? { contract } : {},
|
|
4077
|
+
...values.status === "open" || values.status === "archived" ? { status: values.status } : {}
|
|
4078
|
+
};
|
|
4079
|
+
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"));
|
|
4080
|
+
const { feature: feature2 } = await client2.request("features.update", { feature: id, ...patch });
|
|
4081
|
+
if (values.json) return printJson(feature2);
|
|
4082
|
+
printFeature(feature2);
|
|
4083
|
+
return;
|
|
4084
|
+
}
|
|
4085
|
+
if (action === "archive") {
|
|
4086
|
+
const id = args[1];
|
|
4087
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
4088
|
+
const { feature: feature2 } = await client2.request("features.update", { feature: id, status: "archived" });
|
|
4089
|
+
if (values.json) return printJson(feature2);
|
|
4090
|
+
writers.out(`${tr("\u0444\u0438\u0447\u0430 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043E\u0432\u0430\u043D\u0430", "feature archived")}: ${feature2.id}`);
|
|
4091
|
+
return;
|
|
4092
|
+
}
|
|
4093
|
+
if (action === "delete") {
|
|
4094
|
+
const id = args[1];
|
|
4095
|
+
if (!id) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 id \u0444\u0438\u0447\u0438", "pass the feature id"));
|
|
4096
|
+
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"));
|
|
4097
|
+
await client2.request("features.delete", { feature: id });
|
|
4098
|
+
writers.out(`${tr("\u0444\u0438\u0447\u0430 \u0443\u0434\u0430\u043B\u0435\u043D\u0430", "feature deleted")}: ${id}`);
|
|
4099
|
+
return;
|
|
4100
|
+
}
|
|
4101
|
+
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")]);
|
|
4102
|
+
});
|
|
4103
|
+
}
|
|
3235
4104
|
async function openReview(root, args, values) {
|
|
3236
4105
|
if (!args.length) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043D\u043E\u043C\u0435\u0440 \u0438\u043B\u0438 \u0441\u0441\u044B\u043B\u043A\u0443 \u043D\u0430 \u0440\u0435\u0432\u044C\u044E", "pass a review number or URL"));
|
|
3237
4106
|
await withClient(async ({ client: client2 }) => {
|
|
@@ -3270,14 +4139,23 @@ async function ui(arg, values) {
|
|
|
3270
4139
|
});
|
|
3271
4140
|
const info = await daemonInfo();
|
|
3272
4141
|
if (!info) fail(tr("\u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D", "the daemon is not running"), "revdeck daemon start");
|
|
4142
|
+
if (!info.token) {
|
|
4143
|
+
fail(
|
|
4144
|
+
tr("UI-\u0442\u043E\u043A\u0435\u043D \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \u0445\u043E\u0441\u0442\u0435: \u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435 \u043E\u043D \u043D\u0435 \u043F\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044F", "the UI token is available on the host only: it is not passed into the container"),
|
|
4145
|
+
tr("\u043E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 `revdeck ui` \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "run `revdeck ui` on the host")
|
|
4146
|
+
);
|
|
4147
|
+
}
|
|
3273
4148
|
const url = `${uiBaseUrl(info)}/?t=${info.token}`;
|
|
3274
4149
|
writers.out(url);
|
|
3275
4150
|
if (values.open) openBrowser(url);
|
|
3276
4151
|
}
|
|
3277
|
-
function printUi(
|
|
4152
|
+
function printUi(reviewId2, values) {
|
|
3278
4153
|
const info = daemonInfoSync();
|
|
3279
4154
|
if (!info) return writers.err(tr("\u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D: revdeck daemon start", "the daemon is not running: revdeck daemon start"));
|
|
3280
|
-
|
|
4155
|
+
if (!info.token) {
|
|
4156
|
+
return writers.err(tr("UI-\u0442\u043E\u043A\u0435\u043D \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \u0445\u043E\u0441\u0442\u0435: \u043E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 `revdeck ui` \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "the UI token is available on the host only: run `revdeck ui` on the host"));
|
|
4157
|
+
}
|
|
4158
|
+
const url = `${uiBaseUrl(info)}/?t=${info.token}${reviewId2 ? `&review=${encodeURIComponent(reviewId2)}` : ""}`;
|
|
3281
4159
|
writers.out(`UI: ${url}`);
|
|
3282
4160
|
if (values.open) openBrowser(url);
|
|
3283
4161
|
}
|
|
@@ -3369,11 +4247,12 @@ async function daemon(action, values = {}) {
|
|
|
3369
4247
|
}
|
|
3370
4248
|
usage(["daemon <start|stop|status|restart|logs|install|uninstall>"]);
|
|
3371
4249
|
}
|
|
3372
|
-
async function status() {
|
|
4250
|
+
async function status(root, values) {
|
|
3373
4251
|
await withClient(async ({ client: client2 }) => {
|
|
3374
|
-
const
|
|
4252
|
+
const params = values.all === true ? {} : { root };
|
|
4253
|
+
const { reviews } = await client2.request("reviews.list", params);
|
|
3375
4254
|
if (!reviews.length) {
|
|
3376
|
-
writers.out(tr("\u0440\u0435\u0432\u044C\u044E \u0435\u0449\u0451 \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0438\u0441\u044C", "no reviews opened yet"));
|
|
4255
|
+
writers.out(tr("\u0432 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0435 \u0440\u0435\u0432\u044C\u044E \u0435\u0449\u0451 \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0438\u0441\u044C", "no reviews opened in this project yet"));
|
|
3377
4256
|
return;
|
|
3378
4257
|
}
|
|
3379
4258
|
for (const item of reviews) writers.out(reviewLine(item));
|
|
@@ -3607,11 +4486,11 @@ async function react(arg, values) {
|
|
|
3607
4486
|
}
|
|
3608
4487
|
async function attach(arg, values) {
|
|
3609
4488
|
if (!values.file) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 --file \u0441 \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u043E\u0439 \u0438\u043B\u0438 \u0432\u0438\u0434\u0435\u043E", "pass --file with an image or video"));
|
|
3610
|
-
const name =
|
|
4489
|
+
const name = path11.basename(String(values.file));
|
|
3611
4490
|
const spec = attachmentSpec(name);
|
|
3612
4491
|
if (!spec) fail(tr("\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B PNG, JPEG, GIF, WebP, AVIF, MP4, WebM, OGV \u0438 MOV", "PNG, JPEG, GIF, WebP, AVIF, MP4, WebM, OGV and MOV are allowed"));
|
|
3613
4492
|
const file = String(values.file);
|
|
3614
|
-
const info = await
|
|
4493
|
+
const info = await stat2(file).catch(() => null);
|
|
3615
4494
|
if (!info?.isFile()) fail(tr(`\u043D\u0435\u0442 \u0444\u0430\u0439\u043B\u0430 ${file}`, `file ${file} does not exist`));
|
|
3616
4495
|
if (info.size > MAX_ATTACHMENT_BYTES) {
|
|
3617
4496
|
fail(tr(`\u0444\u0430\u0439\u043B \u0431\u043E\u043B\u044C\u0448\u0435 ${Math.floor(MAX_ATTACHMENT_BYTES / (1024 * 1024))} \u041C\u0411`, `file is larger than ${Math.floor(MAX_ATTACHMENT_BYTES / (1024 * 1024))} MB`));
|
|
@@ -3649,9 +4528,9 @@ function defaultSelection2(review, kind) {
|
|
|
3649
4528
|
}
|
|
3650
4529
|
return review.notes.filter((note) => !note.posted).map((note) => note.id);
|
|
3651
4530
|
}
|
|
3652
|
-
async function publishSelection(client2,
|
|
4531
|
+
async function publishSelection(client2, reviewId2, kind, ids, values) {
|
|
3653
4532
|
const { preview } = await client2.request("publish.preview", {
|
|
3654
|
-
review:
|
|
4533
|
+
review: reviewId2,
|
|
3655
4534
|
kind,
|
|
3656
4535
|
ids
|
|
3657
4536
|
});
|
|
@@ -3673,13 +4552,13 @@ async function publishSelection(client2, reviewId, kind, ids, values) {
|
|
|
3673
4552
|
return;
|
|
3674
4553
|
}
|
|
3675
4554
|
const { approval } = await client2.request("publish.approve", {
|
|
3676
|
-
review:
|
|
4555
|
+
review: reviewId2,
|
|
3677
4556
|
kind,
|
|
3678
4557
|
ids,
|
|
3679
4558
|
hash: preview.plan.hash
|
|
3680
4559
|
});
|
|
3681
4560
|
const { result } = await client2.request("publish.commit", {
|
|
3682
|
-
review:
|
|
4561
|
+
review: reviewId2,
|
|
3683
4562
|
approvalId: approval.id
|
|
3684
4563
|
});
|
|
3685
4564
|
for (const item of result.results) {
|
|
@@ -3712,6 +4591,18 @@ async function checks(root, arg, values) {
|
|
|
3712
4591
|
await withClient(async ({ client: client2 }) => {
|
|
3713
4592
|
const { review } = await resolveReview(client2, root, reviewArg(values, arg), values);
|
|
3714
4593
|
if (values.run && !values.yes) fail(tr("\u0437\u0430\u043F\u0443\u0441\u043A \u043F\u0440\u043E\u0432\u0435\u0440\u043E\u043A \u043C\u0435\u043D\u044F\u0435\u0442 \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u0435: \u0434\u043E\u0431\u0430\u0432\u044C\u0442\u0435 --yes, \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C", "running checks changes the environment: add --yes to confirm"));
|
|
4594
|
+
if (!values.json) {
|
|
4595
|
+
const { rules: plan } = await client2.request("rules.get", {
|
|
4596
|
+
review: review.id
|
|
4597
|
+
});
|
|
4598
|
+
const ids = values.ids ? parseList(values.ids) : null;
|
|
4599
|
+
const selected = plan.checks.filter((check) => ids ? ids.includes(check.id) : check.matched);
|
|
4600
|
+
if (selected.length) {
|
|
4601
|
+
writers.out(tr("\u041A\u043E\u043C\u0430\u043D\u0434\u044B \u043F\u0440\u043E\u0432\u0435\u0440\u043E\u043A:", "Check commands:"));
|
|
4602
|
+
for (const check of selected) writers.out(` ${check.id}: ${check.argv.join(" ")}`);
|
|
4603
|
+
writers.out("");
|
|
4604
|
+
}
|
|
4605
|
+
}
|
|
3715
4606
|
const { results } = await client2.request("checks.run", {
|
|
3716
4607
|
review: review.id,
|
|
3717
4608
|
allowRun: values.run === true && values.yes === true,
|
|
@@ -3827,8 +4718,8 @@ async function doctor(root) {
|
|
|
3827
4718
|
]);
|
|
3828
4719
|
}
|
|
3829
4720
|
}
|
|
3830
|
-
const { existsSync:
|
|
3831
|
-
const skill =
|
|
4721
|
+
const { existsSync: existsSync9 } = await import("node:fs");
|
|
4722
|
+
const skill = existsSync9(path11.join(root, ".agents", "skills", "revdeck", "SKILL.md")) || existsSync9(path11.join(root, ".claude", "skills", "revdeck", "SKILL.md")) || existsSync9(path11.join(root, ".cursor", "commands", "revdeck.md"));
|
|
3832
4723
|
rows.push(["adapter", skill ? "ok" : "warn", skill ? tr("\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D", "installed") : tr("\u043D\u0435\u0442: revdeck init", "missing: revdeck init")]);
|
|
3833
4724
|
for (const [name, status2, detail] of rows) {
|
|
3834
4725
|
writers.out(`${status2 === "ok" ? "\u2714" : status2 === "warn" ? "!" : "\u2716"} ${name.padEnd(10)} ${detail}`);
|