revdeck 0.6.0 → 0.8.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 +66 -1
- package/CONTRIBUTING.md +5 -1
- package/README.md +57 -17
- package/README.ru.md +59 -21
- package/SECURITY.md +1 -1
- package/dist/cli.js +485 -263
- package/dist/cli.js.map +4 -4
- package/dist/daemon.js +428 -121
- package/dist/daemon.js.map +4 -4
- package/dist/mcp.js +76 -28
- 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 +3 -0
- package/docs/architecture.md +10 -6
- 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 +23 -11
- package/docs/configuration.md +25 -8
- package/docs/integrations.md +30 -16
- package/docs/protocol.md +34 -13
- package/docs/ru/README.md +3 -0
- package/docs/ru/architecture.md +10 -6
- package/docs/ru/capabilities.md +24 -10
- package/docs/ru/configuration.md +21 -6
- package/docs/ru/integrations.md +29 -16
- package/docs/ru/protocol.md +33 -12
- package/docs/ru/threat-model.md +6 -5
- package/docs/threat-model.md +10 -8
- package/package.json +5 -2
- package/skills/revdeck/en/Feedback.md +3 -2
- package/skills/revdeck/en/Review.md +3 -2
- package/skills/revdeck/ru/Feedback.md +3 -2
- package/skills/revdeck/ru/Review.md +2 -2
- package/dist/ui/assets/index-BH0dNFhd.css +0 -1
- package/dist/ui/assets/index-Wz1DYbiv.js +0 -14
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ var __esm = (fn, res, err) => function __init() {
|
|
|
11
11
|
|
|
12
12
|
// src/core/paths.ts
|
|
13
13
|
import { constants, existsSync } from "node:fs";
|
|
14
|
-
import { lstat, mkdir, open, realpath, rename, unlink } from "node:fs/promises";
|
|
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";
|
|
@@ -24,6 +24,15 @@ function findRepoRoot(start = process.cwd()) {
|
|
|
24
24
|
dir = parent;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
function toHostRoot(root, hostRoot = process.env.REVDECK_HOST_ROOT, containerRoot = findRepoRoot()) {
|
|
28
|
+
const resolved = path.resolve(root);
|
|
29
|
+
const target = hostRoot?.trim();
|
|
30
|
+
if (!target) return resolved;
|
|
31
|
+
const relative = path.relative(path.resolve(containerRoot), resolved);
|
|
32
|
+
if (relative === "") return path.resolve(target);
|
|
33
|
+
if (relative.startsWith("..") || path.isAbsolute(relative)) return resolved;
|
|
34
|
+
return path.join(path.resolve(target), relative);
|
|
35
|
+
}
|
|
27
36
|
function findConfigFile(root) {
|
|
28
37
|
for (const name of CONFIG_FILES) {
|
|
29
38
|
const candidate = path.join(root, name);
|
|
@@ -96,13 +105,41 @@ async function readTextNoFollow(file, maxBytes = 4 * 1024 * 1024) {
|
|
|
96
105
|
await handle.close();
|
|
97
106
|
}
|
|
98
107
|
}
|
|
99
|
-
async function
|
|
108
|
+
async function openInsideRoot(root, target) {
|
|
109
|
+
const resolvedTarget = path.resolve(target);
|
|
100
110
|
const realRoot = await realpath(path.resolve(root));
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
111
|
+
let handle;
|
|
112
|
+
try {
|
|
113
|
+
handle = await open(resolvedTarget, process.platform === "win32" ? "r" : constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (error.code === "ELOOP") {
|
|
116
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
117
|
+
}
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const info = await handle.stat();
|
|
122
|
+
if (!info.isFile()) throw new Error(`${path.basename(target)}: not a regular file`);
|
|
123
|
+
if (process.platform === "linux") {
|
|
124
|
+
const actual = await realpath(`/proc/self/fd/${handle.fd}`);
|
|
125
|
+
if (!isInside(realRoot, actual)) {
|
|
126
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
const actual = await realpath(resolvedTarget);
|
|
130
|
+
if (!isInside(realRoot, actual)) {
|
|
131
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
132
|
+
}
|
|
133
|
+
const onDisk = await stat(actual);
|
|
134
|
+
if (onDisk.dev !== info.dev || onDisk.ino !== info.ino) {
|
|
135
|
+
throw new Error(`${path.basename(target)}: path changed during read`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return handle;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
await handle.close();
|
|
141
|
+
throw error;
|
|
104
142
|
}
|
|
105
|
-
return realTarget;
|
|
106
143
|
}
|
|
107
144
|
function packageRoot() {
|
|
108
145
|
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -197,8 +234,8 @@ function globToRegExp(glob) {
|
|
|
197
234
|
function escapeRegExp(value) {
|
|
198
235
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
199
236
|
}
|
|
200
|
-
function classifyFile(
|
|
201
|
-
const lower =
|
|
237
|
+
function classifyFile(path12) {
|
|
238
|
+
const lower = path12.toLowerCase();
|
|
202
239
|
if (/(^|\/)(node_modules|dist|build|coverage|vendor)\//.test(lower)) return "generated";
|
|
203
240
|
if (/\.(md|mdx|rst|txt|adoc)$/.test(lower) || /(^|\/)(docs?|adr)\//.test(lower)) return "docs";
|
|
204
241
|
if (/(^|\/)(__tests__|tests?|spec|e2e)\//.test(lower) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /_test\.go$/.test(lower)) return "test";
|
|
@@ -382,11 +419,138 @@ var init_review_roles = __esm({
|
|
|
382
419
|
}
|
|
383
420
|
});
|
|
384
421
|
|
|
422
|
+
// src/core/exec.ts
|
|
423
|
+
import { execFile } from "node:child_process";
|
|
424
|
+
import { access, constants as constants2 } from "node:fs/promises";
|
|
425
|
+
import os2 from "node:os";
|
|
426
|
+
import path2 from "node:path";
|
|
427
|
+
function scrubEnv(extra) {
|
|
428
|
+
const env = {};
|
|
429
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
430
|
+
if (SECRET_ENV.includes(key)) continue;
|
|
431
|
+
env[key] = value;
|
|
432
|
+
}
|
|
433
|
+
env.PAGER = "cat";
|
|
434
|
+
env.GIT_PAGER = "cat";
|
|
435
|
+
env.GIT_TERMINAL_PROMPT = "0";
|
|
436
|
+
env.NO_COLOR = "1";
|
|
437
|
+
env.CLICOLOR = "0";
|
|
438
|
+
env.FORCE_COLOR = "0";
|
|
439
|
+
env.TERM = "dumb";
|
|
440
|
+
return { ...env, ...extra };
|
|
441
|
+
}
|
|
442
|
+
async function resolveExecutable(command) {
|
|
443
|
+
if (command.includes("/") || command.includes("\\")) {
|
|
444
|
+
try {
|
|
445
|
+
await access(command, constants2.X_OK);
|
|
446
|
+
return command;
|
|
447
|
+
} catch {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
const override = process.env[`REVDECK_${command.toUpperCase()}`];
|
|
452
|
+
if (override) return override;
|
|
453
|
+
const cached = RESOLVED.get(command);
|
|
454
|
+
if (cached) return cached;
|
|
455
|
+
const dirs = [
|
|
456
|
+
...(process.env.PATH ?? "").split(path2.delimiter),
|
|
457
|
+
path2.join(os2.homedir(), ".local", "bin"),
|
|
458
|
+
path2.join(os2.homedir(), ".local", "share", "mise", "shims"),
|
|
459
|
+
path2.join(os2.homedir(), ".asdf", "shims"),
|
|
460
|
+
path2.join(os2.homedir(), ".npm-global", "bin"),
|
|
461
|
+
"/opt/homebrew/bin",
|
|
462
|
+
"/usr/local/bin",
|
|
463
|
+
"/usr/bin",
|
|
464
|
+
"/bin"
|
|
465
|
+
].filter(Boolean);
|
|
466
|
+
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
467
|
+
for (const dir of [...new Set(dirs)]) {
|
|
468
|
+
for (const extension of extensions) {
|
|
469
|
+
const candidate = path2.join(dir, `${command}${extension}`);
|
|
470
|
+
try {
|
|
471
|
+
await access(candidate, constants2.X_OK);
|
|
472
|
+
RESOLVED.set(command, candidate);
|
|
473
|
+
return candidate;
|
|
474
|
+
} catch {
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return null;
|
|
479
|
+
}
|
|
480
|
+
var SECRET_ENV, RESOLVED, run;
|
|
481
|
+
var init_exec = __esm({
|
|
482
|
+
"src/core/exec.ts"() {
|
|
483
|
+
"use strict";
|
|
484
|
+
SECRET_ENV = [
|
|
485
|
+
"GITLAB_TOKEN",
|
|
486
|
+
"GITLAB_PRIVATE_TOKEN",
|
|
487
|
+
"GLAB_TOKEN",
|
|
488
|
+
"CI_JOB_TOKEN",
|
|
489
|
+
"GH_TOKEN",
|
|
490
|
+
"GITHUB_TOKEN",
|
|
491
|
+
"GITHUB_ENTERPRISE_TOKEN",
|
|
492
|
+
"GIT_ASKPASS",
|
|
493
|
+
"SSH_ASKPASS",
|
|
494
|
+
"REVDECK_TOKEN"
|
|
495
|
+
];
|
|
496
|
+
RESOLVED = /* @__PURE__ */ new Map();
|
|
497
|
+
run = async (command, args, options = {}) => {
|
|
498
|
+
const executable = await resolveExecutable(command) ?? command;
|
|
499
|
+
return new Promise((resolve, reject) => {
|
|
500
|
+
const child = execFile(
|
|
501
|
+
executable,
|
|
502
|
+
args,
|
|
503
|
+
{
|
|
504
|
+
cwd: options.cwd,
|
|
505
|
+
env: scrubEnv(options.env),
|
|
506
|
+
timeout: options.timeoutMs ?? 12e4,
|
|
507
|
+
maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
|
|
508
|
+
encoding: "utf8",
|
|
509
|
+
windowsHide: true,
|
|
510
|
+
shell: false
|
|
511
|
+
},
|
|
512
|
+
(error, stdout, stderr) => {
|
|
513
|
+
const exitCode = error?.code;
|
|
514
|
+
const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
|
|
515
|
+
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
516
|
+
const reason = (stderr || stdout || error.message).trim();
|
|
517
|
+
reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
resolve({ stdout, stderr, code });
|
|
521
|
+
}
|
|
522
|
+
);
|
|
523
|
+
if (options.input !== void 0) {
|
|
524
|
+
child.stdin?.end(options.input);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// src/core/git-files.ts
|
|
532
|
+
async function gitTrackState(root, relative) {
|
|
533
|
+
try {
|
|
534
|
+
const { stdout } = await run("git", ["-C", root, "ls-files", "--error-unmatch", "--", relative], {
|
|
535
|
+
timeoutMs: 1e4
|
|
536
|
+
});
|
|
537
|
+
return stdout.trim() ? "tracked" : "unknown";
|
|
538
|
+
} catch (error) {
|
|
539
|
+
return error.code === 1 ? "untracked" : "unknown";
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
var init_git_files = __esm({
|
|
543
|
+
"src/core/git-files.ts"() {
|
|
544
|
+
"use strict";
|
|
545
|
+
init_exec();
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
|
|
385
549
|
// src/core/config.ts
|
|
386
550
|
import { z } from "zod";
|
|
387
551
|
import { parse as parseYaml } from "yaml";
|
|
388
552
|
import { existsSync as existsSync2 } from "node:fs";
|
|
389
|
-
import
|
|
553
|
+
import path3 from "node:path";
|
|
390
554
|
function isRecord(value) {
|
|
391
555
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
392
556
|
}
|
|
@@ -408,10 +572,30 @@ function mergeConfigData(base, local) {
|
|
|
408
572
|
}
|
|
409
573
|
async function loadConfig(root = findRepoRoot()) {
|
|
410
574
|
const warnings = [];
|
|
575
|
+
if (!existsSync2(root)) {
|
|
576
|
+
warnings.push(
|
|
577
|
+
tr(
|
|
578
|
+
`\u043A\u0430\u0442\u0430\u043B\u043E\u0433 ${root} \u043D\u0435 \u0432\u0438\u0434\u0435\u043D \u0442\u043E\u043C\u0443, \u043A\u0442\u043E \u0447\u0438\u0442\u0430\u0435\u0442 \u043A\u043E\u043D\u0444\u0438\u0433: \u0432 devcontainer \u0434\u0435\u043C\u043E\u043D \u043D\u0430 \u0445\u043E\u0441\u0442\u0435 \u043D\u0435 \u0432\u0438\u0434\u0438\u0442 \u043F\u0443\u0442\u044C \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0430 \u2014 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 revdeck devcontainer --write \u0438\u043B\u0438 \u0437\u0430\u0434\u0430\u0439\u0442\u0435 REVDECK_HOST_ROOT`,
|
|
579
|
+
`the directory ${root} is not visible to the config reader: in a devcontainer the host daemon cannot see the container path \u2014 run revdeck devcontainer --write or set REVDECK_HOST_ROOT`
|
|
580
|
+
)
|
|
581
|
+
);
|
|
582
|
+
}
|
|
411
583
|
const file = findConfigFile(root);
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
584
|
+
let localFile = findLocalConfigFile(root);
|
|
585
|
+
if (localFile && existsSync2(path3.join(root, ".git"))) {
|
|
586
|
+
const state = await gitTrackState(root, path3.relative(root, localFile));
|
|
587
|
+
if (state !== "untracked") {
|
|
588
|
+
warnings.push(
|
|
589
|
+
tr(
|
|
590
|
+
".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",
|
|
591
|
+
".revdeck.local.yml is tracked by git: a repository file is ignored as personal overrides"
|
|
592
|
+
)
|
|
593
|
+
);
|
|
594
|
+
localFile = null;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
const baseData = file ? parseYamlData(await readTextNoFollow(file), path3.relative(root, file) || file) : {};
|
|
598
|
+
const localData = localFile ? parseYamlData(await readTextNoFollow(localFile), path3.relative(root, localFile) || localFile) : {};
|
|
415
599
|
if (!file && !localFile) {
|
|
416
600
|
warnings.push(tr("\u0444\u0430\u0439\u043B .revdeck.yml \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u043F\u0440\u0430\u0432\u0438\u043B\u0430 \u0432\u0437\u044F\u0442\u044B \u0438\u0437 \u0430\u0432\u0442\u043E\u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432", ".revdeck.yml not found: rules come from auto-discovered documents"));
|
|
417
601
|
}
|
|
@@ -421,7 +605,7 @@ async function loadConfig(root = findRepoRoot()) {
|
|
|
421
605
|
const localReadOnly = isRecord(localData) && isRecord(localData.review) && localData.review.readOnly === true;
|
|
422
606
|
config2.review.readOnly = baseReadOnly || localReadOnly;
|
|
423
607
|
if (!config2.rules.sources.length && !config2.rules.map.length) {
|
|
424
|
-
const found = DISCOVERED_SOURCES.filter((item) => existsSync2(
|
|
608
|
+
const found = DISCOVERED_SOURCES.filter((item) => existsSync2(path3.join(root, item)));
|
|
425
609
|
config2.rules.sources = found;
|
|
426
610
|
if (!found.length) {
|
|
427
611
|
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"));
|
|
@@ -436,17 +620,24 @@ async function loadConfig(root = findRepoRoot()) {
|
|
|
436
620
|
}
|
|
437
621
|
function assertConfigPath(root, relative) {
|
|
438
622
|
const cleaned = relative.split("#")[0];
|
|
439
|
-
const resolved =
|
|
440
|
-
const rel =
|
|
441
|
-
if (rel.startsWith("..") ||
|
|
623
|
+
const resolved = path3.resolve(root, cleaned);
|
|
624
|
+
const rel = path3.relative(root, resolved);
|
|
625
|
+
if (rel.startsWith("..") || path3.isAbsolute(rel)) {
|
|
442
626
|
throw new ConfigError(tr(`\u043F\u0443\u0442\u044C ${relative} \u0432\u044B\u0445\u043E\u0434\u0438\u0442 \u0437\u0430 \u043F\u0440\u0435\u0434\u0435\u043B\u044B \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F`, `path ${relative} escapes the repository`));
|
|
443
627
|
}
|
|
444
628
|
return resolved;
|
|
445
629
|
}
|
|
446
630
|
async function readConfigFile(root, relative, maxBytes = 4 * 1024 * 1024) {
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
631
|
+
const handle = await openInsideRoot(root, assertConfigPath(root, relative));
|
|
632
|
+
try {
|
|
633
|
+
const info = await handle.stat();
|
|
634
|
+
if (info.size > maxBytes) {
|
|
635
|
+
throw new Error(`${path3.basename(relative)}: file is larger than ${Math.round(maxBytes / 1024)} KB`);
|
|
636
|
+
}
|
|
637
|
+
return await handle.readFile({ encoding: "utf8" });
|
|
638
|
+
} finally {
|
|
639
|
+
await handle.close();
|
|
640
|
+
}
|
|
450
641
|
}
|
|
451
642
|
function checksForPaths(config2, paths) {
|
|
452
643
|
return config2.checks.map((check) => {
|
|
@@ -463,6 +654,7 @@ var init_config = __esm({
|
|
|
463
654
|
init_glob();
|
|
464
655
|
init_locale();
|
|
465
656
|
init_review_roles();
|
|
657
|
+
init_git_files();
|
|
466
658
|
matchSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
467
659
|
customRoleSchema = z.object({
|
|
468
660
|
title: z.string().min(1).max(120),
|
|
@@ -616,16 +808,16 @@ var VERSION;
|
|
|
616
808
|
var init_version = __esm({
|
|
617
809
|
"src/version.ts"() {
|
|
618
810
|
"use strict";
|
|
619
|
-
VERSION = "0.
|
|
811
|
+
VERSION = "0.8.0";
|
|
620
812
|
}
|
|
621
813
|
});
|
|
622
814
|
|
|
623
815
|
// src/client.ts
|
|
624
816
|
import net from "node:net";
|
|
625
817
|
import { spawn } from "node:child_process";
|
|
626
|
-
import { existsSync as
|
|
818
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
627
819
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
628
|
-
import
|
|
820
|
+
import path6 from "node:path";
|
|
629
821
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
630
822
|
async function connectSocket(file = socketPath(), timeoutMs = 1500) {
|
|
631
823
|
return new Promise((resolve, reject) => {
|
|
@@ -664,16 +856,17 @@ function devcontainerHint() {
|
|
|
664
856
|
return [
|
|
665
857
|
"\u0434\u0435\u043C\u043E\u043D revdeck \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u043D\u0430 \u0445\u043E\u0441\u0442\u0435",
|
|
666
858
|
"\u043D\u0430 \u0445\u043E\u0441\u0442\u0435: revdeck daemon start",
|
|
667
|
-
`\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435
|
|
859
|
+
`\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 mount \u0441\u043E\u043A\u0435\u0442\u0430 \u0438\u0437 revdeck devcontainer --write: ${runtime} (state: ${state})`,
|
|
860
|
+
"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",
|
|
668
861
|
"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"
|
|
669
862
|
].join("; ");
|
|
670
863
|
}
|
|
671
864
|
async function devcontainerHttpClient() {
|
|
672
865
|
const { info, error } = await daemonInfoRead();
|
|
673
866
|
if (!info) return { client: null, error: `${daemonInfoPath()}: ${error}` };
|
|
674
|
-
if (!info.port || !info.
|
|
867
|
+
if (!info.port || !info.agentToken) return { client: null, error: `${daemonInfoPath()}: \u043D\u0435\u0442 port/agentToken` };
|
|
675
868
|
const host = process.env.REVDECK_UI_HOST ?? "host.docker.internal";
|
|
676
|
-
return { client: new HttpClient(`http://${host}:${info.port}`, info.
|
|
869
|
+
return { client: new HttpClient(`http://${host}:${info.port}`, info.agentToken), error: "" };
|
|
677
870
|
}
|
|
678
871
|
async function ensureDaemon(options = {}) {
|
|
679
872
|
const url = process.env.REVDECK_URL;
|
|
@@ -695,11 +888,11 @@ async function ensureDaemon(options = {}) {
|
|
|
695
888
|
throw new RpcError(
|
|
696
889
|
`devcontainer HTTP: ${httpError.message}`,
|
|
697
890
|
"DEVCONTAINER",
|
|
698
|
-
"\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; \
|
|
891
|
+
"\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"
|
|
699
892
|
);
|
|
700
893
|
}
|
|
701
894
|
}
|
|
702
|
-
throw new RpcError(`devcontainer: ${http.error || devcontainerHint()}`, "DEVCONTAINER", "\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \
|
|
895
|
+
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");
|
|
703
896
|
}
|
|
704
897
|
if (options.autoStart === false) throw error;
|
|
705
898
|
}
|
|
@@ -732,15 +925,15 @@ async function spawnDaemon(extraArgs = []) {
|
|
|
732
925
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
733
926
|
}
|
|
734
927
|
function daemonEntry() {
|
|
735
|
-
const here =
|
|
736
|
-
const built =
|
|
737
|
-
if (
|
|
738
|
-
const source =
|
|
739
|
-
if (
|
|
928
|
+
const here = path6.dirname(fileURLToPath2(import.meta.url));
|
|
929
|
+
const built = path6.join(here, "daemon.js");
|
|
930
|
+
if (existsSync5(built)) return { command: process.execPath, args: [built] };
|
|
931
|
+
const source = path6.join(here, "daemon", "main.ts");
|
|
932
|
+
if (existsSync5(source)) {
|
|
740
933
|
return { command: process.execPath, args: ["--import", "tsx", source] };
|
|
741
934
|
}
|
|
742
|
-
const sibling =
|
|
743
|
-
if (
|
|
935
|
+
const sibling = path6.join(here, "..", "dist", "daemon.js");
|
|
936
|
+
if (existsSync5(sibling)) return { command: process.execPath, args: [sibling] };
|
|
744
937
|
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");
|
|
745
938
|
}
|
|
746
939
|
function uiBaseUrl(info) {
|
|
@@ -866,115 +1059,6 @@ var init_client = __esm({
|
|
|
866
1059
|
}
|
|
867
1060
|
});
|
|
868
1061
|
|
|
869
|
-
// src/core/exec.ts
|
|
870
|
-
import { execFile } from "node:child_process";
|
|
871
|
-
import { access, constants as constants2 } from "node:fs/promises";
|
|
872
|
-
import os2 from "node:os";
|
|
873
|
-
import path5 from "node:path";
|
|
874
|
-
function scrubEnv(extra) {
|
|
875
|
-
const env = {};
|
|
876
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
877
|
-
if (SECRET_ENV.includes(key)) continue;
|
|
878
|
-
env[key] = value;
|
|
879
|
-
}
|
|
880
|
-
env.PAGER = "cat";
|
|
881
|
-
env.GIT_PAGER = "cat";
|
|
882
|
-
env.GIT_TERMINAL_PROMPT = "0";
|
|
883
|
-
env.NO_COLOR = "1";
|
|
884
|
-
env.CLICOLOR = "0";
|
|
885
|
-
env.FORCE_COLOR = "0";
|
|
886
|
-
env.TERM = "dumb";
|
|
887
|
-
return { ...env, ...extra };
|
|
888
|
-
}
|
|
889
|
-
async function resolveExecutable(command) {
|
|
890
|
-
if (command.includes("/") || command.includes("\\")) {
|
|
891
|
-
try {
|
|
892
|
-
await access(command, constants2.X_OK);
|
|
893
|
-
return command;
|
|
894
|
-
} catch {
|
|
895
|
-
return null;
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
const override = process.env[`REVDECK_${command.toUpperCase()}`];
|
|
899
|
-
if (override) return override;
|
|
900
|
-
const cached = RESOLVED.get(command);
|
|
901
|
-
if (cached) return cached;
|
|
902
|
-
const dirs = [
|
|
903
|
-
...(process.env.PATH ?? "").split(path5.delimiter),
|
|
904
|
-
path5.join(os2.homedir(), ".local", "bin"),
|
|
905
|
-
path5.join(os2.homedir(), ".local", "share", "mise", "shims"),
|
|
906
|
-
path5.join(os2.homedir(), ".asdf", "shims"),
|
|
907
|
-
path5.join(os2.homedir(), ".npm-global", "bin"),
|
|
908
|
-
"/opt/homebrew/bin",
|
|
909
|
-
"/usr/local/bin",
|
|
910
|
-
"/usr/bin",
|
|
911
|
-
"/bin"
|
|
912
|
-
].filter(Boolean);
|
|
913
|
-
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
914
|
-
for (const dir of [...new Set(dirs)]) {
|
|
915
|
-
for (const extension of extensions) {
|
|
916
|
-
const candidate = path5.join(dir, `${command}${extension}`);
|
|
917
|
-
try {
|
|
918
|
-
await access(candidate, constants2.X_OK);
|
|
919
|
-
RESOLVED.set(command, candidate);
|
|
920
|
-
return candidate;
|
|
921
|
-
} catch {
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
return null;
|
|
926
|
-
}
|
|
927
|
-
var SECRET_ENV, RESOLVED, run;
|
|
928
|
-
var init_exec = __esm({
|
|
929
|
-
"src/core/exec.ts"() {
|
|
930
|
-
"use strict";
|
|
931
|
-
SECRET_ENV = [
|
|
932
|
-
"GITLAB_TOKEN",
|
|
933
|
-
"GITLAB_PRIVATE_TOKEN",
|
|
934
|
-
"GLAB_TOKEN",
|
|
935
|
-
"CI_JOB_TOKEN",
|
|
936
|
-
"GH_TOKEN",
|
|
937
|
-
"GITHUB_TOKEN",
|
|
938
|
-
"GITHUB_ENTERPRISE_TOKEN",
|
|
939
|
-
"GIT_ASKPASS",
|
|
940
|
-
"SSH_ASKPASS",
|
|
941
|
-
"REVDECK_TOKEN"
|
|
942
|
-
];
|
|
943
|
-
RESOLVED = /* @__PURE__ */ new Map();
|
|
944
|
-
run = async (command, args, options = {}) => {
|
|
945
|
-
const executable = await resolveExecutable(command) ?? command;
|
|
946
|
-
return new Promise((resolve, reject) => {
|
|
947
|
-
const child = execFile(
|
|
948
|
-
executable,
|
|
949
|
-
args,
|
|
950
|
-
{
|
|
951
|
-
cwd: options.cwd,
|
|
952
|
-
env: scrubEnv(options.env),
|
|
953
|
-
timeout: options.timeoutMs ?? 12e4,
|
|
954
|
-
maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
|
|
955
|
-
encoding: "utf8",
|
|
956
|
-
windowsHide: true,
|
|
957
|
-
shell: false
|
|
958
|
-
},
|
|
959
|
-
(error, stdout, stderr) => {
|
|
960
|
-
const exitCode = error?.code;
|
|
961
|
-
const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
|
|
962
|
-
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
963
|
-
const reason = (stderr || stdout || error.message).trim();
|
|
964
|
-
reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
resolve({ stdout, stderr, code });
|
|
968
|
-
}
|
|
969
|
-
);
|
|
970
|
-
if (options.input !== void 0) {
|
|
971
|
-
child.stdin?.end(options.input);
|
|
972
|
-
}
|
|
973
|
-
});
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
});
|
|
977
|
-
|
|
978
1062
|
// src/core/git.ts
|
|
979
1063
|
function parseRemote(url) {
|
|
980
1064
|
const value = url.trim();
|
|
@@ -1477,6 +1561,9 @@ var main_exports = {};
|
|
|
1477
1561
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1478
1562
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
1479
1563
|
import { z as z2 } from "zod";
|
|
1564
|
+
function daemonRoot(root) {
|
|
1565
|
+
return toHostRoot(root, process.env.REVDECK_HOST_ROOT, defaultRoot);
|
|
1566
|
+
}
|
|
1480
1567
|
async function client() {
|
|
1481
1568
|
if (!clientPromise) clientPromise = ensureDaemon().then((result) => result.client);
|
|
1482
1569
|
return clientPromise;
|
|
@@ -1666,7 +1753,7 @@ var init_main = __esm({
|
|
|
1666
1753
|
}
|
|
1667
1754
|
const result = await call(
|
|
1668
1755
|
"reviews.remoteList",
|
|
1669
|
-
{ root: current2.root, scope: listScope, limit: limit ?? 50 }
|
|
1756
|
+
{ root: daemonRoot(current2.root), scope: listScope, limit: limit ?? 50 }
|
|
1670
1757
|
);
|
|
1671
1758
|
const text = result.items.map((item) => `#${item.ref.number} ${item.title} \xB7 ${item.author} \xB7 ${item.updatedAt}`).join("\n") || "Empty.";
|
|
1672
1759
|
return ok(`${result.platform}:${result.project}
|
|
@@ -1703,7 +1790,7 @@ ${text}`, result);
|
|
|
1703
1790
|
continue;
|
|
1704
1791
|
}
|
|
1705
1792
|
const result = await call("reviews.open", {
|
|
1706
|
-
root: current2.root,
|
|
1793
|
+
root: daemonRoot(current2.root),
|
|
1707
1794
|
input: value
|
|
1708
1795
|
});
|
|
1709
1796
|
reviews.push(result.review);
|
|
@@ -2243,17 +2330,52 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
|
|
|
2243
2330
|
// src/cli/main.ts
|
|
2244
2331
|
init_paths();
|
|
2245
2332
|
init_config();
|
|
2246
|
-
import { readFile as readFile7, stat } from "node:fs/promises";
|
|
2333
|
+
import { readFile as readFile7, stat as stat2 } from "node:fs/promises";
|
|
2247
2334
|
import { readFileSync } from "node:fs";
|
|
2248
2335
|
import { parseArgs } from "node:util";
|
|
2249
|
-
import
|
|
2336
|
+
import path11 from "node:path";
|
|
2250
2337
|
|
|
2251
2338
|
// src/core/rules.ts
|
|
2252
2339
|
init_config();
|
|
2340
|
+
import path5 from "node:path";
|
|
2341
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
2342
|
+
|
|
2343
|
+
// src/core/doc-policy.ts
|
|
2344
|
+
init_config();
|
|
2345
|
+
init_errors();
|
|
2346
|
+
init_git_files();
|
|
2347
|
+
init_locale();
|
|
2348
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
2349
|
+
import path4 from "node:path";
|
|
2350
|
+
var DOC_EXTENSION = /\.(md|mdx|rst|txt|adoc)$/i;
|
|
2351
|
+
var PROFILE_EXTENSION = /\.(md|mdx|rst|txt|adoc|ya?ml|json)$/i;
|
|
2352
|
+
var SECRET_PATH = /(^|\/)(\.env(\..*)?|\.npmrc|\.git(\/.*)?|\.revdeck\.local\.(ya?ml)|id_(rsa|ed25519|ecdsa)(\.pub)?|.*\.(pem|key|p12|pfx|jks|keystore|tfvars|tfstate))$/i;
|
|
2353
|
+
async function assertSafeDocument(root, relative, kind = "rules") {
|
|
2354
|
+
const clean = relative.split("#")[0];
|
|
2355
|
+
const resolved = assertConfigPath(root, clean);
|
|
2356
|
+
if (SECRET_PATH.test(clean)) {
|
|
2357
|
+
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`));
|
|
2358
|
+
}
|
|
2359
|
+
if (!(kind === "profile" ? PROFILE_EXTENSION : DOC_EXTENSION).test(clean)) {
|
|
2360
|
+
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`));
|
|
2361
|
+
}
|
|
2362
|
+
if (existsSync3(path4.join(root, ".git"))) {
|
|
2363
|
+
const state = await gitTrackState(root, clean);
|
|
2364
|
+
if (state !== "tracked") {
|
|
2365
|
+
throw new ConfigError(
|
|
2366
|
+
tr(
|
|
2367
|
+
`${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)`,
|
|
2368
|
+
`${relative}: document is not tracked by git (or git is unavailable)`
|
|
2369
|
+
)
|
|
2370
|
+
);
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
return resolved;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
// src/core/rules.ts
|
|
2253
2377
|
init_glob();
|
|
2254
2378
|
init_redact();
|
|
2255
|
-
import path3 from "node:path";
|
|
2256
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
2257
2379
|
var MAX_READ_BYTES = 16 * 1024 * 1024;
|
|
2258
2380
|
async function buildEffectiveRules(options) {
|
|
2259
2381
|
const { root, config: config2, configPath } = options;
|
|
@@ -2272,14 +2394,14 @@ async function buildEffectiveRules(options) {
|
|
|
2272
2394
|
const relative = rawPath;
|
|
2273
2395
|
let resolved;
|
|
2274
2396
|
try {
|
|
2275
|
-
resolved =
|
|
2397
|
+
resolved = await assertSafeDocument(root, relative, "rules");
|
|
2276
2398
|
} catch (error) {
|
|
2277
|
-
warnings.push(
|
|
2399
|
+
warnings.push(error.message);
|
|
2278
2400
|
return { path: relative, exists: false, sections: [], excerpt: "", truncated: false };
|
|
2279
2401
|
}
|
|
2280
2402
|
let cached = cache.get(resolved);
|
|
2281
2403
|
if (!cached) {
|
|
2282
|
-
if (!
|
|
2404
|
+
if (!existsSync4(resolved)) {
|
|
2283
2405
|
cached = { exists: false, text: "", truncated: false };
|
|
2284
2406
|
warnings.push(`${t("\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442", "document")} ${relative} ${t("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D", "not found")}`);
|
|
2285
2407
|
} else {
|
|
@@ -2332,7 +2454,7 @@ async function buildEffectiveRules(options) {
|
|
|
2332
2454
|
scopes.push({ file: "", kind: "other", documents });
|
|
2333
2455
|
}
|
|
2334
2456
|
return {
|
|
2335
|
-
configPath: configPath ?
|
|
2457
|
+
configPath: configPath ? path5.relative(root, configPath) : null,
|
|
2336
2458
|
scopes,
|
|
2337
2459
|
checks: checksForPaths(config2, files),
|
|
2338
2460
|
warnings: [...new Set(warnings)]
|
|
@@ -2456,19 +2578,23 @@ init_redact();
|
|
|
2456
2578
|
init_locale();
|
|
2457
2579
|
init_exec();
|
|
2458
2580
|
init_format();
|
|
2459
|
-
import { existsSync as
|
|
2581
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
2460
2582
|
import { cp, lstat as lstat2, mkdir as mkdir2, readdir, readFile as readFile3, rm, symlink, writeFile } from "node:fs/promises";
|
|
2461
|
-
import
|
|
2583
|
+
import path7 from "node:path";
|
|
2462
2584
|
function mcpServer(locale2) {
|
|
2463
2585
|
return { command: "npx", args: ["-y", "revdeck", "mcp"], env: { REVDECK_LANG: locale2 } };
|
|
2464
2586
|
}
|
|
2587
|
+
function initProvider(remote, requested) {
|
|
2588
|
+
if (requested && requested !== "auto") return requested;
|
|
2589
|
+
return remote ?? "gitlab";
|
|
2590
|
+
}
|
|
2465
2591
|
async function runInit(rootInput, options) {
|
|
2466
2592
|
const root = findRepoRoot(rootInput);
|
|
2467
2593
|
writers.out(`${tr("\u043F\u0440\u043E\u0435\u043A\u0442", "project")}: ${root}`);
|
|
2468
2594
|
const remote = await gitRemote(root);
|
|
2469
|
-
const configFile =
|
|
2470
|
-
if (
|
|
2471
|
-
writers.out(`\u2714 ${tr("\u043A\u043E\u043D\u0444\u0438\u0433 \u0443\u0436\u0435 \u0435\u0441\u0442\u044C", "config already exists")}: ${
|
|
2595
|
+
const configFile = path7.join(root, ".revdeck.yml");
|
|
2596
|
+
if (existsSync6(configFile) && !options.force) {
|
|
2597
|
+
writers.out(`\u2714 ${tr("\u043A\u043E\u043D\u0444\u0438\u0433 \u0443\u0436\u0435 \u0435\u0441\u0442\u044C", "config already exists")}: ${path7.relative(root, configFile)}`);
|
|
2472
2598
|
} else {
|
|
2473
2599
|
let sources = [];
|
|
2474
2600
|
try {
|
|
@@ -2480,7 +2606,7 @@ async function runInit(rootInput, options) {
|
|
|
2480
2606
|
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"),
|
|
2481
2607
|
"version: 1",
|
|
2482
2608
|
"provider:",
|
|
2483
|
-
` type: ${remote?.platform ??
|
|
2609
|
+
` type: ${initProvider(remote?.platform ?? null, options.provider)}`,
|
|
2484
2610
|
...remote ? [` host: ${remote.host}`, ` project: ${remote.project}`] : [" # host: gitlab.example.com", " # project: group/project"],
|
|
2485
2611
|
"output:",
|
|
2486
2612
|
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"),
|
|
@@ -2508,7 +2634,7 @@ async function runInit(rootInput, options) {
|
|
|
2508
2634
|
""
|
|
2509
2635
|
];
|
|
2510
2636
|
await writeFile(configFile, lines.join("\n"), { mode: 420 });
|
|
2511
|
-
writers.out(`\u2714 ${tr("\u0441\u043E\u0437\u0434\u0430\u043D", "created")} ${
|
|
2637
|
+
writers.out(`\u2714 ${tr("\u0441\u043E\u0437\u0434\u0430\u043D", "created")} ${path7.relative(root, configFile)}`);
|
|
2512
2638
|
}
|
|
2513
2639
|
await ensureGitignore(root);
|
|
2514
2640
|
const adapters = options.adapters.length ? options.adapters : detectAdapters(root);
|
|
@@ -2572,13 +2698,13 @@ var SPECS = {
|
|
|
2572
2698
|
};
|
|
2573
2699
|
function detectAdapters(root) {
|
|
2574
2700
|
const adapters = /* @__PURE__ */ new Set(["agents"]);
|
|
2575
|
-
if (
|
|
2576
|
-
if (
|
|
2577
|
-
if (
|
|
2578
|
-
if (
|
|
2579
|
-
if (
|
|
2580
|
-
if (
|
|
2581
|
-
if (
|
|
2701
|
+
if (existsSync6(path7.join(root, ".claude")) || existsSync6(path7.join(root, "CLAUDE.md"))) adapters.add("claude");
|
|
2702
|
+
if (existsSync6(path7.join(root, ".cursor"))) adapters.add("cursor");
|
|
2703
|
+
if (existsSync6(path7.join(root, ".codex")) || existsSync6(path7.join(root, "AGENTS.md"))) adapters.add("codex");
|
|
2704
|
+
if (existsSync6(path7.join(root, ".github"))) adapters.add("copilot");
|
|
2705
|
+
if (existsSync6(path7.join(root, ".dsh")) || existsSync6(path7.join(root, "dsh.yml"))) adapters.add("dsh");
|
|
2706
|
+
if (existsSync6(path7.join(root, ".gemini")) || existsSync6(path7.join(root, "GEMINI.md"))) adapters.add("gemini");
|
|
2707
|
+
if (existsSync6(path7.join(root, ".opencode"))) adapters.add("opencode");
|
|
2582
2708
|
return [...adapters];
|
|
2583
2709
|
}
|
|
2584
2710
|
async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
|
|
@@ -2588,16 +2714,16 @@ async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
|
|
|
2588
2714
|
return;
|
|
2589
2715
|
}
|
|
2590
2716
|
if (spec.linkSkill && canonicalSkill) await linkSkill(root, canonicalSkill, locale2);
|
|
2591
|
-
if (spec.mcp) await mergeMcpJson(
|
|
2717
|
+
if (spec.mcp) await mergeMcpJson(path7.join(root, spec.mcp), root, mcp);
|
|
2592
2718
|
for (const file of spec.files ?? []) {
|
|
2593
|
-
const target =
|
|
2594
|
-
if (
|
|
2595
|
-
writers.out(`! ${
|
|
2719
|
+
const target = path7.join(root, file.path);
|
|
2720
|
+
if (existsSync6(target)) {
|
|
2721
|
+
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")}`);
|
|
2596
2722
|
continue;
|
|
2597
2723
|
}
|
|
2598
|
-
await mkdir2(
|
|
2724
|
+
await mkdir2(path7.dirname(target), { recursive: true });
|
|
2599
2725
|
await writeFile(target, typeof file.content === "string" ? file.content : file.content(locale2));
|
|
2600
|
-
writers.out(`\u2714 ${
|
|
2726
|
+
writers.out(`\u2714 ${path7.relative(root, target)}`);
|
|
2601
2727
|
}
|
|
2602
2728
|
if (adapter === "dsh") {
|
|
2603
2729
|
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):")}`);
|
|
@@ -2614,12 +2740,12 @@ async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
|
|
|
2614
2740
|
}
|
|
2615
2741
|
}
|
|
2616
2742
|
async function installSkill(root, locale2) {
|
|
2617
|
-
const source =
|
|
2618
|
-
if (!
|
|
2743
|
+
const source = path7.join(packageRoot(), "skills", "revdeck", locale2);
|
|
2744
|
+
if (!existsSync6(source)) {
|
|
2619
2745
|
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")}`);
|
|
2620
2746
|
return null;
|
|
2621
2747
|
}
|
|
2622
|
-
const target =
|
|
2748
|
+
const target = path7.join(root, CANONICAL_SKILL);
|
|
2623
2749
|
await copySkill(source, target);
|
|
2624
2750
|
writers.out(`\u2714 ${tr("\u0441\u043A\u0438\u043B\u043B", "skill")}: ${CANONICAL_SKILL}`);
|
|
2625
2751
|
return target;
|
|
@@ -2627,16 +2753,16 @@ async function installSkill(root, locale2) {
|
|
|
2627
2753
|
async function copySkill(source, target) {
|
|
2628
2754
|
await mkdir2(target, { recursive: true });
|
|
2629
2755
|
for (const entry of await skillFiles(source)) {
|
|
2630
|
-
const file =
|
|
2631
|
-
await mkdir2(
|
|
2632
|
-
await cp(
|
|
2756
|
+
const file = path7.join(target, entry);
|
|
2757
|
+
await mkdir2(path7.dirname(file), { recursive: true });
|
|
2758
|
+
await cp(path7.join(source, entry), file, { force: true });
|
|
2633
2759
|
}
|
|
2634
2760
|
}
|
|
2635
2761
|
async function linkSkill(root, canonicalSkill, locale2) {
|
|
2636
|
-
const target =
|
|
2637
|
-
const source =
|
|
2638
|
-
const skillTarget =
|
|
2639
|
-
await mkdir2(
|
|
2762
|
+
const target = path7.join(root, ".claude", "skills", "revdeck");
|
|
2763
|
+
const source = path7.join(canonicalSkill, "SKILL.md");
|
|
2764
|
+
const skillTarget = path7.join(target, "SKILL.md");
|
|
2765
|
+
await mkdir2(path7.dirname(target), { recursive: true });
|
|
2640
2766
|
const existing = await lstat2(target).catch(() => null);
|
|
2641
2767
|
if (existing) {
|
|
2642
2768
|
if (existing.isSymbolicLink()) {
|
|
@@ -2665,18 +2791,18 @@ This file is a shim. The full procedure is \`.agents/skills/revdeck/SKILL.md\`;
|
|
|
2665
2791
|
`;
|
|
2666
2792
|
await writeFile(skillTarget, shim);
|
|
2667
2793
|
} else {
|
|
2668
|
-
await symlink(
|
|
2794
|
+
await symlink(path7.relative(target, source), skillTarget, "file");
|
|
2669
2795
|
}
|
|
2670
2796
|
writers.out(`\u2714 ${tr("\u0441\u043A\u0438\u043B\u043B", "skill")}: .claude/skills/revdeck/SKILL.md -> ${CANONICAL_SKILL}/SKILL.md`);
|
|
2671
2797
|
}
|
|
2672
2798
|
async function isManagedSkillDir(dir) {
|
|
2673
|
-
const skill =
|
|
2674
|
-
if (!
|
|
2799
|
+
const skill = path7.join(dir, "SKILL.md");
|
|
2800
|
+
if (!existsSync6(skill)) return false;
|
|
2675
2801
|
const text = await readFile3(skill, "utf8").catch(() => "");
|
|
2676
2802
|
return /^name:\s*revdeck\s*$/m.test(text);
|
|
2677
2803
|
}
|
|
2678
2804
|
async function skillFiles(dir, prefix = "") {
|
|
2679
|
-
const entries = await readdir(
|
|
2805
|
+
const entries = await readdir(path7.join(dir, prefix), { withFileTypes: true });
|
|
2680
2806
|
const files = [];
|
|
2681
2807
|
for (const entry of entries) {
|
|
2682
2808
|
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
@@ -2687,11 +2813,11 @@ async function skillFiles(dir, prefix = "") {
|
|
|
2687
2813
|
}
|
|
2688
2814
|
async function mergeMcpJson(file, root, mcp) {
|
|
2689
2815
|
let data = {};
|
|
2690
|
-
if (
|
|
2816
|
+
if (existsSync6(file)) {
|
|
2691
2817
|
try {
|
|
2692
2818
|
data = JSON.parse(await readFile3(file, "utf8"));
|
|
2693
2819
|
} catch {
|
|
2694
|
-
writers.err(`! ${
|
|
2820
|
+
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")}`);
|
|
2695
2821
|
return;
|
|
2696
2822
|
}
|
|
2697
2823
|
}
|
|
@@ -2702,11 +2828,11 @@ async function mergeMcpJson(file, root, mcp) {
|
|
|
2702
2828
|
data.mcpServers = servers;
|
|
2703
2829
|
await writeFile(file, `${JSON.stringify(data, null, 2)}
|
|
2704
2830
|
`);
|
|
2705
|
-
writers.out(`\u2714 MCP: ${
|
|
2831
|
+
writers.out(`\u2714 MCP: ${path7.relative(root, file)}`);
|
|
2706
2832
|
}
|
|
2707
2833
|
async function ensureGitignore(root) {
|
|
2708
|
-
const file =
|
|
2709
|
-
let current2 =
|
|
2834
|
+
const file = path7.join(root, ".gitignore");
|
|
2835
|
+
let current2 = existsSync6(file) ? await readFile3(file, "utf8") : "";
|
|
2710
2836
|
const entries = [".revdeck/", ".revdeck.local.yml", ".revdeck.local.yaml"];
|
|
2711
2837
|
const added = [];
|
|
2712
2838
|
for (const entry of entries) {
|
|
@@ -2728,17 +2854,17 @@ async function installService(host) {
|
|
|
2728
2854
|
...gh ? [`REVDECK_GH=${gh}`] : []
|
|
2729
2855
|
];
|
|
2730
2856
|
const root = packageRoot();
|
|
2731
|
-
const daemon2 =
|
|
2857
|
+
const daemon2 = path7.join(root, "dist", "daemon.js");
|
|
2732
2858
|
const hostArgs = host ? ` --host ${host}` : "";
|
|
2733
|
-
if (!
|
|
2734
|
-
if (daemon2.includes(`${
|
|
2859
|
+
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"));
|
|
2860
|
+
if (daemon2.includes(`${path7.sep}_npx${path7.sep}`)) {
|
|
2735
2861
|
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."));
|
|
2736
2862
|
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"));
|
|
2737
2863
|
}
|
|
2738
2864
|
if (process.platform === "linux") {
|
|
2739
|
-
const dir =
|
|
2865
|
+
const dir = path7.join(process.env.XDG_CONFIG_HOME || path7.join(process.env.HOME || "", ".config"), "systemd", "user");
|
|
2740
2866
|
await mkdir2(dir, { recursive: true });
|
|
2741
|
-
const unit =
|
|
2867
|
+
const unit = path7.join(dir, "revdeck.service");
|
|
2742
2868
|
await writeFile(
|
|
2743
2869
|
unit,
|
|
2744
2870
|
[
|
|
@@ -2762,9 +2888,9 @@ async function installService(host) {
|
|
|
2762
2888
|
return unit;
|
|
2763
2889
|
}
|
|
2764
2890
|
if (process.platform === "darwin") {
|
|
2765
|
-
const dir =
|
|
2891
|
+
const dir = path7.join(process.env.HOME || "", "Library", "LaunchAgents");
|
|
2766
2892
|
await mkdir2(dir, { recursive: true });
|
|
2767
|
-
const file =
|
|
2893
|
+
const file = path7.join(dir, "io.revdeck.daemon.plist");
|
|
2768
2894
|
await writeFile(
|
|
2769
2895
|
file,
|
|
2770
2896
|
`<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -2796,9 +2922,9 @@ function xmlEscape(value) {
|
|
|
2796
2922
|
|
|
2797
2923
|
// src/cli/eject.ts
|
|
2798
2924
|
init_paths();
|
|
2799
|
-
import { existsSync as
|
|
2925
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
2800
2926
|
import { lstat as lstat3, readFile as readFile5, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
|
|
2801
|
-
import
|
|
2927
|
+
import path9 from "node:path";
|
|
2802
2928
|
|
|
2803
2929
|
// src/core/jsonc.ts
|
|
2804
2930
|
function parseJsonc(text) {
|
|
@@ -2886,16 +3012,23 @@ import { applyEdits as applyEdits2, modify as modify2 } from "jsonc-parser";
|
|
|
2886
3012
|
|
|
2887
3013
|
// src/cli/devcontainer.ts
|
|
2888
3014
|
init_paths();
|
|
2889
|
-
import { existsSync as
|
|
3015
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
2890
3016
|
import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
|
|
2891
|
-
import
|
|
3017
|
+
import os3 from "node:os";
|
|
3018
|
+
import path8 from "node:path";
|
|
2892
3019
|
import { applyEdits, modify, parse as parseJsonc2 } from "jsonc-parser";
|
|
2893
3020
|
init_locale();
|
|
2894
3021
|
init_format();
|
|
2895
3022
|
var CONTAINER_RUNTIME_DIR = "/run/revdeck";
|
|
2896
3023
|
var CONTAINER_STATE_DIR = "/var/lib/revdeck";
|
|
2897
3024
|
var CONTAINER_UI_HOST = "host.docker.internal";
|
|
2898
|
-
function
|
|
3025
|
+
function hostRootExpression(root, home = process.env.HOME || process.env.USERPROFILE || os3.homedir()) {
|
|
3026
|
+
const relative = path8.relative(home, path8.resolve(root));
|
|
3027
|
+
if (path8.isAbsolute(relative) || relative.startsWith("..")) return null;
|
|
3028
|
+
const suffix = relative ? `/${relative.split(path8.sep).join("/")}` : "";
|
|
3029
|
+
return `\${localEnv:HOME}\${localEnv:USERPROFILE}${suffix}`;
|
|
3030
|
+
}
|
|
3031
|
+
function devcontainerPatch(hostRoot) {
|
|
2899
3032
|
const bridge = "${localEnv:HOME}${localEnv:USERPROFILE}/.local/state/revdeck/devcontainer";
|
|
2900
3033
|
return {
|
|
2901
3034
|
mounts: [
|
|
@@ -2906,13 +3039,15 @@ function devcontainerPatch() {
|
|
|
2906
3039
|
REVDECK_RUNTIME_DIR: CONTAINER_RUNTIME_DIR,
|
|
2907
3040
|
REVDECK_STATE_DIR: CONTAINER_STATE_DIR,
|
|
2908
3041
|
REVDECK_DEV_CONTAINER: "1",
|
|
2909
|
-
REVDECK_UI_HOST: CONTAINER_UI_HOST
|
|
3042
|
+
REVDECK_UI_HOST: CONTAINER_UI_HOST,
|
|
3043
|
+
...hostRoot ? { REVDECK_HOST_ROOT: hostRoot } : {}
|
|
2910
3044
|
},
|
|
2911
3045
|
remoteEnv: {
|
|
2912
3046
|
REVDECK_RUNTIME_DIR: CONTAINER_RUNTIME_DIR,
|
|
2913
3047
|
REVDECK_STATE_DIR: CONTAINER_STATE_DIR,
|
|
2914
3048
|
REVDECK_DEV_CONTAINER: "1",
|
|
2915
|
-
REVDECK_UI_HOST: CONTAINER_UI_HOST
|
|
3049
|
+
REVDECK_UI_HOST: CONTAINER_UI_HOST,
|
|
3050
|
+
...hostRoot ? { REVDECK_HOST_ROOT: hostRoot } : {}
|
|
2916
3051
|
},
|
|
2917
3052
|
runArgs: [`--add-host=${CONTAINER_UI_HOST}:host-gateway`]
|
|
2918
3053
|
};
|
|
@@ -2945,8 +3080,8 @@ function applyDevcontainerPatch(text, patch) {
|
|
|
2945
3080
|
const mounts = Array.isArray(parsed.mounts) ? [...parsed.mounts] : [];
|
|
2946
3081
|
for (const mount of patch.mounts) {
|
|
2947
3082
|
const index = mounts.findIndex((item) => isRecord2(item) && item.target === mount.target);
|
|
2948
|
-
const
|
|
2949
|
-
current2 = applyEdits(current2, modify(current2,
|
|
3083
|
+
const path12 = ["mounts", index >= 0 ? index : mounts.length];
|
|
3084
|
+
current2 = applyEdits(current2, modify(current2, path12, mount, formatting));
|
|
2950
3085
|
if (index >= 0) mounts[index] = mount;
|
|
2951
3086
|
else mounts.push(mount);
|
|
2952
3087
|
}
|
|
@@ -2969,15 +3104,26 @@ function applyDevcontainerPatch(text, patch) {
|
|
|
2969
3104
|
}
|
|
2970
3105
|
async function runDevcontainer(rootInput, options) {
|
|
2971
3106
|
const root = findRepoRoot(rootInput);
|
|
2972
|
-
const
|
|
3107
|
+
const hostRoot = hostRootExpression(root);
|
|
3108
|
+
const patch = devcontainerPatch(hostRoot);
|
|
2973
3109
|
await ensureDir(devcontainerRunDir());
|
|
2974
3110
|
await ensureDir(devcontainerStateDir());
|
|
2975
|
-
const dir =
|
|
2976
|
-
const file =
|
|
3111
|
+
const dir = path8.join(root, ".devcontainer");
|
|
3112
|
+
const file = path8.join(dir, "devcontainer.json");
|
|
2977
3113
|
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:"));
|
|
2978
3114
|
writers.out(` ${tr("\u0441\u043E\u043A\u0435\u0442", "socket")}: ${devcontainerRunDir()} -> ${CONTAINER_RUNTIME_DIR}`);
|
|
2979
3115
|
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")})`);
|
|
2980
|
-
if (
|
|
3116
|
+
if (hostRoot) {
|
|
3117
|
+
writers.out(` ${tr("\u0440\u0430\u0431\u043E\u0447\u0430\u044F \u043A\u043E\u043F\u0438\u044F \u0445\u043E\u0441\u0442\u0430", "host working copy")}: ${hostRoot}`);
|
|
3118
|
+
} else {
|
|
3119
|
+
writers.err(
|
|
3120
|
+
tr(
|
|
3121
|
+
"! \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0439 \u0432\u043D\u0435 \u0434\u043E\u043C\u0430\u0448\u043D\u0435\u0433\u043E \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430: \u0437\u0430\u0434\u0430\u0439\u0442\u0435 REVDECK_HOST_ROOT=<\u043F\u0443\u0442\u044C \u043D\u0430 \u0445\u043E\u0441\u0442\u0435> \u0432 devcontainer.json \u0432\u0440\u0443\u0447\u043D\u0443\u044E, \u0438\u043D\u0430\u0447\u0435 \u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u0443\u0432\u0438\u0434\u0438\u0442 .revdeck.yml",
|
|
3122
|
+
"! the repository is outside the home directory: set REVDECK_HOST_ROOT=<host path> in devcontainer.json manually, otherwise the daemon will not see .revdeck.yml"
|
|
3123
|
+
)
|
|
3124
|
+
);
|
|
3125
|
+
}
|
|
3126
|
+
if (!existsSync7(devcontainerSocketPath())) {
|
|
2981
3127
|
writers.err(
|
|
2982
3128
|
tr(
|
|
2983
3129
|
"! \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",
|
|
@@ -2995,7 +3141,7 @@ async function runDevcontainer(rootInput, options) {
|
|
|
2995
3141
|
return;
|
|
2996
3142
|
}
|
|
2997
3143
|
await mkdir3(dir, { recursive: true });
|
|
2998
|
-
const existed =
|
|
3144
|
+
const existed = existsSync7(file);
|
|
2999
3145
|
let output;
|
|
3000
3146
|
if (existed) {
|
|
3001
3147
|
const text = await readFile4(file, "utf8");
|
|
@@ -3004,8 +3150,8 @@ async function runDevcontainer(rootInput, options) {
|
|
|
3004
3150
|
} catch (error) {
|
|
3005
3151
|
throw new Error(
|
|
3006
3152
|
tr(
|
|
3007
|
-
`${
|
|
3008
|
-
`${
|
|
3153
|
+
`${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`,
|
|
3154
|
+
`${path8.relative(root, file)}: could not parse JSONC (${error.message}); add the mounts manually`
|
|
3009
3155
|
)
|
|
3010
3156
|
);
|
|
3011
3157
|
}
|
|
@@ -3015,7 +3161,7 @@ async function runDevcontainer(rootInput, options) {
|
|
|
3015
3161
|
`;
|
|
3016
3162
|
}
|
|
3017
3163
|
await writeFile2(file, output);
|
|
3018
|
-
writers.out(`\u2714 ${
|
|
3164
|
+
writers.out(`\u2714 ${path8.relative(root, file)}`);
|
|
3019
3165
|
const mcpFiles = await mergeMcpEnv(root, patch.containerEnv);
|
|
3020
3166
|
if (!mcpFiles) {
|
|
3021
3167
|
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."));
|
|
@@ -3029,16 +3175,17 @@ async function runDevcontainer(rootInput, options) {
|
|
|
3029
3175
|
writers.out(tr(" macOS/Docker Desktop: \u0434\u043E\u0441\u0442\u0430\u0442\u043E\u0447\u043D\u043E revdeck daemon restart; Linux \u043F\u0440\u0438 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u043C \u0441\u043E\u043A\u0435\u0442\u0435: revdeck daemon restart --host 0.0.0.0.", " macOS/Docker Desktop: revdeck daemon restart is enough; on Linux with an unreachable socket: revdeck daemon restart --host 0.0.0.0."));
|
|
3030
3176
|
}
|
|
3031
3177
|
async function mergeMcpEnv(root, env) {
|
|
3178
|
+
const mcpEnv = Object.fromEntries(Object.entries(env).filter(([name]) => name !== "REVDECK_HOST_ROOT"));
|
|
3032
3179
|
let changed = 0;
|
|
3033
3180
|
for (const relative of [".mcp.json", ".cursor/mcp.json"]) {
|
|
3034
|
-
const file =
|
|
3035
|
-
if (!
|
|
3181
|
+
const file = path8.join(root, relative);
|
|
3182
|
+
if (!existsSync7(file)) continue;
|
|
3036
3183
|
try {
|
|
3037
3184
|
const data = JSON.parse(await readFile4(file, "utf8"));
|
|
3038
3185
|
const servers = isRecord2(data.mcpServers) ? data.mcpServers : null;
|
|
3039
3186
|
const server2 = servers && isRecord2(servers.revdeck) ? servers.revdeck : null;
|
|
3040
3187
|
if (!server2) continue;
|
|
3041
|
-
server2.env = { ...isRecord2(server2.env) ? server2.env : {}, ...
|
|
3188
|
+
server2.env = { ...isRecord2(server2.env) ? server2.env : {}, ...mcpEnv };
|
|
3042
3189
|
await writeFile2(file, `${JSON.stringify(data, null, 2)}
|
|
3043
3190
|
`);
|
|
3044
3191
|
changed += 1;
|
|
@@ -3070,13 +3217,13 @@ async function runEject(rootInput, options) {
|
|
|
3070
3217
|
const warnings = [];
|
|
3071
3218
|
if (!options.keepConfig) {
|
|
3072
3219
|
for (const name of CONFIG_FILES2) {
|
|
3073
|
-
const file =
|
|
3074
|
-
if (
|
|
3220
|
+
const file = path9.join(root, name);
|
|
3221
|
+
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 }) });
|
|
3075
3222
|
}
|
|
3076
3223
|
}
|
|
3077
3224
|
for (const name of SKILL_DIRS) {
|
|
3078
|
-
const target =
|
|
3079
|
-
if (!
|
|
3225
|
+
const target = path9.join(root, name);
|
|
3226
|
+
if (!existsSync8(target)) continue;
|
|
3080
3227
|
const managed = await isManagedSkill(target);
|
|
3081
3228
|
if (!managed) {
|
|
3082
3229
|
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")}`);
|
|
@@ -3085,8 +3232,8 @@ async function runEject(rootInput, options) {
|
|
|
3085
3232
|
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 }) });
|
|
3086
3233
|
}
|
|
3087
3234
|
for (const name of COMMAND_FILES) {
|
|
3088
|
-
const file =
|
|
3089
|
-
if (!
|
|
3235
|
+
const file = path9.join(root, name);
|
|
3236
|
+
if (!existsSync8(file)) continue;
|
|
3090
3237
|
const text = await readFile5(file, "utf8").catch(() => "");
|
|
3091
3238
|
if (!/revdeck/i.test(text)) {
|
|
3092
3239
|
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")}`);
|
|
@@ -3095,8 +3242,8 @@ async function runEject(rootInput, options) {
|
|
|
3095
3242
|
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 }) });
|
|
3096
3243
|
}
|
|
3097
3244
|
for (const name of MCP_FILES) {
|
|
3098
|
-
const file =
|
|
3099
|
-
if (!
|
|
3245
|
+
const file = path9.join(root, name);
|
|
3246
|
+
if (!existsSync8(file)) continue;
|
|
3100
3247
|
const text = await readFile5(file, "utf8").catch(() => "");
|
|
3101
3248
|
let data;
|
|
3102
3249
|
try {
|
|
@@ -3117,8 +3264,8 @@ async function runEject(rootInput, options) {
|
|
|
3117
3264
|
}
|
|
3118
3265
|
});
|
|
3119
3266
|
}
|
|
3120
|
-
const devcontainer =
|
|
3121
|
-
if (
|
|
3267
|
+
const devcontainer = path9.join(root, ".devcontainer", "devcontainer.json");
|
|
3268
|
+
if (existsSync8(devcontainer)) {
|
|
3122
3269
|
const text = await readFile5(devcontainer, "utf8");
|
|
3123
3270
|
try {
|
|
3124
3271
|
const parsed = parseJsonc(text);
|
|
@@ -3136,7 +3283,7 @@ async function runEject(rootInput, options) {
|
|
|
3136
3283
|
for (const key of ["containerEnv", "remoteEnv"]) {
|
|
3137
3284
|
if (!isRecord2(parsed[key])) continue;
|
|
3138
3285
|
const env = { ...parsed[key] };
|
|
3139
|
-
for (const name of ["REVDECK_RUNTIME_DIR", "REVDECK_STATE_DIR", "REVDECK_DEV_CONTAINER", "REVDECK_UI_HOST"]) delete env[name];
|
|
3286
|
+
for (const name of ["REVDECK_RUNTIME_DIR", "REVDECK_STATE_DIR", "REVDECK_DEV_CONTAINER", "REVDECK_UI_HOST", "REVDECK_HOST_ROOT"]) delete env[name];
|
|
3140
3287
|
if (Object.keys(env).length !== Object.keys(parsed[key]).length) {
|
|
3141
3288
|
current2 = applyEdits2(current2, modify2(current2, [key], env, formatting));
|
|
3142
3289
|
changed = true;
|
|
@@ -3163,12 +3310,12 @@ async function runEject(rootInput, options) {
|
|
|
3163
3310
|
warnings.push(`.devcontainer/devcontainer.json: ${tr("\u043D\u0435 JSONC \u2014 \u043D\u0435 \u0442\u0440\u043E\u0433\u0430\u044E", "not JSONC \u2014 leaving it untouched")}`);
|
|
3164
3311
|
}
|
|
3165
3312
|
}
|
|
3166
|
-
const cache =
|
|
3167
|
-
if (
|
|
3313
|
+
const cache = path9.join(root, ".revdeck");
|
|
3314
|
+
if (existsSync8(cache)) {
|
|
3168
3315
|
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 }) });
|
|
3169
3316
|
}
|
|
3170
|
-
const gitignore =
|
|
3171
|
-
if (
|
|
3317
|
+
const gitignore = path9.join(root, ".gitignore");
|
|
3318
|
+
if (existsSync8(gitignore)) {
|
|
3172
3319
|
const text = await readFile5(gitignore, "utf8");
|
|
3173
3320
|
if (/(^|\n)\.revdeck\/?\s*(\n|$)/.test(text)) {
|
|
3174
3321
|
changes.push({
|
|
@@ -3205,8 +3352,8 @@ async function isManagedSkill(target) {
|
|
|
3205
3352
|
const info = await lstat3(target);
|
|
3206
3353
|
if (info.isSymbolicLink()) return true;
|
|
3207
3354
|
if (!info.isDirectory()) return false;
|
|
3208
|
-
const skill =
|
|
3209
|
-
if (!
|
|
3355
|
+
const skill = path9.join(target, "SKILL.md");
|
|
3356
|
+
if (!existsSync8(skill)) return false;
|
|
3210
3357
|
const text = await readFile5(skill, "utf8");
|
|
3211
3358
|
return /^name:\s*revdeck\s*$/m.test(text) || /revdeck/i.test(text.slice(0, 2e3));
|
|
3212
3359
|
} catch {
|
|
@@ -3219,7 +3366,7 @@ init_client();
|
|
|
3219
3366
|
init_format();
|
|
3220
3367
|
init_locale();
|
|
3221
3368
|
import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile4 } from "node:fs/promises";
|
|
3222
|
-
import
|
|
3369
|
+
import path10 from "node:path";
|
|
3223
3370
|
async function reviewFor(client2, root, arg) {
|
|
3224
3371
|
if (arg && /^(gitlab|github):/.test(arg)) {
|
|
3225
3372
|
const { review } = await client2.request("reviews.get", { review: arg });
|
|
@@ -3275,12 +3422,12 @@ async function exportReview(root, arg, dir) {
|
|
|
3275
3422
|
const { client: client2 } = await ensureDaemon();
|
|
3276
3423
|
try {
|
|
3277
3424
|
const review = await reviewFor(client2, root, arg);
|
|
3278
|
-
const target =
|
|
3425
|
+
const target = path10.resolve(root, dir);
|
|
3279
3426
|
await mkdir4(target, { recursive: true });
|
|
3280
3427
|
const base = `mr-${review.info.ref.number}`;
|
|
3281
3428
|
const files = [];
|
|
3282
3429
|
const write = async (name, data) => {
|
|
3283
|
-
const file =
|
|
3430
|
+
const file = path10.join(target, name);
|
|
3284
3431
|
await writeFile4(file, `${JSON.stringify(data, null, 2)}
|
|
3285
3432
|
`, { mode: 420 });
|
|
3286
3433
|
files.push(name);
|
|
@@ -3346,9 +3493,9 @@ async function exportReview(root, arg, dir) {
|
|
|
3346
3493
|
}
|
|
3347
3494
|
}
|
|
3348
3495
|
await write(`${base}-published.json`, published);
|
|
3349
|
-
await writeFile4(
|
|
3496
|
+
await writeFile4(path10.join(target, `${base}.diff`), await serializeDiff(client2, review), { mode: 420 });
|
|
3350
3497
|
files.push(`${base}.diff`);
|
|
3351
|
-
writers.out(`${tr("\u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043E \u0432", "exported to")} ${
|
|
3498
|
+
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(", ")}`);
|
|
3352
3499
|
} finally {
|
|
3353
3500
|
client2.close();
|
|
3354
3501
|
}
|
|
@@ -3357,11 +3504,11 @@ async function importReview(root, arg, dir) {
|
|
|
3357
3504
|
const { client: client2 } = await ensureDaemon();
|
|
3358
3505
|
try {
|
|
3359
3506
|
const review = await reviewFor(client2, root, arg);
|
|
3360
|
-
const target =
|
|
3507
|
+
const target = path10.resolve(root, dir);
|
|
3361
3508
|
const base = `mr-${review.info.ref.number}`;
|
|
3362
3509
|
const read = async (name) => {
|
|
3363
3510
|
try {
|
|
3364
|
-
return JSON.parse(await readFile6(
|
|
3511
|
+
return JSON.parse(await readFile6(path10.join(target, name), "utf8"));
|
|
3365
3512
|
} catch {
|
|
3366
3513
|
return null;
|
|
3367
3514
|
}
|
|
@@ -3466,6 +3613,7 @@ var OPTIONS = {
|
|
|
3466
3613
|
review: { type: "string" },
|
|
3467
3614
|
root: { type: "string" },
|
|
3468
3615
|
platform: { type: "string" },
|
|
3616
|
+
provider: { type: "string" },
|
|
3469
3617
|
project: { type: "string" },
|
|
3470
3618
|
host: { type: "string" },
|
|
3471
3619
|
branch: { type: "string" },
|
|
@@ -3520,9 +3668,9 @@ function parse(argv) {
|
|
|
3520
3668
|
}
|
|
3521
3669
|
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
|
|
3522
3670
|
|
|
3523
|
-
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
|
|
3671
|
+
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]
|
|
3524
3672
|
revdeck eject \u0443\u0434\u0430\u043B\u0438\u0442\u044C revdeck \u0438\u0437 \u043F\u0440\u043E\u0435\u043A\u0442\u0430 (--yes; --keep-config)
|
|
3525
|
-
revdeck devcontainer \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C devcontainer \u043A \u0434\u0435\u043C\u043E\u043D\u0443 \u0445\u043E\u0441\u0442\u0430 (--write)
|
|
3673
|
+
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; \u043F\u0443\u0442\u044C \u0445\u043E\u0441\u0442\u0430 \u0432 REVDECK_HOST_ROOT)
|
|
3526
3674
|
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
|
|
3527
3675
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
3528
3676
|
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)
|
|
@@ -3544,19 +3692,20 @@ var HELP_RU = `revdeck ${VERSION} \u2014 \u0440\u0435\u0432\u044C\u044E GitLab/G
|
|
|
3544
3692
|
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
|
|
3545
3693
|
revdeck publish <N> [--kind reply|finding|note] [--ids a,b] [--yes]
|
|
3546
3694
|
revdeck rules [<N>] [--explain <\u043F\u0443\u0442\u044C>]
|
|
3547
|
-
revdeck checks <N> [--run --yes]
|
|
3695
|
+
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
|
|
3548
3696
|
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
|
|
3549
3697
|
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
|
|
3550
3698
|
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
|
|
3551
3699
|
revdeck mcp \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C MCP-\u0441\u0435\u0440\u0432\u0435\u0440 (stdio)
|
|
3552
3700
|
|
|
3553
3701
|
\u041E\u0431\u0449\u0438\u0435 \u0444\u043B\u0430\u0433\u0438: --json, --root <\u043F\u0443\u0442\u044C>, --review <id>, --lang ru|en, --help.
|
|
3554
|
-
\u041F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F \
|
|
3702
|
+
\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
|
|
3703
|
+
\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.`;
|
|
3555
3704
|
var HELP_EN = `revdeck ${VERSION} \u2014 code review for GitLab/GitHub, for humans and agents
|
|
3556
3705
|
|
|
3557
|
-
revdeck init set up a project: .revdeck.yml, adapters, MCP
|
|
3706
|
+
revdeck init set up a project: .revdeck.yml, adapters, MCP [--provider gitlab|github|auto]
|
|
3558
3707
|
revdeck eject remove revdeck from the project (--yes; --keep-config)
|
|
3559
|
-
revdeck devcontainer connect a devcontainer to the host daemon (--write)
|
|
3708
|
+
revdeck devcontainer connect a devcontainer to the host daemon (--write; host path in REVDECK_HOST_ROOT)
|
|
3560
3709
|
revdeck doctor check the environment and access
|
|
3561
3710
|
revdeck daemon <start|stop|restart|status|logs|install|uninstall>
|
|
3562
3711
|
revdeck projects projects and their working copies (add <path> \u2014 register)
|
|
@@ -3578,14 +3727,15 @@ var HELP_EN = `revdeck ${VERSION} \u2014 code review for GitLab/GitHub, for huma
|
|
|
3578
3727
|
revdeck attach <N> --file <path> upload an image/video to the platform
|
|
3579
3728
|
revdeck publish <N> [--kind reply|finding|note] [--ids a,b] [--yes]
|
|
3580
3729
|
revdeck rules [<N>] [--explain <path>]
|
|
3581
|
-
revdeck checks <N> [--run --yes]
|
|
3730
|
+
revdeck checks <N> [--run --yes] checks run by a human on the host/UI only
|
|
3582
3731
|
revdeck export <N> [--dir .revdeck] export to the legacy file format
|
|
3583
3732
|
revdeck import <N> [--dir .revdeck] import from the legacy format
|
|
3584
3733
|
revdeck config [--json] effective project config
|
|
3585
3734
|
revdeck mcp start the MCP server (stdio)
|
|
3586
3735
|
|
|
3587
3736
|
Common flags: --json, --root <path>, --review <id>, --lang ru|en, --help.
|
|
3588
|
-
Publishing
|
|
3737
|
+
Publishing, checks and administration are human-only: the agent bridge gets CAPABILITY and the
|
|
3738
|
+
container CLI refuses --run/--yes. Publishing never happens without --yes.`;
|
|
3589
3739
|
var helpText = () => tr(HELP_RU, HELP_EN);
|
|
3590
3740
|
async function main2() {
|
|
3591
3741
|
const argv = process.argv.slice(2);
|
|
@@ -3607,9 +3757,49 @@ async function main2() {
|
|
|
3607
3757
|
return;
|
|
3608
3758
|
}
|
|
3609
3759
|
const root = String(values.root ?? findRepoRoot());
|
|
3760
|
+
if (isDevContainer()) {
|
|
3761
|
+
const featureAction = command === "feature" ? positionals[0] ?? "list" : "";
|
|
3762
|
+
const projectAction = command === "projects" ? positionals[0] ?? "list" : "";
|
|
3763
|
+
if (command === "checks" && values.run === true) {
|
|
3764
|
+
fail(
|
|
3765
|
+
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"),
|
|
3766
|
+
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")
|
|
3767
|
+
);
|
|
3768
|
+
}
|
|
3769
|
+
if ((command === "publish" || command === "reply") && values.yes === true && values["dry-run"] !== true) {
|
|
3770
|
+
fail(
|
|
3771
|
+
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"),
|
|
3772
|
+
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)")
|
|
3773
|
+
);
|
|
3774
|
+
}
|
|
3775
|
+
if (command === "feature" && ["create", "update", "archive", "delete", "add", "remove", "reorder", "note", "note-delete"].includes(featureAction)) {
|
|
3776
|
+
fail(
|
|
3777
|
+
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"),
|
|
3778
|
+
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")
|
|
3779
|
+
);
|
|
3780
|
+
}
|
|
3781
|
+
if (command === "projects" && ["update", "remove", "delete"].includes(projectAction)) {
|
|
3782
|
+
fail(
|
|
3783
|
+
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"),
|
|
3784
|
+
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")
|
|
3785
|
+
);
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3610
3788
|
switch (command) {
|
|
3611
|
-
case "init":
|
|
3612
|
-
|
|
3789
|
+
case "init": {
|
|
3790
|
+
const provider = values.provider === void 0 ? void 0 : String(values.provider);
|
|
3791
|
+
if (provider && provider !== "auto" && provider !== "gitlab" && provider !== "github") {
|
|
3792
|
+
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"));
|
|
3793
|
+
}
|
|
3794
|
+
return runInit(root, {
|
|
3795
|
+
force: values.force === true,
|
|
3796
|
+
adapters: parseList(values.adapters),
|
|
3797
|
+
noService: values["no-service"] === true,
|
|
3798
|
+
locale: values.lang === "ru" || values.lang === "en" ? values.lang : detectLocale(),
|
|
3799
|
+
outputLanguage: values.lang === "ru" || values.lang === "en" ? values.lang : "auto",
|
|
3800
|
+
...provider ? { provider } : {}
|
|
3801
|
+
});
|
|
3802
|
+
}
|
|
3613
3803
|
case "eject":
|
|
3614
3804
|
return runEject(root, { yes: values.yes === true && values["dry-run"] !== true, keepConfig: values["keep-config"] === true });
|
|
3615
3805
|
case "devcontainer":
|
|
@@ -3695,7 +3885,7 @@ async function resolveReview(client2, root, arg, values) {
|
|
|
3695
3885
|
}
|
|
3696
3886
|
if (arg) {
|
|
3697
3887
|
const result = await client2.request("reviews.open", {
|
|
3698
|
-
root,
|
|
3888
|
+
root: toHostRoot(root),
|
|
3699
3889
|
input: arg,
|
|
3700
3890
|
...values.platform ? { platform: values.platform } : {},
|
|
3701
3891
|
...values.project ? { project: values.project } : {},
|
|
@@ -3725,7 +3915,7 @@ async function list(root, values) {
|
|
|
3725
3915
|
if (values.remote) {
|
|
3726
3916
|
await withClient(async ({ client: client2 }) => {
|
|
3727
3917
|
const result = await client2.request("reviews.remoteList", {
|
|
3728
|
-
root,
|
|
3918
|
+
root: toHostRoot(root),
|
|
3729
3919
|
scope: values.scope ?? "open",
|
|
3730
3920
|
limit: Number(values.limit ?? 50)
|
|
3731
3921
|
});
|
|
@@ -3739,7 +3929,7 @@ async function list(root, values) {
|
|
|
3739
3929
|
}
|
|
3740
3930
|
await withClient(async ({ client: client2 }) => {
|
|
3741
3931
|
const project = typeof values.project === "string" && values.project.trim() ? values.project.trim() : void 0;
|
|
3742
|
-
const params = values.all === true ? {} : project ? { project } : { root };
|
|
3932
|
+
const params = values.all === true ? {} : project ? { project } : { root: toHostRoot(root) };
|
|
3743
3933
|
const { reviews } = await client2.request("reviews.list", params);
|
|
3744
3934
|
if (values.json) return printJson({ reviews });
|
|
3745
3935
|
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>"));
|
|
@@ -3751,7 +3941,9 @@ async function projects(root, args, values) {
|
|
|
3751
3941
|
await withClient(async ({ client: client2 }) => {
|
|
3752
3942
|
if (action === "add") {
|
|
3753
3943
|
const target = args[1] ?? values.root ?? root;
|
|
3754
|
-
const result = await client2.request("projects.register", {
|
|
3944
|
+
const result = await client2.request("projects.register", {
|
|
3945
|
+
root: toHostRoot(target)
|
|
3946
|
+
});
|
|
3755
3947
|
if (values.json) return printJson(result);
|
|
3756
3948
|
if (!result.project) return writers.out(tr("\u043F\u0440\u043E\u0435\u043A\u0442 \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0451\u043D: \u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 git remote \u0438 .revdeck.yml", "could not determine the project: check git remote and .revdeck.yml"));
|
|
3757
3949
|
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}`);
|
|
@@ -3957,7 +4149,7 @@ async function openReview(root, args, values) {
|
|
|
3957
4149
|
await withClient(async ({ client: client2 }) => {
|
|
3958
4150
|
const requests = args.map(async (input) => {
|
|
3959
4151
|
const result = await client2.request("reviews.open", {
|
|
3960
|
-
root,
|
|
4152
|
+
root: toHostRoot(root),
|
|
3961
4153
|
input,
|
|
3962
4154
|
...values.platform ? { platform: values.platform } : {},
|
|
3963
4155
|
...values.project ? { project: values.project } : {},
|
|
@@ -3990,6 +4182,12 @@ async function ui(arg, values) {
|
|
|
3990
4182
|
});
|
|
3991
4183
|
const info = await daemonInfo();
|
|
3992
4184
|
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");
|
|
4185
|
+
if (!info.token) {
|
|
4186
|
+
fail(
|
|
4187
|
+
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"),
|
|
4188
|
+
tr("\u043E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 `revdeck ui` \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "run `revdeck ui` on the host")
|
|
4189
|
+
);
|
|
4190
|
+
}
|
|
3993
4191
|
const url = `${uiBaseUrl(info)}/?t=${info.token}`;
|
|
3994
4192
|
writers.out(url);
|
|
3995
4193
|
if (values.open) openBrowser(url);
|
|
@@ -3997,6 +4195,9 @@ async function ui(arg, values) {
|
|
|
3997
4195
|
function printUi(reviewId2, values) {
|
|
3998
4196
|
const info = daemonInfoSync();
|
|
3999
4197
|
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"));
|
|
4198
|
+
if (!info.token) {
|
|
4199
|
+
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"));
|
|
4200
|
+
}
|
|
4000
4201
|
const url = `${uiBaseUrl(info)}/?t=${info.token}${reviewId2 ? `&review=${encodeURIComponent(reviewId2)}` : ""}`;
|
|
4001
4202
|
writers.out(`UI: ${url}`);
|
|
4002
4203
|
if (values.open) openBrowser(url);
|
|
@@ -4091,7 +4292,7 @@ async function daemon(action, values = {}) {
|
|
|
4091
4292
|
}
|
|
4092
4293
|
async function status(root, values) {
|
|
4093
4294
|
await withClient(async ({ client: client2 }) => {
|
|
4094
|
-
const params = values.all === true ? {} : { root };
|
|
4295
|
+
const params = values.all === true ? {} : { root: toHostRoot(root) };
|
|
4095
4296
|
const { reviews } = await client2.request("reviews.list", params);
|
|
4096
4297
|
if (!reviews.length) {
|
|
4097
4298
|
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"));
|
|
@@ -4328,11 +4529,11 @@ async function react(arg, values) {
|
|
|
4328
4529
|
}
|
|
4329
4530
|
async function attach(arg, values) {
|
|
4330
4531
|
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"));
|
|
4331
|
-
const name =
|
|
4532
|
+
const name = path11.basename(String(values.file));
|
|
4332
4533
|
const spec = attachmentSpec(name);
|
|
4333
4534
|
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"));
|
|
4334
4535
|
const file = String(values.file);
|
|
4335
|
-
const info = await
|
|
4536
|
+
const info = await stat2(file).catch(() => null);
|
|
4336
4537
|
if (!info?.isFile()) fail(tr(`\u043D\u0435\u0442 \u0444\u0430\u0439\u043B\u0430 ${file}`, `file ${file} does not exist`));
|
|
4337
4538
|
if (info.size > MAX_ATTACHMENT_BYTES) {
|
|
4338
4539
|
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`));
|
|
@@ -4433,6 +4634,18 @@ async function checks(root, arg, values) {
|
|
|
4433
4634
|
await withClient(async ({ client: client2 }) => {
|
|
4434
4635
|
const { review } = await resolveReview(client2, root, reviewArg(values, arg), values);
|
|
4435
4636
|
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"));
|
|
4637
|
+
if (!values.json) {
|
|
4638
|
+
const { rules: plan } = await client2.request("rules.get", {
|
|
4639
|
+
review: review.id
|
|
4640
|
+
});
|
|
4641
|
+
const ids = values.ids ? parseList(values.ids) : null;
|
|
4642
|
+
const selected = plan.checks.filter((check) => ids ? ids.includes(check.id) : check.matched);
|
|
4643
|
+
if (selected.length) {
|
|
4644
|
+
writers.out(tr("\u041A\u043E\u043C\u0430\u043D\u0434\u044B \u043F\u0440\u043E\u0432\u0435\u0440\u043E\u043A:", "Check commands:"));
|
|
4645
|
+
for (const check of selected) writers.out(` ${check.id}: ${check.argv.join(" ")}`);
|
|
4646
|
+
writers.out("");
|
|
4647
|
+
}
|
|
4648
|
+
}
|
|
4436
4649
|
const { results } = await client2.request("checks.run", {
|
|
4437
4650
|
review: review.id,
|
|
4438
4651
|
allowRun: values.run === true && values.yes === true,
|
|
@@ -4478,6 +4691,15 @@ async function doctor(root) {
|
|
|
4478
4691
|
rows.push(["node", major >= 22 ? "ok" : "fail", process.version]);
|
|
4479
4692
|
if (container) {
|
|
4480
4693
|
rows.push(["mode", "ok", tr("devcontainer: revdeck \u0438 gh/glab \u0440\u0430\u0431\u043E\u0442\u0430\u044E\u0442 \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "devcontainer: revdeck and gh/glab run on the host")]);
|
|
4694
|
+
const hostRoot = process.env.REVDECK_HOST_ROOT?.trim();
|
|
4695
|
+
rows.push([
|
|
4696
|
+
"host root",
|
|
4697
|
+
hostRoot ? "ok" : "warn",
|
|
4698
|
+
hostRoot ?? tr(
|
|
4699
|
+
"\u043D\u0435 \u0437\u0430\u0434\u0430\u043D: \u0434\u0435\u043C\u043E\u043D \u0445\u043E\u0441\u0442\u0430 \u043D\u0435 \u0443\u0432\u0438\u0434\u0438\u0442 .revdeck.yml \u2014 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 revdeck devcontainer --write",
|
|
4700
|
+
"not set: the host daemon will not see .revdeck.yml \u2014 run revdeck devcontainer --write"
|
|
4701
|
+
)
|
|
4702
|
+
]);
|
|
4481
4703
|
}
|
|
4482
4704
|
const binaries = {};
|
|
4483
4705
|
for (const bin of ["glab", "gh", "git"]) {
|
|
@@ -4548,8 +4770,8 @@ async function doctor(root) {
|
|
|
4548
4770
|
]);
|
|
4549
4771
|
}
|
|
4550
4772
|
}
|
|
4551
|
-
const { existsSync:
|
|
4552
|
-
const skill =
|
|
4773
|
+
const { existsSync: existsSync9 } = await import("node:fs");
|
|
4774
|
+
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"));
|
|
4553
4775
|
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")]);
|
|
4554
4776
|
for (const [name, status2, detail] of rows) {
|
|
4555
4777
|
writers.out(`${status2 === "ok" ? "\u2714" : status2 === "warn" ? "!" : "\u2716"} ${name.padEnd(10)} ${detail}`);
|