revdeck 0.3.1 → 0.3.3

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
@@ -168,7 +168,7 @@ var VERSION;
168
168
  var init_version = __esm({
169
169
  "src/version.ts"() {
170
170
  "use strict";
171
- VERSION = "0.3.1";
171
+ VERSION = "0.3.3";
172
172
  }
173
173
  });
174
174
 
@@ -277,6 +277,16 @@ function uiBaseUrl(info) {
277
277
  if (!isDevContainer() || !host) return info.url;
278
278
  return `http://${host}:${info.port}`;
279
279
  }
280
+ async function daemonBinaries() {
281
+ try {
282
+ const client2 = await connectSocket(void 0, 800);
283
+ const ping = await client2.request("ping");
284
+ client2.close();
285
+ return ping.binaries ?? null;
286
+ } catch {
287
+ return null;
288
+ }
289
+ }
280
290
  async function isDaemonRunning() {
281
291
  try {
282
292
  const client2 = await connectSocket(void 0, 400);
@@ -1105,7 +1115,7 @@ init_paths();
1105
1115
  import { readFile as readFile7, stat } from "node:fs/promises";
1106
1116
  import { readFileSync } from "node:fs";
1107
1117
  import { parseArgs } from "node:util";
1108
- import path9 from "node:path";
1118
+ import path10 from "node:path";
1109
1119
 
1110
1120
  // src/core/config.ts
1111
1121
  init_paths();
@@ -1178,8 +1188,8 @@ function globToRegExp(glob) {
1178
1188
  function escapeRegExp(value) {
1179
1189
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1180
1190
  }
1181
- function classifyFile(path10) {
1182
- const lower = path10.toLowerCase();
1191
+ function classifyFile(path11) {
1192
+ const lower = path11.toLowerCase();
1183
1193
  if (/(^|\/)(node_modules|dist|build|coverage|vendor)\//.test(lower)) return "generated";
1184
1194
  if (/\.(md|mdx|rst|txt|adoc)$/.test(lower) || /(^|\/)(docs?|adr)\//.test(lower)) return "docs";
1185
1195
  if (/(^|\/)(__tests__|tests?|spec|e2e)\//.test(lower) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /_test\.go$/.test(lower)) return "test";
@@ -1496,6 +1506,9 @@ init_client();
1496
1506
 
1497
1507
  // src/core/exec.ts
1498
1508
  import { execFile } from "node:child_process";
1509
+ import { access, constants } from "node:fs/promises";
1510
+ import os2 from "node:os";
1511
+ import path5 from "node:path";
1499
1512
  var SECRET_ENV = [
1500
1513
  "GITLAB_TOKEN",
1501
1514
  "GITLAB_PRIVATE_TOKEN",
@@ -1523,42 +1536,76 @@ function scrubEnv(extra) {
1523
1536
  env.TERM = "dumb";
1524
1537
  return { ...env, ...extra };
1525
1538
  }
1526
- var run = (command, args, options = {}) => new Promise((resolve, reject) => {
1527
- const child = execFile(
1528
- command,
1529
- args,
1530
- {
1531
- cwd: options.cwd,
1532
- env: scrubEnv(options.env),
1533
- timeout: options.timeoutMs ?? 12e4,
1534
- maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
1535
- encoding: "utf8",
1536
- windowsHide: true,
1537
- shell: false
1538
- },
1539
- (error, stdout, stderr) => {
1540
- const exitCode = error?.code;
1541
- const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
1542
- if (error && !(options.allowExitCodes ?? []).includes(code)) {
1543
- const reason = (stderr || stdout || error.message).trim();
1544
- reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
1545
- return;
1539
+ var RESOLVED = /* @__PURE__ */ new Map();
1540
+ async function resolveExecutable(command) {
1541
+ if (command.includes("/") || command.includes("\\")) {
1542
+ try {
1543
+ await access(command, constants.X_OK);
1544
+ return command;
1545
+ } catch {
1546
+ return null;
1547
+ }
1548
+ }
1549
+ const override = process.env[`REVDECK_${command.toUpperCase()}`];
1550
+ if (override) return override;
1551
+ const cached = RESOLVED.get(command);
1552
+ if (cached) return cached;
1553
+ const dirs = [
1554
+ ...(process.env.PATH ?? "").split(path5.delimiter),
1555
+ path5.join(os2.homedir(), ".local", "bin"),
1556
+ path5.join(os2.homedir(), ".local", "share", "mise", "shims"),
1557
+ path5.join(os2.homedir(), ".asdf", "shims"),
1558
+ path5.join(os2.homedir(), ".npm-global", "bin"),
1559
+ "/opt/homebrew/bin",
1560
+ "/usr/local/bin",
1561
+ "/usr/bin",
1562
+ "/bin"
1563
+ ].filter(Boolean);
1564
+ const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
1565
+ for (const dir of [...new Set(dirs)]) {
1566
+ for (const extension of extensions) {
1567
+ const candidate = path5.join(dir, `${command}${extension}`);
1568
+ try {
1569
+ await access(candidate, constants.X_OK);
1570
+ RESOLVED.set(command, candidate);
1571
+ return candidate;
1572
+ } catch {
1546
1573
  }
1547
- resolve({ stdout, stderr, code });
1548
1574
  }
1549
- );
1550
- if (options.input !== void 0) {
1551
- child.stdin?.end(options.input);
1552
- }
1553
- });
1554
- async function which(command) {
1555
- try {
1556
- await run(process.platform === "win32" ? "where" : "which", [command], { timeoutMs: 5e3 });
1557
- return true;
1558
- } catch {
1559
- return false;
1560
1575
  }
1576
+ return null;
1561
1577
  }
1578
+ var run = async (command, args, options = {}) => {
1579
+ const executable = await resolveExecutable(command) ?? command;
1580
+ return new Promise((resolve, reject) => {
1581
+ const child = execFile(
1582
+ executable,
1583
+ args,
1584
+ {
1585
+ cwd: options.cwd,
1586
+ env: scrubEnv(options.env),
1587
+ timeout: options.timeoutMs ?? 12e4,
1588
+ maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
1589
+ encoding: "utf8",
1590
+ windowsHide: true,
1591
+ shell: false
1592
+ },
1593
+ (error, stdout, stderr) => {
1594
+ const exitCode = error?.code;
1595
+ const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
1596
+ if (error && !(options.allowExitCodes ?? []).includes(code)) {
1597
+ const reason = (stderr || stdout || error.message).trim();
1598
+ reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
1599
+ return;
1600
+ }
1601
+ resolve({ stdout, stderr, code });
1602
+ }
1603
+ );
1604
+ if (options.input !== void 0) {
1605
+ child.stdin?.end(options.input);
1606
+ }
1607
+ });
1608
+ };
1562
1609
 
1563
1610
  // src/cli/main.ts
1564
1611
  init_redact();
@@ -1607,8 +1654,8 @@ init_format();
1607
1654
  // src/cli/init.ts
1608
1655
  init_paths();
1609
1656
  import { existsSync as existsSync5 } from "node:fs";
1610
- import { appendFile, cp, lstat as lstat2, mkdir as mkdir2, readdir, readFile as readFile3, readlink, rm, symlink, writeFile } from "node:fs/promises";
1611
- import path5 from "node:path";
1657
+ import { appendFile, cp, lstat as lstat2, mkdir as mkdir2, readdir, readFile as readFile3, rm, symlink, writeFile } from "node:fs/promises";
1658
+ import path6 from "node:path";
1612
1659
  init_redact();
1613
1660
  init_locale();
1614
1661
  init_format();
@@ -1619,9 +1666,9 @@ async function runInit(rootInput, options) {
1619
1666
  const root = findRepoRoot(rootInput);
1620
1667
  writers.out(`${tr("\u043F\u0440\u043E\u0435\u043A\u0442", "project")}: ${root}`);
1621
1668
  const remote = await gitRemote(root);
1622
- const configFile = path5.join(root, ".revdeck.yml");
1669
+ const configFile = path6.join(root, ".revdeck.yml");
1623
1670
  if (existsSync5(configFile) && !options.force) {
1624
- writers.out(`\u2714 ${tr("\u043A\u043E\u043D\u0444\u0438\u0433 \u0443\u0436\u0435 \u0435\u0441\u0442\u044C", "config already exists")}: ${path5.relative(root, configFile)}`);
1671
+ writers.out(`\u2714 ${tr("\u043A\u043E\u043D\u0444\u0438\u0433 \u0443\u0436\u0435 \u0435\u0441\u0442\u044C", "config already exists")}: ${path6.relative(root, configFile)}`);
1625
1672
  } else {
1626
1673
  let sources = [];
1627
1674
  try {
@@ -1650,7 +1697,7 @@ async function runInit(rootInput, options) {
1650
1697
  ""
1651
1698
  ];
1652
1699
  await writeFile(configFile, lines.join("\n"), { mode: 420 });
1653
- writers.out(`\u2714 ${tr("\u0441\u043E\u0437\u0434\u0430\u043D", "created")} ${path5.relative(root, configFile)}`);
1700
+ writers.out(`\u2714 ${tr("\u0441\u043E\u0437\u0434\u0430\u043D", "created")} ${path6.relative(root, configFile)}`);
1654
1701
  }
1655
1702
  await ensureGitignore(root);
1656
1703
  const adapters = options.adapters.length ? options.adapters : detectAdapters(root);
@@ -1714,13 +1761,13 @@ var SPECS = {
1714
1761
  };
1715
1762
  function detectAdapters(root) {
1716
1763
  const adapters = /* @__PURE__ */ new Set(["agents"]);
1717
- if (existsSync5(path5.join(root, ".claude")) || existsSync5(path5.join(root, "CLAUDE.md"))) adapters.add("claude");
1718
- if (existsSync5(path5.join(root, ".cursor"))) adapters.add("cursor");
1719
- if (existsSync5(path5.join(root, ".codex")) || existsSync5(path5.join(root, "AGENTS.md"))) adapters.add("codex");
1720
- if (existsSync5(path5.join(root, ".github"))) adapters.add("copilot");
1721
- if (existsSync5(path5.join(root, ".dsh")) || existsSync5(path5.join(root, "dsh.yml"))) adapters.add("dsh");
1722
- if (existsSync5(path5.join(root, ".gemini")) || existsSync5(path5.join(root, "GEMINI.md"))) adapters.add("gemini");
1723
- if (existsSync5(path5.join(root, ".opencode"))) adapters.add("opencode");
1764
+ if (existsSync5(path6.join(root, ".claude")) || existsSync5(path6.join(root, "CLAUDE.md"))) adapters.add("claude");
1765
+ if (existsSync5(path6.join(root, ".cursor"))) adapters.add("cursor");
1766
+ if (existsSync5(path6.join(root, ".codex")) || existsSync5(path6.join(root, "AGENTS.md"))) adapters.add("codex");
1767
+ if (existsSync5(path6.join(root, ".github"))) adapters.add("copilot");
1768
+ if (existsSync5(path6.join(root, ".dsh")) || existsSync5(path6.join(root, "dsh.yml"))) adapters.add("dsh");
1769
+ if (existsSync5(path6.join(root, ".gemini")) || existsSync5(path6.join(root, "GEMINI.md"))) adapters.add("gemini");
1770
+ if (existsSync5(path6.join(root, ".opencode"))) adapters.add("opencode");
1724
1771
  return [...adapters];
1725
1772
  }
1726
1773
  async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
@@ -1729,17 +1776,17 @@ async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
1729
1776
  writers.err(`! ${tr("\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439 \u0430\u0434\u0430\u043F\u0442\u0435\u0440", "unknown adapter")}: ${adapter} (${Object.keys(SPECS).join(", ")})`);
1730
1777
  return;
1731
1778
  }
1732
- if (spec.linkSkill && canonicalSkill) await linkSkill(root, canonicalSkill);
1733
- if (spec.mcp) await mergeMcpJson(path5.join(root, spec.mcp), root, mcp);
1779
+ if (spec.linkSkill && canonicalSkill) await linkSkill(root, canonicalSkill, locale2);
1780
+ if (spec.mcp) await mergeMcpJson(path6.join(root, spec.mcp), root, mcp);
1734
1781
  for (const file of spec.files ?? []) {
1735
- const target = path5.join(root, file.path);
1782
+ const target = path6.join(root, file.path);
1736
1783
  if (existsSync5(target)) {
1737
- writers.out(`! ${path5.relative(root, target)} ${tr("\u0443\u0436\u0435 \u0435\u0441\u0442\u044C: \u043D\u0435 \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0438\u0441\u044B\u0432\u0430\u044E", "already exists: not overwriting")}`);
1784
+ writers.out(`! ${path6.relative(root, target)} ${tr("\u0443\u0436\u0435 \u0435\u0441\u0442\u044C: \u043D\u0435 \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0438\u0441\u044B\u0432\u0430\u044E", "already exists: not overwriting")}`);
1738
1785
  continue;
1739
1786
  }
1740
- await mkdir2(path5.dirname(target), { recursive: true });
1787
+ await mkdir2(path6.dirname(target), { recursive: true });
1741
1788
  await writeFile(target, typeof file.content === "string" ? file.content : file.content(locale2));
1742
- writers.out(`\u2714 ${path5.relative(root, target)}`);
1789
+ writers.out(`\u2714 ${path6.relative(root, target)}`);
1743
1790
  }
1744
1791
  if (adapter === "dsh") {
1745
1792
  writers.out(` ${tr("DSH: \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0435 MCP \u0432 \u043F\u0440\u043E\u0444\u0438\u043B\u0435 (Cordis YAML):", "DSH: add the MCP server to your profile (Cordis YAML):")}`);
@@ -1756,12 +1803,12 @@ async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
1756
1803
  }
1757
1804
  }
1758
1805
  async function installSkill(root, locale2) {
1759
- const source = path5.join(packageRoot(), "skills", "revdeck", locale2);
1806
+ const source = path6.join(packageRoot(), "skills", "revdeck", locale2);
1760
1807
  if (!existsSync5(source)) {
1761
1808
  writers.err(`! ${tr("\u043A\u0430\u0442\u0430\u043B\u043E\u0433 skills/revdeck \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u043F\u0430\u043A\u0435\u0442 \u0441\u043E\u0431\u0440\u0430\u043D \u043D\u0435 \u043F\u043E\u043B\u043D\u043E\u0441\u0442\u044C\u044E", "skills/revdeck not found: the package is incomplete")}`);
1762
1809
  return null;
1763
1810
  }
1764
- const target = path5.join(root, CANONICAL_SKILL);
1811
+ const target = path6.join(root, CANONICAL_SKILL);
1765
1812
  await copySkill(source, target);
1766
1813
  writers.out(`\u2714 ${tr("\u0441\u043A\u0438\u043B\u043B", "skill")}: ${CANONICAL_SKILL}`);
1767
1814
  return target;
@@ -1769,46 +1816,56 @@ async function installSkill(root, locale2) {
1769
1816
  async function copySkill(source, target) {
1770
1817
  await mkdir2(target, { recursive: true });
1771
1818
  for (const entry of await skillFiles(source)) {
1772
- const file = path5.join(target, entry);
1773
- await mkdir2(path5.dirname(file), { recursive: true });
1774
- await cp(path5.join(source, entry), file, { force: true });
1819
+ const file = path6.join(target, entry);
1820
+ await mkdir2(path6.dirname(file), { recursive: true });
1821
+ await cp(path6.join(source, entry), file, { force: true });
1775
1822
  }
1776
1823
  }
1777
- async function linkSkill(root, canonicalSkill) {
1778
- const target = path5.join(root, ".claude", "skills", "revdeck");
1779
- const relative = path5.relative(path5.dirname(target), canonicalSkill);
1780
- await mkdir2(path5.dirname(target), { recursive: true });
1824
+ async function linkSkill(root, canonicalSkill, locale2) {
1825
+ const target = path6.join(root, ".claude", "skills", "revdeck");
1826
+ const source = path6.join(canonicalSkill, "SKILL.md");
1827
+ const skillTarget = path6.join(target, "SKILL.md");
1828
+ await mkdir2(path6.dirname(target), { recursive: true });
1781
1829
  const existing = await lstat2(target).catch(() => null);
1782
1830
  if (existing) {
1783
1831
  if (existing.isSymbolicLink()) {
1784
- const current2 = await readlink(target).catch(() => "");
1785
- if (current2 === relative) {
1786
- writers.out(`\u2714 ${tr("\u0441\u043A\u0438\u043B\u043B", "skill")}: .claude/skills/revdeck -> ${CANONICAL_SKILL}`);
1787
- return;
1788
- }
1789
1832
  await rm(target, { force: true });
1790
1833
  } else if (existing.isDirectory() && await isManagedSkillDir(target)) {
1791
1834
  await rm(target, { recursive: true, force: true });
1792
1835
  } else {
1793
- writers.out(`! .claude/skills/revdeck ${tr("\u0443\u0436\u0435 \u0435\u0441\u0442\u044C: \u043D\u0435 \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0438\u0441\u044B\u0432\u0430\u044E", "already exists: not overwriting")}`);
1836
+ writers.out(`! .claude/skills/revdeck ${tr("\u0443\u0436\u0435 \u0435\u0441\u0442\u044C \u0438 \u043D\u0435 \u043F\u043E\u0445\u043E\u0436 \u043D\u0430 revdeck: \u043D\u0435 \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0438\u0441\u044B\u0432\u0430\u044E", "already exists and does not look like revdeck: not overwriting")}`);
1794
1837
  return;
1795
1838
  }
1796
1839
  }
1840
+ await mkdir2(target, { recursive: true });
1797
1841
  if (process.platform === "win32") {
1798
- await copySkill(canonicalSkill, target);
1842
+ const shim = locale2 === "ru" ? `---
1843
+ name: revdeck
1844
+ description: "\u041A\u0430\u043D\u043E\u043D\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u0441\u043A\u0438\u043B\u043B revdeck"
1845
+ ---
1846
+
1847
+ \u042D\u0442\u043E\u0442 \u0444\u0430\u0439\u043B \u2014 shim. \u041F\u043E\u043B\u043D\u0430\u044F \u043F\u0440\u043E\u0446\u0435\u0434\u0443\u0440\u0430: \`.agents/skills/revdeck/SKILL.md\`; \u0432\u0441\u043F\u043E\u043C\u043E\u0433\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u044B \u2014 \u0432 \`.agents/skills/revdeck/\`.
1848
+ ` : `---
1849
+ name: revdeck
1850
+ description: "Canonical revdeck skill"
1851
+ ---
1852
+
1853
+ This file is a shim. The full procedure is \`.agents/skills/revdeck/SKILL.md\`; supporting files are in \`.agents/skills/revdeck/\`.
1854
+ `;
1855
+ await writeFile(skillTarget, shim);
1799
1856
  } else {
1800
- await symlink(relative, target, "dir");
1857
+ await symlink(path6.relative(target, source), skillTarget, "file");
1801
1858
  }
1802
- writers.out(`\u2714 ${tr("\u0441\u043A\u0438\u043B\u043B", "skill")}: .claude/skills/revdeck -> ${CANONICAL_SKILL}`);
1859
+ writers.out(`\u2714 ${tr("\u0441\u043A\u0438\u043B\u043B", "skill")}: .claude/skills/revdeck/SKILL.md -> ${CANONICAL_SKILL}/SKILL.md`);
1803
1860
  }
1804
1861
  async function isManagedSkillDir(dir) {
1805
- const skill = path5.join(dir, "SKILL.md");
1862
+ const skill = path6.join(dir, "SKILL.md");
1806
1863
  if (!existsSync5(skill)) return false;
1807
1864
  const text = await readFile3(skill, "utf8").catch(() => "");
1808
1865
  return /^name:\s*revdeck\s*$/m.test(text);
1809
1866
  }
1810
1867
  async function skillFiles(dir, prefix = "") {
1811
- const entries = await readdir(path5.join(dir, prefix), { withFileTypes: true });
1868
+ const entries = await readdir(path6.join(dir, prefix), { withFileTypes: true });
1812
1869
  const files = [];
1813
1870
  for (const entry of entries) {
1814
1871
  const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
@@ -1823,7 +1880,7 @@ async function mergeMcpJson(file, root, mcp) {
1823
1880
  try {
1824
1881
  data = JSON.parse(await readFile3(file, "utf8"));
1825
1882
  } catch {
1826
- writers.err(`! ${path5.relative(root, file)} ${tr("\u043F\u043E\u0432\u0440\u0435\u0436\u0434\u0451\u043D: \u043D\u0435 \u0442\u0440\u043E\u0433\u0430\u044E", "is broken: leaving it untouched")}`);
1883
+ writers.err(`! ${path6.relative(root, file)} ${tr("\u043F\u043E\u0432\u0440\u0435\u0436\u0434\u0451\u043D: \u043D\u0435 \u0442\u0440\u043E\u0433\u0430\u044E", "is broken: leaving it untouched")}`);
1827
1884
  return;
1828
1885
  }
1829
1886
  }
@@ -1832,10 +1889,10 @@ async function mergeMcpJson(file, root, mcp) {
1832
1889
  data.mcpServers = servers;
1833
1890
  await writeFile(file, `${JSON.stringify(data, null, 2)}
1834
1891
  `);
1835
- writers.out(`\u2714 MCP: ${path5.relative(root, file)}`);
1892
+ writers.out(`\u2714 MCP: ${path6.relative(root, file)}`);
1836
1893
  }
1837
1894
  async function ensureGitignore(root) {
1838
- const file = path5.join(root, ".gitignore");
1895
+ const file = path6.join(root, ".gitignore");
1839
1896
  const current2 = existsSync5(file) ? await readFile3(file, "utf8") : "";
1840
1897
  if (/(^|\n)\.revdeck\/?\s*$/m.test(current2)) return;
1841
1898
  await appendFile(file, `${current2 && !current2.endsWith("\n") ? "\n" : ""}.revdeck/
@@ -1843,17 +1900,24 @@ async function ensureGitignore(root) {
1843
1900
  writers.out(tr("\u2714 .revdeck/ \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D \u0432 .gitignore", "\u2714 .revdeck/ added to .gitignore"));
1844
1901
  }
1845
1902
  async function installService() {
1903
+ const glab = await resolveExecutable("glab");
1904
+ const gh = await resolveExecutable("gh");
1905
+ const envVars = [
1906
+ `PATH=${process.env.PATH ?? ""}`,
1907
+ ...glab ? [`REVDECK_GLAB=${glab}`] : [],
1908
+ ...gh ? [`REVDECK_GH=${gh}`] : []
1909
+ ];
1846
1910
  const root = packageRoot();
1847
- const daemon2 = path5.join(root, "dist", "daemon.js");
1911
+ const daemon2 = path6.join(root, "dist", "daemon.js");
1848
1912
  if (!existsSync5(daemon2)) throw new Error(tr("\u043D\u0435\u0442 dist/daemon.js: \u0441\u043D\u0430\u0447\u0430\u043B\u0430 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 npm run build", "dist/daemon.js is missing: run npm run build first"));
1849
- if (daemon2.includes(`${path5.sep}_npx${path5.sep}`)) {
1913
+ if (daemon2.includes(`${path6.sep}_npx${path6.sep}`)) {
1850
1914
  writers.err(tr("! \u043F\u0430\u043A\u0435\u0442 \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0447\u0435\u0440\u0435\u0437 npx: \u043F\u0443\u0442\u044C \u043A \u0434\u0435\u043C\u043E\u043D\u0443 \u043C\u043E\u0436\u0435\u0442 \u0438\u0441\u0447\u0435\u0437\u043D\u0443\u0442\u044C \u043F\u0440\u0438 \u043E\u0447\u0438\u0441\u0442\u043A\u0435 \u043A\u0435\u0448\u0430.", "! running from an npx cache: the daemon path can be evicted."));
1851
1915
  writers.err(tr(" \u0434\u043B\u044F \u0430\u0432\u0442\u043E\u0437\u0430\u043F\u0443\u0441\u043A\u0430 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435 \u0433\u043B\u043E\u0431\u0430\u043B\u044C\u043D\u043E: npm install -g revdeck", " install globally for auto-start: npm install -g revdeck"));
1852
1916
  }
1853
1917
  if (process.platform === "linux") {
1854
- const dir = path5.join(process.env.XDG_CONFIG_HOME || path5.join(process.env.HOME || "", ".config"), "systemd", "user");
1918
+ const dir = path6.join(process.env.XDG_CONFIG_HOME || path6.join(process.env.HOME || "", ".config"), "systemd", "user");
1855
1919
  await mkdir2(dir, { recursive: true });
1856
- const unit = path5.join(dir, "revdeck.service");
1920
+ const unit = path6.join(dir, "revdeck.service");
1857
1921
  await writeFile(
1858
1922
  unit,
1859
1923
  [
@@ -1863,6 +1927,7 @@ async function installService() {
1863
1927
  "",
1864
1928
  "[Service]",
1865
1929
  `ExecStart=${process.execPath} ${daemon2}`,
1930
+ ...envVars.map((item) => `Environment="${systemdEscape(item)}"`),
1866
1931
  "Restart=on-failure",
1867
1932
  "RestartSec=2",
1868
1933
  "",
@@ -1876,9 +1941,9 @@ async function installService() {
1876
1941
  return unit;
1877
1942
  }
1878
1943
  if (process.platform === "darwin") {
1879
- const dir = path5.join(process.env.HOME || "", "Library", "LaunchAgents");
1944
+ const dir = path6.join(process.env.HOME || "", "Library", "LaunchAgents");
1880
1945
  await mkdir2(dir, { recursive: true });
1881
- const file = path5.join(dir, "io.revdeck.daemon.plist");
1946
+ const file = path6.join(dir, "io.revdeck.daemon.plist");
1882
1947
  await writeFile(
1883
1948
  file,
1884
1949
  `<?xml version="1.0" encoding="UTF-8"?>
@@ -1886,6 +1951,7 @@ async function installService() {
1886
1951
  <plist version="1.0"><dict>
1887
1952
  <key>Label</key><string>io.revdeck.daemon</string>
1888
1953
  <key>ProgramArguments</key><array><string>${process.execPath}</string><string>${daemon2}</string></array>
1954
+ <key>EnvironmentVariables</key><dict>${envVars.map((item) => `<key>${xmlEscape(item.slice(0, item.indexOf("=")))}</key><string>${xmlEscape(item.slice(item.indexOf("=") + 1))}</string>`).join("")}</dict>
1889
1955
  <key>RunAtLoad</key><true/>
1890
1956
  <key>KeepAlive</key><true/>
1891
1957
  </dict></plist>
@@ -1900,12 +1966,18 @@ async function installService() {
1900
1966
  function describeError(error) {
1901
1967
  return redactLine(error instanceof Error ? error.message : error);
1902
1968
  }
1969
+ function systemdEscape(value) {
1970
+ return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/%/g, "%%");
1971
+ }
1972
+ function xmlEscape(value) {
1973
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1974
+ }
1903
1975
 
1904
1976
  // src/cli/eject.ts
1905
1977
  init_paths();
1906
1978
  import { existsSync as existsSync7 } from "node:fs";
1907
1979
  import { lstat as lstat3, readFile as readFile5, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
1908
- import path7 from "node:path";
1980
+ import path8 from "node:path";
1909
1981
 
1910
1982
  // src/core/jsonc.ts
1911
1983
  function parseJsonc(text) {
@@ -1995,7 +2067,7 @@ import { applyEdits as applyEdits2, modify as modify2 } from "jsonc-parser";
1995
2067
  init_paths();
1996
2068
  import { existsSync as existsSync6 } from "node:fs";
1997
2069
  import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
1998
- import path6 from "node:path";
2070
+ import path7 from "node:path";
1999
2071
  import { applyEdits, modify, parse as parseJsonc2 } from "jsonc-parser";
2000
2072
  init_locale();
2001
2073
  init_format();
@@ -2052,8 +2124,8 @@ function applyDevcontainerPatch(text, patch) {
2052
2124
  const mounts = Array.isArray(parsed.mounts) ? [...parsed.mounts] : [];
2053
2125
  for (const mount of patch.mounts) {
2054
2126
  const index = mounts.findIndex((item) => isRecord(item) && item.target === mount.target);
2055
- const path10 = ["mounts", index >= 0 ? index : mounts.length];
2056
- current2 = applyEdits(current2, modify(current2, path10, mount, formatting));
2127
+ const path11 = ["mounts", index >= 0 ? index : mounts.length];
2128
+ current2 = applyEdits(current2, modify(current2, path11, mount, formatting));
2057
2129
  if (index >= 0) mounts[index] = mount;
2058
2130
  else mounts.push(mount);
2059
2131
  }
@@ -2079,8 +2151,8 @@ async function runDevcontainer(rootInput, options) {
2079
2151
  const patch = devcontainerPatch();
2080
2152
  await ensureDir(devcontainerRunDir());
2081
2153
  await ensureDir(devcontainerStateDir());
2082
- const dir = path6.join(root, ".devcontainer");
2083
- const file = path6.join(dir, "devcontainer.json");
2154
+ const dir = path7.join(root, ".devcontainer");
2155
+ const file = path7.join(dir, "devcontainer.json");
2084
2156
  writers.out(tr("\u041C\u043E\u0441\u0442 revdeck \u0434\u043B\u044F \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0430:", "revdeck bridge for the container:"));
2085
2157
  writers.out(` ${tr("\u0441\u043E\u043A\u0435\u0442", "socket")}: ${devcontainerRunDir()} -> ${CONTAINER_RUNTIME_DIR}`);
2086
2158
  writers.out(` ${tr("\u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435", "state")}: ${devcontainerStateDir()} -> ${CONTAINER_STATE_DIR} (${tr("\u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0442\u0435\u043D\u0438\u0435", "read-only")})`);
@@ -2111,8 +2183,8 @@ async function runDevcontainer(rootInput, options) {
2111
2183
  } catch (error) {
2112
2184
  throw new Error(
2113
2185
  tr(
2114
- `${path6.relative(root, file)}: \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C JSONC (${error.message}); \u0434\u043E\u0431\u0430\u0432\u044C\u0442\u0435 mounts \u0432\u0440\u0443\u0447\u043D\u0443\u044E`,
2115
- `${path6.relative(root, file)}: could not parse JSONC (${error.message}); add the mounts manually`
2186
+ `${path7.relative(root, file)}: \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C JSONC (${error.message}); \u0434\u043E\u0431\u0430\u0432\u044C\u0442\u0435 mounts \u0432\u0440\u0443\u0447\u043D\u0443\u044E`,
2187
+ `${path7.relative(root, file)}: could not parse JSONC (${error.message}); add the mounts manually`
2116
2188
  )
2117
2189
  );
2118
2190
  }
@@ -2122,7 +2194,7 @@ async function runDevcontainer(rootInput, options) {
2122
2194
  `;
2123
2195
  }
2124
2196
  await writeFile2(file, output);
2125
- writers.out(`\u2714 ${path6.relative(root, file)}`);
2197
+ writers.out(`\u2714 ${path7.relative(root, file)}`);
2126
2198
  if (existed) writers.out(tr(" \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438 \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u044B.", " comments were preserved."));
2127
2199
  writers.out("");
2128
2200
  writers.out(tr("\u0414\u0430\u043B\u044C\u0448\u0435:", "Next:"));
@@ -2152,12 +2224,12 @@ async function runEject(rootInput, options) {
2152
2224
  const warnings = [];
2153
2225
  if (!options.keepConfig) {
2154
2226
  for (const name of CONFIG_FILES2) {
2155
- const file = path7.join(root, name);
2227
+ const file = path8.join(root, name);
2156
2228
  if (existsSync7(file)) changes.push({ path: name, action: tr("\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043A\u043E\u043D\u0444\u0438\u0433", "remove config"), remove: () => rm2(file, { force: true }) });
2157
2229
  }
2158
2230
  }
2159
2231
  for (const name of SKILL_DIRS) {
2160
- const target = path7.join(root, name);
2232
+ const target = path8.join(root, name);
2161
2233
  if (!existsSync7(target)) continue;
2162
2234
  const managed = await isManagedSkill(target);
2163
2235
  if (!managed) {
@@ -2167,7 +2239,7 @@ async function runEject(rootInput, options) {
2167
2239
  changes.push({ path: name, action: tr("\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u043A\u0438\u043B\u043B", "remove skill"), remove: () => rm2(target, { recursive: true, force: true }) });
2168
2240
  }
2169
2241
  for (const name of COMMAND_FILES) {
2170
- const file = path7.join(root, name);
2242
+ const file = path8.join(root, name);
2171
2243
  if (!existsSync7(file)) continue;
2172
2244
  const text = await readFile5(file, "utf8").catch(() => "");
2173
2245
  if (!/revdeck/i.test(text)) {
@@ -2177,7 +2249,7 @@ async function runEject(rootInput, options) {
2177
2249
  changes.push({ path: name, action: tr("\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043A\u043E\u043C\u0430\u043D\u0434\u0443", "remove command"), remove: () => rm2(file, { force: true }) });
2178
2250
  }
2179
2251
  for (const name of MCP_FILES) {
2180
- const file = path7.join(root, name);
2252
+ const file = path8.join(root, name);
2181
2253
  if (!existsSync7(file)) continue;
2182
2254
  const text = await readFile5(file, "utf8").catch(() => "");
2183
2255
  let data;
@@ -2199,7 +2271,7 @@ async function runEject(rootInput, options) {
2199
2271
  }
2200
2272
  });
2201
2273
  }
2202
- const devcontainer = path7.join(root, ".devcontainer", "devcontainer.json");
2274
+ const devcontainer = path8.join(root, ".devcontainer", "devcontainer.json");
2203
2275
  if (existsSync7(devcontainer)) {
2204
2276
  const text = await readFile5(devcontainer, "utf8");
2205
2277
  try {
@@ -2245,11 +2317,11 @@ async function runEject(rootInput, options) {
2245
2317
  warnings.push(`.devcontainer/devcontainer.json: ${tr("\u043D\u0435 JSONC \u2014 \u043D\u0435 \u0442\u0440\u043E\u0433\u0430\u044E", "not JSONC \u2014 leaving it untouched")}`);
2246
2318
  }
2247
2319
  }
2248
- const cache = path7.join(root, ".revdeck");
2320
+ const cache = path8.join(root, ".revdeck");
2249
2321
  if (existsSync7(cache)) {
2250
2322
  changes.push({ path: ".revdeck/", action: tr("\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u043A\u0435\u0448", "remove local cache"), remove: () => rm2(cache, { recursive: true, force: true }) });
2251
2323
  }
2252
- const gitignore = path7.join(root, ".gitignore");
2324
+ const gitignore = path8.join(root, ".gitignore");
2253
2325
  if (existsSync7(gitignore)) {
2254
2326
  const text = await readFile5(gitignore, "utf8");
2255
2327
  if (/(^|\n)\.revdeck\/?\s*(\n|$)/.test(text)) {
@@ -2287,7 +2359,7 @@ async function isManagedSkill(target) {
2287
2359
  const info = await lstat3(target);
2288
2360
  if (info.isSymbolicLink()) return true;
2289
2361
  if (!info.isDirectory()) return false;
2290
- const skill = path7.join(target, "SKILL.md");
2362
+ const skill = path8.join(target, "SKILL.md");
2291
2363
  if (!existsSync7(skill)) return false;
2292
2364
  const text = await readFile5(skill, "utf8");
2293
2365
  return /^name:\s*revdeck\s*$/m.test(text) || /revdeck/i.test(text.slice(0, 2e3));
@@ -2301,7 +2373,7 @@ init_client();
2301
2373
  init_format();
2302
2374
  init_locale();
2303
2375
  import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile4 } from "node:fs/promises";
2304
- import path8 from "node:path";
2376
+ import path9 from "node:path";
2305
2377
  async function reviewFor(client2, root, arg) {
2306
2378
  if (arg && /^(gitlab|github):/.test(arg)) {
2307
2379
  const { review } = await client2.request("reviews.get", { review: arg });
@@ -2357,12 +2429,12 @@ async function exportReview(root, arg, dir) {
2357
2429
  const { client: client2 } = await ensureDaemon();
2358
2430
  try {
2359
2431
  const review = await reviewFor(client2, root, arg);
2360
- const target = path8.resolve(root, dir);
2432
+ const target = path9.resolve(root, dir);
2361
2433
  await mkdir4(target, { recursive: true });
2362
2434
  const base = `mr-${review.info.ref.number}`;
2363
2435
  const files = [];
2364
2436
  const write = async (name, data) => {
2365
- const file = path8.join(target, name);
2437
+ const file = path9.join(target, name);
2366
2438
  await writeFile4(file, `${JSON.stringify(data, null, 2)}
2367
2439
  `, { mode: 420 });
2368
2440
  files.push(name);
@@ -2428,9 +2500,9 @@ async function exportReview(root, arg, dir) {
2428
2500
  }
2429
2501
  }
2430
2502
  await write(`${base}-published.json`, published);
2431
- await writeFile4(path8.join(target, `${base}.diff`), await serializeDiff(client2, review), { mode: 420 });
2503
+ await writeFile4(path9.join(target, `${base}.diff`), await serializeDiff(client2, review), { mode: 420 });
2432
2504
  files.push(`${base}.diff`);
2433
- writers.out(`${tr("\u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043E \u0432", "exported to")} ${path8.relative(root, target)}: ${files.join(", ")}`);
2505
+ writers.out(`${tr("\u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043E \u0432", "exported to")} ${path9.relative(root, target)}: ${files.join(", ")}`);
2434
2506
  } finally {
2435
2507
  client2.close();
2436
2508
  }
@@ -2439,11 +2511,11 @@ async function importReview(root, arg, dir) {
2439
2511
  const { client: client2 } = await ensureDaemon();
2440
2512
  try {
2441
2513
  const review = await reviewFor(client2, root, arg);
2442
- const target = path8.resolve(root, dir);
2514
+ const target = path9.resolve(root, dir);
2443
2515
  const base = `mr-${review.info.ref.number}`;
2444
2516
  const read = async (name) => {
2445
2517
  try {
2446
- return JSON.parse(await readFile6(path8.join(target, name), "utf8"));
2518
+ return JSON.parse(await readFile6(path9.join(target, name), "utf8"));
2447
2519
  } catch {
2448
2520
  return null;
2449
2521
  }
@@ -3086,7 +3158,7 @@ async function react(arg, values) {
3086
3158
  }
3087
3159
  async function attach(arg, values) {
3088
3160
  if (!values.file) fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 --file \u0441 \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u043E\u0439 \u0438\u043B\u0438 \u0432\u0438\u0434\u0435\u043E", "pass --file with an image or video"));
3089
- const name = path9.basename(String(values.file));
3161
+ const name = path10.basename(String(values.file));
3090
3162
  const spec = attachmentSpec(name);
3091
3163
  if (!spec) fail(tr("\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B PNG, JPEG, GIF, WebP, AVIF, MP4, WebM, OGV \u0438 MOV", "PNG, JPEG, GIF, WebP, AVIF, MP4, WebM, OGV and MOV are allowed"));
3092
3164
  const file = String(values.file);
@@ -3237,13 +3309,21 @@ async function doctor(root) {
3237
3309
  }
3238
3310
  const binaries = {};
3239
3311
  for (const bin of ["glab", "gh", "git"]) {
3240
- const present = await which(bin);
3312
+ const resolved = await resolveExecutable(bin);
3313
+ const present = resolved !== null;
3241
3314
  binaries[bin] = present;
3242
3315
  if (container && (bin === "glab" || bin === "gh")) {
3243
3316
  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")]);
3244
3317
  continue;
3245
3318
  }
3246
- rows.push([bin, present ? "ok" : "warn", present ? tr("\u043D\u0430\u0439\u0434\u0435\u043D", "found") : tr("\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D", "not found")]);
3319
+ rows.push([
3320
+ bin,
3321
+ present ? "ok" : "warn",
3322
+ present ? resolved : tr(
3323
+ `\u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435 ${bin} \u0438\u043B\u0438 \u0434\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u0435\u0433\u043E \u0432 PATH (REVDECK_${bin.toUpperCase()})`,
3324
+ `not found: install ${bin} or add it to PATH (REVDECK_${bin.toUpperCase()})`
3325
+ )
3326
+ ]);
3247
3327
  }
3248
3328
  let host;
3249
3329
  try {
@@ -3281,8 +3361,22 @@ async function doctor(root) {
3281
3361
  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)")
3282
3362
  ]);
3283
3363
  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")]);
3364
+ if (running) {
3365
+ const seen = await daemonBinaries();
3366
+ for (const bin of ["glab", "gh"]) {
3367
+ if (!seen) {
3368
+ 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")]);
3369
+ continue;
3370
+ }
3371
+ rows.push([
3372
+ `daemon ${bin}`,
3373
+ seen[bin] ? "ok" : "fail",
3374
+ 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")
3375
+ ]);
3376
+ }
3377
+ }
3284
3378
  const { existsSync: existsSync8 } = await import("node:fs");
3285
- const skill = existsSync8(path9.join(root, ".agents", "skills", "revdeck", "SKILL.md")) || existsSync8(path9.join(root, ".claude", "skills", "revdeck", "SKILL.md")) || existsSync8(path9.join(root, ".cursor", "commands", "revdeck.md"));
3379
+ const skill = existsSync8(path10.join(root, ".agents", "skills", "revdeck", "SKILL.md")) || existsSync8(path10.join(root, ".claude", "skills", "revdeck", "SKILL.md")) || existsSync8(path10.join(root, ".cursor", "commands", "revdeck.md"));
3286
3380
  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")]);
3287
3381
  for (const [name, status2, detail] of rows) {
3288
3382
  writers.out(`${status2 === "ok" ? "\u2714" : status2 === "warn" ? "!" : "\u2716"} ${name.padEnd(10)} ${detail}`);