revdeck 0.3.1 → 0.3.2

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.2";
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();
@@ -1608,7 +1655,7 @@ init_format();
1608
1655
  init_paths();
1609
1656
  import { existsSync as existsSync5 } from "node:fs";
1610
1657
  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";
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) {
@@ -1730,16 +1777,16 @@ async function installAdapter(root, adapter, mcp, locale2, canonicalSkill) {
1730
1777
  return;
1731
1778
  }
1732
1779
  if (spec.linkSkill && canonicalSkill) await linkSkill(root, canonicalSkill);
1733
- if (spec.mcp) await mergeMcpJson(path5.join(root, spec.mcp), root, mcp);
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,15 +1816,15 @@ 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
1824
  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 });
1825
+ const target = path6.join(root, ".claude", "skills", "revdeck");
1826
+ const relative = path6.relative(path6.dirname(target), canonicalSkill);
1827
+ await mkdir2(path6.dirname(target), { recursive: true });
1781
1828
  const existing = await lstat2(target).catch(() => null);
1782
1829
  if (existing) {
1783
1830
  if (existing.isSymbolicLink()) {
@@ -1802,13 +1849,13 @@ async function linkSkill(root, canonicalSkill) {
1802
1849
  writers.out(`\u2714 ${tr("\u0441\u043A\u0438\u043B\u043B", "skill")}: .claude/skills/revdeck -> ${CANONICAL_SKILL}`);
1803
1850
  }
1804
1851
  async function isManagedSkillDir(dir) {
1805
- const skill = path5.join(dir, "SKILL.md");
1852
+ const skill = path6.join(dir, "SKILL.md");
1806
1853
  if (!existsSync5(skill)) return false;
1807
1854
  const text = await readFile3(skill, "utf8").catch(() => "");
1808
1855
  return /^name:\s*revdeck\s*$/m.test(text);
1809
1856
  }
1810
1857
  async function skillFiles(dir, prefix = "") {
1811
- const entries = await readdir(path5.join(dir, prefix), { withFileTypes: true });
1858
+ const entries = await readdir(path6.join(dir, prefix), { withFileTypes: true });
1812
1859
  const files = [];
1813
1860
  for (const entry of entries) {
1814
1861
  const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
@@ -1823,7 +1870,7 @@ async function mergeMcpJson(file, root, mcp) {
1823
1870
  try {
1824
1871
  data = JSON.parse(await readFile3(file, "utf8"));
1825
1872
  } 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")}`);
1873
+ 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
1874
  return;
1828
1875
  }
1829
1876
  }
@@ -1832,10 +1879,10 @@ async function mergeMcpJson(file, root, mcp) {
1832
1879
  data.mcpServers = servers;
1833
1880
  await writeFile(file, `${JSON.stringify(data, null, 2)}
1834
1881
  `);
1835
- writers.out(`\u2714 MCP: ${path5.relative(root, file)}`);
1882
+ writers.out(`\u2714 MCP: ${path6.relative(root, file)}`);
1836
1883
  }
1837
1884
  async function ensureGitignore(root) {
1838
- const file = path5.join(root, ".gitignore");
1885
+ const file = path6.join(root, ".gitignore");
1839
1886
  const current2 = existsSync5(file) ? await readFile3(file, "utf8") : "";
1840
1887
  if (/(^|\n)\.revdeck\/?\s*$/m.test(current2)) return;
1841
1888
  await appendFile(file, `${current2 && !current2.endsWith("\n") ? "\n" : ""}.revdeck/
@@ -1843,17 +1890,24 @@ async function ensureGitignore(root) {
1843
1890
  writers.out(tr("\u2714 .revdeck/ \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D \u0432 .gitignore", "\u2714 .revdeck/ added to .gitignore"));
1844
1891
  }
1845
1892
  async function installService() {
1893
+ const glab = await resolveExecutable("glab");
1894
+ const gh = await resolveExecutable("gh");
1895
+ const envVars = [
1896
+ `PATH=${process.env.PATH ?? ""}`,
1897
+ ...glab ? [`REVDECK_GLAB=${glab}`] : [],
1898
+ ...gh ? [`REVDECK_GH=${gh}`] : []
1899
+ ];
1846
1900
  const root = packageRoot();
1847
- const daemon2 = path5.join(root, "dist", "daemon.js");
1901
+ const daemon2 = path6.join(root, "dist", "daemon.js");
1848
1902
  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}`)) {
1903
+ if (daemon2.includes(`${path6.sep}_npx${path6.sep}`)) {
1850
1904
  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
1905
  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
1906
  }
1853
1907
  if (process.platform === "linux") {
1854
- const dir = path5.join(process.env.XDG_CONFIG_HOME || path5.join(process.env.HOME || "", ".config"), "systemd", "user");
1908
+ const dir = path6.join(process.env.XDG_CONFIG_HOME || path6.join(process.env.HOME || "", ".config"), "systemd", "user");
1855
1909
  await mkdir2(dir, { recursive: true });
1856
- const unit = path5.join(dir, "revdeck.service");
1910
+ const unit = path6.join(dir, "revdeck.service");
1857
1911
  await writeFile(
1858
1912
  unit,
1859
1913
  [
@@ -1863,6 +1917,7 @@ async function installService() {
1863
1917
  "",
1864
1918
  "[Service]",
1865
1919
  `ExecStart=${process.execPath} ${daemon2}`,
1920
+ ...envVars.map((item) => `Environment="${systemdEscape(item)}"`),
1866
1921
  "Restart=on-failure",
1867
1922
  "RestartSec=2",
1868
1923
  "",
@@ -1876,9 +1931,9 @@ async function installService() {
1876
1931
  return unit;
1877
1932
  }
1878
1933
  if (process.platform === "darwin") {
1879
- const dir = path5.join(process.env.HOME || "", "Library", "LaunchAgents");
1934
+ const dir = path6.join(process.env.HOME || "", "Library", "LaunchAgents");
1880
1935
  await mkdir2(dir, { recursive: true });
1881
- const file = path5.join(dir, "io.revdeck.daemon.plist");
1936
+ const file = path6.join(dir, "io.revdeck.daemon.plist");
1882
1937
  await writeFile(
1883
1938
  file,
1884
1939
  `<?xml version="1.0" encoding="UTF-8"?>
@@ -1886,6 +1941,7 @@ async function installService() {
1886
1941
  <plist version="1.0"><dict>
1887
1942
  <key>Label</key><string>io.revdeck.daemon</string>
1888
1943
  <key>ProgramArguments</key><array><string>${process.execPath}</string><string>${daemon2}</string></array>
1944
+ <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
1945
  <key>RunAtLoad</key><true/>
1890
1946
  <key>KeepAlive</key><true/>
1891
1947
  </dict></plist>
@@ -1900,12 +1956,18 @@ async function installService() {
1900
1956
  function describeError(error) {
1901
1957
  return redactLine(error instanceof Error ? error.message : error);
1902
1958
  }
1959
+ function systemdEscape(value) {
1960
+ return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/%/g, "%%");
1961
+ }
1962
+ function xmlEscape(value) {
1963
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1964
+ }
1903
1965
 
1904
1966
  // src/cli/eject.ts
1905
1967
  init_paths();
1906
1968
  import { existsSync as existsSync7 } from "node:fs";
1907
1969
  import { lstat as lstat3, readFile as readFile5, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
1908
- import path7 from "node:path";
1970
+ import path8 from "node:path";
1909
1971
 
1910
1972
  // src/core/jsonc.ts
1911
1973
  function parseJsonc(text) {
@@ -1995,7 +2057,7 @@ import { applyEdits as applyEdits2, modify as modify2 } from "jsonc-parser";
1995
2057
  init_paths();
1996
2058
  import { existsSync as existsSync6 } from "node:fs";
1997
2059
  import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
1998
- import path6 from "node:path";
2060
+ import path7 from "node:path";
1999
2061
  import { applyEdits, modify, parse as parseJsonc2 } from "jsonc-parser";
2000
2062
  init_locale();
2001
2063
  init_format();
@@ -2052,8 +2114,8 @@ function applyDevcontainerPatch(text, patch) {
2052
2114
  const mounts = Array.isArray(parsed.mounts) ? [...parsed.mounts] : [];
2053
2115
  for (const mount of patch.mounts) {
2054
2116
  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));
2117
+ const path11 = ["mounts", index >= 0 ? index : mounts.length];
2118
+ current2 = applyEdits(current2, modify(current2, path11, mount, formatting));
2057
2119
  if (index >= 0) mounts[index] = mount;
2058
2120
  else mounts.push(mount);
2059
2121
  }
@@ -2079,8 +2141,8 @@ async function runDevcontainer(rootInput, options) {
2079
2141
  const patch = devcontainerPatch();
2080
2142
  await ensureDir(devcontainerRunDir());
2081
2143
  await ensureDir(devcontainerStateDir());
2082
- const dir = path6.join(root, ".devcontainer");
2083
- const file = path6.join(dir, "devcontainer.json");
2144
+ const dir = path7.join(root, ".devcontainer");
2145
+ const file = path7.join(dir, "devcontainer.json");
2084
2146
  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
2147
  writers.out(` ${tr("\u0441\u043E\u043A\u0435\u0442", "socket")}: ${devcontainerRunDir()} -> ${CONTAINER_RUNTIME_DIR}`);
2086
2148
  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 +2173,8 @@ async function runDevcontainer(rootInput, options) {
2111
2173
  } catch (error) {
2112
2174
  throw new Error(
2113
2175
  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`
2176
+ `${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`,
2177
+ `${path7.relative(root, file)}: could not parse JSONC (${error.message}); add the mounts manually`
2116
2178
  )
2117
2179
  );
2118
2180
  }
@@ -2122,7 +2184,7 @@ async function runDevcontainer(rootInput, options) {
2122
2184
  `;
2123
2185
  }
2124
2186
  await writeFile2(file, output);
2125
- writers.out(`\u2714 ${path6.relative(root, file)}`);
2187
+ writers.out(`\u2714 ${path7.relative(root, file)}`);
2126
2188
  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
2189
  writers.out("");
2128
2190
  writers.out(tr("\u0414\u0430\u043B\u044C\u0448\u0435:", "Next:"));
@@ -2152,12 +2214,12 @@ async function runEject(rootInput, options) {
2152
2214
  const warnings = [];
2153
2215
  if (!options.keepConfig) {
2154
2216
  for (const name of CONFIG_FILES2) {
2155
- const file = path7.join(root, name);
2217
+ const file = path8.join(root, name);
2156
2218
  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
2219
  }
2158
2220
  }
2159
2221
  for (const name of SKILL_DIRS) {
2160
- const target = path7.join(root, name);
2222
+ const target = path8.join(root, name);
2161
2223
  if (!existsSync7(target)) continue;
2162
2224
  const managed = await isManagedSkill(target);
2163
2225
  if (!managed) {
@@ -2167,7 +2229,7 @@ async function runEject(rootInput, options) {
2167
2229
  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
2230
  }
2169
2231
  for (const name of COMMAND_FILES) {
2170
- const file = path7.join(root, name);
2232
+ const file = path8.join(root, name);
2171
2233
  if (!existsSync7(file)) continue;
2172
2234
  const text = await readFile5(file, "utf8").catch(() => "");
2173
2235
  if (!/revdeck/i.test(text)) {
@@ -2177,7 +2239,7 @@ async function runEject(rootInput, options) {
2177
2239
  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
2240
  }
2179
2241
  for (const name of MCP_FILES) {
2180
- const file = path7.join(root, name);
2242
+ const file = path8.join(root, name);
2181
2243
  if (!existsSync7(file)) continue;
2182
2244
  const text = await readFile5(file, "utf8").catch(() => "");
2183
2245
  let data;
@@ -2199,7 +2261,7 @@ async function runEject(rootInput, options) {
2199
2261
  }
2200
2262
  });
2201
2263
  }
2202
- const devcontainer = path7.join(root, ".devcontainer", "devcontainer.json");
2264
+ const devcontainer = path8.join(root, ".devcontainer", "devcontainer.json");
2203
2265
  if (existsSync7(devcontainer)) {
2204
2266
  const text = await readFile5(devcontainer, "utf8");
2205
2267
  try {
@@ -2245,11 +2307,11 @@ async function runEject(rootInput, options) {
2245
2307
  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
2308
  }
2247
2309
  }
2248
- const cache = path7.join(root, ".revdeck");
2310
+ const cache = path8.join(root, ".revdeck");
2249
2311
  if (existsSync7(cache)) {
2250
2312
  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
2313
  }
2252
- const gitignore = path7.join(root, ".gitignore");
2314
+ const gitignore = path8.join(root, ".gitignore");
2253
2315
  if (existsSync7(gitignore)) {
2254
2316
  const text = await readFile5(gitignore, "utf8");
2255
2317
  if (/(^|\n)\.revdeck\/?\s*(\n|$)/.test(text)) {
@@ -2287,7 +2349,7 @@ async function isManagedSkill(target) {
2287
2349
  const info = await lstat3(target);
2288
2350
  if (info.isSymbolicLink()) return true;
2289
2351
  if (!info.isDirectory()) return false;
2290
- const skill = path7.join(target, "SKILL.md");
2352
+ const skill = path8.join(target, "SKILL.md");
2291
2353
  if (!existsSync7(skill)) return false;
2292
2354
  const text = await readFile5(skill, "utf8");
2293
2355
  return /^name:\s*revdeck\s*$/m.test(text) || /revdeck/i.test(text.slice(0, 2e3));
@@ -2301,7 +2363,7 @@ init_client();
2301
2363
  init_format();
2302
2364
  init_locale();
2303
2365
  import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile4 } from "node:fs/promises";
2304
- import path8 from "node:path";
2366
+ import path9 from "node:path";
2305
2367
  async function reviewFor(client2, root, arg) {
2306
2368
  if (arg && /^(gitlab|github):/.test(arg)) {
2307
2369
  const { review } = await client2.request("reviews.get", { review: arg });
@@ -2357,12 +2419,12 @@ async function exportReview(root, arg, dir) {
2357
2419
  const { client: client2 } = await ensureDaemon();
2358
2420
  try {
2359
2421
  const review = await reviewFor(client2, root, arg);
2360
- const target = path8.resolve(root, dir);
2422
+ const target = path9.resolve(root, dir);
2361
2423
  await mkdir4(target, { recursive: true });
2362
2424
  const base = `mr-${review.info.ref.number}`;
2363
2425
  const files = [];
2364
2426
  const write = async (name, data) => {
2365
- const file = path8.join(target, name);
2427
+ const file = path9.join(target, name);
2366
2428
  await writeFile4(file, `${JSON.stringify(data, null, 2)}
2367
2429
  `, { mode: 420 });
2368
2430
  files.push(name);
@@ -2428,9 +2490,9 @@ async function exportReview(root, arg, dir) {
2428
2490
  }
2429
2491
  }
2430
2492
  await write(`${base}-published.json`, published);
2431
- await writeFile4(path8.join(target, `${base}.diff`), await serializeDiff(client2, review), { mode: 420 });
2493
+ await writeFile4(path9.join(target, `${base}.diff`), await serializeDiff(client2, review), { mode: 420 });
2432
2494
  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(", ")}`);
2495
+ 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
2496
  } finally {
2435
2497
  client2.close();
2436
2498
  }
@@ -2439,11 +2501,11 @@ async function importReview(root, arg, dir) {
2439
2501
  const { client: client2 } = await ensureDaemon();
2440
2502
  try {
2441
2503
  const review = await reviewFor(client2, root, arg);
2442
- const target = path8.resolve(root, dir);
2504
+ const target = path9.resolve(root, dir);
2443
2505
  const base = `mr-${review.info.ref.number}`;
2444
2506
  const read = async (name) => {
2445
2507
  try {
2446
- return JSON.parse(await readFile6(path8.join(target, name), "utf8"));
2508
+ return JSON.parse(await readFile6(path9.join(target, name), "utf8"));
2447
2509
  } catch {
2448
2510
  return null;
2449
2511
  }
@@ -3086,7 +3148,7 @@ async function react(arg, values) {
3086
3148
  }
3087
3149
  async function attach(arg, values) {
3088
3150
  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));
3151
+ const name = path10.basename(String(values.file));
3090
3152
  const spec = attachmentSpec(name);
3091
3153
  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
3154
  const file = String(values.file);
@@ -3237,13 +3299,21 @@ async function doctor(root) {
3237
3299
  }
3238
3300
  const binaries = {};
3239
3301
  for (const bin of ["glab", "gh", "git"]) {
3240
- const present = await which(bin);
3302
+ const resolved = await resolveExecutable(bin);
3303
+ const present = resolved !== null;
3241
3304
  binaries[bin] = present;
3242
3305
  if (container && (bin === "glab" || bin === "gh")) {
3243
3306
  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
3307
  continue;
3245
3308
  }
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")]);
3309
+ rows.push([
3310
+ bin,
3311
+ present ? "ok" : "warn",
3312
+ present ? resolved : tr(
3313
+ `\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()})`,
3314
+ `not found: install ${bin} or add it to PATH (REVDECK_${bin.toUpperCase()})`
3315
+ )
3316
+ ]);
3247
3317
  }
3248
3318
  let host;
3249
3319
  try {
@@ -3281,8 +3351,22 @@ async function doctor(root) {
3281
3351
  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
3352
  ]);
3283
3353
  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")]);
3354
+ if (running) {
3355
+ const seen = await daemonBinaries();
3356
+ for (const bin of ["glab", "gh"]) {
3357
+ if (!seen) {
3358
+ 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")]);
3359
+ continue;
3360
+ }
3361
+ rows.push([
3362
+ `daemon ${bin}`,
3363
+ seen[bin] ? "ok" : "fail",
3364
+ 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")
3365
+ ]);
3366
+ }
3367
+ }
3284
3368
  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"));
3369
+ 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
3370
  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
3371
  for (const [name, status2, detail] of rows) {
3288
3372
  writers.out(`${status2 === "ok" ? "\u2714" : status2 === "warn" ? "!" : "\u2716"} ${name.padEnd(10)} ${detail}`);