revdeck 0.17.0 → 0.18.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/dist/cli.js CHANGED
@@ -811,7 +811,7 @@ var VERSION;
811
811
  var init_version = __esm({
812
812
  "src/version.ts"() {
813
813
  "use strict";
814
- VERSION = "0.17.0";
814
+ VERSION = "0.18.0";
815
815
  }
816
816
  });
817
817
 
@@ -1159,13 +1159,190 @@ var init_refs = __esm({
1159
1159
  }
1160
1160
  });
1161
1161
 
1162
+ // src/cli/report.ts
1163
+ import os3 from "node:os";
1164
+ function createPalette(stream) {
1165
+ const enabled = (() => {
1166
+ if (process.env.NO_COLOR) return false;
1167
+ const force = process.env.FORCE_COLOR;
1168
+ if (force === "0") return false;
1169
+ if (force !== void 0 && force !== "") return true;
1170
+ return Boolean(stream.isTTY) && process.env.TERM !== "dumb";
1171
+ })();
1172
+ const wrap = (open3, close) => (text) => enabled ? `\x1B[${open3}m${text}\x1B[${close}m` : text;
1173
+ return {
1174
+ enabled,
1175
+ bold: wrap("1", "22"),
1176
+ dim: wrap("2", "22"),
1177
+ red: wrap("31", "39"),
1178
+ green: wrap("32", "39"),
1179
+ yellow: wrap("33", "39"),
1180
+ blue: wrap("34", "39"),
1181
+ magenta: wrap("35", "39"),
1182
+ cyan: wrap("36", "39"),
1183
+ link: (text) => enabled ? `\x1B[4;34m${text}\x1B[0m` : text
1184
+ };
1185
+ }
1186
+ function tildify(value, home = os3.homedir()) {
1187
+ if (!value || !home) return value;
1188
+ const prefix = home.replace(/[\\/]+$/, "");
1189
+ if (value === prefix) return "~";
1190
+ if (value.startsWith(`${prefix}/`) || value.startsWith(`${prefix}\\`)) return `~${value.slice(prefix.length)}`;
1191
+ return value;
1192
+ }
1193
+ function padEnd(value, width) {
1194
+ const length = [...value].length;
1195
+ return length >= width ? value : value + " ".repeat(width - length);
1196
+ }
1197
+ function rows(fields) {
1198
+ const width = Math.max(...fields.map(([label]) => [...label].length));
1199
+ return fields.map(([label, value]) => ` ${colors.dim(padEnd(label, width))} ${value}`);
1200
+ }
1201
+ function startTitle(mode) {
1202
+ if (mode === "restarted") return tr("\u0414\u0435\u043C\u043E\u043D \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0449\u0435\u043D", "Daemon restarted");
1203
+ if (mode === "running") return tr("\u0414\u0435\u043C\u043E\u043D \u0443\u0436\u0435 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442", "Daemon already running");
1204
+ return tr("\u0414\u0435\u043C\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D", "Daemon started");
1205
+ }
1206
+ function daemonStartedLines(view, mode = "started") {
1207
+ return [
1208
+ "",
1209
+ ` ${colors.dim("revdeck")} ${colors.dim(view.version)}`,
1210
+ "",
1211
+ ` ${colors.green("\u25CF")} ${colors.bold(startTitle(mode))} ${colors.dim(`\xB7 pid ${view.pid}`)}`,
1212
+ "",
1213
+ ...rows([
1214
+ [tr("\u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441", "ui"), colors.link(view.url)],
1215
+ [tr("\u0441\u043E\u043A\u0435\u0442", "socket"), colors.dim(tildify(view.socket))],
1216
+ [tr("\u0434\u0430\u043D\u043D\u044B\u0435", "state"), colors.dim(tildify(view.stateDir))],
1217
+ [tr("\u043B\u043E\u0433", "log"), colors.dim(tildify(view.logPath))]
1218
+ ]),
1219
+ "",
1220
+ START_FOOTER(),
1221
+ ""
1222
+ ];
1223
+ }
1224
+ function daemonStatusLines(view) {
1225
+ return [
1226
+ "",
1227
+ ` ${colors.green("\u25CF")} ${colors.bold(tr("\u0414\u0435\u043C\u043E\u043D \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442", "Daemon is running"))} ${colors.dim(`\xB7 pid ${view.pid}`)}`,
1228
+ "",
1229
+ ...rows([
1230
+ [tr("\u0432\u0435\u0440\u0441\u0438\u044F", "version"), view.version],
1231
+ [tr("\u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441", "ui"), colors.link(view.url)],
1232
+ [tr("\u0437\u0430\u043F\u0443\u0449\u0435\u043D", "started"), view.startedAt],
1233
+ ...view.health ? [[tr("\u0437\u0434\u043E\u0440\u043E\u0432\u044C\u0435", "health"), view.health]] : [],
1234
+ [tr("\u0441\u043E\u043A\u0435\u0442", "socket"), colors.dim(tildify(view.socket))],
1235
+ [tr("\u043B\u043E\u0433", "log"), colors.dim(tildify(view.logPath))]
1236
+ ]),
1237
+ "",
1238
+ ` ${colors.dim(tr("\u0421\u0441\u044B\u043B\u043A\u0430 \u0434\u043B\u044F \u0432\u0445\u043E\u0434\u0430:", "Sign-in link:"))} ${colors.cyan("revdeck ui --open")}`,
1239
+ ""
1240
+ ];
1241
+ }
1242
+ function daemonNotRunningLines() {
1243
+ return [
1244
+ "",
1245
+ ` ${colors.dim("\u25CB")} ${colors.bold(tr("\u0414\u0435\u043C\u043E\u043D \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D", "Daemon is not running"))}`,
1246
+ "",
1247
+ ` ${colors.dim(tr("\u0417\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C:", "Start it:"))} ${colors.cyan("revdeck daemon start")}`,
1248
+ ""
1249
+ ];
1250
+ }
1251
+ function daemonNotRunningLine() {
1252
+ return ` ${colors.dim("\u25CB")} ${colors.dim(tr("\u0414\u0435\u043C\u043E\u043D \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D", "Daemon is not running"))}`;
1253
+ }
1254
+ function daemonStoppedLines(info) {
1255
+ const details = [
1256
+ ...info.pid ? [`pid ${info.pid}`] : [],
1257
+ ...info.uptime ? [tr(`\u0440\u0430\u0431\u043E\u0442\u0430\u043B ${info.uptime}`, `was up ${info.uptime}`)] : []
1258
+ ];
1259
+ return [
1260
+ "",
1261
+ ` ${colors.dim("\u25CB")} ${colors.bold(tr("\u0414\u0435\u043C\u043E\u043D \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D", "Daemon stopped"))}${details.length ? ` ${colors.dim(`\xB7 ${details.join(" \xB7 ")}`)}` : ""}`,
1262
+ ""
1263
+ ];
1264
+ }
1265
+ function daemonLogHeader(logPath2, limit, follow = false, rotatedPath) {
1266
+ const hint = follow ? tr("\xB7 \u0441\u043B\u0435\u0436\u0435\u043D\u0438\u0435, Ctrl-C \u2014 \u0432\u044B\u0445\u043E\u0434", "\xB7 following, Ctrl-C to stop") : `\xB7 ${tr("\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435", "last")} ${limit} ${plural(limit, "\u0441\u0442\u0440\u043E\u043A\u0430", "\u0441\u0442\u0440\u043E\u043A\u0438", "\u0441\u0442\u0440\u043E\u043A", "line", "lines")}`;
1267
+ return [
1268
+ "",
1269
+ ` ${colors.bold(tr("\u041B\u043E\u0433 \u0434\u0435\u043C\u043E\u043D\u0430", "Daemon log"))} ${colors.dim(hint)}`,
1270
+ ` ${colors.dim(tildify(logPath2))}`,
1271
+ ...rotatedPath ? [` ${colors.dim(tr("\u043F\u043B\u044E\u0441 \u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0438\u0439", "plus the previous"))} ${colors.dim(tildify(rotatedPath))}`] : [],
1272
+ ""
1273
+ ];
1274
+ }
1275
+ function daemonLogEmptyLines(logPath2) {
1276
+ return [
1277
+ "",
1278
+ ` ${colors.dim("\u25CB")} ${colors.bold(tr("\u041B\u043E\u0433 \u043F\u0443\u0441\u0442", "The log is empty"))} ${colors.dim(tr("\xB7 \u0434\u0435\u043C\u043E\u043D \u0435\u0449\u0451 \u043D\u0435 \u0437\u0430\u043F\u0443\u0441\u043A\u0430\u043B\u0441\u044F", "\xB7 the daemon has not started yet"))}`,
1279
+ ` ${colors.dim(tildify(logPath2))}`,
1280
+ ""
1281
+ ];
1282
+ }
1283
+ function formatLogLine(line) {
1284
+ const match = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z) (.+)$/.exec(line);
1285
+ if (!match) return ` ${line}`;
1286
+ const at = new Date(match[1]);
1287
+ const body = match[2];
1288
+ if (Number.isNaN(at.getTime())) return ` ${line}`;
1289
+ const time = at.toLocaleTimeString(locale() === "ru" ? "ru-RU" : "en-GB", { hour12: false });
1290
+ const marked = /error|failed|unavailable|fatal/i.test(body) ? colors.red(body) : body;
1291
+ return ` ${colors.dim(time)} ${marked}`;
1292
+ }
1293
+ function doctorLines(name, status2, detail) {
1294
+ const mark = status2 === "ok" ? colors.green("\u2714") : status2 === "warn" ? colors.yellow("!") : colors.red("\u2716");
1295
+ const [first = "", ...rest] = detail.split("\n");
1296
+ return [
1297
+ ` ${mark} ${colors.dim(padEnd(name, 10))} ${first}`,
1298
+ ...rest.filter(Boolean).map((line) => `${" ".repeat(15)}${colors.dim(line)}`)
1299
+ ];
1300
+ }
1301
+ function errorLine(message, hint) {
1302
+ return [
1303
+ `${errorColors.red("revdeck:")} ${message}`,
1304
+ ...hint ? [` ${errorColors.dim(hint)}`] : []
1305
+ ];
1306
+ }
1307
+ function warningLine(message) {
1308
+ return `${errorColors.yellow("!")} ${message}`;
1309
+ }
1310
+ function compactDetail(value, max = 160) {
1311
+ const first = value.split("\n").map((line) => line.trim()).find(Boolean) ?? value.trim();
1312
+ if (first.length <= max) return first;
1313
+ const cut = first.slice(0, max);
1314
+ const space = cut.lastIndexOf(" ");
1315
+ return `${(space > max * 0.6 ? cut.slice(0, space) : cut).replace(/[.,;:\s]+$/, "")}\u2026`;
1316
+ }
1317
+ function durationSince(iso) {
1318
+ const started = new Date(iso).getTime();
1319
+ if (!Number.isFinite(started)) return null;
1320
+ const ms = Math.max(0, Date.now() - started);
1321
+ const minutes = Math.floor(ms / 6e4);
1322
+ if (minutes < 1) return tr("\u043C\u0435\u043D\u044C\u0448\u0435 \u043C\u0438\u043D\u0443\u0442\u044B", "less than a minute");
1323
+ if (minutes < 60) return tr(`${minutes} \u043C\u0438\u043D`, `${minutes} min`);
1324
+ const hours = Math.floor(minutes / 60);
1325
+ if (hours < 24) return tr(`${hours} \u0447`, `${hours} h`);
1326
+ const days = Math.floor(hours / 24);
1327
+ return tr(`${days} \u0434\u043D`, `${days} d`);
1328
+ }
1329
+ var colors, errorColors, START_FOOTER;
1330
+ var init_report = __esm({
1331
+ "src/cli/report.ts"() {
1332
+ "use strict";
1333
+ init_locale();
1334
+ colors = createPalette(process.stdout);
1335
+ errorColors = createPalette(process.stderr);
1336
+ START_FOOTER = () => ` ${colors.dim(tr("\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441:", "Open the UI:"))} ${colors.cyan("revdeck ui --open")}`;
1337
+ }
1338
+ });
1339
+
1162
1340
  // src/cli/format.ts
