revdeck 0.6.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 +47 -1
- package/README.md +47 -16
- package/README.ru.md +49 -20
- package/SECURITY.md +1 -1
- package/dist/cli.js +417 -247
- package/dist/cli.js.map +4 -4
- package/dist/daemon.js +420 -121
- package/dist/daemon.js.map +4 -4
- package/dist/mcp.js +54 -26
- 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 +21 -10
- package/docs/configuration.md +24 -8
- package/docs/integrations.md +17 -14
- 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 +22 -9
- package/docs/ru/configuration.md +20 -6
- package/docs/ru/integrations.md +16 -14
- 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 +1 -1
- 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/daemon.js
CHANGED
|
@@ -139,7 +139,7 @@ var init_errors = __esm({
|
|
|
139
139
|
import { execFile } from "node:child_process";
|
|
140
140
|
import { access, constants as constants2 } from "node:fs/promises";
|
|
141
141
|
import os2 from "node:os";
|
|
142
|
-
import
|
|
142
|
+
import path3 from "node:path";
|
|
143
143
|
function scrubEnv(extra) {
|
|
144
144
|
const env = {};
|
|
145
145
|
for (const [key, value] of Object.entries(process.env)) {
|
|
@@ -169,11 +169,11 @@ async function resolveExecutable(command) {
|
|
|
169
169
|
const cached = RESOLVED.get(command);
|
|
170
170
|
if (cached) return cached;
|
|
171
171
|
const dirs = [
|
|
172
|
-
...(process.env.PATH ?? "").split(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
...(process.env.PATH ?? "").split(path3.delimiter),
|
|
173
|
+
path3.join(os2.homedir(), ".local", "bin"),
|
|
174
|
+
path3.join(os2.homedir(), ".local", "share", "mise", "shims"),
|
|
175
|
+
path3.join(os2.homedir(), ".asdf", "shims"),
|
|
176
|
+
path3.join(os2.homedir(), ".npm-global", "bin"),
|
|
177
177
|
"/opt/homebrew/bin",
|
|
178
178
|
"/usr/local/bin",
|
|
179
179
|
"/usr/bin",
|
|
@@ -182,7 +182,7 @@ async function resolveExecutable(command) {
|
|
|
182
182
|
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
183
183
|
for (const dir of [...new Set(dirs)]) {
|
|
184
184
|
for (const extension of extensions) {
|
|
185
|
-
const candidate =
|
|
185
|
+
const candidate = path3.join(dir, `${command}${extension}`);
|
|
186
186
|
try {
|
|
187
187
|
await access(candidate, constants2.X_OK);
|
|
188
188
|
RESOLVED.set(command, candidate);
|
|
@@ -419,11 +419,11 @@ function diffStats(files) {
|
|
|
419
419
|
function changedPaths(files) {
|
|
420
420
|
return files.map((file) => file.path);
|
|
421
421
|
}
|
|
422
|
-
function findFile(files,
|
|
423
|
-
return files.find((file) => file.path ===
|
|
422
|
+
function findFile(files, path12) {
|
|
423
|
+
return files.find((file) => file.path === path12) ?? files.find((file) => file.oldPath === path12);
|
|
424
424
|
}
|
|
425
|
-
function findNewLine(files,
|
|
426
|
-
const file = findFile(files,
|
|
425
|
+
function findNewLine(files, path12, line) {
|
|
426
|
+
const file = findFile(files, path12);
|
|
427
427
|
if (!file) return void 0;
|
|
428
428
|
for (const hunk of file.hunks) {
|
|
429
429
|
for (const item of hunk.lines) {
|
|
@@ -432,8 +432,8 @@ function findNewLine(files, path11, line) {
|
|
|
432
432
|
}
|
|
433
433
|
return void 0;
|
|
434
434
|
}
|
|
435
|
-
function snippetAround(files,
|
|
436
|
-
const file = findFile(files,
|
|
435
|
+
function snippetAround(files, path12, line, radius = 6) {
|
|
436
|
+
const file = findFile(files, path12);
|
|
437
437
|
if (!file || line == null) return null;
|
|
438
438
|
const flat = file.hunks.flatMap((hunk) => hunk.lines);
|
|
439
439
|
const target = flat.findIndex((item) => item.newLine === line);
|
|
@@ -446,9 +446,9 @@ function snippetAround(files, path11, line, radius = 6) {
|
|
|
446
446
|
target: item.newLine === line
|
|
447
447
|
}));
|
|
448
448
|
}
|
|
449
|
-
function linePosition(files,
|
|
450
|
-
const file = findFile(files,
|
|
451
|
-
const found = findNewLine(files,
|
|
449
|
+
function linePosition(files, path12, line) {
|
|
450
|
+
const file = findFile(files, path12);
|
|
451
|
+
const found = findNewLine(files, path12, line);
|
|
452
452
|
if (!file || !found) return null;
|
|
453
453
|
return { newPath: file.path, newLine: line, oldPath: file.oldPath, oldLine: found.kind === " " ? found.oldLine : null };
|
|
454
454
|
}
|
|
@@ -465,7 +465,7 @@ var init_diff = __esm({
|
|
|
465
465
|
// src/providers/util.ts
|
|
466
466
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
467
467
|
import { tmpdir } from "node:os";
|
|
468
|
-
import
|
|
468
|
+
import path7 from "node:path";
|
|
469
469
|
function parseJson(stdout, source) {
|
|
470
470
|
const text2 = stdout.trim();
|
|
471
471
|
if (!text2) throw new ProviderError(tr(`${source}: \u043F\u0443\u0441\u0442\u043E\u0439 \u043E\u0442\u0432\u0435\u0442`, `${source}: empty response`));
|
|
@@ -496,8 +496,8 @@ function cliError(error, platform, host) {
|
|
|
496
496
|
throw new ProviderError(`${platform}: ${message || tr("\u043A\u043E\u043C\u0430\u043D\u0434\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0430\u0441\u044C \u0441 \u043E\u0448\u0438\u0431\u043A\u043E\u0439", "the command failed")}`);
|
|
497
497
|
}
|
|
498
498
|
async function withTempJson(data, fn) {
|
|
499
|
-
const dir = await mkdtemp(
|
|
500
|
-
const file =
|
|
499
|
+
const dir = await mkdtemp(path7.join(tmpdir(), "revdeck-"));
|
|
500
|
+
const file = path7.join(dir, "payload.json");
|
|
501
501
|
try {
|
|
502
502
|
await writeFile(file, JSON.stringify(data), { mode: 384, flag: "wx" });
|
|
503
503
|
return await fn(file);
|
|
@@ -505,8 +505,8 @@ async function withTempJson(data, fn) {
|
|
|
505
505
|
await rm(dir, { recursive: true, force: true });
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
function query(
|
|
509
|
-
const url = new URL(
|
|
508
|
+
function query(path12, params) {
|
|
509
|
+
const url = new URL(path12.startsWith("/") ? path12 : `/${path12}`, "http://local");
|
|
510
510
|
for (const [key, value] of Object.entries(params)) {
|
|
511
511
|
if (value !== void 0 && value !== "") url.searchParams.set(key, String(value));
|
|
512
512
|
}
|
|
@@ -1158,16 +1158,16 @@ rename to ${newPath}
|
|
|
1158
1158
|
});
|
|
1159
1159
|
|
|
1160
1160
|
// src/daemon/main.ts
|
|
1161
|
-
import { existsSync as
|
|
1161
|
+
import { existsSync as existsSync5, readFileSync } from "node:fs";
|
|
1162
1162
|
import { appendFile, open as open2, readFile as readFile3, unlink as unlink4 } from "node:fs/promises";
|
|
1163
1163
|
import net2 from "node:net";
|
|
1164
|
-
import
|
|
1164
|
+
import path11 from "node:path";
|
|
1165
1165
|
import { fileURLToPath } from "node:url";
|
|
1166
1166
|
import { parseArgs } from "node:util";
|
|
1167
1167
|
|
|
1168
1168
|
// src/core/paths.ts
|
|
1169
1169
|
import { constants, existsSync } from "node:fs";
|
|
1170
|
-
import { lstat, mkdir, open, realpath, rename, unlink } from "node:fs/promises";
|
|
1170
|
+
import { lstat, mkdir, open, realpath, rename, stat, unlink } from "node:fs/promises";
|
|
1171
1171
|
import path from "node:path";
|
|
1172
1172
|
import os from "node:os";
|
|
1173
1173
|
function findRepoRoot(start = process.cwd()) {
|
|
@@ -1259,30 +1259,40 @@ async function readTextNoFollow(file, maxBytes = 4 * 1024 * 1024) {
|
|
|
1259
1259
|
await handle.close();
|
|
1260
1260
|
}
|
|
1261
1261
|
}
|
|
1262
|
-
async function
|
|
1262
|
+
async function openInsideRoot(root, target) {
|
|
1263
|
+
const resolvedTarget = path.resolve(target);
|
|
1263
1264
|
const realRoot = await realpath(path.resolve(root));
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1265
|
+
let handle;
|
|
1266
|
+
try {
|
|
1267
|
+
handle = await open(resolvedTarget, process.platform === "win32" ? "r" : constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
1268
|
+
} catch (error) {
|
|
1269
|
+
if (error.code === "ELOOP") {
|
|
1270
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
1271
|
+
}
|
|
1272
|
+
throw error;
|
|
1267
1273
|
}
|
|
1268
|
-
return realTarget;
|
|
1269
|
-
}
|
|
1270
|
-
async function readTextPrefixNoFollow(file, maxBytes = 4 * 1024 * 1024) {
|
|
1271
|
-
const info = await lstat(file);
|
|
1272
|
-
if (info.isSymbolicLink()) throw new Error(`${path.basename(file)}: symbolic link, read refused`);
|
|
1273
|
-
if (!info.isFile()) throw new Error(`${path.basename(file)}: not a regular file`);
|
|
1274
|
-
const limit = Math.max(1, Math.min(Math.floor(maxBytes), 16 * 1024 * 1024));
|
|
1275
|
-
const flags = process.platform === "win32" ? "r" : constants.O_RDONLY | constants.O_NOFOLLOW;
|
|
1276
|
-
const handle = await open(file, flags);
|
|
1277
1274
|
try {
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1275
|
+
const info = await handle.stat();
|
|
1276
|
+
if (!info.isFile()) throw new Error(`${path.basename(target)}: not a regular file`);
|
|
1277
|
+
if (process.platform === "linux") {
|
|
1278
|
+
const actual = await realpath(`/proc/self/fd/${handle.fd}`);
|
|
1279
|
+
if (!isInside(realRoot, actual)) {
|
|
1280
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
1281
|
+
}
|
|
1282
|
+
} else {
|
|
1283
|
+
const actual = await realpath(resolvedTarget);
|
|
1284
|
+
if (!isInside(realRoot, actual)) {
|
|
1285
|
+
throw new Error(`${path.basename(target)}: path escapes the repository`);
|
|
1286
|
+
}
|
|
1287
|
+
const onDisk = await stat(actual);
|
|
1288
|
+
if (onDisk.dev !== info.dev || onDisk.ino !== info.ino) {
|
|
1289
|
+
throw new Error(`${path.basename(target)}: path changed during read`);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
return handle;
|
|
1293
|
+
} catch (error) {
|
|
1285
1294
|
await handle.close();
|
|
1295
|
+
throw error;
|
|
1286
1296
|
}
|
|
1287
1297
|
}
|
|
1288
1298
|
async function writeFileAtomic(file, data, mode = 384, dirMode = 448) {
|
|
@@ -1308,8 +1318,8 @@ async function writeFileAtomic(file, data, mode = 384, dirMode = 448) {
|
|
|
1308
1318
|
init_redact();
|
|
1309
1319
|
|
|
1310
1320
|
// src/version.ts
|
|
1311
|
-
var VERSION = "0.
|
|
1312
|
-
var PROTOCOL_VERSION =
|
|
1321
|
+
var VERSION = "0.7.0";
|
|
1322
|
+
var PROTOCOL_VERSION = 2;
|
|
1313
1323
|
|
|
1314
1324
|
// src/daemon/main.ts
|
|
1315
1325
|
init_locale();
|
|
@@ -1730,6 +1740,34 @@ var Store = class {
|
|
|
1730
1740
|
getProject(key) {
|
|
1731
1741
|
return this.listProjects().find((project) => project.key === key) ?? null;
|
|
1732
1742
|
}
|
|
1743
|
+
/** Переименование проекта и явное управление root'ами рабочих копий. */
|
|
1744
|
+
updateProject(key, patch, now = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
1745
|
+
const current2 = this.getProject(key);
|
|
1746
|
+
if (!current2) return null;
|
|
1747
|
+
const title = (patch.title ?? current2.title).trim();
|
|
1748
|
+
if (!title) throw new Error(tr("\u043D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u043F\u0440\u043E\u0435\u043A\u0442\u0430 \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u0431\u044B\u0442\u044C \u043F\u0443\u0441\u0442\u044B\u043C", "project title cannot be empty"));
|
|
1749
|
+
const roots = patch.roots === void 0 ? null : [...new Set(patch.roots.map((root) => root.trim()).filter(Boolean))];
|
|
1750
|
+
this.transaction(() => {
|
|
1751
|
+
this.db.prepare("UPDATE projects SET title = ?, updated_at = ? WHERE key = ?").run(title.slice(0, 120), now, key);
|
|
1752
|
+
if (roots !== null) {
|
|
1753
|
+
this.db.prepare("DELETE FROM project_roots WHERE project_key = ?").run(key);
|
|
1754
|
+
const insert = this.db.prepare("INSERT INTO project_roots (project_key, root, last_seen_at) VALUES (?, ?, ?)");
|
|
1755
|
+
for (const root of roots) insert.run(key, root, now);
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
return this.getProject(key);
|
|
1759
|
+
}
|
|
1760
|
+
/** Удаляет проект вместе с его локальными ревью; платформа не затрагивается. */
|
|
1761
|
+
removeProject(key) {
|
|
1762
|
+
const countRow = this.db.prepare("SELECT COUNT(*) AS count FROM reviews WHERE project_key = ?").get(key);
|
|
1763
|
+
const reviews = Number(countRow?.count ?? 0);
|
|
1764
|
+
this.transaction(() => {
|
|
1765
|
+
this.db.prepare("DELETE FROM approvals WHERE review_id IN (SELECT id FROM reviews WHERE project_key = ?)").run(key);
|
|
1766
|
+
this.db.prepare("DELETE FROM reviews WHERE project_key = ?").run(key);
|
|
1767
|
+
this.db.prepare("DELETE FROM projects WHERE key = ?").run(key);
|
|
1768
|
+
});
|
|
1769
|
+
return reviews;
|
|
1770
|
+
}
|
|
1733
1771
|
// ---------------------------------------------------------------- features
|
|
1734
1772
|
featureMembers(id) {
|
|
1735
1773
|
const rows = this.db.prepare(
|
|
@@ -2291,14 +2329,14 @@ import { EventEmitter } from "node:events";
|
|
|
2291
2329
|
import { createHash as createHash2, randomBytes as randomBytes2 } from "node:crypto";
|
|
2292
2330
|
import { mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
2293
2331
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
2294
|
-
import
|
|
2332
|
+
import path8 from "node:path";
|
|
2295
2333
|
|
|
2296
2334
|
// src/core/config.ts
|
|
2297
2335
|
import { z } from "zod";
|
|
2298
2336
|
init_errors();
|
|
2299
2337
|
import { parse as parseYaml } from "yaml";
|
|
2300
2338
|
import { existsSync as existsSync2 } from "node:fs";
|
|
2301
|
-
import
|
|
2339
|
+
import path4 from "node:path";
|
|
2302
2340
|
|
|
2303
2341
|
// src/core/glob.ts
|
|
2304
2342
|
function globToRegExp(glob) {
|
|
@@ -2344,8 +2382,8 @@ function globToRegExp(glob) {
|
|
|
2344
2382
|
function escapeRegExp(value) {
|
|
2345
2383
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2346
2384
|
}
|
|
2347
|
-
function classifyFile(
|
|
2348
|
-
const lower =
|
|
2385
|
+
function classifyFile(path12) {
|
|
2386
|
+
const lower = path12.toLowerCase();
|
|
2349
2387
|
if (/(^|\/)(node_modules|dist|build|coverage|vendor)\//.test(lower)) return "generated";
|
|
2350
2388
|
if (/\.(md|mdx|rst|txt|adoc)$/.test(lower) || /(^|\/)(docs?|adr)\//.test(lower)) return "docs";
|
|
2351
2389
|
if (/(^|\/)(__tests__|tests?|spec|e2e)\//.test(lower) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /_test\.go$/.test(lower)) return "test";
|
|
@@ -2490,6 +2528,19 @@ function roleCriteriaText(role) {
|
|
|
2490
2528
|
return role.criteria.length ? `\xA7${role.criteria.join(", \xA7")}` : "";
|
|
2491
2529
|
}
|
|
2492
2530
|
|
|
2531
|
+
// src/core/git-files.ts
|
|
2532
|
+
init_exec();
|
|
2533
|
+
async function gitTrackState(root, relative) {
|
|
2534
|
+
try {
|
|
2535
|
+
const { stdout } = await run("git", ["-C", root, "ls-files", "--error-unmatch", "--", relative], {
|
|
2536
|
+
timeoutMs: 1e4
|
|
2537
|
+
});
|
|
2538
|
+
return stdout.trim() ? "tracked" : "unknown";
|
|
2539
|
+
} catch (error) {
|
|
2540
|
+
return error.code === 1 ? "untracked" : "unknown";
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2493
2544
|
// src/core/config.ts
|
|
2494
2545
|
var matchSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
2495
2546
|
var customRoleSchema = z.object({
|
|
@@ -2628,9 +2679,21 @@ function mergeConfigData(base, local) {
|
|
|
2628
2679
|
async function loadConfig(root = findRepoRoot()) {
|
|
2629
2680
|
const warnings = [];
|
|
2630
2681
|
const file = findConfigFile(root);
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2682
|
+
let localFile = findLocalConfigFile(root);
|
|
2683
|
+
if (localFile && existsSync2(path4.join(root, ".git"))) {
|
|
2684
|
+
const state = await gitTrackState(root, path4.relative(root, localFile));
|
|
2685
|
+
if (state !== "untracked") {
|
|
2686
|
+
warnings.push(
|
|
2687
|
+
tr(
|
|
2688
|
+
".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",
|
|
2689
|
+
".revdeck.local.yml is tracked by git: a repository file is ignored as personal overrides"
|
|
2690
|
+
)
|
|
2691
|
+
);
|
|
2692
|
+
localFile = null;
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
const baseData = file ? parseYamlData(await readTextNoFollow(file), path4.relative(root, file) || file) : {};
|
|
2696
|
+
const localData = localFile ? parseYamlData(await readTextNoFollow(localFile), path4.relative(root, localFile) || localFile) : {};
|
|
2634
2697
|
if (!file && !localFile) {
|
|
2635
2698
|
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"));
|
|
2636
2699
|
}
|
|
@@ -2640,7 +2703,7 @@ async function loadConfig(root = findRepoRoot()) {
|
|
|
2640
2703
|
const localReadOnly = isRecord(localData) && isRecord(localData.review) && localData.review.readOnly === true;
|
|
2641
2704
|
config.review.readOnly = baseReadOnly || localReadOnly;
|
|
2642
2705
|
if (!config.rules.sources.length && !config.rules.map.length) {
|
|
2643
|
-
const found = DISCOVERED_SOURCES.filter((item) => existsSync2(
|
|
2706
|
+
const found = DISCOVERED_SOURCES.filter((item) => existsSync2(path4.join(root, item)));
|
|
2644
2707
|
config.rules.sources = found;
|
|
2645
2708
|
if (!found.length) {
|
|
2646
2709
|
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"));
|
|
@@ -2655,22 +2718,38 @@ async function loadConfig(root = findRepoRoot()) {
|
|
|
2655
2718
|
}
|
|
2656
2719
|
function assertConfigPath(root, relative) {
|
|
2657
2720
|
const cleaned = relative.split("#")[0];
|
|
2658
|
-
const resolved =
|
|
2659
|
-
const rel =
|
|
2660
|
-
if (rel.startsWith("..") ||
|
|
2721
|
+
const resolved = path4.resolve(root, cleaned);
|
|
2722
|
+
const rel = path4.relative(root, resolved);
|
|
2723
|
+
if (rel.startsWith("..") || path4.isAbsolute(rel)) {
|
|
2661
2724
|
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`));
|
|
2662
2725
|
}
|
|
2663
2726
|
return resolved;
|
|
2664
2727
|
}
|
|
2665
2728
|
async function readConfigFile(root, relative, maxBytes = 4 * 1024 * 1024) {
|
|
2666
|
-
const
|
|
2667
|
-
|
|
2668
|
-
|
|
2729
|
+
const handle = await openInsideRoot(root, assertConfigPath(root, relative));
|
|
2730
|
+
try {
|
|
2731
|
+
const info = await handle.stat();
|
|
2732
|
+
if (info.size > maxBytes) {
|
|
2733
|
+
throw new Error(`${path4.basename(relative)}: file is larger than ${Math.round(maxBytes / 1024)} KB`);
|
|
2734
|
+
}
|
|
2735
|
+
return await handle.readFile({ encoding: "utf8" });
|
|
2736
|
+
} finally {
|
|
2737
|
+
await handle.close();
|
|
2738
|
+
}
|
|
2669
2739
|
}
|
|
2670
2740
|
async function readConfigPrefix(root, relative, maxBytes = 4 * 1024 * 1024) {
|
|
2671
|
-
const
|
|
2672
|
-
|
|
2673
|
-
|
|
2741
|
+
const handle = await openInsideRoot(root, assertConfigPath(root, relative));
|
|
2742
|
+
try {
|
|
2743
|
+
const limit = Math.max(1, Math.min(Math.floor(maxBytes), 16 * 1024 * 1024));
|
|
2744
|
+
const buffer = Buffer.allocUnsafe(limit + 1);
|
|
2745
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
2746
|
+
return {
|
|
2747
|
+
text: buffer.subarray(0, Math.min(bytesRead, limit)).toString("utf8"),
|
|
2748
|
+
truncated: bytesRead > limit
|
|
2749
|
+
};
|
|
2750
|
+
} finally {
|
|
2751
|
+
await handle.close();
|
|
2752
|
+
}
|
|
2674
2753
|
}
|
|
2675
2754
|
function checksForPaths(config, paths) {
|
|
2676
2755
|
return config.checks.map((check) => {
|
|
@@ -2679,6 +2758,37 @@ function checksForPaths(config, paths) {
|
|
|
2679
2758
|
});
|
|
2680
2759
|
}
|
|
2681
2760
|
|
|
2761
|
+
// src/core/doc-policy.ts
|
|
2762
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
2763
|
+
import path5 from "node:path";
|
|
2764
|
+
init_errors();
|
|
2765
|
+
init_locale();
|
|
2766
|
+
var DOC_EXTENSION = /\.(md|mdx|rst|txt|adoc)$/i;
|
|
2767
|
+
var PROFILE_EXTENSION = /\.(md|mdx|rst|txt|adoc|ya?ml|json)$/i;
|
|
2768
|
+
var SECRET_PATH = /(^|\/)(\.env(\..*)?|\.npmrc|\.git(\/.*)?|\.revdeck\.local\.(ya?ml)|id_(rsa|ed25519|ecdsa)(\.pub)?|.*\.(pem|key|p12|pfx|jks|keystore|tfvars|tfstate))$/i;
|
|
2769
|
+
async function assertSafeDocument(root, relative, kind = "rules") {
|
|
2770
|
+
const clean = relative.split("#")[0];
|
|
2771
|
+
const resolved = assertConfigPath(root, clean);
|
|
2772
|
+
if (SECRET_PATH.test(clean)) {
|
|
2773
|
+
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`));
|
|
2774
|
+
}
|
|
2775
|
+
if (!(kind === "profile" ? PROFILE_EXTENSION : DOC_EXTENSION).test(clean)) {
|
|
2776
|
+
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`));
|
|
2777
|
+
}
|
|
2778
|
+
if (existsSync3(path5.join(root, ".git"))) {
|
|
2779
|
+
const state = await gitTrackState(root, clean);
|
|
2780
|
+
if (state !== "tracked") {
|
|
2781
|
+
throw new ConfigError(
|
|
2782
|
+
tr(
|
|
2783
|
+
`${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)`,
|
|
2784
|
+
`${relative}: document is not tracked by git (or git is unavailable)`
|
|
2785
|
+
)
|
|
2786
|
+
);
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
return resolved;
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2682
2792
|
// src/core/git.ts
|
|
2683
2793
|
init_exec();
|
|
2684
2794
|
var SSH_SCP = /^(?:ssh:\/\/)?(?:[^@/]+@)?([^:/]+)(?::(\d+))?[:/](.+?)(?:\.git)?\/?$/;
|
|
@@ -2725,8 +2835,8 @@ async function currentBranch(root) {
|
|
|
2725
2835
|
}
|
|
2726
2836
|
|
|
2727
2837
|
// src/core/rules.ts
|
|
2728
|
-
import
|
|
2729
|
-
import { existsSync as
|
|
2838
|
+
import path6 from "node:path";
|
|
2839
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
2730
2840
|
init_redact();
|
|
2731
2841
|
var MAX_READ_BYTES = 16 * 1024 * 1024;
|
|
2732
2842
|
async function buildEffectiveRules(options) {
|
|
@@ -2746,14 +2856,14 @@ async function buildEffectiveRules(options) {
|
|
|
2746
2856
|
const relative = rawPath;
|
|
2747
2857
|
let resolved;
|
|
2748
2858
|
try {
|
|
2749
|
-
resolved =
|
|
2859
|
+
resolved = await assertSafeDocument(root, relative, "rules");
|
|
2750
2860
|
} catch (error) {
|
|
2751
|
-
warnings.push(
|
|
2861
|
+
warnings.push(error.message);
|
|
2752
2862
|
return { path: relative, exists: false, sections: [], excerpt: "", truncated: false };
|
|
2753
2863
|
}
|
|
2754
2864
|
let cached = cache.get(resolved);
|
|
2755
2865
|
if (!cached) {
|
|
2756
|
-
if (!
|
|
2866
|
+
if (!existsSync4(resolved)) {
|
|
2757
2867
|
cached = { exists: false, text: "", truncated: false };
|
|
2758
2868
|
warnings.push(`${t("\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442", "document")} ${relative} ${t("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D", "not found")}`);
|
|
2759
2869
|
} else {
|
|
@@ -2806,7 +2916,7 @@ async function buildEffectiveRules(options) {
|
|
|
2806
2916
|
scopes.push({ file: "", kind: "other", documents });
|
|
2807
2917
|
}
|
|
2808
2918
|
return {
|
|
2809
|
-
configPath: configPath ?
|
|
2919
|
+
configPath: configPath ? path6.relative(root, configPath) : null,
|
|
2810
2920
|
scopes,
|
|
2811
2921
|
checks: checksForPaths(config, files),
|
|
2812
2922
|
warnings: [...new Set(warnings)]
|
|
@@ -2927,8 +3037,8 @@ var CLASS_LABEL = {
|
|
|
2927
3037
|
};
|
|
2928
3038
|
function computeGroups(diff, custom = []) {
|
|
2929
3039
|
const groups = /* @__PURE__ */ new Map();
|
|
2930
|
-
const add = (group,
|
|
2931
|
-
group.files.push(
|
|
3040
|
+
const add = (group, path12, additions, deletions) => {
|
|
3041
|
+
group.files.push(path12);
|
|
2932
3042
|
group.additions += additions;
|
|
2933
3043
|
group.deletions += deletions;
|
|
2934
3044
|
groups.set(group.id, group);
|
|
@@ -2989,23 +3099,23 @@ function maskSecret(value) {
|
|
|
2989
3099
|
if (trimmed.length <= 8) return "***";
|
|
2990
3100
|
return `${trimmed.slice(0, 4)}\u2026${trimmed.slice(-2)}`;
|
|
2991
3101
|
}
|
|
2992
|
-
function isAllowlisted(
|
|
3102
|
+
function isAllowlisted(path12, rule, allowlist) {
|
|
2993
3103
|
return allowlist.some((entry) => {
|
|
2994
3104
|
const normalized = entry.trim();
|
|
2995
3105
|
if (!normalized) return false;
|
|
2996
3106
|
if (normalized === rule || normalized === `rule:${rule}`) return true;
|
|
2997
3107
|
if (normalized.startsWith("rule:")) return false;
|
|
2998
|
-
return globToRegExp(normalized).test(
|
|
3108
|
+
return globToRegExp(normalized).test(path12);
|
|
2999
3109
|
});
|
|
3000
3110
|
}
|
|
3001
|
-
function scanLines(
|
|
3002
|
-
if (!options.includeTests && classifyFile(
|
|
3111
|
+
function scanLines(path12, lines, options = {}) {
|
|
3112
|
+
if (!options.includeTests && classifyFile(path12) === "test") return [];
|
|
3003
3113
|
const allowlist = options.allowlist ?? [];
|
|
3004
3114
|
const findings = [];
|
|
3005
3115
|
for (const line of lines) {
|
|
3006
3116
|
let specific = false;
|
|
3007
3117
|
for (const pattern of PATTERNS) {
|
|
3008
|
-
if (isAllowlisted(
|
|
3118
|
+
if (isAllowlisted(path12, pattern.id, allowlist)) continue;
|
|
3009
3119
|
if (pattern.id === "generic-secret" && specific) continue;
|
|
3010
3120
|
pattern.regex.lastIndex = 0;
|
|
3011
3121
|
const match = pattern.regex.exec(line.text);
|
|
@@ -3014,7 +3124,7 @@ function scanLines(path11, lines, options = {}) {
|
|
|
3014
3124
|
findings.push({
|
|
3015
3125
|
rule: pattern.id,
|
|
3016
3126
|
title: pattern.title,
|
|
3017
|
-
file:
|
|
3127
|
+
file: path12,
|
|
3018
3128
|
line: line.number,
|
|
3019
3129
|
preview: maskSecret(match[0])
|
|
3020
3130
|
});
|
|
@@ -3668,7 +3778,7 @@ function parseOpenApi(text2) {
|
|
|
3668
3778
|
const info = isRecord2(document.info) ? document.info : {};
|
|
3669
3779
|
const paths = isRecord2(document.paths) ? document.paths : {};
|
|
3670
3780
|
const operations = [];
|
|
3671
|
-
for (const [
|
|
3781
|
+
for (const [path12, value] of Object.entries(paths)) {
|
|
3672
3782
|
if (!isRecord2(value)) continue;
|
|
3673
3783
|
for (const method of METHODS) {
|
|
3674
3784
|
const operation = value[method];
|
|
@@ -3679,7 +3789,7 @@ function parseOpenApi(text2) {
|
|
|
3679
3789
|
const media = isRecord2(firstMedia) ? firstMedia : {};
|
|
3680
3790
|
operations.push({
|
|
3681
3791
|
method: method.toUpperCase(),
|
|
3682
|
-
path:
|
|
3792
|
+
path: path12,
|
|
3683
3793
|
operationId: String(operation.operationId ?? ""),
|
|
3684
3794
|
summary: String(operation.summary ?? ""),
|
|
3685
3795
|
parameters: parametersOf(operation, document),
|
|
@@ -3731,9 +3841,9 @@ function renderOpenApiSummary(summary) {
|
|
|
3731
3841
|
}
|
|
3732
3842
|
return lines.join("\n");
|
|
3733
3843
|
}
|
|
3734
|
-
function openApiPathRegExp(
|
|
3735
|
-
if (
|
|
3736
|
-
const escaped =
|
|
3844
|
+
function openApiPathRegExp(path12) {
|
|
3845
|
+
if (path12 === "/") return /(?!)/;
|
|
3846
|
+
const escaped = path12.replace(/\{[^}]+\}/g, "\0").replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\u0000/g, "[^/?#\\s]+");
|
|
3737
3847
|
return new RegExp(`(?<![\\w-])${escaped}(?![\\w-])`);
|
|
3738
3848
|
}
|
|
3739
3849
|
|
|
@@ -4046,8 +4156,30 @@ var ReviewService = class {
|
|
|
4046
4156
|
const loaded = await loadConfig(root);
|
|
4047
4157
|
const context = await projectContext(root, loaded.config);
|
|
4048
4158
|
const key = this.store.registerProject(context, root, this.now().toISOString());
|
|
4159
|
+
this.store.audit(null, "project.register", { key, root });
|
|
4160
|
+
this.events.emit("project", { key, at: this.now().toISOString() });
|
|
4049
4161
|
return this.store.getProject(key);
|
|
4050
4162
|
}
|
|
4163
|
+
updateProject(keyInput, patch) {
|
|
4164
|
+
const key = keyInput.trim();
|
|
4165
|
+
if (!this.store.getProject(key)) throw new Error(tr(`\u043F\u0440\u043E\u0435\u043A\u0442 ${key} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D`, `project ${key} not found`));
|
|
4166
|
+
const project = this.store.updateProject(key, patch, this.now().toISOString());
|
|
4167
|
+
this.store.audit(null, "project.update", {
|
|
4168
|
+
key,
|
|
4169
|
+
...patch.title === void 0 ? {} : { title: patch.title },
|
|
4170
|
+
...patch.roots === void 0 ? {} : { roots: patch.roots.length }
|
|
4171
|
+
});
|
|
4172
|
+
this.events.emit("project", { key, at: this.now().toISOString() });
|
|
4173
|
+
return project;
|
|
4174
|
+
}
|
|
4175
|
+
removeProject(keyInput) {
|
|
4176
|
+
const key = keyInput.trim();
|
|
4177
|
+
if (!this.store.getProject(key)) throw new Error(tr(`\u043F\u0440\u043E\u0435\u043A\u0442 ${key} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D`, `project ${key} not found`));
|
|
4178
|
+
const reviews = this.store.removeProject(key);
|
|
4179
|
+
this.store.audit(null, "project.remove", { key, reviews });
|
|
4180
|
+
this.events.emit("project", { key, at: this.now().toISOString() });
|
|
4181
|
+
return reviews;
|
|
4182
|
+
}
|
|
4051
4183
|
async projectForRoot(rootInput) {
|
|
4052
4184
|
const root = findRepoRoot(rootInput);
|
|
4053
4185
|
const loaded = await loadConfig(root);
|
|
@@ -4222,6 +4354,7 @@ ${t("\u2026 \u043A\u043E\u043D\u0442\u0440\u0430\u043A\u0442 \u043E\u0431\u0440\
|
|
|
4222
4354
|
break;
|
|
4223
4355
|
}
|
|
4224
4356
|
try {
|
|
4357
|
+
await assertSafeDocument(member.review.root, source, "profile");
|
|
4225
4358
|
const content = await readConfigPrefix(member.review.root, source, remaining);
|
|
4226
4359
|
const profileText = content.text.trim().slice(0, remaining);
|
|
4227
4360
|
remaining -= profileText.length;
|
|
@@ -4531,8 +4664,8 @@ ${errors.join("\n")}`));
|
|
|
4531
4664
|
if (!matchesSignature(buffer, spec.contentType)) {
|
|
4532
4665
|
throw new Error(tr("\u0432\u043B\u043E\u0436\u0435\u043D\u0438\u0435: \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0435 \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0430\u0435\u0442 \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043D\u0438\u0435\u043C", "attachment: content does not match the extension"));
|
|
4533
4666
|
}
|
|
4534
|
-
const dir = await mkdtemp2(
|
|
4535
|
-
const file =
|
|
4667
|
+
const dir = await mkdtemp2(path8.join(tmpdir4(), "revdeck-attachment-"));
|
|
4668
|
+
const file = path8.join(dir, spec.name);
|
|
4536
4669
|
try {
|
|
4537
4670
|
await writeFile2(file, buffer, { mode: 384, flag: "wx" });
|
|
4538
4671
|
const uploaded = await provider.upload({ path: file, name: spec.name, contentType: spec.contentType });
|
|
@@ -5082,8 +5215,8 @@ init_redact();
|
|
|
5082
5215
|
init_errors();
|
|
5083
5216
|
import http from "node:http";
|
|
5084
5217
|
import { createReadStream } from "node:fs";
|
|
5085
|
-
import { readFile as readFile2, stat } from "node:fs/promises";
|
|
5086
|
-
import
|
|
5218
|
+
import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
|
|
5219
|
+
import path9 from "node:path";
|
|
5087
5220
|
import { timingSafeEqual } from "node:crypto";
|
|
5088
5221
|
|
|
5089
5222
|
// src/daemon/rpc.ts
|
|
@@ -5092,6 +5225,50 @@ import { chmod, unlink as unlink2 } from "node:fs/promises";
|
|
|
5092
5225
|
init_redact();
|
|
5093
5226
|
init_errors();
|
|
5094
5227
|
init_exec();
|
|
5228
|
+
|
|
5229
|
+
// src/daemon/capabilities.ts
|
|
5230
|
+
var AGENT_METHODS = /* @__PURE__ */ new Set([
|
|
5231
|
+
"ping",
|
|
5232
|
+
"projects.list",
|
|
5233
|
+
"reviews.list",
|
|
5234
|
+
"reviews.get",
|
|
5235
|
+
"reviews.open",
|
|
5236
|
+
"reviews.refresh",
|
|
5237
|
+
"reviews.remoteList",
|
|
5238
|
+
"versions.list",
|
|
5239
|
+
"versions.get",
|
|
5240
|
+
"secrets.get",
|
|
5241
|
+
"analytics.get",
|
|
5242
|
+
"diff.get",
|
|
5243
|
+
"rules.get",
|
|
5244
|
+
"features.list",
|
|
5245
|
+
"features.get",
|
|
5246
|
+
"features.context",
|
|
5247
|
+
"features.forReview",
|
|
5248
|
+
"features.addNote",
|
|
5249
|
+
"features.updateNote",
|
|
5250
|
+
"features.deleteNote",
|
|
5251
|
+
"drafts.put",
|
|
5252
|
+
"findings.put",
|
|
5253
|
+
"findings.list",
|
|
5254
|
+
"summary.put",
|
|
5255
|
+
"notes.add",
|
|
5256
|
+
"notes.update",
|
|
5257
|
+
"notes.delete",
|
|
5258
|
+
"publish.preview"
|
|
5259
|
+
]);
|
|
5260
|
+
var AGENT_POLICY = {
|
|
5261
|
+
name: "agent",
|
|
5262
|
+
capabilities: /* @__PURE__ */ new Set(["read", "draft"]),
|
|
5263
|
+
allows: (method) => AGENT_METHODS.has(method)
|
|
5264
|
+
};
|
|
5265
|
+
var HUMAN_POLICY = {
|
|
5266
|
+
name: "human",
|
|
5267
|
+
capabilities: /* @__PURE__ */ new Set(["read", "draft", "publish", "checks", "admin"]),
|
|
5268
|
+
allows: () => true
|
|
5269
|
+
};
|
|
5270
|
+
|
|
5271
|
+
// src/daemon/rpc.ts
|
|
5095
5272
|
var MAX_LINE = 40 * 1024 * 1024;
|
|
5096
5273
|
function featureReviewInput(value) {
|
|
5097
5274
|
if (typeof value === "string") return { review: value };
|
|
@@ -5101,11 +5278,36 @@ function featureReviewInput(value) {
|
|
|
5101
5278
|
...typeof item.role === "string" ? { role: item.role } : {}
|
|
5102
5279
|
};
|
|
5103
5280
|
}
|
|
5104
|
-
|
|
5281
|
+
function assertAgentFeatureNote(service, featureId, noteId, policy) {
|
|
5282
|
+
if (policy.name !== "agent") return;
|
|
5283
|
+
const note = service.getFeature(featureId).notes.find((item) => item.id === noteId);
|
|
5284
|
+
if (!note || note.author !== "agent") {
|
|
5285
|
+
throw new MrReviewError(
|
|
5286
|
+
"\u0430\u0433\u0435\u043D\u0442 \u043C\u043E\u0436\u0435\u0442 \u0438\u0437\u043C\u0435\u043D\u044F\u0442\u044C \u0442\u043E\u043B\u044C\u043A\u043E \u0441\u0432\u043E\u0438 feature-\u0437\u0430\u043C\u0435\u0442\u043A\u0438",
|
|
5287
|
+
"CAPABILITY",
|
|
5288
|
+
"\u0437\u0430\u043C\u0435\u0442\u043A\u0438 \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u0430 \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u0443\u0435\u0442 \u0438 \u0443\u0434\u0430\u043B\u044F\u0435\u0442 \u0447\u0435\u043B\u043E\u0432\u0435\u043A \u0432 UI/CLI"
|
|
5289
|
+
);
|
|
5290
|
+
}
|
|
5291
|
+
}
|
|
5292
|
+
async function dispatch(service, method, params, policy = HUMAN_POLICY) {
|
|
5293
|
+
if (!policy.allows(method)) {
|
|
5294
|
+
throw new MrReviewError(
|
|
5295
|
+
`\u043C\u0435\u0442\u043E\u0434 ${method} \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u044D\u0442\u043E\u043C\u0443 \u043A\u043B\u0438\u0435\u043D\u0442\u0443`,
|
|
5296
|
+
"CAPABILITY",
|
|
5297
|
+
policy.name === "agent" ? "\u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F, checks, \u0440\u0435\u0448\u0435\u043D\u0438\u044F \u0438 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u044F\u044E\u0442\u0441\u044F \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u043E\u043C \u0432 UI \u0438\u043B\u0438 CLI \u043D\u0430 \u0445\u043E\u0441\u0442\u0435" : void 0
|
|
5298
|
+
);
|
|
5299
|
+
}
|
|
5105
5300
|
switch (method) {
|
|
5106
5301
|
case "ping": {
|
|
5107
5302
|
const [glab, gh, git] = await Promise.all(["glab", "gh", "git"].map((name) => resolveExecutable(name)));
|
|
5108
|
-
return {
|
|
5303
|
+
return {
|
|
5304
|
+
ok: true,
|
|
5305
|
+
version: VERSION,
|
|
5306
|
+
protocol: PROTOCOL_VERSION,
|
|
5307
|
+
pid: process.pid,
|
|
5308
|
+
capabilities: [...policy.capabilities],
|
|
5309
|
+
binaries: { glab, gh, git }
|
|
5310
|
+
};
|
|
5109
5311
|
}
|
|
5110
5312
|
case "projects.list":
|
|
5111
5313
|
return { projects: service.listProjects() };
|
|
@@ -5115,6 +5317,23 @@ async function dispatch(service, method, params) {
|
|
|
5115
5317
|
const project = await service.registerProject(root);
|
|
5116
5318
|
return { project, projects: service.listProjects() };
|
|
5117
5319
|
}
|
|
5320
|
+
case "projects.update": {
|
|
5321
|
+
const project = String(params.project ?? "");
|
|
5322
|
+
if (!project) throw new MrReviewError("\u043D\u0443\u0436\u0435\u043D \u043A\u043B\u044E\u0447 \u043F\u0440\u043E\u0435\u043A\u0442\u0430");
|
|
5323
|
+
return {
|
|
5324
|
+
project: service.updateProject(project, {
|
|
5325
|
+
...typeof params.title === "string" ? { title: params.title } : {},
|
|
5326
|
+
...Array.isArray(params.roots) ? { roots: params.roots.map(String) } : {}
|
|
5327
|
+
}),
|
|
5328
|
+
projects: service.listProjects()
|
|
5329
|
+
};
|
|
5330
|
+
}
|
|
5331
|
+
case "projects.remove": {
|
|
5332
|
+
const project = String(params.project ?? "");
|
|
5333
|
+
if (!project) throw new MrReviewError("\u043D\u0443\u0436\u0435\u043D \u043A\u043B\u044E\u0447 \u043F\u0440\u043E\u0435\u043A\u0442\u0430");
|
|
5334
|
+
const removedReviews = service.removeProject(project);
|
|
5335
|
+
return { removedReviews, projects: service.listProjects() };
|
|
5336
|
+
}
|
|
5118
5337
|
case "features.list": {
|
|
5119
5338
|
const project = typeof params.project === "string" && params.project.trim() ? params.project.trim() : void 0;
|
|
5120
5339
|
return { features: service.listFeatures(project, params.includeArchived === true) };
|
|
@@ -5155,28 +5374,38 @@ async function dispatch(service, method, params) {
|
|
|
5155
5374
|
Array.isArray(params.reviews) ? params.reviews.map(String) : []
|
|
5156
5375
|
)
|
|
5157
5376
|
};
|
|
5158
|
-
case "features.addNote":
|
|
5377
|
+
case "features.addNote": {
|
|
5378
|
+
const featureId = String(params.feature ?? "");
|
|
5159
5379
|
return {
|
|
5160
|
-
note: service.addFeatureNote(
|
|
5380
|
+
note: service.addFeatureNote(featureId, {
|
|
5161
5381
|
...params.kind === "finding" || params.kind === "note" ? { kind: params.kind } : {},
|
|
5162
5382
|
...typeof params.level === "string" ? { level: params.level } : {},
|
|
5163
5383
|
title: String(params.title ?? ""),
|
|
5164
5384
|
body: String(params.body ?? ""),
|
|
5165
|
-
|
|
5385
|
+
author: policy.name === "agent" ? "agent" : params.author === "agent" || params.author === "human" ? params.author : "human"
|
|
5166
5386
|
})
|
|
5167
5387
|
};
|
|
5168
|
-
|
|
5388
|
+
}
|
|
5389
|
+
case "features.updateNote": {
|
|
5390
|
+
const featureId = String(params.feature ?? "");
|
|
5391
|
+
const noteId = String(params.note ?? "");
|
|
5392
|
+
assertAgentFeatureNote(service, featureId, noteId, policy);
|
|
5169
5393
|
return {
|
|
5170
|
-
note: service.updateFeatureNote(
|
|
5394
|
+
note: service.updateFeatureNote(featureId, noteId, {
|
|
5171
5395
|
...params.kind === "finding" || params.kind === "note" ? { kind: params.kind } : {},
|
|
5172
5396
|
...typeof params.level === "string" ? { level: params.level } : {},
|
|
5173
5397
|
...typeof params.title === "string" ? { title: params.title } : {},
|
|
5174
5398
|
...typeof params.body === "string" ? { body: params.body } : {}
|
|
5175
5399
|
})
|
|
5176
5400
|
};
|
|
5177
|
-
|
|
5178
|
-
|
|
5401
|
+
}
|
|
5402
|
+
case "features.deleteNote": {
|
|
5403
|
+
const featureId = String(params.feature ?? "");
|
|
5404
|
+
const noteId = String(params.note ?? "");
|
|
5405
|
+
assertAgentFeatureNote(service, featureId, noteId, policy);
|
|
5406
|
+
service.deleteFeatureNote(featureId, noteId);
|
|
5179
5407
|
return { ok: true };
|
|
5408
|
+
}
|
|
5180
5409
|
case "features.delete":
|
|
5181
5410
|
service.deleteFeature(String(params.feature ?? ""));
|
|
5182
5411
|
return { ok: true };
|
|
@@ -5278,8 +5507,16 @@ async function dispatch(service, method, params) {
|
|
|
5278
5507
|
toAgent: params.toAgent !== false
|
|
5279
5508
|
})
|
|
5280
5509
|
};
|
|
5281
|
-
case "notes.update":
|
|
5282
|
-
|
|
5510
|
+
case "notes.update": {
|
|
5511
|
+
const patch = { ...params.patch ?? {} };
|
|
5512
|
+
if (policy.name === "agent") {
|
|
5513
|
+
delete patch.posted;
|
|
5514
|
+
delete patch.discussionId;
|
|
5515
|
+
delete patch.noteId;
|
|
5516
|
+
delete patch.error;
|
|
5517
|
+
}
|
|
5518
|
+
return { note: service.updateNote(String(params.review ?? ""), String(params.noteId ?? ""), patch) };
|
|
5519
|
+
}
|
|
5283
5520
|
case "notes.delete":
|
|
5284
5521
|
service.deleteNote(String(params.review ?? ""), String(params.noteId ?? ""));
|
|
5285
5522
|
return { ok: true };
|
|
@@ -5336,7 +5573,7 @@ async function startRpcServer(service, socketFile, options = {}) {
|
|
|
5336
5573
|
const request = parseRequest(line);
|
|
5337
5574
|
queue = queue.then(async () => {
|
|
5338
5575
|
if (!request) return;
|
|
5339
|
-
const response = await respond(service, request);
|
|
5576
|
+
const response = await respond(service, request, options.policy ?? HUMAN_POLICY);
|
|
5340
5577
|
if (!socket.destroyed) socket.write(`${JSON.stringify(response)}
|
|
5341
5578
|
`);
|
|
5342
5579
|
});
|
|
@@ -5372,11 +5609,11 @@ function parseRequest(line) {
|
|
|
5372
5609
|
return null;
|
|
5373
5610
|
}
|
|
5374
5611
|
}
|
|
5375
|
-
async function respond(service, request) {
|
|
5612
|
+
async function respond(service, request, policy) {
|
|
5376
5613
|
const id = request.id ?? null;
|
|
5377
5614
|
if (typeof request.method !== "string") return { id, error: { message: "\u043D\u0435 \u0443\u043A\u0430\u0437\u0430\u043D method" } };
|
|
5378
5615
|
try {
|
|
5379
|
-
const result = await dispatch(service, request.method, request.params ?? {});
|
|
5616
|
+
const result = await dispatch(service, request.method, request.params ?? {}, policy);
|
|
5380
5617
|
return { id, result };
|
|
5381
5618
|
} catch (error) {
|
|
5382
5619
|
return {
|
|
@@ -5464,9 +5701,24 @@ async function startHttpServer(options) {
|
|
|
5464
5701
|
reply(res, 403, { ok: false, error: "\u043D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0439 Origin" });
|
|
5465
5702
|
return;
|
|
5466
5703
|
}
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5704
|
+
let url;
|
|
5705
|
+
let jar;
|
|
5706
|
+
try {
|
|
5707
|
+
url = new URL(req.url ?? "/", `http://127.0.0.1:${port2}`);
|
|
5708
|
+
jar = cookies(req.headers.cookie);
|
|
5709
|
+
} catch {
|
|
5710
|
+
reply(res, 400, { ok: false, error: "\u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0437\u0430\u043F\u0440\u043E\u0441" });
|
|
5711
|
+
return;
|
|
5712
|
+
}
|
|
5713
|
+
const presented = String(jar[COOKIE] ?? "");
|
|
5714
|
+
const isHuman = safeEqual(presented, token);
|
|
5715
|
+
const isAgent = Boolean(options.agentToken) && safeEqual(presented, options.agentToken);
|
|
5716
|
+
const authorized = isHuman || isAgent;
|
|
5717
|
+
const isRpc = req.method === "POST" && url.pathname === "/api/rpc";
|
|
5718
|
+
if (authorized && !isHuman && !isRpc) {
|
|
5719
|
+
reply(res, 403, { ok: false, error: "\u0430\u0433\u0435\u043D\u0442\u0441\u043A\u0438\u0439 \u0442\u043E\u043A\u0435\u043D: \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E /api/rpc" });
|
|
5720
|
+
return;
|
|
5721
|
+
}
|
|
5470
5722
|
try {
|
|
5471
5723
|
if (req.method === "GET" && url.pathname === "/") {
|
|
5472
5724
|
const provided = url.searchParams.get("t");
|
|
@@ -5486,26 +5738,26 @@ async function startHttpServer(options) {
|
|
|
5486
5738
|
res.end('<meta charset="utf-8"><h1>\u041D\u0443\u0436\u043D\u0430 \u0441\u0441\u044B\u043B\u043A\u0430 \u0437\u0430\u043F\u0443\u0441\u043A\u0430</h1><p>\u041E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u0430\u0434\u0440\u0435\u0441 \u0438\u0437 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0430: \u043E\u043D \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 \u043E\u0434\u043D\u043E\u0440\u0430\u0437\u043E\u0432\u044B\u0439 \u0442\u043E\u043A\u0435\u043D.</p>');
|
|
5487
5739
|
return;
|
|
5488
5740
|
}
|
|
5489
|
-
const html = await readFile2(
|
|
5741
|
+
const html = await readFile2(path9.join(options.uiDir, "index.html"));
|
|
5490
5742
|
res.writeHead(200, { ...SECURITY_HEADERS, "content-type": MIME[".html"], "cache-control": "no-store" });
|
|
5491
5743
|
res.end(html);
|
|
5492
5744
|
return;
|
|
5493
5745
|
}
|
|
5494
5746
|
if (req.method === "GET" && (url.pathname.startsWith("/assets/") || url.pathname === "/favicon.svg")) {
|
|
5495
5747
|
const relative = url.pathname === "/favicon.svg" ? "favicon.svg" : url.pathname.slice("/assets/".length);
|
|
5496
|
-
const target =
|
|
5497
|
-
if (!target.startsWith(
|
|
5748
|
+
const target = path9.resolve(options.uiDir, url.pathname === "/favicon.svg" ? "" : "assets", relative);
|
|
5749
|
+
if (!target.startsWith(path9.resolve(options.uiDir) + path9.sep) || relative.includes("..")) {
|
|
5498
5750
|
reply(res, 404, { ok: false, error: "\u043D\u0435\u0442 \u0444\u0430\u0439\u043B\u0430" });
|
|
5499
5751
|
return;
|
|
5500
5752
|
}
|
|
5501
|
-
const info = await
|
|
5753
|
+
const info = await stat2(target).catch(() => null);
|
|
5502
5754
|
if (!info?.isFile()) {
|
|
5503
5755
|
reply(res, 404, { ok: false, error: "\u043D\u0435\u0442 \u0444\u0430\u0439\u043B\u0430" });
|
|
5504
5756
|
return;
|
|
5505
5757
|
}
|
|
5506
5758
|
res.writeHead(200, {
|
|
5507
5759
|
...SECURITY_HEADERS,
|
|
5508
|
-
"content-type": MIME[
|
|
5760
|
+
"content-type": MIME[path9.extname(target)] ?? "application/octet-stream",
|
|
5509
5761
|
"cache-control": "public, max-age=31536000, immutable"
|
|
5510
5762
|
});
|
|
5511
5763
|
createReadStream(target).pipe(res);
|
|
@@ -5540,16 +5792,24 @@ data: ${JSON.stringify(event)}
|
|
|
5540
5792
|
res.write(`event: feature
|
|
5541
5793
|
data: ${JSON.stringify(event)}
|
|
5542
5794
|
|
|
5795
|
+
`);
|
|
5796
|
+
};
|
|
5797
|
+
const projectListener = (event) => {
|
|
5798
|
+
res.write(`event: project
|
|
5799
|
+
data: ${JSON.stringify(event)}
|
|
5800
|
+
|
|
5543
5801
|
`);
|
|
5544
5802
|
};
|
|
5545
5803
|
service.events.on("review", reviewListener);
|
|
5546
5804
|
service.events.on("feature", featureListener);
|
|
5805
|
+
service.events.on("project", projectListener);
|
|
5547
5806
|
const heartbeat = setInterval(() => res.write(": ping\n\n"), 25e3);
|
|
5548
5807
|
heartbeat.unref?.();
|
|
5549
5808
|
req.on("close", () => {
|
|
5550
5809
|
clearInterval(heartbeat);
|
|
5551
5810
|
service.events.off("review", reviewListener);
|
|
5552
5811
|
service.events.off("feature", featureListener);
|
|
5812
|
+
service.events.off("project", projectListener);
|
|
5553
5813
|
});
|
|
5554
5814
|
return;
|
|
5555
5815
|
}
|
|
@@ -5640,6 +5900,23 @@ data: ${JSON.stringify(event)}
|
|
|
5640
5900
|
reply(res, 200, { ok: true, project, projects: service.listProjects() });
|
|
5641
5901
|
return;
|
|
5642
5902
|
}
|
|
5903
|
+
case "/api/projects/update": {
|
|
5904
|
+
const project = String(body.project ?? "");
|
|
5905
|
+
if (!project) throw Object.assign(new Error("\u043D\u0443\u0436\u0435\u043D \u043A\u043B\u044E\u0447 \u043F\u0440\u043E\u0435\u043A\u0442\u0430"), { status: 400 });
|
|
5906
|
+
const updated = service.updateProject(project, {
|
|
5907
|
+
...typeof body.title === "string" ? { title: body.title } : {},
|
|
5908
|
+
...Array.isArray(body.roots) ? { roots: body.roots.map(String) } : {}
|
|
5909
|
+
});
|
|
5910
|
+
reply(res, 200, { ok: true, project: updated, projects: service.listProjects() });
|
|
5911
|
+
return;
|
|
5912
|
+
}
|
|
5913
|
+
case "/api/projects/remove": {
|
|
5914
|
+
const project = String(body.project ?? "");
|
|
5915
|
+
if (!project) throw Object.assign(new Error("\u043D\u0443\u0436\u0435\u043D \u043A\u043B\u044E\u0447 \u043F\u0440\u043E\u0435\u043A\u0442\u0430"), { status: 400 });
|
|
5916
|
+
const removedReviews = service.removeProject(project);
|
|
5917
|
+
reply(res, 200, { ok: true, removedReviews, projects: service.listProjects() });
|
|
5918
|
+
return;
|
|
5919
|
+
}
|
|
5643
5920
|
case "/api/reviews/open": {
|
|
5644
5921
|
const root = String(body.root ?? "");
|
|
5645
5922
|
if (!root) throw Object.assign(new Error("\u043D\u0443\u0436\u0435\u043D root \u0440\u0430\u0431\u043E\u0447\u0435\u0439 \u043A\u043E\u043F\u0438\u0438"), { status: 400 });
|
|
@@ -5752,7 +6029,12 @@ data: ${JSON.stringify(event)}
|
|
|
5752
6029
|
return;
|
|
5753
6030
|
}
|
|
5754
6031
|
case "/api/rpc": {
|
|
5755
|
-
const result = await dispatch(
|
|
6032
|
+
const result = await dispatch(
|
|
6033
|
+
service,
|
|
6034
|
+
String(body.method ?? ""),
|
|
6035
|
+
body.params ?? {},
|
|
6036
|
+
isHuman ? HUMAN_POLICY : AGENT_POLICY
|
|
6037
|
+
);
|
|
5756
6038
|
reply(res, 200, { ok: true, result });
|
|
5757
6039
|
return;
|
|
5758
6040
|
}
|
|
@@ -5789,15 +6071,29 @@ data: ${JSON.stringify(event)}
|
|
|
5789
6071
|
|
|
5790
6072
|
// src/daemon/bridge.ts
|
|
5791
6073
|
import { unlink as unlink3 } from "node:fs/promises";
|
|
5792
|
-
import
|
|
6074
|
+
import path10 from "node:path";
|
|
5793
6075
|
async function startDevcontainerBridge(service, info) {
|
|
5794
|
-
await ensureDir(
|
|
6076
|
+
await ensureDir(path10.dirname(devcontainerBridgeDir()), 448);
|
|
5795
6077
|
await ensureDir(devcontainerBridgeDir(), 448);
|
|
5796
6078
|
await ensureDir(devcontainerRunDir(), 493);
|
|
5797
6079
|
await ensureDir(devcontainerStateDir(), 493);
|
|
5798
|
-
const rpc = await startRpcServer(service, devcontainerSocketPath(), {
|
|
6080
|
+
const rpc = await startRpcServer(service, devcontainerSocketPath(), {
|
|
6081
|
+
mode: 438,
|
|
6082
|
+
dirMode: 493,
|
|
6083
|
+
policy: AGENT_POLICY
|
|
6084
|
+
});
|
|
5799
6085
|
try {
|
|
5800
|
-
const payload = {
|
|
6086
|
+
const payload = {
|
|
6087
|
+
pid: info.pid,
|
|
6088
|
+
port: info.port,
|
|
6089
|
+
url: info.url,
|
|
6090
|
+
socket: devcontainerSocketPath(),
|
|
6091
|
+
startedAt: info.startedAt,
|
|
6092
|
+
version: info.version,
|
|
6093
|
+
protocol: info.protocol,
|
|
6094
|
+
capabilities: [...AGENT_POLICY.capabilities],
|
|
6095
|
+
agentToken: info.agentToken
|
|
6096
|
+
};
|
|
5801
6097
|
await writeFileAtomic(devcontainerInfoPath(), `${JSON.stringify(payload, null, 2)}
|
|
5802
6098
|
`, 420, 493);
|
|
5803
6099
|
} catch (error) {
|
|
@@ -5854,6 +6150,7 @@ async function main() {
|
|
|
5854
6150
|
return;
|
|
5855
6151
|
}
|
|
5856
6152
|
const token = (await import("node:crypto")).randomBytes(32).toString("hex");
|
|
6153
|
+
const agentToken = (await import("node:crypto")).randomBytes(32).toString("hex");
|
|
5857
6154
|
const store = new Store(databasePath());
|
|
5858
6155
|
const service = new ReviewService({
|
|
5859
6156
|
store,
|
|
@@ -5861,10 +6158,11 @@ async function main() {
|
|
|
5861
6158
|
});
|
|
5862
6159
|
const socket = socketPath();
|
|
5863
6160
|
const rpc = await startRpcServer(service, socket);
|
|
5864
|
-
const uiDir = values["ui-dir"] ?
|
|
6161
|
+
const uiDir = values["ui-dir"] ? path11.resolve(values["ui-dir"]) : path11.join(packageRoot(), "dist", "ui");
|
|
5865
6162
|
const http2 = await startHttpServer({
|
|
5866
6163
|
service,
|
|
5867
6164
|
token,
|
|
6165
|
+
agentToken,
|
|
5868
6166
|
uiDir,
|
|
5869
6167
|
...values.port ? { port: Number(values.port) } : {},
|
|
5870
6168
|
...values.host ? { host: String(values.host) } : {},
|
|
@@ -5875,6 +6173,7 @@ async function main() {
|
|
|
5875
6173
|
pid: process.pid,
|
|
5876
6174
|
port: http2.port,
|
|
5877
6175
|
token,
|
|
6176
|
+
agentToken,
|
|
5878
6177
|
url: http2.url,
|
|
5879
6178
|
socket,
|
|
5880
6179
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -5913,7 +6212,7 @@ async function main() {
|
|
|
5913
6212
|
service.close();
|
|
5914
6213
|
await unlink4(daemonInfoPath()).catch(() => void 0);
|
|
5915
6214
|
await lock.close().catch(() => void 0);
|
|
5916
|
-
await unlink4(
|
|
6215
|
+
await unlink4(path11.join(stateDir(), "daemon.lock")).catch(() => void 0);
|
|
5917
6216
|
process.exit(0);
|
|
5918
6217
|
}
|
|
5919
6218
|
};
|
|
@@ -5925,24 +6224,24 @@ async function main() {
|
|
|
5925
6224
|
}
|
|
5926
6225
|
}
|
|
5927
6226
|
function packageRoot() {
|
|
5928
|
-
let dir =
|
|
6227
|
+
let dir = path11.dirname(fileURLToPath(import.meta.url));
|
|
5929
6228
|
for (; ; ) {
|
|
5930
|
-
const candidate =
|
|
5931
|
-
if (
|
|
6229
|
+
const candidate = path11.join(dir, "package.json");
|
|
6230
|
+
if (existsSync5(candidate)) {
|
|
5932
6231
|
try {
|
|
5933
6232
|
const parsed = JSON.parse(readFileSync(candidate, "utf8"));
|
|
5934
6233
|
if (parsed.name === "revdeck") return dir;
|
|
5935
6234
|
} catch {
|
|
5936
6235
|
}
|
|
5937
6236
|
}
|
|
5938
|
-
const parent =
|
|
6237
|
+
const parent = path11.dirname(dir);
|
|
5939
6238
|
if (parent === dir) return process.cwd();
|
|
5940
6239
|
dir = parent;
|
|
5941
6240
|
}
|
|
5942
6241
|
}
|
|
5943
6242
|
async function runningDaemon() {
|
|
5944
6243
|
const infoPath = daemonInfoPath();
|
|
5945
|
-
if (!
|
|
6244
|
+
if (!existsSync5(infoPath)) return null;
|
|
5946
6245
|
let info;
|
|
5947
6246
|
try {
|
|
5948
6247
|
info = JSON.parse(readFileSync(infoPath, "utf8"));
|
|
@@ -5974,7 +6273,7 @@ async function runningDaemon() {
|
|
|
5974
6273
|
return reachable ? info : null;
|
|
5975
6274
|
}
|
|
5976
6275
|
async function acquireLock() {
|
|
5977
|
-
const file =
|
|
6276
|
+
const file = path11.join(stateDir(), "daemon.lock");
|
|
5978
6277
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
5979
6278
|
try {
|
|
5980
6279
|
const handle = await open2(file, "wx", 384);
|