1163
1341
  function printJson(value) {
1164
1342
  writers.out(JSON.stringify(value, null, 2));
1165
1343
  }
1166
1344
  function fail(message, hint) {
1167
- writers.err(`revdeck: ${redact(message)}`);
1168
- if (hint) writers.err(` ${redact(hint)}`);
1345
+ for (const line of errorLine(redact(message), hint ? redact(hint) : void 0)) writers.err(line);
1169
1346
  process.exit(1);
1170
1347
  }
1171
1348
  function usage(lines) {
@@ -1205,6 +1382,7 @@ var init_format = __esm({
1205
1382
  "use strict";
1206
1383
  init_redact();
1207
1384
  init_locale();
1385
+ init_report();
1208
1386
  writers = {
1209
1387
  out: (text) => process.stdout.write(`${text}
1210
1388
  `),
@@ -2535,7 +2713,7 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
2535
2713
  // src/cli/main.ts
2536
2714
  init_paths();
2537
2715
  init_config();
2538
- import { readFile as readFile7, stat as stat2 } from "node:fs/promises";
2716
+ import { open as open2, readFile as readFile8, stat as stat2 } from "node:fs/promises";
2539
2717
  import { readFileSync } from "node:fs";
2540
2718
  import { parseArgs } from "node:util";
2541
2719
  import path11 from "node:path";
@@ -2774,6 +2952,7 @@ init_refs();
2774
2952
  init_version();
2775
2953
  init_locale();
2776
2954
  init_format();
2955
+ init_report();
2777
2956
 
2778
2957
  // src/cli/init.ts
2779
2958
  init_paths();
@@ -3186,10 +3365,293 @@ function xmlEscape(value) {
3186
3365
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3187
3366
  }
3188
3367
 
3368
+ // src/cli/tools.ts
3369
+ init_client();
3370
+ init_exec();
3371
+ init_locale();
3372
+ init_format();
3373
+ init_report();
3374
+ import { createInterface } from "node:readline/promises";
3375
+ var TOOL_URL = {
3376
+ glab: "https://docs.gitlab.com/cli/installation/",
3377
+ gh: "https://cli.github.com/"
3378
+ };
3379
+ var TOOL_LABEL = {
3380
+ git: "git",
3381
+ glab: "glab (GitLab CLI)",
3382
+ gh: "gh (GitHub CLI)"
3383
+ };
3384
+ var VERSION_ARGS = {
3385
+ git: ["--version"],
3386
+ glab: ["--version"],
3387
+ gh: ["--version"]
3388
+ };
3389
+ function parseTools(value) {
3390
+ if (!value || value === "all") return { tools: ["glab", "gh"], label: "glab \u0438 gh" };
3391
+ if (value === "glab" || value === "gh") return { tools: [value], label: value };
3392
+ fail(
3393
+ tr(`\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439 \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442: ${value}`, `unknown tool: ${value}`),
3394
+ tr("\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E: glab, gh \u0438\u043B\u0438 all", "allowed: glab, gh or all")
3395
+ );
3396
+ }
3397
+ async function toolVersion(bin) {
3398
+ try {
3399
+ const result = await run(bin, VERSION_ARGS[bin], { timeoutMs: 5e3 });
3400
+ const line = `${result.stdout}
3401
+ ${result.stderr}`.split("\n").map((item) => item.trim()).find(Boolean);
3402
+ return line ? line.slice(0, 120) : null;
3403
+ } catch {
3404
+ return null;
3405
+ }
3406
+ }
3407
+ async function toolState(bin) {
3408
+ const path12 = await resolveExecutable(bin);
3409
+ if (!path12) return { name: bin, path: null, version: null };
3410
+ return { name: bin, path: path12, version: await toolVersion(bin) };
3411
+ }
3412
+ function installPlan(tool, managers) {
3413
+ const url = TOOL_URL[tool];
3414
+ if (managers.brew) {
3415
+ return { tool, url, manager: "brew", command: `brew install ${tool}`, automatic: true };
3416
+ }
3417
+ if (managers.pacman) {
3418
+ const pkg = tool === "glab" ? "glab" : "github-cli";
3419
+ return {
3420
+ tool,
3421
+ url,
3422
+ manager: "pacman",
3423
+ command: `sudo pacman -S ${pkg}`,
3424
+ automatic: false,
3425
+ manualReason: tr("\u043D\u0443\u0436\u0435\u043D sudo: \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u043A\u043E\u043C\u0430\u043D\u0434\u0443 \u0432\u0440\u0443\u0447\u043D\u0443\u044E", "requires sudo: run the command manually")
3426
+ };
3427
+ }
3428
+ if (tool === "gh" && managers.winget) {
3429
+ return {
3430
+ tool,
3431
+ url,
3432
+ manager: "winget",
3433
+ command: "winget install --id GitHub.cli --accept-package-agreements --accept-source-agreements",
3434
+ automatic: true
3435
+ };
3436
+ }
3437
+ return { tool, url, manager: null, command: null, automatic: false };
3438
+ }
3439
+ async function detectManagers() {
3440
+ const managers = {};
3441
+ for (const name of ["brew", "pacman", "winget"]) {
3442
+ const found = await resolveExecutable(name);
3443
+ if (found) managers[name] = found;
3444
+ }
3445
+ return managers;
3446
+ }
3447
+ function planFor(tool, managers) {
3448
+ return installPlan(tool, managers);
3449
+ }
3450
+ function planLines(plan) {
3451
+ const lines = [
3452
+ ` ${colors.bold(TOOL_LABEL[plan.tool])} ${colors.dim(tr("\u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D", "not installed"))}`,
3453
+ ` ${colors.dim(tr("\u0438\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u044F:", "guide:"))} ${plan.url}`
3454
+ ];
3455
+ if (plan.command) {
3456
+ lines.push(` ${colors.dim(tr("\u043A\u043E\u043C\u0430\u043D\u0434\u0430:", "command:"))} ${colors.cyan(plan.command)}`);
3457
+ }
3458
+ if (plan.manualReason) lines.push(` ${colors.yellow("!")} ${plan.manualReason}`);
3459
+ return lines;
3460
+ }
3461
+ async function confirmTool(plan) {
3462
+ if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
3463
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
3464
+ try {
3465
+ const answer = (await rl.question(tr(`\u0423\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C ${plan.tool} \u0447\u0435\u0440\u0435\u0437 ${plan.manager}? [y/N] `, `Install ${plan.tool} with ${plan.manager}? [y/N] `))).trim().toLowerCase();
3466
+ return ["y", "yes", "\u0434", "\u0434\u0430"].includes(answer);
3467
+ } finally {
3468
+ rl.close();
3469
+ }
3470
+ }
3471
+ function managerCommand(plan) {
3472
+ if (plan.manager === "brew") return { command: "brew", args: ["install", plan.tool] };
3473
+ if (plan.manager === "winget") {
3474
+ return {
3475
+ command: "winget",
3476
+ args: ["install", "--id", "GitHub.cli", "--accept-package-agreements", "--accept-source-agreements"]
3477
+ };
3478
+ }
3479
+ return null;
3480
+ }
3481
+ async function installOne(plan, yes) {
3482
+ const invocation = managerCommand(plan);
3483
+ if (!invocation) return { ok: false, executed: false };
3484
+ if (!yes && !await confirmTool(plan)) {
3485
+ return { ok: false, executed: false, error: tr("\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043E\u0442\u043C\u0435\u043D\u0435\u043D\u0430", "installation cancelled") };
3486
+ }
3487
+ try {
3488
+ const result = await run(invocation.command, invocation.args, { timeoutMs: 15 * 6e4, maxBuffer: 16 * 1024 * 1024 });
3489
+ const detail = `${result.stdout}
3490
+ ${result.stderr}`.trim();
3491
+ if (detail) writers.err(colors.dim(detail.split("\n").slice(-3).join("\n")));
3492
+ return { ok: true, executed: true };
3493
+ } catch (error) {
3494
+ return { ok: false, executed: true, error: error instanceof Error ? error.message : String(error) };
3495
+ }
3496
+ }
3497
+ async function toolsStatus(json) {
3498
+ const managers = await detectManagers();
3499
+ const statuses = [];
3500
+ for (const name of ["git", "glab", "gh"]) {
3501
+ const status2 = await toolState(name);
3502
+ if (!status2.path && name !== "git") status2.plan = planFor(name, managers);
3503
+ statuses.push(status2);
3504
+ }
3505
+ if (json) {
3506
+ printJson({
3507
+ tools: statuses.map((status2) => ({
3508
+ name: status2.name,
3509
+ found: Boolean(status2.path),
3510
+ path: status2.path,
3511
+ version: status2.version,
3512
+ ...status2.plan ? { install: status2.plan } : {}
3513
+ })),
3514
+ managers: Object.keys(managers)
3515
+ });
3516
+ return;
3517
+ }
3518
+ writers.out("");
3519
+ for (const status2 of statuses) {
3520
+ const mark = status2.path ? colors.green("\u2714") : colors.red("\u2716");
3521
+ const detail = status2.path ? status2.version ?? tr("\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D", "installed") : tr("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D", "not found");
3522
+ writers.out(` ${mark} ${colors.bold(status2.name.padEnd(5))} ${detail}`);
3523
+ if (!status2.path && status2.plan) for (const line of planLines(status2.plan)) writers.out(line);
3524
+ if (!status2.path && status2.name === "git") {
3525
+ writers.out(` ${colors.yellow("!")} ${tr("git \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u0435\u043D: \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435 \u0435\u0433\u043E \u0441\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u043C \u043F\u0430\u043A\u0435\u0442\u043D\u044B\u043C \u043C\u0435\u043D\u0435\u0434\u0436\u0435\u0440\u043E\u043C", "git is required: install it with the system package manager")}`);
3526
+ }
3527
+ }
3528
+ writers.out("");
3529
+ const available = Object.keys(managers);
3530
+ writers.out(
3531
+ ` ${colors.dim(tr("\u043F\u0430\u043A\u0435\u0442\u043D\u044B\u0435 \u043C\u0435\u043D\u0435\u0434\u0436\u0435\u0440\u044B:", "package managers:"))} ${available.length ? colors.cyan(available.join(", ")) : tr("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B", "none found")}`
3532
+ );
3533
+ writers.out("");
3534
+ }
3535
+ async function toolsInstall(toolArg, values) {
3536
+ const dryRun = values["dry-run"] === true;
3537
+ const json = values.json === true;
3538
+ const yes = values.yes === true;
3539
+ if (json && !dryRun && !yes) {
3540
+ fail(tr("\u0441 --json \u043D\u0443\u0436\u0435\u043D --dry-run \u0438\u043B\u0438 --yes", "with --json pass --dry-run or --yes"));
3541
+ }
3542
+ const requested = parseTools(toolArg);
3543
+ const managers = await detectManagers();
3544
+ const plans = [];
3545
+ for (const tool of requested.tools) {
3546
+ if (await resolveExecutable(tool)) {
3547
+ continue;
3548
+ }
3549
+ plans.push(planFor(tool, managers));
3550
+ }
3551
+ if (!plans.length) {
3552
+ if (json) printJson({ plans: [], installed: requested.tools });
3553
+ else writers.out(` ${colors.green("\u2714")} ${tr(`${requested.label} \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D${requested.tools.length > 1 ? "\u044B" : ""}`, `${requested.label} already installed`)}`);
3554
+ return;
3555
+ }
3556
+ if (json && dryRun) {
3557
+ printJson({ plans });
3558
+ return;
3559
+ }
3560
+ if (dryRun) {
3561
+ writers.out("");
3562
+ writers.out(` ${colors.bold(tr("\u041F\u043B\u0430\u043D \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0438", "Install plan"))} ${colors.dim(tr("\xB7 \u043D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043F\u0443\u0449\u0435\u043D\u043E", "\xB7 nothing will be executed"))}`);
3563
+ writers.out("");
3564
+ for (const plan of plans) for (const line of planLines(plan)) writers.out(line);
3565
+ const automatic = plans.filter((plan) => plan.automatic);
3566
+ writers.out("");
3567
+ if (automatic.length) {
3568
+ writers.out(
3569
+ ` ${colors.dim(tr("\u0412\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C:", "Run:"))} ${colors.cyan(`revdeck tools install ${automatic.map((plan) => plan.tool).join(" ")} --yes`)}`
3570
+ );
3571
+ } else {
3572
+ writers.out(` ${colors.dim(tr("\u0410\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0430: \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u043A\u043E\u043C\u0430\u043D\u0434\u0443 \u0432\u044B\u0448\u0435.", "Automatic installation is unavailable: run the command above."))}`);
3573
+ }
3574
+ writers.out("");
3575
+ return;
3576
+ }
3577
+ let failed = false;
3578
+ const results = [];
3579
+ for (const plan of plans) {
3580
+ if (!plan.automatic) {
3581
+ failed = true;
3582
+ writers.out("");
3583
+ const lines = planLines(plan);
3584
+ for (const line of lines) writers.out(line);
3585
+ if (!plan.command) writers.out(` ${tr("\u0423\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435 \u043F\u043E \u0438\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u0438:", "Install using the guide:")} ${plan.url}`);
3586
+ results.push({ tool: plan.tool, executed: false, ok: false });
3587
+ continue;
3588
+ }
3589
+ if (!json) writers.out(`
3590
+ ${tr("\u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u044E", "Installing")} ${plan.tool} ${tr("\u0447\u0435\u0440\u0435\u0437", "with")} ${plan.manager}\u2026`);
3591
+ const result = await installOne(plan, yes);
3592
+ results.push({ tool: plan.tool, executed: result.executed, ok: result.ok, ...result.error ? { error: result.error } : {} });
3593
+ if (!result.ok) {
3594
+ failed = true;
3595
+ if (!json) writers.err(warningLine(result.error ?? tr(`\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C ${plan.tool}`, `could not install ${plan.tool}`)));
3596
+ continue;
3597
+ }
3598
+ const path12 = await resolveExecutable(plan.tool);
3599
+ if (!json) {
3600
+ if (path12) writers.out(` ${colors.green("\u2714")} ${plan.tool} ${tr("\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D", "installed")}: ${path12}`);
3601
+ else {
3602
+ writers.out(` ${warningLine(tr(`${plan.tool} \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D, \u043D\u043E \u043D\u0435 \u0432\u0438\u0434\u0435\u043D \u0432 PATH \u0434\u0435\u043C\u043E\u043D\u0430: \u0437\u0430\u0434\u0430\u0439\u0442\u0435 REVDECK_${plan.tool.toUpperCase()} \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0435 \u0434\u0435\u043C\u043E\u043D`, `${plan.tool} is installed but not visible in the daemon PATH: set REVDECK_${plan.tool.toUpperCase()} or restart the daemon`))}`);
3603
+ failed = true;
3604
+ }
3605
+ }
3606
+ }
3607
+ if (json) {
3608
+ printJson({ plans, results });
3609
+ } else if (!failed) {
3610
+ writers.out(`
3611
+ ${colors.dim(tr("\u041F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0435 \u0434\u0435\u043C\u043E\u043D:", "Restart the daemon:"))} ${colors.cyan("revdeck daemon restart")}
3612
+ `);
3613
+ }
3614
+ if (failed) process.exitCode = 1;
3615
+ }
3616
+ async function tools(positionals, values) {
3617
+ if (isDevContainer()) {
3618
+ fail(
3619
+ tr("CLI \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C \u0438 \u043F\u0430\u043A\u0435\u0442\u043D\u044B\u0435 \u043C\u0435\u043D\u0435\u0434\u0436\u0435\u0440\u044B \u043F\u0440\u043E\u0432\u0435\u0440\u044F\u044E\u0442\u0441\u044F \u0438 \u0441\u0442\u0430\u0432\u044F\u0442\u0441\u044F \u043D\u0430 \u0445\u043E\u0441\u0442\u0435, \u0430 \u043D\u0435 \u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435", "platform CLIs and package managers are checked and installed on the host, not in the container"),
3620
+ tr("\u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 revdeck tools \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "run revdeck tools on the host")
3621
+ );
3622
+ }
3623
+ const action = positionals[0] ?? "status";
3624
+ if (action === "status") {
3625
+ await toolsStatus(values.json === true);
3626
+ return;
3627
+ }
3628
+ if (action === "install") {
3629
+ await toolsInstall(positionals[1], values);
3630
+ return;
3631
+ }
3632
+ fail(tr(`\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u043E\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435: ${action}`, `unknown action: ${action}`), tr("\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E: status, install", "allowed: status, install"));
3633
+ }
3634
+
3635
+ // src/cli/log-tail.ts
3636
+ import { readFile as readFile4 } from "node:fs/promises";
3637
+ async function fileLines(file) {
3638
+ const text = await readFile4(file, "utf8").catch(() => "");
3639
+ return text.trimEnd() ? text.trimEnd().split("\n") : [];
3640
+ }
3641
+ async function logTail(file, limit) {
3642
+ const current2 = await fileLines(file);
3643
+ if (current2.length >= limit) return { lines: current2.slice(-limit), rotated: null };
3644
+ const previousFile = `${file}.1`;
3645
+ const previous = await fileLines(previousFile);
3646
+ const needed = limit - current2.length;
3647
+ const head = needed > 0 ? previous.slice(-needed) : [];
3648
+ return { lines: [...head, ...current2], rotated: head.length ? previousFile : null };
3649
+ }
3650
+
3189
3651
  // src/cli/eject.ts
3190
3652
  init_paths();
3191
3653
  import { existsSync as existsSync8 } from "node:fs";
3192
- import { lstat as lstat3, readFile as readFile5, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
3654
+ import { lstat as lstat3, readFile as readFile6, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
3193
3655
  import path9 from "node:path";
3194
3656
 
3195
3657
  // src/core/jsonc.ts
@@ -3279,7 +3741,7 @@ import { applyEdits as applyEdits2, modify as modify2 } from "jsonc-parser";
3279
3741
  // src/cli/devcontainer.ts
3280
3742
  init_paths();
3281
3743
  import { existsSync as existsSync7 } from "node:fs";
3282
- import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
3744
+ import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile2 } from "node:fs/promises";
3283
3745
  import path8 from "node:path";
3284
3746
  import { applyEdits, modify, parse as parseJsonc2 } from "jsonc-parser";
3285
3747
  init_locale();
@@ -3394,7 +3856,7 @@ async function runDevcontainer(rootInput, options) {
3394
3856
  const existed = existsSync7(file);
3395
3857
  let output;
3396
3858
  if (existed) {
3397
- const text = await readFile4(file, "utf8");
3859
+ const text = await readFile5(file, "utf8");
3398
3860
  try {
3399
3861
  output = applyDevcontainerPatch(text, patch);
3400
3862
  } catch (error) {
@@ -3431,7 +3893,7 @@ async function mergeMcpEnv(root, env) {
3431
3893
  const file = path8.join(root, relative);
3432
3894
  if (!existsSync7(file)) continue;
3433
3895
  try {
3434
- const data = JSON.parse(await readFile4(file, "utf8"));
3896
+ const data = JSON.parse(await readFile5(file, "utf8"));
3435
3897
  const servers = isRecord2(data.mcpServers) ? data.mcpServers : null;
3436
3898
  const server2 = servers && isRecord2(servers.revdeck) ? servers.revdeck : null;
3437
3899
  if (!server2) continue;
@@ -3484,7 +3946,7 @@ async function runEject(rootInput, options) {
3484
3946
  for (const name of COMMAND_FILES) {
3485
3947
  const file = path9.join(root, name);
3486
3948
  if (!existsSync8(file)) continue;
3487
- const text = await readFile5(file, "utf8").catch(() => "");
3949
+ const text = await readFile6(file, "utf8").catch(() => "");
3488
3950
  if (!/revdeck/i.test(text)) {
3489
3951
  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")}`);
3490
3952
  continue;
@@ -3494,7 +3956,7 @@ async function runEject(rootInput, options) {
3494
3956
  for (const name of MCP_FILES) {
3495
3957
  const file = path9.join(root, name);
3496
3958
  if (!existsSync8(file)) continue;
3497
- const text = await readFile5(file, "utf8").catch(() => "");
3959
+ const text = await readFile6(file, "utf8").catch(() => "");
3498
3960
  let data;
3499
3961
  try {
3500
3962
  data = JSON.parse(text);
@@ -3516,7 +3978,7 @@ async function runEject(rootInput, options) {
3516
3978
  }
3517
3979
  const devcontainer = path9.join(root, ".devcontainer", "devcontainer.json");
3518
3980
  if (existsSync8(devcontainer)) {
3519
- const text = await readFile5(devcontainer, "utf8");
3981
+ const text = await readFile6(devcontainer, "utf8");
3520
3982
  try {
3521
3983
  const parsed = parseJsonc(text);
3522
3984
  if (isRecord2(parsed)) {
@@ -3566,7 +4028,7 @@ async function runEject(rootInput, options) {
3566
4028
  }
3567
4029
  const gitignore = path9.join(root, ".gitignore");
3568
4030
  if (existsSync8(gitignore)) {
3569
- const text = await readFile5(gitignore, "utf8");
4031
+ const text = await readFile6(gitignore, "utf8");
3570
4032
  if (/(^|\n)\.revdeck\/?\s*(\n|$)/.test(text)) {
3571
4033
  changes.push({
3572
4034
  path: ".gitignore",
@@ -3604,7 +4066,7 @@ async function isManagedSkill(target) {
3604
4066
  if (!info.isDirectory()) return false;
3605
4067
  const skill = path9.join(target, "SKILL.md");
3606
4068
  if (!existsSync8(skill)) return false;
3607
- const text = await readFile5(skill, "utf8");
4069
+ const text = await readFile6(skill, "utf8");
3608
4070
  return /^name:\s*revdeck\s*$/m.test(text) || /revdeck/i.test(text.slice(0, 2e3));
3609
4071
  } catch {
3610
4072
  return false;
@@ -3615,7 +4077,7 @@ async function isManagedSkill(target) {
3615
4077
  init_client();
3616
4078
  init_format();
3617
4079
  init_locale();
3618
- import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile4 } from "node:fs/promises";
4080
+ import { mkdir as mkdir4, readFile as readFile7, writeFile as writeFile4 } from "node:fs/promises";
3619
4081
  import path10 from "node:path";
3620
4082
  async function reviewFor(client2, root, arg) {
3621
4083
  if (arg && /^(gitlab|github):/.test(arg)) {
@@ -3758,7 +4220,7 @@ async function importReview(root, arg, dir) {
3758
4220
  const base = `mr-${review.info.ref.number}`;
3759
4221
  const read = async (name) => {
3760
4222
  try {
3761
- return JSON.parse(await readFile6(path10.join(target, name), "utf8"));
4223
+ return JSON.parse(await readFile7(path10.join(target, name), "utf8"));
3762
4224
  } catch {
3763
4225
  return null;
3764
4226
  }
@@ -3856,8 +4318,15 @@ function normalizeContentType(value) {
3856
4318
  // src/cli/main.ts
3857
4319
  init_context();
3858
4320
  init_scenario();
4321
+ for (const stream of [process.stdout, process.stderr]) {
4322
+ stream.on("error", (error) => {
4323
+ if (error.code === "EPIPE") process.exit(0);
4324
+ });
4325
+ }
3859
4326
  var OPTIONS = {
3860
4327
  json: { type: "boolean", default: false },
4328
+ follow: { type: "boolean", default: false },
4329
+ lines: { type: "string" },
3861
4330
  help: { type: "boolean", default: false },
3862
4331
  yes: { type: "boolean", default: false },
3863
4332
  "dry-run": { type: "boolean", default: false },
@@ -3868,6 +4337,7 @@ var OPTIONS = {
3868
4337
  provider: { type: "string" },
3869
4338
  project: { type: "string" },
3870
4339
  host: { type: "string" },
4340
+ port: { type: "string" },
3871
4341
  branch: { type: "string" },
3872
4342
  file: { type: "string" },
3873
4343
  body: { type: "string" },
@@ -3927,7 +4397,9 @@ var HELP_RU = `revdeck ${VERSION} \u2014 \u0440\u0435\u0432\u044C\u044E GitLab/G
3927
4397
  revdeck eject \u0443\u0434\u0430\u043B\u0438\u0442\u044C revdeck \u0438\u0437 \u043F\u0440\u043E\u0435\u043A\u0442\u0430 (--yes; --keep-config)
3928
4398
  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)
3929
4399
  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
3930
- revdeck daemon <start|stop|restart|status|logs|install|uninstall>
4400
+ revdeck daemon <start|stop|restart|status|logs|install|uninstall> [--port N] [--json]
4401
+ revdeck daemon logs [--lines N] [--follow] \u0445\u0432\u043E\u0441\u0442 \u043B\u043E\u0433\u0430 (--json \u2014 \u043C\u0430\u0448\u0438\u043D\u043D\u044B\u0439 \u0432\u044B\u0432\u043E\u0434)
4402
+ revdeck tools [status|install <glab|gh|all>] [--dry-run] [--yes] [--json] \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u0435 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C
3931
4403
  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)
3932
4404
  revdeck feature \u0444\u0438\u0447\u0438: list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete
3933
4405
  revdeck list \u0440\u0435\u0432\u044C\u044E \u0442\u0435\u043A\u0443\u0449\u0435\u0433\u043E \u043F\u0440\u043E\u0435\u043A\u0442\u0430 (--all \u2014 \u0432\u0441\u0435 \u043F\u0440\u043E\u0435\u043A\u0442\u044B; --remote \u2014 \u0441 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B)
@@ -3966,7 +4438,9 @@ var HELP_EN = `revdeck ${VERSION} \u2014 code review for GitLab/GitHub, for huma
3966
4438
  revdeck eject remove revdeck from the project (--yes; --keep-config)
3967
4439
  revdeck devcontainer connect a devcontainer to the host daemon (--write; host path in REVDECK_HOST_ROOT)
3968
4440
  revdeck doctor check the environment and access
3969
- revdeck daemon <start|stop|restart|status|logs|install|uninstall>
4441
+ revdeck daemon <start|stop|restart|status|logs|install|uninstall> [--port N] [--json]
4442
+ revdeck daemon logs [--lines N] [--follow] \u0445\u0432\u043E\u0441\u0442 \u043B\u043E\u0433\u0430 (--json \u2014 \u043C\u0430\u0448\u0438\u043D\u043D\u044B\u0439 \u0432\u044B\u0432\u043E\u0434)
4443
+ revdeck tools [status|install <glab|gh|all>] [--dry-run] [--yes] [--json] \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u0435 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C
3970
4444
  revdeck projects projects and their working copies (add <path> \u2014 register)
3971
4445
  revdeck feature features: list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete
3972
4446
  revdeck list reviews of the current project (--all \u2014 all projects; --remote \u2014 from the platform)
@@ -4069,6 +4543,8 @@ async function main2() {
4069
4543
  return runDevcontainer(root, { write: values.write === true });
4070
4544
  case "doctor":
4071
4545
  return doctor(root);
4546
+ case "tools":
4547
+ return tools(positionals, values);
4072
4548
  case "daemon":
4073
4549
  return daemon(positionals[0] ?? "status", values);
4074
4550
  case "projects":
@@ -4244,7 +4720,7 @@ function featureRef(value) {
4244
4720
  async function textFromFile(file, label) {
4245
4721
  if (typeof file !== "string" || !file.trim()) return void 0;
4246
4722
  try {
4247
- return await readFile7(file, "utf8");
4723
+ return await readFile8(file, "utf8");
4248
4724
  } catch (error) {
4249
4725
  fail(tr(`\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C ${label}: ${error.message}`, `could not read the ${label}: ${error.message}`));
4250
4726
  }
@@ -4502,27 +4978,62 @@ async function daemon(action, values = {}) {
4502
4978
  );
4503
4979
  }
4504
4980
  if (action === "start") {
4505
- const { client: client2, started } = await ensureDaemon({
4506
- ...values.host ? { daemonArgs: ["--host", String(values.host)] } : {}
4507
- });
4508
- const ping = await client2.request("ping");
4509
- client2.close();
4510
- const info = await daemonInfo();
4511
- writers.out(`${started ? tr("\u0437\u0430\u043F\u0443\u0449\u0435\u043D", "started") : tr("\u0443\u0436\u0435 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442", "already running")} ${tr("\u0434\u0435\u043C\u043E\u043D", "daemon")} pid ${ping.pid}, ${tr("\u0432\u0435\u0440\u0441\u0438\u044F", "version")} ${ping.version}`);
4512
- if (values.host && !started) {
4513
- writers.err(tr("! \u0443\u0436\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D\u043D\u044B\u0439 \u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u043C\u0435\u043D\u044F\u0435\u0442 bind-\u0430\u0434\u0440\u0435\u0441: \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 revdeck daemon restart --host 0.0.0.0", "! a running daemon does not rebind: use revdeck daemon restart --host 0.0.0.0"));
4514
- }
4515
- if (info) writers.out(`${uiBaseUrl(info)}/?t=${info.token}`);
4981
+ await startDaemon(values, "started");
4982
+ return;
4983
+ }
4984
+ if (action === "restart") {
4985
+ const previous = await stopDaemon();
4986
+ await startDaemon(values, previous ? "restarted" : "started");
4516
4987
  return;
4517
4988
  }
4518
4989
  if (action === "status") {
4519
4990
  const running = await isDaemonRunning();
4520
4991
  const info = await daemonInfo();
4521
4992
  if (!running || !info) {
4522
- writers.out(tr("\u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D", "the daemon is not running"));
4523
- process.exit(1);
4993
+ if (values.json) printJson({ running: false });
4994
+ else for (const line of daemonNotRunningLines()) writers.out(line);
4995
+ process.exitCode = 1;
4996
+ return;
4997
+ }
4998
+ const health = await daemonHealth(info);
4999
+ if (values.json) {
5000
+ printJson({
5001
+ running: true,
5002
+ pid: info.pid,
5003
+ version: info.version,
5004
+ protocol: info.protocol,
5005
+ url: uiBaseUrl(info),
5006
+ socket: info.socket,
5007
+ stateDir: stateDir(),
5008
+ logPath: logPath(),
5009
+ startedAt: info.startedAt,
5010
+ health,
5011
+ versionMismatch: Boolean(health && health.version && health.version !== VERSION)
5012
+ });
5013
+ return;
5014
+ }
5015
+ const healthField = health ? health.ok ? `ok \xB7 ${health.reviews} ${plural(health.reviews, "\u0440\u0435\u0432\u044C\u044E", "\u0440\u0435\u0432\u044C\u044E", "\u0440\u0435\u0432\u044C\u044E", "review", "reviews")}` : tr("\u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442", "not responding") : tr("\u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442", "not responding");
5016
+ for (const line of daemonStatusLines({
5017
+ version: info.version,
5018
+ pid: info.pid,
5019
+ url: uiBaseUrl(info),
5020
+ socket: info.socket,
5021
+ stateDir: stateDir(),
5022
+ logPath: logPath(),
5023
+ startedAt: when(info.startedAt),
5024
+ health: healthField
5025
+ })) writers.out(line);
5026
+ if (health && health.version && health.version !== VERSION) {
5027
+ writers.out(
5028
+ ` ${warningLine(
5029
+ tr(
5030
+ `\u0434\u0435\u043C\u043E\u043D \u0441\u043E\u043E\u0431\u0449\u0430\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044E ${health.version}, CLI \u2014 ${VERSION}: \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0435 \u0434\u0435\u043C\u043E\u043D`,
5031
+ `the daemon reports ${health.version}, the CLI is ${VERSION}: restart the daemon`
5032
+ )
5033
+ )}`
5034
+ );
5035
+ writers.out("");
4524
5036
  }
4525
- writers.out(`pid ${info.pid} \xB7 ${info.url} \xB7 ${when(info.startedAt)}`);
4526
5037
  return;
4527
5038
  }
4528
5039
  if (action === "install") {
@@ -4530,40 +5041,219 @@ async function daemon(action, values = {}) {
4530
5041
  return;
4531
5042
  }
4532
5043
  if (action === "uninstall") {
4533
- writers.out(tr("\u0443\u0434\u0430\u043B\u0438\u0442\u0435 unit \u0432\u0440\u0443\u0447\u043D\u0443\u044E: systemctl --user disable --now revdeck (Linux) \u0438\u043B\u0438 launchctl unload (macOS)", "remove the unit manually: systemctl --user disable --now revdeck (Linux) or launchctl unload (macOS)"));
5044
+ writers.out(tr("\u0423\u0434\u0430\u043B\u0438\u0442\u0435 \u0430\u0432\u0442\u043E\u0437\u0430\u043F\u0443\u0441\u043A \u0432\u0440\u0443\u0447\u043D\u0443\u044E:", "Remove the autostart manually:"));
5045
+ writers.out(` ${tr("Linux", "Linux")} systemctl --user disable --now revdeck`);
5046
+ writers.out(` ${tr("macOS", "macOS")} launchctl unload ~/Library/LaunchAgents/io.revdeck.daemon.plist`);
4534
5047
  return;
4535
5048
  }
4536
5049
  if (action === "stop") {
4537
- const info = await daemonInfo();
4538
- if (!info) {
4539
- writers.out(tr("\u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D", "the daemon is not running"));
5050
+ const stopped = await stopDaemon();
5051
+ if (values.json) {
5052
+ printJson(
5053
+ stopped ? { stopped: true, pid: stopped.pid, startedAt: stopped.startedAt, uptime: durationSince(stopped.startedAt) } : { stopped: false }
5054
+ );
4540
5055
  return;
4541
5056
  }
4542
- try {
4543
- process.kill(info.pid, "SIGTERM");
4544
- } catch {
4545
- }
4546
- const deadline = Date.now() + 5e3;
4547
- while (Date.now() < deadline && await isDaemonRunning()) {
4548
- await new Promise((resolve) => setTimeout(resolve, 100));
5057
+ if (!stopped) {
5058
+ writers.out(daemonNotRunningLine());
5059
+ return;
4549
5060
  }
4550
- writers.out(tr("\u0434\u0435\u043C\u043E\u043D \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D", "daemon stopped"));
5061
+ for (const line of daemonStoppedLines({ pid: stopped.pid, uptime: durationSince(stopped.startedAt) })) writers.out(line);
4551
5062
  return;
4552
5063
  }
4553
- if (action === "restart") {
4554
- await daemon("stop");
4555
- return daemon("start", values);
4556
- }
4557
5064
  if (action === "logs") {
5065
+ await daemonLogs(values.follow === true, values.json === true, parseLogLines(values.lines));
5066
+ return;
5067
+ }
5068
+ usage(["daemon <start|stop|status|restart|logs|install|uninstall>"]);
5069
+ }
5070
+ function parseCliPort(value) {
5071
+ if (value === void 0 || value === false) return null;
5072
+ const port = Number(value);
5073
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
5074
+ fail(tr(`\u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u043F\u043E\u0440\u0442 ${String(value)}: \u043D\u0443\u0436\u043D\u043E 1\u201365535`, `invalid port ${String(value)}: expected 1\u201365535`));
5075
+ }
5076
+ return port;
5077
+ }
5078
+ async function daemonHealth(info) {
5079
+ if (!info.token) return null;
5080
+ try {
5081
+ const response = await fetch(`${info.url}/api/health`, {
5082
+ headers: { cookie: `revdeck_session=${encodeURIComponent(info.token)}` },
5083
+ signal: AbortSignal.timeout(1500)
5084
+ });
5085
+ const data = await response.json();
5086
+ if (!response.ok || data.ok !== true) return null;
5087
+ return { ok: true, ...data.version ? { version: data.version } : {}, reviews: Number(data.reviews ?? 0) };
5088
+ } catch {
5089
+ return null;
5090
+ }
5091
+ }
5092
+ var LOG_TAIL = 80;
5093
+ var LOG_FOLLOW_MS = 500;
5094
+ function parseLogLines(value) {
5095
+ if (value === void 0 || value === false) return LOG_TAIL;
5096
+ const lines = Number(value);
5097
+ if (!Number.isInteger(lines) || lines < 1 || lines > 5e3) {
5098
+ fail(tr(`\u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E \u0441\u0442\u0440\u043E\u043A: ${String(value)}`, `invalid line count: ${String(value)}`), tr("\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E 1\u20135000", "expected 1\u20135000"));
5099
+ }
5100
+ return lines;
5101
+ }
5102
+ async function daemonLogs(follow, json, limit) {
5103
+ const file = logPath();
5104
+ const tail = await logTail(file, limit);
5105
+ const size = await stat2(file).catch(() => null);
5106
+ if (json && !follow) {
5107
+ printJson({ path: file, lines: tail.lines });
5108
+ return;
5109
+ }
5110
+ if (!follow) {
5111
+ if (!tail.lines.length) {
5112
+ for (const line of daemonLogEmptyLines(file)) writers.out(line);
5113
+ return;
5114
+ }
5115
+ for (const line of daemonLogHeader(file, limit, false, tail.rotated ?? void 0)) writers.out(line);
5116
+ for (const line of tail.lines) writers.out(formatLogLine(line));
5117
+ writers.out("");
5118
+ return;
5119
+ }
5120
+ let inode = size?.ino ?? 0;
5121
+ let offset = size?.size ?? 0;
5122
+ if (!json) for (const line of daemonLogHeader(file, limit, true, tail.rotated ?? void 0)) writers.out(line);
5123
+ const print = (line) => {
5124
+ if (json) writers.out(JSON.stringify({ path: file, line }));
5125
+ else writers.out(formatLogLine(line));
5126
+ };
5127
+ for (const line of tail.lines) print(line);
5128
+ let remainder = "";
5129
+ let busy = false;
5130
+ const readNew = async () => {
5131
+ const handle = await open2(file, "r").catch(() => null);
5132
+ if (!handle) return "";
4558
5133
  try {
4559
- const text = await readFile7(logPath(), "utf8");
4560
- writers.out(text.split("\n").slice(-80).join("\n"));
4561
- } catch {
4562
- writers.out(tr("\u043B\u043E\u0433 \u043F\u0443\u0441\u0442", "the log is empty"));
5134
+ const info = await handle.stat();
5135
+ if (info.ino && info.ino !== inode || info.size < offset) {
5136
+ inode = info.ino;
5137
+ offset = 0;
5138
+ }
5139
+ if (info.size <= offset) return "";
5140
+ const length = Math.min(info.size - offset, 256 * 1024);
5141
+ const buffer = Buffer.alloc(length);
5142
+ const { bytesRead } = await handle.read(buffer, 0, length, offset);
5143
+ offset += bytesRead;
5144
+ return buffer.subarray(0, bytesRead).toString("utf8");
5145
+ } finally {
5146
+ await handle.close();
5147
+ }
5148
+ };
5149
+ const tick = async () => {
5150
+ if (busy) return;
5151
+ busy = true;
5152
+ try {
5153
+ const chunk = await readNew();
5154
+ if (!chunk) return;
5155
+ remainder += chunk;
5156
+ const parts = remainder.split("\n");
5157
+ remainder = parts.pop() ?? "";
5158
+ for (const line of parts) print(line);
5159
+ } finally {
5160
+ busy = false;
5161
+ }
5162
+ };
5163
+ const timer = setInterval(() => void tick(), LOG_FOLLOW_MS);
5164
+ await new Promise((resolve) => {
5165
+ const stop = () => resolve();
5166
+ process.once("SIGINT", stop);
5167
+ process.once("SIGTERM", stop);
5168
+ });
5169
+ clearInterval(timer);
5170
+ if (remainder) print(remainder);
5171
+ }
5172
+ async function startDaemon(values, mode) {
5173
+ const port = parseCliPort(values.port);
5174
+ const daemonArgs = [
5175
+ ...values.host ? ["--host", String(values.host)] : [],
5176
+ ...port ? ["--port", String(port)] : []
5177
+ ];
5178
+ const hint = setTimeout(
5179
+ () => writers.err(errorColors.dim(tr(" \u0437\u0430\u043F\u0443\u0441\u043A\u0430\u044E \u0434\u0435\u043C\u043E\u043D\u2026", " starting the daemon\u2026"))),
5180
+ 700
5181
+ );
5182
+ const { client: client2, started } = await ensureDaemon({ ...daemonArgs.length ? { daemonArgs } : {} }).finally(() => clearTimeout(hint));
5183
+ const ping = await client2.request("ping");
5184
+ client2.close();
5185
+ const info = await daemonInfo();
5186
+ if (!info) {
5187
+ if (values.json) {
5188
+ printJson({ running: true, started, restarted: mode === "restarted", pid: ping.pid, version: ping.version });
5189
+ } else {
5190
+ writers.out(` ${tr("\u0434\u0435\u043C\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D", "daemon started")} \xB7 pid ${ping.pid} \xB7 ${tr("\u0432\u0435\u0440\u0441\u0438\u044F", "version")} ${ping.version}`);
4563
5191
  }
4564
5192
  return;
4565
5193
  }
4566
- usage(["daemon <start|stop|status|restart|logs|install|uninstall>"]);
5194
+ if (values.json) {
5195
+ const base = uiBaseUrl(info);
5196
+ printJson({
5197
+ running: true,
5198
+ started,
5199
+ restarted: mode === "restarted",
5200
+ pid: ping.pid,
5201
+ version: ping.version,
5202
+ url: base,
5203
+ ui: `${base}${info.token ? `/?t=${info.token}` : ""}`,
5204
+ socket: info.socket,
5205
+ stateDir: stateDir(),
5206
+ logPath: logPath()
5207
+ });
5208
+ return;
5209
+ }
5210
+ for (const line of daemonStartedLines(
5211
+ {
5212
+ version: ping.version,
5213
+ pid: ping.pid,
5214
+ url: `${uiBaseUrl(info)}${info.token ? `/?t=${info.token}` : ""}`,
5215
+ socket: info.socket,
5216
+ stateDir: stateDir(),
5217
+ logPath: logPath()
5218
+ },
5219
+ mode === "restarted" ? "restarted" : started ? "started" : "running"
5220
+ )) {
5221
+ writers.out(line);
5222
+ }
5223
+ if (!started && values.host) {
5224
+ writers.err(
5225
+ warningLine(
5226
+ tr(
5227
+ "\u0443\u0436\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D\u043D\u044B\u0439 \u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u043C\u0435\u043D\u044F\u0435\u0442 bind-\u0430\u0434\u0440\u0435\u0441: \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 revdeck daemon restart --host 0.0.0.0",
5228
+ "a running daemon does not rebind: use revdeck daemon restart --host 0.0.0.0"
5229
+ )
5230
+ )
5231
+ );
5232
+ }
5233
+ if (!started && port) {
5234
+ writers.err(
5235
+ warningLine(
5236
+ tr(
5237
+ `\u0443\u0436\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D\u043D\u044B\u0439 \u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u043C\u0435\u043D\u044F\u0435\u0442 \u043F\u043E\u0440\u0442: \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 revdeck daemon restart --port ${port}`,
5238
+ `a running daemon does not rebind: use revdeck daemon restart --port ${port}`
5239
+ )
5240
+ )
5241
+ );
5242
+ }
5243
+ }
5244
+ async function stopDaemon() {
5245
+ if (!await isDaemonRunning()) return null;
5246
+ const info = await daemonInfo();
5247
+ if (!info) return null;
5248
+ try {
5249
+ process.kill(info.pid, "SIGTERM");
5250
+ } catch {
5251
+ }
5252
+ const deadline = Date.now() + 5e3;
5253
+ while (Date.now() < deadline && await isDaemonRunning()) {
5254
+ await new Promise((resolve) => setTimeout(resolve, 100));
5255
+ }
5256
+ return info;
4567
5257
  }
4568
5258
  async function status(root, values) {
4569
5259
  await withClient(async ({ client: client2 }) => {
@@ -4708,7 +5398,7 @@ async function findings(arg, action, values) {
4708
5398
  const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);
4709
5399
  if (action === "set") {
4710
5400
  if (!values.file) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 --file \u0441 JSON \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0439", "pass --file with findings JSON"));
4711
- const raw = JSON.parse(await readFile7(String(values.file), "utf8"));
5401
+ const raw = JSON.parse(await readFile8(String(values.file), "utf8"));
4712
5402
  const list2 = Array.isArray(raw) ? raw : raw.findings;
4713
5403
  if (!Array.isArray(list2)) fail(tr("\u043E\u0436\u0438\u0434\u0430\u043B\u0441\u044F \u043C\u0430\u0441\u0441\u0438\u0432 \u0438\u043B\u0438 {findings: [...]}", "expected an array or {findings: [...]}"));
4714
5404
  const { findings: saved } = await client2.request("findings.put", { review: review.id, findings: list2 });
@@ -4735,7 +5425,7 @@ async function findings(arg, action, values) {
4735
5425
  }
4736
5426
  async function summary(arg, values) {
4737
5427
  if (!values.file && process.stdin.isTTY) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 --file \u0441 JSON \u0432\u044B\u0436\u0438\u043C\u043A\u0438 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 \u0435\u0451 \u0447\u0435\u0440\u0435\u0437 stdin", "pass --file with summary JSON or pipe it via stdin"));
4738
- const raw = values.file ? JSON.parse(await readFile7(String(values.file), "utf8")) : JSON.parse(await readStdin());
5428
+ const raw = values.file ? JSON.parse(await readFile8(String(values.file), "utf8")) : JSON.parse(await readStdin());
4739
5429
  await withClient(async ({ client: client2 }) => {
4740
5430
  const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);
4741
5431
  const result = await client2.request("summary.put", { review: review.id, summary: raw });
@@ -4876,7 +5566,7 @@ async function attach(arg, values) {
4876
5566
  if (info.size > MAX_ATTACHMENT_BYTES) {
4877
5567
  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`));
4878
5568
  }
4879
- const data = await readFile7(file);
5569
+ const data = await readFile8(file);
4880
5570
  await withClient(async ({ client: client2 }) => {
4881
5571
  const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);
4882
5572
  const result = await client2.request("attachments.upload", {
@@ -5012,7 +5702,7 @@ async function readBodyInput(values) {
5012
5702
  if (values["body-file"] !== void 0) {
5013
5703
  const file = String(values["body-file"]);
5014
5704
  if (file === "-") return readStdin();
5015
- return readFile7(file, "utf8");
5705
+ return readFile8(file, "utf8");
5016
5706
  }
5017
5707
  if (process.stdin.isTTY) return null;
5018
5708
  return readStdin();
@@ -5023,14 +5713,14 @@ async function readStdin() {
5023
5713
  return Buffer.concat(chunks).toString("utf8");
5024
5714
  }
5025
5715
  async function doctor(root) {
5026
- const rows = [];
5716
+ const rows2 = [];
5027
5717
  const container = isDevContainer();
5028
5718
  const major = Number(process.version.slice(1).split(".")[0]);
5029
- rows.push(["node", major >= 22 ? "ok" : "fail", process.version]);
5719
+ rows2.push(["node", major >= 22 ? "ok" : "fail", process.version]);
5030
5720
  if (container) {
5031
- 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")]);
5721
+ rows2.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")]);
5032
5722
  const hostRoot = process.env.REVDECK_HOST_ROOT?.trim();
5033
- rows.push([
5723
+ rows2.push([
5034
5724
  "host root",
5035
5725
  hostRoot ? "ok" : "warn",
5036
5726
  hostRoot ?? tr(
@@ -5045,10 +5735,10 @@ async function doctor(root) {
5045
5735
  const present = resolved !== null;
5046
5736
  binaries[bin] = present;
5047
5737
  if (container && (bin === "glab" || bin === "gh")) {
5048
- rows.push([bin, "ok", present ? tr("\u0435\u0441\u0442\u044C \u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435, \u043D\u043E \u043D\u0435 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442\u0441\u044F", "present in the container but unused") : tr("\u043D\u0435 \u043D\u0443\u0436\u0435\u043D \u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435: \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "not needed in the container: the host runs it")]);
5738
+ rows2.push([bin, "ok", present ? tr("\u0435\u0441\u0442\u044C \u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435, \u043D\u043E \u043D\u0435 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442\u0441\u044F", "present in the container but unused") : tr("\u043D\u0435 \u043D\u0443\u0436\u0435\u043D \u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435: \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "not needed in the container: the host runs it")]);
5049
5739
  continue;
5050
5740
  }
5051
- rows.push([
5741
+ rows2.push([
5052
5742
  bin,
5053
5743
  present ? "ok" : "warn",
5054
5744
  present ? resolved : tr(
@@ -5063,11 +5753,11 @@ async function doctor(root) {
5063
5753
  const loaded = await loadConfig(root);
5064
5754
  host = loaded.config.provider.host ?? (await gitRemote(root))?.host;
5065
5755
  providerType = loaded.config.provider.type;
5066
- rows.push(["config", loaded.path ? "ok" : "warn", loaded.path ?? tr("\u043D\u0435\u0442 .revdeck.yml (\u0430\u0432\u0442\u043E\u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u0438\u0435)", "no .revdeck.yml (auto-discovery)")]);
5067
- if (loaded.localPath) rows.push(["local config", "ok", loaded.localPath]);
5068
- for (const warning of loaded.warnings) rows.push(["warning", "warn", warning]);
5756
+ rows2.push(["config", loaded.path ? "ok" : "warn", loaded.path ?? tr("\u043D\u0435\u0442 .revdeck.yml (\u0430\u0432\u0442\u043E\u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u0438\u0435)", "no .revdeck.yml (auto-discovery)")]);
5757
+ if (loaded.localPath) rows2.push(["local config", "ok", loaded.localPath]);
5758
+ for (const warning of loaded.warnings) rows2.push(["warning", "warn", warning]);
5069
5759
  } catch (error) {
5070
- rows.push(["config", "fail", redactLine(error)]);
5760
+ rows2.push(["config", "fail", redactLine(error)]);
5071
5761
  }
5072
5762
  if (!container) {
5073
5763
  const platform = providerType !== "auto" ? providerType : detectPlatform(host ?? "");
@@ -5075,37 +5765,45 @@ async function doctor(root) {
5075
5765
  if (host && binaries.glab && platform !== "github") {
5076
5766
  try {
5077
5767
  await run("glab", ["auth", "status", "--hostname", host], { timeoutMs: 15e3 });
5078
- rows.push(["glab auth", "ok", host]);
5768
+ rows2.push(["glab auth", "ok", host]);
5079
5769
  } catch (error) {
5080
- rows.push(["glab auth", "warn", `${tr("\u043D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u0430 \u043A", "no access to")} ${host}: ${redactLine(error).slice(0, 120)}; ${uiHint}`]);
5770
+ rows2.push([
5771
+ "glab auth",
5772
+ "warn",
5773
+ [tr(`\u043D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u0430 \u043A ${host}`, `no access to ${host}`), compactDetail(redactLine(error), 120), uiHint].join("\n")
5774
+ ]);
5081
5775
  }
5082
5776
  }
5083
5777
  if (host && binaries.gh && platform !== "gitlab") {
5084
5778
  try {
5085
5779
  await run("gh", ["auth", "status"], { timeoutMs: 15e3, env: { GH_HOST: host } });
5086
- rows.push(["gh auth", "ok", host]);
5780
+ rows2.push(["gh auth", "ok", host]);
5087
5781
  } catch (error) {
5088
- rows.push(["gh auth", "warn", `${tr("\u043D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u0430 \u043A", "no access to")} ${host}: ${redactLine(error).slice(0, 120)}; ${uiHint}`]);
5782
+ rows2.push([
5783
+ "gh auth",
5784
+ "warn",
5785
+ [tr(`\u043D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u0430 \u043A ${host}`, `no access to ${host}`), compactDetail(redactLine(error), 120), uiHint].join("\n")
5786
+ ]);
5089
5787
  }
5090
5788
  }
5091
5789
  }
5092
5790
  const running = await isDaemonRunning();
5093
5791
  const info = await daemonInfo();
5094
5792
  const daemonStatus = running ? "ok" : container ? "fail" : "warn";
5095
- rows.push([
5793
+ rows2.push([
5096
5794
  "daemon",
5097
5795
  daemonStatus,
5098
- running && info ? `${uiBaseUrl(info)} (pid ${info.pid})` : container ? tr("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u043D\u0430 \u0445\u043E\u0441\u0442\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 revdeck daemon start", "not found: run revdeck daemon start on the host") : tr("\u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D (\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0441\u044F \u0441\u0430\u043C)", "not running (starts on demand)")
5796
+ running && info ? `${uiBaseUrl(info)} \xB7 pid ${info.pid}` : container ? tr("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u043D\u0430 \u0445\u043E\u0441\u0442\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 revdeck daemon start", "not found: run revdeck daemon start on the host") : tr("\u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D (\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0441\u044F \u0441\u0430\u043C)", "not running (starts on demand)")
5099
5797
  ]);
5100
- rows.push(["ui", running ? "ok" : "warn", info ? uiBaseUrl(info) : tr("\u0431\u0443\u0434\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u043F\u043E\u0441\u043B\u0435 \u0437\u0430\u043F\u0443\u0441\u043A\u0430", "available after the daemon starts")]);
5798
+ rows2.push(["ui", running ? "ok" : "warn", info ? uiBaseUrl(info) : tr("\u0431\u0443\u0434\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u043F\u043E\u0441\u043B\u0435 \u0437\u0430\u043F\u0443\u0441\u043A\u0430", "available after the daemon starts")]);
5101
5799
  if (running) {
5102
5800
  const seen = await daemonBinaries();
5103
5801
  for (const bin of ["glab", "gh"]) {
5104
5802
  if (!seen) {
5105
- rows.push([`daemon ${bin}`, "warn", tr("\u0434\u0435\u043C\u043E\u043D \u0441\u0442\u0430\u0440\u043E\u0439 \u0432\u0435\u0440\u0441\u0438\u0438: \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0435 \u0435\u0433\u043E", "old daemon version: restart it")]);
5803
+ rows2.push([`daemon ${bin}`, "warn", tr("\u0434\u0435\u043C\u043E\u043D \u0441\u0442\u0430\u0440\u043E\u0439 \u0432\u0435\u0440\u0441\u0438\u0438: \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0435 \u0435\u0433\u043E", "old daemon version: restart it")]);
5106
5804
  continue;
5107
5805
  }
5108
- rows.push([
5806
+ rows2.push([
5109
5807
  `daemon ${bin}`,
5110
5808
  seen[bin] ? "ok" : "fail",
5111
5809
  seen[bin] ?? tr("\u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u0432\u0438\u0434\u0438\u0442 \u0431\u0438\u043D\u0430\u0440\u043D\u0438\u043A: \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u0435 PATH \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435 \u0441\u0435\u0440\u0432\u0438\u0441", "the daemon cannot see the binary: update PATH or reinstall the service")
@@ -5114,11 +5812,13 @@ async function doctor(root) {
5114
5812
  }
5115
5813
  const { existsSync: existsSync9 } = await import("node:fs");
5116
5814
  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"));
5117
- 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")]);
5118
- for (const [name, status2, detail] of rows) {
5119
- writers.out(`${status2 === "ok" ? "\u2714" : status2 === "warn" ? "!" : "\u2716"} ${name.padEnd(10)} ${detail}`);
5815
+ rows2.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")]);
5816
+ for (const [name, status2, detail] of rows2) for (const line of doctorLines(name, status2, detail)) writers.out(line);
5817
+ if (!host) {
5818
+ writers.out(
5819
+ warningLine(tr("\u0445\u043E\u0441\u0442 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0451\u043D: \u0443\u043A\u0430\u0436\u0438\u0442\u0435 provider.host \u0432 .revdeck.yml", "platform host is unknown: set provider.host in .revdeck.yml"))
5820
+ );
5120
5821
  }
5121
- if (!host) writers.out(tr("! \u0445\u043E\u0441\u0442 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0451\u043D: \u0443\u043A\u0430\u0436\u0438\u0442\u0435 provider.host \u0432 .revdeck.yml", "! platform host is unknown: set provider.host in .revdeck.yml"));
5122
5822
  }
5123
5823
  main2().catch((error) => {
5124
5824
  fail(error instanceof Error ? error.message : String(error), error.hint);