@moberg_hr/work-tree 2.22.4 → 2.22.5

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.
@@ -624,7 +624,7 @@ import "./chunk-FGBLFF4O.js";
624
624
  import "./chunk-ED6YLB4S.js";
625
625
  import {
626
626
  VERSION
627
- } from "./chunk-TDJVYUF2.js";
627
+ } from "./chunk-EXZ4A6VJ.js";
628
628
  import {
629
629
  resolveProjectTarget
630
630
  } from "./chunk-IPHADNF5.js";
@@ -738,7 +738,7 @@ function createStartupQuestions(deps) {
738
738
  }
739
739
 
740
740
  // src/server/web-server.ts
741
- import fs19 from "fs";
741
+ import fs20 from "fs";
742
742
 
743
743
  // src/core/conversations/last-reply.ts
744
744
  function lastReplyOf(entries) {
@@ -1809,29 +1809,79 @@ function mountSessionReviewRoutes(app, deps) {
1809
1809
  }
1810
1810
 
1811
1811
  // src/server/routes/session-show-routes.ts
1812
- import path5 from "path";
1812
+ import path6 from "path";
1813
1813
 
1814
1814
  // src/core/sessions/shown-file.ts
1815
- import fs5 from "fs";
1816
- import path4 from "path";
1815
+ import fs6 from "fs";
1816
+ import path5 from "path";
1817
1817
 
1818
1818
  // src/core/worktree/terminal-paths.ts
1819
- import fs4 from "fs";
1819
+ import fs5 from "fs";
1820
1820
  import os from "os";
1821
- import path3 from "path";
1821
+ import path4 from "path";
1822
1822
 
1823
- // src/core/worktree/code-browse.ts
1823
+ // src/core/platform/network-mounts.ts
1824
1824
  import fs3 from "fs";
1825
1825
  import path2 from "path";
1826
+ var NETWORK_TYPES = /^(?:nfs\d?|smbfs|afpfs|webdav|cifs|smb3?|autofs|sshfs|fuse\.sshfs|9p|davfs)$/i;
1827
+ var DARWIN_AUTOMOUNTS = ["/home", "/net", "/Network"];
1828
+ var KEEP_MS = 6e4;
1829
+ function parseNetworkMounts(text, platform) {
1830
+ const roots = [];
1831
+ for (const line of text.split(/\r?\n/)) {
1832
+ if (platform === "darwin") {
1833
+ const m = / on (\/.*?) \(([^,)]+)/.exec(line);
1834
+ if (m && NETWORK_TYPES.test(m[2].trim())) roots.push(m[1]);
1835
+ } else {
1836
+ const [, where, type] = line.split(" ");
1837
+ if (where && type && NETWORK_TYPES.test(type)) roots.push(where.replace(/\\040/g, " "));
1838
+ }
1839
+ }
1840
+ return roots;
1841
+ }
1842
+ function readMountTable(platform) {
1843
+ if (platform === "linux") return fs3.readFileSync("/proc/mounts", "utf-8");
1844
+ if (platform !== "darwin") return "";
1845
+ const r = spawn_default.sync("/sbin/mount", [], { encoding: "utf-8", timeout: 2e3, windowsHide: true });
1846
+ return typeof r.stdout === "string" ? r.stdout : "";
1847
+ }
1848
+ var cached = null;
1849
+ function networkMountRoots(platform = process.platform, now = Date.now()) {
1850
+ if (cached && now - cached.at < KEEP_MS) return cached.roots;
1851
+ let mounts = [];
1852
+ try {
1853
+ mounts = parseNetworkMounts(readMountTable(platform), platform);
1854
+ } catch {
1855
+ }
1856
+ const roots = [...platform === "darwin" ? DARWIN_AUTOMOUNTS : [], ...mounts];
1857
+ cached = { at: now, roots };
1858
+ return roots;
1859
+ }
1860
+ function onNetworkVolume(p, roots, platform = process.platform) {
1861
+ const win = platform === "win32";
1862
+ const norm4 = (s) => {
1863
+ const n = win ? path2.win32.normalize(s).replace(/\\/g, "/") : path2.posix.normalize(s);
1864
+ return win || platform === "darwin" ? n.toLowerCase() : n;
1865
+ };
1866
+ const at = norm4(p);
1867
+ return roots.some((root) => {
1868
+ const r = norm4(root).replace(/\/+$/, "");
1869
+ return r !== "" && (at === r || at.startsWith(r + "/"));
1870
+ });
1871
+ }
1872
+
1873
+ // src/core/worktree/code-browse.ts
1874
+ import fs4 from "fs";
1875
+ import path3 from "path";
1826
1876
  var MAX_CODE_FILES = 5e4;
1827
1877
  var MAX_CODE_FILE_BYTES = 2 * 1024 * 1024;
1828
1878
  var LIST_TTL_MS = 3e3;
1829
1879
  function codeRoots(s) {
1830
- return s.paths.map((p) => ({ name: path2.basename(p), root: p }));
1880
+ return s.paths.map((p) => ({ name: path3.basename(p), root: p }));
1831
1881
  }
1832
1882
  function groupRoot(s) {
1833
1883
  if (!s.isGroup || s.paths.length === 0) return null;
1834
- const parents = [...new Set(s.paths.map((p) => path2.dirname(p)))];
1884
+ const parents = [...new Set(s.paths.map((p) => path3.dirname(p)))];
1835
1885
  return parents.length === 1 ? parents[0] : null;
1836
1886
  }
1837
1887
  var realIo = {
@@ -1904,7 +1954,7 @@ async function changedFiles(root, base, io = realIo) {
1904
1954
  async function listCodeFiles(s, io = realIo) {
1905
1955
  const repos = await Promise.all(
1906
1956
  codeRoots(s).map(async ({ name, root }) => {
1907
- if (!fs3.existsSync(root)) return { name, files: [], changed: [], truncated: false };
1957
+ if (!fs4.existsSync(root)) return { name, files: [], changed: [], truncated: false };
1908
1958
  const [all, changed] = await Promise.all([listRepoFiles(root, io), changedFiles(root, s.baseBranches?.[root] ?? s.baseBranch, io)]);
1909
1959
  const listed = new Set(all);
1910
1960
  return {
@@ -1921,7 +1971,7 @@ function groupRootFiles(s) {
1921
1971
  const dir = groupRoot(s);
1922
1972
  if (!dir) return [];
1923
1973
  try {
1924
- return fs3.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && isGroupNote(e.name)).map((e) => e.name).sort();
1974
+ return fs4.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && isGroupNote(e.name)).map((e) => e.name).sort();
1925
1975
  } catch {
1926
1976
  return [];
1927
1977
  }
@@ -1940,12 +1990,12 @@ async function codeFilePath(s, repo, rel, io = realIo) {
1940
1990
  if (!root) return { error: "unknown repo" };
1941
1991
  if (!allowed) return { error: "not listed" };
1942
1992
  try {
1943
- const full = path2.resolve(root, rel);
1944
- const realRoot = fs3.realpathSync.native(root);
1945
- const real = fs3.realpathSync.native(full);
1946
- const inside2 = path2.relative(realRoot, real);
1947
- if (!inside2 || inside2.startsWith("..") || path2.isAbsolute(inside2)) return { error: "not listed" };
1948
- const st = fs3.statSync(real);
1993
+ const full = path3.resolve(root, rel);
1994
+ const realRoot = fs4.realpathSync.native(root);
1995
+ const real = fs4.realpathSync.native(full);
1996
+ const inside2 = path3.relative(realRoot, real);
1997
+ if (!inside2 || inside2.startsWith("..") || path3.isAbsolute(inside2)) return { error: "not listed" };
1998
+ const st = fs4.statSync(real);
1949
1999
  if (!st.isFile()) return { error: "unreadable" };
1950
2000
  return { real, size: st.size };
1951
2001
  } catch (err) {
@@ -1957,7 +2007,7 @@ async function readCodeFile(s, repo, rel, io = realIo) {
1957
2007
  if ("error" in at) return at;
1958
2008
  if (at.size > MAX_CODE_FILE_BYTES) return { repo, path: rel, size: at.size, text: null, reason: "too-large" };
1959
2009
  try {
1960
- const buf = await fs3.promises.readFile(at.real);
2010
+ const buf = await fs4.promises.readFile(at.real);
1961
2011
  if (buf.subarray(0, 8e3).includes(0)) return { repo, path: rel, size: at.size, text: null, reason: "binary" };
1962
2012
  return { repo, path: rel, size: at.size, text: buf.toString("utf-8") };
1963
2013
  } catch (err) {
@@ -1967,36 +2017,37 @@ async function readCodeFile(s, repo, rel, io = realIo) {
1967
2017
 
1968
2018
  // src/core/worktree/terminal-path-refs.ts
1969
2019
  function splitLine(raw) {
1970
- let path25 = raw;
2020
+ let path26 = raw;
1971
2021
  let line;
1972
- const m = /:(\d+)(?::\d+)?$/.exec(path25);
2022
+ const m = /:(\d+)(?::\d+)?$/.exec(path26);
1973
2023
  if (m) {
1974
- path25 = path25.slice(0, m.index);
2024
+ path26 = path26.slice(0, m.index);
1975
2025
  const n = Number(m[1]);
1976
2026
  if (n > 0) line = n;
1977
2027
  }
1978
- const url = /^file:\/\/([^/]*)(\/.*)?$/i.exec(path25);
2028
+ const url = /^file:\/\/([^/]*)(\/.*)?$/i.exec(path26);
1979
2029
  if (url) {
1980
- path25 = url[2] ?? "/";
2030
+ path26 = url[2] ?? "/";
1981
2031
  try {
1982
- path25 = decodeURIComponent(path25);
2032
+ path26 = decodeURIComponent(path26);
1983
2033
  } catch {
1984
2034
  }
1985
- if (/^\/[A-Za-z]:[\\/]/.test(path25)) path25 = path25.slice(1);
2035
+ if (/^\/[A-Za-z]:[\\/]/.test(path26)) path26 = path26.slice(1);
1986
2036
  }
1987
- return line === void 0 ? { path: path25 } : { path: path25, line };
2037
+ return line === void 0 ? { path: path26 } : { path: path26, line };
1988
2038
  }
1989
2039
 
1990
2040
  // src/core/worktree/terminal-paths.ts
1991
2041
  var VIEWER_EXTENSIONS = /* @__PURE__ */ new Set(["html", "htm", "pdf", "png", "jpg", "jpeg", "gif", "webp", "svg"]);
1992
2042
  var MAX_TERMINAL_LINE = 1e7;
1993
2043
  var realIo2 = {
1994
- listFiles: (root) => listRepoFiles(root)
2044
+ listFiles: (root) => listRepoFiles(root),
2045
+ networkRoots: () => networkMountRoots()
1995
2046
  };
1996
2047
  function onDisk(candidate) {
1997
2048
  try {
1998
- const real = fs4.realpathSync.native(candidate);
1999
- const st = fs4.statSync(real);
2049
+ const real = fs5.realpathSync.native(candidate);
2050
+ const st = fs5.statSync(real);
2000
2051
  if (st.isDirectory()) return { real, kind: "dir" };
2001
2052
  if (st.isFile()) return { real, kind: "file" };
2002
2053
  return null;
@@ -2006,7 +2057,7 @@ function onDisk(candidate) {
2006
2057
  }
2007
2058
  function found(raw, at, line) {
2008
2059
  if (at.kind === "dir") return { raw, path: at.real, kind: "dir", opens: "reveal" };
2009
- const ext = path3.extname(at.real).slice(1).toLowerCase();
2060
+ const ext = path4.extname(at.real).slice(1).toLowerCase();
2010
2061
  const opens = VIEWER_EXTENSIONS.has(ext) ? "app" : "editor";
2011
2062
  return line === void 0 ? { raw, path: at.real, kind: "file", opens } : { raw, path: at.real, kind: "file", opens, line };
2012
2063
  }
@@ -2027,7 +2078,7 @@ async function listedMatches(session, rel, io) {
2027
2078
  if (!want || want.split("/").includes("..")) return [];
2028
2079
  const lists = await Promise.all(
2029
2080
  codeRoots(session).map(async ({ root }) => {
2030
- if (!fs4.existsSync(root)) return { root, files: [] };
2081
+ if (!fs5.existsSync(root)) return { root, files: [] };
2031
2082
  try {
2032
2083
  return { root, files: await io.listFiles(root) };
2033
2084
  } catch {
@@ -2039,7 +2090,7 @@ async function listedMatches(session, rel, io) {
2039
2090
  for (const { root, files } of lists) {
2040
2091
  for (const f of files) {
2041
2092
  if (f !== want && !f.endsWith("/" + want)) continue;
2042
- const at = onDisk(path3.join(root, f));
2093
+ const at = onDisk(path4.join(root, f));
2043
2094
  if (at) hits.set(at.real, at);
2044
2095
  }
2045
2096
  }
@@ -2051,17 +2102,19 @@ async function resolveTerminalPath(session, raw, io = realIo2) {
2051
2102
  const p = split.path;
2052
2103
  const line = split.line !== void 0 && split.line <= MAX_TERMINAL_LINE ? split.line : void 0;
2053
2104
  if (!p || refusedPath(raw, p)) return missing(raw);
2105
+ const local = (abs) => !onNetworkVolume(abs, io.networkRoots?.() ?? []);
2054
2106
  if (/^~(?=$|[\\/])/.test(p)) {
2055
- const at = onDisk(path3.join(os.homedir(), p.slice(1)));
2107
+ const abs = path4.join(os.homedir(), p.slice(1));
2108
+ const at = local(abs) ? onDisk(abs) : null;
2056
2109
  return at ? found(raw, at, line) : missing(raw);
2057
2110
  }
2058
- if (path3.isAbsolute(p)) {
2059
- const at = onDisk(p);
2111
+ if (path4.isAbsolute(p)) {
2112
+ const at = local(p) ? onDisk(p) : null;
2060
2113
  return at ? found(raw, at, line) : missing(raw);
2061
2114
  }
2062
2115
  if (/^[A-Za-z]:[\\/]/.test(p)) return missing(raw);
2063
2116
  for (const root of relativeRoots(session)) {
2064
- const at = onDisk(path3.resolve(root, p));
2117
+ const at = onDisk(path4.resolve(root, p));
2065
2118
  if (at) return found(raw, at, line);
2066
2119
  }
2067
2120
  const matches = await listedMatches(session, p, io);
@@ -2074,17 +2127,17 @@ async function resolveTerminalPath(session, raw, io = realIo2) {
2074
2127
  }
2075
2128
  function editorFolder(session, real) {
2076
2129
  const first = session.paths[0];
2077
- const folder = first && session.isGroup ? path3.dirname(first) : first;
2130
+ const folder = first && session.isGroup ? path4.dirname(first) : first;
2078
2131
  if (folder) {
2079
2132
  let realFolder = folder;
2080
2133
  try {
2081
- realFolder = fs4.realpathSync.native(folder);
2134
+ realFolder = fs5.realpathSync.native(folder);
2082
2135
  } catch {
2083
2136
  }
2084
- const rel = path3.relative(realFolder, real);
2085
- if (rel && rel !== ".." && !rel.startsWith(".." + path3.sep) && !path3.isAbsolute(rel)) return folder;
2137
+ const rel = path4.relative(realFolder, real);
2138
+ if (rel && rel !== ".." && !rel.startsWith(".." + path4.sep) && !path4.isAbsolute(rel)) return folder;
2086
2139
  }
2087
- return path3.dirname(real);
2140
+ return path4.dirname(real);
2088
2141
  }
2089
2142
  async function openTerminalPath(session, raw, how, deps = {}) {
2090
2143
  const r = await resolveTerminalPath(session, raw, deps.io ?? realIo2);
@@ -2124,13 +2177,13 @@ function imageType(file) {
2124
2177
  };
2125
2178
  return types[ext] ?? null;
2126
2179
  }
2127
- var norm = (p) => path4.resolve(p).replace(/\\/g, "/").replace(/\/+$/, "");
2180
+ var norm = (p) => path5.resolve(p).replace(/\\/g, "/").replace(/\/+$/, "");
2128
2181
  var sameStart = (a, b) => process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
2129
2182
  function locateInSession(s, file) {
2130
2183
  const target = norm(file);
2131
- const roots = s.paths.map((p) => ({ repo: path4.basename(norm(p)), root: norm(p) }));
2184
+ const roots = s.paths.map((p) => ({ repo: path5.basename(norm(p)), root: norm(p) }));
2132
2185
  if (s.isGroup && roots.length) {
2133
- const parents = [...new Set(roots.map((r) => path4.posix.dirname(r.root)))];
2186
+ const parents = [...new Set(roots.map((r) => path5.posix.dirname(r.root)))];
2134
2187
  if (parents.length === 1) roots.push({ repo: "", root: parents[0] });
2135
2188
  }
2136
2189
  const holding = roots.filter((r) => target.length > r.root.length + 1 && sameStart(target.slice(0, r.root.length + 1), `${r.root}/`)).sort((a, b) => b.root.length - a.root.length)[0];
@@ -2150,10 +2203,11 @@ function insideFolders(real, folders, platform = process.platform) {
2150
2203
  return root.length > 0 && target.length > root.length + 1 && target.startsWith(`${root}/`);
2151
2204
  });
2152
2205
  }
2153
- var realTempIo = { realpath: (p) => fs5.promises.realpath(p), stat: (p) => fs5.promises.stat(p) };
2206
+ var realTempIo = { realpath: (p) => fs6.promises.realpath(p), stat: (p) => fs6.promises.stat(p) };
2154
2207
  async function findTempFile(file, folders, io = realTempIo, platform = process.platform) {
2155
- if (refusedPath(file, file, platform) || !(platform === "win32" ? path4.win32 : path4.posix).isAbsolute(file))
2208
+ if (refusedPath(file, file, platform) || !(platform === "win32" ? path5.win32 : path5.posix).isAbsolute(file))
2156
2209
  return { error: "not a local absolute path" };
2210
+ if (onNetworkVolume(file, networkMountRoots(platform), platform)) return { error: "not a local absolute path" };
2157
2211
  let real;
2158
2212
  try {
2159
2213
  real = await io.realpath(file);
@@ -2172,7 +2226,7 @@ async function findTempFile(file, folders, io = realTempIo, platform = process.p
2172
2226
  async function readShownFile(real, limit) {
2173
2227
  let fh;
2174
2228
  try {
2175
- fh = await fs5.promises.open(real, fs5.constants.O_RDONLY | (fs5.constants.O_NOFOLLOW ?? 0));
2229
+ fh = await fs6.promises.open(real, fs6.constants.O_RDONLY | (fs6.constants.O_NOFOLLOW ?? 0));
2176
2230
  } catch {
2177
2231
  return { error: "not there" };
2178
2232
  }
@@ -2196,8 +2250,8 @@ async function readShownFile(real, limit) {
2196
2250
  }
2197
2251
  function shownAbsolute(s, f) {
2198
2252
  if (f.temp) return f.temp;
2199
- const root = f.repo === "" ? s.isGroup && s.paths[0] ? path4.dirname(s.paths[0]) : null : s.paths.find((p) => path4.basename(norm(p)) === f.repo);
2200
- return root ? path4.join(root, ...f.path.split("/")) : null;
2253
+ const root = f.repo === "" ? s.isGroup && s.paths[0] ? path5.dirname(s.paths[0]) : null : s.paths.find((p) => path5.basename(norm(p)) === f.repo);
2254
+ return root ? path5.join(root, ...f.path.split("/")) : null;
2201
2255
  }
2202
2256
  var PANE_TABS = ["file", "diff", "code", "review"];
2203
2257
  function createShownFiles(deps) {
@@ -2291,7 +2345,7 @@ function mountSessionShowRoutes(app, deps) {
2291
2345
  const temp = file ? await findTempFile(file, tempFolders(session)) : { error: "outside" };
2292
2346
  if ("error" in temp)
2293
2347
  return c.json({ error: "That file is not in one of this session\u2019s folders, nor in its agent\u2019s scratch folder." }, 404);
2294
- shown.show(id, { repo: "", path: path5.basename(temp.real), temp: temp.real });
2348
+ shown.show(id, { repo: "", path: path6.basename(temp.real), temp: temp.real });
2295
2349
  return c.json(wire(id));
2296
2350
  }
2297
2351
  const found2 = await locate(session, at.repo, at.path);
@@ -2373,17 +2427,17 @@ function mountSessionShowRoutes(app, deps) {
2373
2427
  }
2374
2428
 
2375
2429
  // src/core/review/local-review-tree.ts
2376
- import path6 from "path";
2377
- var norm2 = (p) => path6.resolve(p).replace(/\\/g, "/").replace(/\/+$/, "");
2430
+ import path7 from "path";
2431
+ var norm2 = (p) => path7.resolve(p).replace(/\\/g, "/").replace(/\/+$/, "");
2378
2432
  function sessionTree(paths, names) {
2379
2433
  const byName = /* @__PURE__ */ new Map();
2380
- for (const p of paths) byName.set(path6.basename(norm2(p)), [...byName.get(path6.basename(norm2(p))) ?? [], norm2(p)]);
2434
+ for (const p of paths) byName.set(path7.basename(norm2(p)), [...byName.get(path7.basename(norm2(p))) ?? [], norm2(p)]);
2381
2435
  const dirs = names.map((n) => byName.get(n));
2382
2436
  if (names.length === 0 || dirs.some((d) => !d || d.length !== 1)) return null;
2383
2437
  const found2 = dirs.map((d) => d[0]);
2384
2438
  if (names.length === 1) return { cwd: found2[0], repos: [{ dir: found2[0], sub: null }] };
2385
- const parent = path6.posix.dirname(found2[0]);
2386
- if (found2.some((d) => path6.posix.dirname(d) !== parent)) return null;
2439
+ const parent = path7.posix.dirname(found2[0]);
2440
+ if (found2.some((d) => path7.posix.dirname(d) !== parent)) return null;
2387
2441
  return { cwd: parent, repos: found2.map((dir, i) => ({ dir, sub: names[i] })) };
2388
2442
  }
2389
2443
  var LOCAL_TREE_TIMEOUT_MS = 42e4;
@@ -2411,7 +2465,7 @@ function reviewFocus(config, aliases) {
2411
2465
 
2412
2466
  // src/core/platform/process-usage.ts
2413
2467
  import { execFile } from "child_process";
2414
- import path7 from "path";
2468
+ import path8 from "path";
2415
2469
  var num = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
2416
2470
  function parseCimUsage(json2) {
2417
2471
  let data;
@@ -2457,7 +2511,7 @@ function parsePsUsage(stdout, now) {
2457
2511
  out.push({
2458
2512
  pid: Number(m[1]),
2459
2513
  ppid: Number(m[2]),
2460
- name: path7.posix.basename(first),
2514
+ name: path8.posix.basename(first),
2461
2515
  exe: first.startsWith("/") ? first : null,
2462
2516
  command,
2463
2517
  memBytes: Number(m[3]) * 1024,
@@ -2581,9 +2635,9 @@ var NOT_NAMES = /* @__PURE__ */ new Set([
2581
2635
  "typeof",
2582
2636
  "await"
2583
2637
  ]);
2584
- function declarationOf(path25, text) {
2638
+ function declarationOf(path26, text) {
2585
2639
  for (const r of RULES) {
2586
- if (!r.ext.test(path25)) continue;
2640
+ if (!r.ext.test(path26)) continue;
2587
2641
  const m = r.re.exec(text);
2588
2642
  if (!m) continue;
2589
2643
  const name = r.name(m);
@@ -2835,8 +2889,8 @@ function mountTerminalPathRoutes(app) {
2835
2889
  app.post("/api/sessions/:id/terminal-paths/open", zValidator3("json", openSchema), async (c) => {
2836
2890
  const session = findSession2(c.req.param("id"));
2837
2891
  if (!session) return c.json({ error: "unknown session" }, 404);
2838
- const { path: path25, how } = c.req.valid("json");
2839
- const r = await openTerminalPath(session, path25, how);
2892
+ const { path: path26, how } = c.req.valid("json");
2893
+ const r = await openTerminalPath(session, path26, how);
2840
2894
  if ("ok" in r) return c.json({ ok: true, opened: r.opened });
2841
2895
  if (r.error === "failed") return c.json({ error: r.message ?? "could not open it" }, 500);
2842
2896
  return c.json({ error: r.error }, 404);
@@ -2946,10 +3000,10 @@ function mountDiffPageRoutes(app, opts) {
2946
3000
  // src/server/routes/setup-routes.ts
2947
3001
  var TOOLS_TTL_MS = 10 * 6e4;
2948
3002
  function mountSetupRoutes(app, opts) {
2949
- let cached2 = null;
3003
+ let cached3 = null;
2950
3004
  const tools = (fresh) => {
2951
- if (fresh || !cached2 || Date.now() - cached2.at > TOOLS_TTL_MS) cached2 = { at: Date.now(), tools: (opts.tools ?? checkTools)() };
2952
- return cached2.tools;
3005
+ if (fresh || !cached3 || Date.now() - cached3.at > TOOLS_TTL_MS) cached3 = { at: Date.now(), tools: (opts.tools ?? checkTools)() };
3006
+ return cached3.tools;
2953
3007
  };
2954
3008
  app.get("/api/setup", async (c) => c.json(await setupState(() => tools(c.req.query("fresh") === "1"))));
2955
3009
  app.post("/api/setup", async (c) => {
@@ -2967,8 +3021,8 @@ function mountSetupRoutes(app, opts) {
2967
3021
  }
2968
3022
 
2969
3023
  // src/core/updates/update-source.ts
2970
- import fs6 from "fs";
2971
- import path8 from "path";
3024
+ import fs7 from "fs";
3025
+ import path9 from "path";
2972
3026
 
2973
3027
  // src/core/updates/updates.ts
2974
3028
  function parseVersion(v) {
@@ -3053,8 +3107,8 @@ function parseDesktopUpdate(text) {
3053
3107
  var RELEASES_REPO = "moberghr/cli-work-tree-manager";
3054
3108
  var RELEASES_URL = `https://api.github.com/repos/${RELEASES_REPO}/releases?per_page=30`;
3055
3109
  var SEEN_KEY = "ui:seen-version";
3056
- var desktopUpdatePath = () => path8.join(getConfigDir(), "desktop-update.json");
3057
- var desktopRequestPath = () => path8.join(getConfigDir(), "desktop-request.json");
3110
+ var desktopUpdatePath = () => path9.join(getConfigDir(), "desktop-update.json");
3111
+ var desktopRequestPath = () => path9.join(getConfigDir(), "desktop-request.json");
3058
3112
  async function fetchReleases(get = (url) => fetch(url, { headers: { "User-Agent": "work", Accept: "application/vnd.github+json" }, signal: AbortSignal.timeout(15e3) }), run2 = defaultRunner) {
3059
3113
  const why = await get(RELEASES_URL).then(
3060
3114
  async (res) => res.ok ? parseReleases(await res.json()) : res.status === 403 ? "GitHub's limit for this address is spent" : `GitHub answered ${res.status}`,
@@ -3094,7 +3148,7 @@ function networkFailure(err) {
3094
3148
  function readDesktopUpdate(file = desktopUpdatePath()) {
3095
3149
  let text;
3096
3150
  try {
3097
- text = fs6.readFileSync(file, "utf-8");
3151
+ text = fs7.readFileSync(file, "utf-8");
3098
3152
  } catch {
3099
3153
  return null;
3100
3154
  }
@@ -3116,7 +3170,7 @@ function markSeenVersion(version) {
3116
3170
  }
3117
3171
  function installKind() {
3118
3172
  const root = packageRoot();
3119
- return installKindOf(root, getConfigDir(), !!root && fs6.existsSync(path8.join(root, ".git")));
3173
+ return installKindOf(root, getConfigDir(), !!root && fs7.existsSync(path9.join(root, ".git")));
3120
3174
  }
3121
3175
  var defaultDeps = () => ({
3122
3176
  fetchReleases: () => fetchReleases(),
@@ -3209,7 +3263,7 @@ function mountAppUpdateRoutes(app, opts) {
3209
3263
  }
3210
3264
 
3211
3265
  // src/server/routes/usage-routes.ts
3212
- import fs7 from "fs";
3266
+ import fs8 from "fs";
3213
3267
  var FRESH_MS = 5e3;
3214
3268
  function createUsageCache(build, ttlMs = FRESH_MS, now = Date.now) {
3215
3269
  let last = null;
@@ -3271,7 +3325,7 @@ function watchUsage(opts) {
3271
3325
  };
3272
3326
  let watcher = null;
3273
3327
  try {
3274
- fs7.mkdirSync(dir, { recursive: true });
3328
+ fs8.mkdirSync(dir, { recursive: true });
3275
3329
  watcher = createFsWatcher({ roots: [dir], onChange });
3276
3330
  } catch (e) {
3277
3331
  report("warn", `[usage] not watching ${dir}: ${e instanceof Error ? e.message : String(e)}`);
@@ -3396,8 +3450,8 @@ var SETTING_PATTERNS = {
3396
3450
  /** A font name or several, comma-separated (the terminal's font; it refuses what would end a CSS value). */
3397
3451
  fontFamily: "^[^;{}<>\\\\]+$"
3398
3452
  };
3399
- var bool = (path25, section, label, help, def, when) => ({
3400
- path: path25,
3453
+ var bool = (path26, section, label, help, def, when) => ({
3454
+ path: path26,
3401
3455
  section,
3402
3456
  label,
3403
3457
  help,
@@ -3867,7 +3921,7 @@ var SETTINGS = [
3867
3921
  "when each Claude next starts"
3868
3922
  )
3869
3923
  ];
3870
- var settingAt = (path25) => SETTINGS.find((f) => f.path === path25);
3924
+ var settingAt = (path26) => SETTINGS.find((f) => f.path === path26);
3871
3925
  function checkSetting(field, raw) {
3872
3926
  const checked = checkValue(field, raw);
3873
3927
  if (checked.ok && checked.value === null && field.required) return { ok: false, error: "it can\u2019t be left empty" };
@@ -3913,16 +3967,16 @@ function checkValue(field, raw) {
3913
3967
  return typeof raw === "string" && k.options.some((o) => o.value === raw) ? { ok: true, value: raw } : { ok: false, error: `one of ${k.options.map((o) => o.value).join(", ")}` };
3914
3968
  }
3915
3969
  }
3916
- function valueAt(obj, path25) {
3970
+ function valueAt(obj, path26) {
3917
3971
  let cur = obj;
3918
- for (const key of path25.split(".")) {
3972
+ for (const key of path26.split(".")) {
3919
3973
  if (!cur || typeof cur !== "object" || Array.isArray(cur)) return void 0;
3920
3974
  cur = cur[key];
3921
3975
  }
3922
3976
  return cur;
3923
3977
  }
3924
- function setValueAt(obj, path25, value) {
3925
- const keys = path25.split(".");
3978
+ function setValueAt(obj, path26, value) {
3979
+ const keys = path26.split(".");
3926
3980
  const chain = [obj];
3927
3981
  let cur = obj;
3928
3982
  for (const key of keys.slice(0, -1)) {
@@ -3962,8 +4016,8 @@ function checkRepoSetting(key, raw) {
3962
4016
  return raw === "all" || raw === "asked" || raw === "off" ? { ok: true, value: raw } : { ok: false, error: "all, asked or off" };
3963
4017
  }
3964
4018
  function repoSettingsOf(raw, alias) {
3965
- const map = (path25) => {
3966
- const m = valueAt(raw, path25);
4019
+ const map = (path26) => {
4020
+ const m = valueAt(raw, path26);
3967
4021
  return m && typeof m === "object" && !Array.isArray(m) ? m : {};
3968
4022
  };
3969
4023
  const checks = map(REPO_SETTING_PATH.requiredChecks)[alias];
@@ -4023,8 +4077,8 @@ function mountSettingsRoutes(app, opts) {
4023
4077
  }
4024
4078
 
4025
4079
  // src/core/settings/settings-admin.ts
4026
- import fs8 from "fs";
4027
- import path9 from "path";
4080
+ import fs9 from "fs";
4081
+ import path10 from "path";
4028
4082
 
4029
4083
  // src/core/settings/terminal-style.ts
4030
4084
  var TERMINAL_COLOR_KEYS = [
@@ -4248,7 +4302,7 @@ var DEFAULT_TERMINAL_STYLE = resolveTerminalStyle({});
4248
4302
  // src/core/settings/settings-admin.ts
4249
4303
  function rawConfig(file = getConfigPath()) {
4250
4304
  try {
4251
- const raw = JSON.parse(fs8.readFileSync(file, "utf-8"));
4305
+ const raw = JSON.parse(fs9.readFileSync(file, "utf-8"));
4252
4306
  return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
4253
4307
  } catch {
4254
4308
  return {};
@@ -4264,13 +4318,13 @@ function readSettings() {
4264
4318
  const colors = checkTerminalColors(valueAt(raw, "terminal.colors"));
4265
4319
  return { values, ...Object.keys(colors).length ? { terminalColors: colors } : {}, configPath: getConfigPath() };
4266
4320
  }
4267
- async function writeSetting(path25, value) {
4268
- const field = settingAt(path25);
4269
- if (!field) throw new SettingsError(`no setting ${path25}`, 404);
4321
+ async function writeSetting(path26, value) {
4322
+ const field = settingAt(path26);
4323
+ if (!field) throw new SettingsError(`no setting ${path26}`, 404);
4270
4324
  const checked = checkSetting(field, value);
4271
4325
  if (!checked.ok) throw new SettingsError(`${field.label}: ${checked.error}`);
4272
- const toWrite = checkedFolders(path25, checked.value);
4273
- await editConfig((raw) => setValueAt(raw, path25, toWrite)).catch((err) => {
4326
+ const toWrite = checkedFolders(path26, checked.value);
4327
+ await editConfig((raw) => setValueAt(raw, path26, toWrite)).catch((err) => {
4274
4328
  throw err instanceof RepoAdminError ? new SettingsError(err.message) : err;
4275
4329
  });
4276
4330
  return readSettings();
@@ -4284,10 +4338,10 @@ function checkedFolders(at, value) {
4284
4338
  if (at === "scanRoots" && Array.isArray(value))
4285
4339
  return value.map((v) => {
4286
4340
  const p = expandHome(v);
4287
- if (!path9.isAbsolute(p))
4341
+ if (!path10.isAbsolute(p))
4288
4342
  throw new SettingsError(`Folders scanned for repos: ${v} isn't a full path (start it from the drive, / or ~)`);
4289
- const full = path9.resolve(p);
4290
- if (!fs8.statSync(full, { throwIfNoEntry: false })?.isDirectory())
4343
+ const full = path10.resolve(p);
4344
+ if (!fs9.statSync(full, { throwIfNoEntry: false })?.isDirectory())
4291
4345
  throw new SettingsError(`Folders scanned for repos: ${full} isn't a folder`);
4292
4346
  return full;
4293
4347
  });
@@ -4342,7 +4396,7 @@ function withOwnStatusLine(source, own) {
4342
4396
  }
4343
4397
 
4344
4398
  // src/core/conversations/timeline-source.ts
4345
- import path10 from "path";
4399
+ import path11 from "path";
4346
4400
 
4347
4401
  // src/core/conversations/timeline.ts
4348
4402
  var SIZE_LABEL = /^(\d+ files? · \+\d+ −\d+|no changes)$/;
@@ -4391,7 +4445,7 @@ async function commitsOf(repo, since, run2) {
4391
4445
  if (log.code !== 0) return [];
4392
4446
  return log.stdout.split("\n").filter(Boolean).map((line) => {
4393
4447
  const [sha, at, ...subject] = line.split(" ");
4394
- return { repo: path10.basename(repo), sha, at, subject: subject.join(" ") };
4448
+ return { repo: path11.basename(repo), sha, at, subject: subject.join(" ") };
4395
4449
  });
4396
4450
  }
4397
4451
  async function sessionTimeline(s, deps = {}) {
@@ -4527,8 +4581,8 @@ function placeJira(issue, detail, cfg) {
4527
4581
  }
4528
4582
 
4529
4583
  // src/server/routes/jira-watch-routes.ts
4530
- import fs9 from "fs";
4531
- import path11 from "path";
4584
+ import fs10 from "fs";
4585
+ import path12 from "path";
4532
4586
 
4533
4587
  // src/core/jira/jira-watch.ts
4534
4588
  var START_PER_SWEEP = 2;
@@ -4731,16 +4785,16 @@ async function sweepJira(deps) {
4731
4785
  var EVERY_MS = 5 * 6e4;
4732
4786
  function aboutRepo(dir) {
4733
4787
  try {
4734
- const readme = ["README.md", "readme.md", "README"].map((n) => path11.join(dir, n)).find((f) => fs9.existsSync(f));
4788
+ const readme = ["README.md", "readme.md", "README"].map((n) => path12.join(dir, n)).find((f) => fs10.existsSync(f));
4735
4789
  if (readme) {
4736
- const line = fs9.readFileSync(readme, "utf8").split(/\r?\n/).map(
4790
+ const line = fs10.readFileSync(readme, "utf8").split(/\r?\n/).map(
4737
4791
  (l) => l.replace(/^[#>*\-\s]+/, "").replace(/[`*_[\]]/g, "").trim()
4738
4792
  ).find((l) => l.length > 20 && !/^(!|<|http)/.test(l));
4739
4793
  if (line) return line.slice(0, 160);
4740
4794
  }
4741
- const pkg = path11.join(dir, "package.json");
4742
- if (fs9.existsSync(pkg)) {
4743
- const d = JSON.parse(fs9.readFileSync(pkg, "utf8")).description;
4795
+ const pkg = path12.join(dir, "package.json");
4796
+ if (fs10.existsSync(pkg)) {
4797
+ const d = JSON.parse(fs10.readFileSync(pkg, "utf8")).description;
4744
4798
  if (typeof d === "string" && d.trim()) return d.trim().slice(0, 160);
4745
4799
  }
4746
4800
  } catch {
@@ -4752,7 +4806,7 @@ function watchTargets(cfg = loadConfig()) {
4752
4806
  const repos = Object.entries(cfg.repos).map(([alias, dir]) => ({
4753
4807
  name: alias,
4754
4808
  kind: "repo",
4755
- members: [path11.basename(dir)],
4809
+ members: [path12.basename(dir)],
4756
4810
  about: aboutRepo(dir)
4757
4811
  }));
4758
4812
  const groups = Object.entries(cfg.groups).map(([name, aliases]) => ({ name, kind: "group", members: aliases }));
@@ -4930,7 +4984,7 @@ function describeStall(s) {
4930
4984
  }
4931
4985
 
4932
4986
  // src/server/web-server.ts
4933
- import path22 from "path";
4987
+ import path23 from "path";
4934
4988
  import { Hono } from "hono";
4935
4989
  import { streamSSE as streamSSE2 } from "hono/streaming";
4936
4990
 
@@ -5337,8 +5391,8 @@ function mountPanesRoutes(app, opts) {
5337
5391
  }
5338
5392
 
5339
5393
  // src/server/routes/worktree-routes.ts
5340
- import fs10 from "fs";
5341
- import path12 from "path";
5394
+ import fs11 from "fs";
5395
+ import path13 from "path";
5342
5396
  import { spawn } from "child_process";
5343
5397
 
5344
5398
  // src/core/platform/started.ts
@@ -5498,7 +5552,7 @@ function mountWorktreeRoutes(app, opts) {
5498
5552
  if (waiting.length) return { body: { error: `Not deleted: ${waiting.join("; ")}.`, blocked: waiting }, status: 409 };
5499
5553
  }
5500
5554
  try {
5501
- const onDisk2 = session.paths.some((p) => fs10.existsSync(p));
5555
+ const onDisk2 = session.paths.some((p) => fs11.existsSync(p));
5502
5556
  if (!sessionOnly && onDisk2 && session.paths.some((p) => wouldRefuseRemoval(p, force ?? false))) {
5503
5557
  return { body: { error: REFUSED }, status: 409 };
5504
5558
  }
@@ -5569,7 +5623,7 @@ function mountWorktreeRoutes(app, opts) {
5569
5623
  const wantsFile = !!body && typeof body === "object" && "path" in body;
5570
5624
  const asked = wantsFile ? openFileSchema.safeParse(body) : null;
5571
5625
  if (asked && !asked.success) return c.json({ error: "repo and path required" }, 400);
5572
- const folder = session.isGroup ? path12.dirname(session.paths[0]) : session.paths[0];
5626
+ const folder = session.isGroup ? path13.dirname(session.paths[0]) : session.paths[0];
5573
5627
  let file;
5574
5628
  if (asked?.success) {
5575
5629
  const at = await codeFilePath(session, asked.data.repo, asked.data.path);
@@ -5616,7 +5670,7 @@ function mountWorktreeRoutes(app, opts) {
5616
5670
  import { zValidator as zValidator7 } from "@hono/zod-validator";
5617
5671
  import { z as z6 } from "zod";
5618
5672
  import { EventEmitter } from "events";
5619
- import path13 from "path";
5673
+ import path14 from "path";
5620
5674
  import { streamSSE } from "hono/streaming";
5621
5675
  function mountScopeRoutes(app, opts) {
5622
5676
  const background = /* @__PURE__ */ new Set();
@@ -5863,7 +5917,7 @@ function mountScopeRoutes(app, opts) {
5863
5917
  const fromSha = fromEntry.repos[p] ?? "HEAD";
5864
5918
  const toSha = toEntry === void 0 ? "working" : toEntry.repos[p] ?? "HEAD";
5865
5919
  return {
5866
- name: path13.basename(p),
5920
+ name: path14.basename(p),
5867
5921
  root: p,
5868
5922
  files: computeRangeDiff({ root: p, fromRef: fromSha, toRef: toSha })
5869
5923
  };
@@ -5880,7 +5934,7 @@ function mountScopeRoutes(app, opts) {
5880
5934
  }
5881
5935
  const resolved = scope.paths.map((p) => resolveRepoDiff(p, base, sessionBaseForPath(p)));
5882
5936
  const repos = scope.paths.map((p, i) => ({
5883
- name: path13.basename(p),
5937
+ name: path14.basename(p),
5884
5938
  root: p,
5885
5939
  resolvedBase: resolved[i].resolvedBase,
5886
5940
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -5911,7 +5965,7 @@ function mountScopeRoutes(app, opts) {
5911
5965
  if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {
5912
5966
  return c.json({ error: "bad path/start/end" }, 400);
5913
5967
  }
5914
- const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path13.basename(p) === repoName);
5968
+ const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path14.basename(p) === repoName);
5915
5969
  if (!root) return c.json({ error: "unknown repo" }, 404);
5916
5970
  const result = readContextLines({ root, relPath, start, end, ref });
5917
5971
  if (!result) return c.json({ error: "cannot read file" }, 400);
@@ -6169,7 +6223,7 @@ function mountTerminalRoutes(app, opts) {
6169
6223
  }
6170
6224
 
6171
6225
  // src/server/routes/status-routes.ts
6172
- import path14 from "path";
6226
+ import path15 from "path";
6173
6227
 
6174
6228
  // src/core/status/notifier.ts
6175
6229
  var MESSAGES = {
@@ -6318,7 +6372,7 @@ function mountStatusRoutes(app, opts) {
6318
6372
  const kind = notifyKindForTransition(status.prevState ? { state: status.prevState } : null, status);
6319
6373
  if (kind) {
6320
6374
  const config = loadConfig();
6321
- const launchDir = session.isGroup && session.paths[0] ? path14.dirname(session.paths[0]) : session.paths[0] ?? body.cwd;
6375
+ const launchDir = session.isGroup && session.paths[0] ? path15.dirname(session.paths[0]) : session.paths[0] ?? body.cwd;
6322
6376
  const name = `${session.target} \xB7 ${session.branch}`;
6323
6377
  const snooze = readSnooze(id);
6324
6378
  const route = snooze?.until && snoozeActive(snooze, { attention: status }) ? "none" : presence.route(id);
@@ -6702,9 +6756,9 @@ function createPrWatch(deps) {
6702
6756
  const r = a;
6703
6757
  if (r.pr.state !== "OPEN" || !r.path || theirs.has(prKey(r))) continue;
6704
6758
  const key = `${id}:${r.repo}:${r.pr.number}`;
6705
- const cached2 = feedbackCache.get(key);
6706
- const fresh = cached2 && r.pr.updatedAt && cached2.number === r.pr.number && cached2.updatedAt === r.pr.updatedAt && (openThreadCount(cached2.fb) === 0 || now() - cached2.at < THREADS_RECHECK_MS);
6707
- const fb = fresh ? cached2.fb : await deps.reviewFeedback(r.path, r.pr.number).catch(() => null);
6759
+ const cached3 = feedbackCache.get(key);
6760
+ const fresh = cached3 && r.pr.updatedAt && cached3.number === r.pr.number && cached3.updatedAt === r.pr.updatedAt && (openThreadCount(cached3.fb) === 0 || now() - cached3.at < THREADS_RECHECK_MS);
6761
+ const fb = fresh ? cached3.fb : await deps.reviewFeedback(r.path, r.pr.number).catch(() => null);
6708
6762
  if (fb && !fresh && r.pr.updatedAt) feedbackCache.set(key, { number: r.pr.number, updatedAt: r.pr.updatedAt, at: now(), fb });
6709
6763
  if (!fb) {
6710
6764
  const was = states.get(id)?.repos.find((p) => p.name === r.repo)?.threads?.filter((t) => t.prNumber === r.pr.number) ?? [];
@@ -7347,9 +7401,9 @@ function mountRailRoutes(app, opts) {
7347
7401
  }
7348
7402
 
7349
7403
  // src/core/worktree/shared-folders.ts
7350
- import fs11 from "fs";
7351
- import path15 from "path";
7352
- var norm3 = (p) => path15.resolve(p).replace(/\\/g, "/").toLowerCase();
7404
+ import fs12 from "fs";
7405
+ import path16 from "path";
7406
+ var norm3 = (p) => path16.resolve(p).replace(/\\/g, "/").toLowerCase();
7353
7407
  function shadowedSessions(sessions, branchCheckedOut2) {
7354
7408
  const byFolder = /* @__PURE__ */ new Map();
7355
7409
  for (const s of sessions) {
@@ -7368,14 +7422,14 @@ function shadowedSessions(sessions, branchCheckedOut2) {
7368
7422
  }
7369
7423
  function branchCheckedOut(dir) {
7370
7424
  try {
7371
- const dotGit = path15.join(dir, ".git");
7425
+ const dotGit = path16.join(dir, ".git");
7372
7426
  let gitDir = dotGit;
7373
- if (fs11.statSync(dotGit).isFile()) {
7374
- const m = /^gitdir:\s*(.+)$/m.exec(fs11.readFileSync(dotGit, "utf8"));
7427
+ if (fs12.statSync(dotGit).isFile()) {
7428
+ const m = /^gitdir:\s*(.+)$/m.exec(fs12.readFileSync(dotGit, "utf8"));
7375
7429
  if (!m) return null;
7376
- gitDir = path15.resolve(dir, m[1].trim());
7430
+ gitDir = path16.resolve(dir, m[1].trim());
7377
7431
  }
7378
- const head = fs11.readFileSync(path15.join(gitDir, "HEAD"), "utf8");
7432
+ const head = fs12.readFileSync(path16.join(gitDir, "HEAD"), "utf8");
7379
7433
  const ref = /^ref:\s*refs\/heads\/(.+)$/m.exec(head);
7380
7434
  return ref ? ref[1].trim() : null;
7381
7435
  } catch {
@@ -7384,18 +7438,18 @@ function branchCheckedOut(dir) {
7384
7438
  }
7385
7439
 
7386
7440
  // src/core/platform/build-stamp.ts
7387
- import fs12 from "fs";
7388
- var cached = null;
7441
+ import fs13 from "fs";
7442
+ var cached2 = null;
7389
7443
  function buildStamp() {
7390
- if (cached) return cached;
7444
+ if (cached2) return cached2;
7391
7445
  const forced = process.env.WORK_BUILD_STAMP;
7392
- if (forced) return cached = forced;
7446
+ if (forced) return cached2 = forced;
7393
7447
  try {
7394
- cached = String(Math.floor(fs12.statSync(process.argv[1]).mtimeMs));
7448
+ cached2 = String(Math.floor(fs13.statSync(process.argv[1]).mtimeMs));
7395
7449
  } catch {
7396
- cached = "unknown";
7450
+ cached2 = "unknown";
7397
7451
  }
7398
- return cached;
7452
+ return cached2;
7399
7453
  }
7400
7454
 
7401
7455
  // src/core/archive/after-archive.ts
@@ -7702,8 +7756,8 @@ function mountPrReplyRoutes(app, opts) {
7702
7756
  }
7703
7757
 
7704
7758
  // src/core/archive/archive-retention.ts
7705
- import fs13 from "fs";
7706
- import path16 from "path";
7759
+ import fs14 from "fs";
7760
+ import path17 from "path";
7707
7761
  import zlib from "zlib";
7708
7762
  var DEFAULT_COMPRESS_AFTER_DAYS = 30;
7709
7763
  var DAY_MS = 24 * 36e5;
@@ -7715,7 +7769,7 @@ function applyArchiveRetention(opts) {
7715
7769
  const out = { compressed: [], dropped: [], bytesSaved: 0 };
7716
7770
  let ids;
7717
7771
  try {
7718
- ids = fs13.readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
7772
+ ids = fs14.readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
7719
7773
  } catch {
7720
7774
  return out;
7721
7775
  }
@@ -7724,17 +7778,17 @@ function applyArchiveRetention(opts) {
7724
7778
  if (!rec) continue;
7725
7779
  const age = now - Date.parse(rec.archivedAt);
7726
7780
  if (!Number.isFinite(age)) continue;
7727
- const ignored = path16.join(archiveDirFor(id, root), "ignored");
7728
- if (compressAfter > 0 && age >= compressAfter * DAY_MS && !rec.ignoredDroppedAt && fs13.existsSync(ignored)) {
7729
- fs13.rmSync(ignored, { recursive: true, force: true });
7781
+ const ignored = path17.join(archiveDirFor(id, root), "ignored");
7782
+ if (compressAfter > 0 && age >= compressAfter * DAY_MS && !rec.ignoredDroppedAt && fs14.existsSync(ignored)) {
7783
+ fs14.rmSync(ignored, { recursive: true, force: true });
7730
7784
  rec.ignoredDroppedAt = new Date(now).toISOString();
7731
7785
  writeArchiveRecord(rec, root);
7732
7786
  }
7733
7787
  if (rec.transcriptsDroppedAt) continue;
7734
- const dir = path16.join(archiveDirFor(id, root), "transcripts");
7788
+ const dir = path17.join(archiveDirFor(id, root), "transcripts");
7735
7789
  if (dropAfter > 0 && age >= dropAfter * DAY_MS) {
7736
7790
  out.bytesSaved += dirBytes(dir);
7737
- fs13.rmSync(dir, { recursive: true, force: true });
7791
+ fs14.rmSync(dir, { recursive: true, force: true });
7738
7792
  rec.transcriptsDroppedAt = new Date(now).toISOString();
7739
7793
  writeArchiveRecord(rec, root);
7740
7794
  out.dropped.push(id);
@@ -7742,16 +7796,16 @@ function applyArchiveRetention(opts) {
7742
7796
  }
7743
7797
  if (compressAfter <= 0 || rec.compressedAt || age < compressAfter * DAY_MS) continue;
7744
7798
  for (const t of rec.transcripts) {
7745
- const plain = path16.join(dir, t.file);
7746
- if (!fs13.existsSync(plain)) continue;
7747
- const data = fs13.readFileSync(plain);
7799
+ const plain = path17.join(dir, t.file);
7800
+ if (!fs14.existsSync(plain)) continue;
7801
+ const data = fs14.readFileSync(plain);
7748
7802
  const gz = zlib.gzipSync(data);
7749
- fs13.writeFileSync(`${plain}.gz`, gz);
7750
- if (!zlib.gunzipSync(fs13.readFileSync(`${plain}.gz`)).equals(data)) {
7751
- fs13.rmSync(`${plain}.gz`, { force: true });
7803
+ fs14.writeFileSync(`${plain}.gz`, gz);
7804
+ if (!zlib.gunzipSync(fs14.readFileSync(`${plain}.gz`)).equals(data)) {
7805
+ fs14.rmSync(`${plain}.gz`, { force: true });
7752
7806
  continue;
7753
7807
  }
7754
- fs13.rmSync(plain, { force: true });
7808
+ fs14.rmSync(plain, { force: true });
7755
7809
  out.bytesSaved += data.length - gz.length;
7756
7810
  }
7757
7811
  rec.compressedAt = new Date(now).toISOString();
@@ -7763,7 +7817,7 @@ function applyArchiveRetention(opts) {
7763
7817
  function dirBytes(dir) {
7764
7818
  let n = 0;
7765
7819
  try {
7766
- for (const f of fs13.readdirSync(dir)) n += fs13.statSync(path16.join(dir, f)).size;
7820
+ for (const f of fs14.readdirSync(dir)) n += fs14.statSync(path17.join(dir, f)).size;
7767
7821
  } catch {
7768
7822
  }
7769
7823
  return n;
@@ -8241,7 +8295,7 @@ function reviewModeOf(alias, config) {
8241
8295
  return { mode: "all", from: "default" };
8242
8296
  }
8243
8297
  function reviewProjects(config) {
8244
- return Object.entries(config.repos).map(([alias, path25]) => ({ alias, path: path25, mode: reviewModeOf(alias, config).mode }));
8298
+ return Object.entries(config.repos).map(([alias, path26]) => ({ alias, path: path26, mode: reviewModeOf(alias, config).mode }));
8245
8299
  }
8246
8300
  function reviewLimits(config) {
8247
8301
  return {
@@ -8392,8 +8446,8 @@ function mountReviewRoutes(app, deps) {
8392
8446
 
8393
8447
  // src/core/review/review-tree.ts
8394
8448
  import { randomBytes } from "crypto";
8395
- import fs14 from "fs";
8396
- import path17 from "path";
8449
+ import fs15 from "fs";
8450
+ import path18 from "path";
8397
8451
 
8398
8452
  // src/core/review/review-source.ts
8399
8453
  var reviewRef = (number) => `refs/work/review/${number}`;
@@ -8449,7 +8503,7 @@ async function dropReviewRef(run2, repoPath, number) {
8449
8503
  }
8450
8504
 
8451
8505
  // src/core/review/review-tree.ts
8452
- var reviewTreesDir = () => path17.join(getConfigDir(), "review-trees");
8506
+ var reviewTreesDir = () => path18.join(getConfigDir(), "review-trees");
8453
8507
  var NO_HOOKS = ".no-hooks";
8454
8508
  var NO_LFS = ["-c", "filter.lfs.smudge=", "-c", "filter.lfs.process=", "-c", "filter.lfs.required=false"];
8455
8509
  var NO_LFS_ENV = { GIT_LFS_SKIP_SMUDGE: "1" };
@@ -8462,17 +8516,17 @@ var runSuffix = () => `${process.pid.toString(36)}${randomBytes(3).toString("hex
8462
8516
  var firstLine = (s) => s.trim().split(/\r?\n/)[0] ?? "";
8463
8517
  function rmTree(dir) {
8464
8518
  try {
8465
- fs14.rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
8519
+ fs15.rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
8466
8520
  } catch {
8467
8521
  }
8468
- return !fs14.existsSync(dir);
8522
+ return !fs15.existsSync(dir);
8469
8523
  }
8470
8524
  async function createReviewTree(run2, at, opts) {
8471
8525
  const root = opts.root ?? reviewTreesDir();
8472
- const dir = path17.join(root, reviewTreeName(at.alias, at.number, at.headSha, opts.run ?? runSuffix()));
8473
- const noHooks = path17.join(root, NO_HOOKS);
8474
- fs14.mkdirSync(noHooks, { recursive: true });
8475
- if (fs14.existsSync(dir)) await removeReviewTree(run2, at.repoPath, dir);
8526
+ const dir = path18.join(root, reviewTreeName(at.alias, at.number, at.headSha, opts.run ?? runSuffix()));
8527
+ const noHooks = path18.join(root, NO_HOOKS);
8528
+ fs15.mkdirSync(noHooks, { recursive: true });
8529
+ if (fs15.existsSync(dir)) await removeReviewTree(run2, at.repoPath, dir);
8476
8530
  const added = await run2(
8477
8531
  "git",
8478
8532
  [
@@ -8507,9 +8561,9 @@ async function createReviewTree(run2, at, opts) {
8507
8561
  }
8508
8562
  const removed = [];
8509
8563
  for (const rel of listed.stdout.split("\0").filter((rel2) => opts.strip(rel2))) {
8510
- const file = path17.join(dir, rel);
8511
- fs14.rmSync(file, { recursive: true, force: true });
8512
- if (fs14.existsSync(file)) {
8564
+ const file = path18.join(dir, rel);
8565
+ fs15.rmSync(file, { recursive: true, force: true });
8566
+ if (fs15.existsSync(file)) {
8513
8567
  await removeReviewTree(run2, at.repoPath, dir);
8514
8568
  return { ok: false, error: `couldn't remove ${rel} from the checkout` };
8515
8569
  }
@@ -8518,7 +8572,7 @@ async function createReviewTree(run2, at, opts) {
8518
8572
  return { ok: true, dir, removed };
8519
8573
  }
8520
8574
  async function removeReviewTree(run2, repoPath, dir) {
8521
- if (fs14.existsSync(dir)) await run2("git", ["worktree", "remove", "--force", "--force", dir], repoPath);
8575
+ if (fs15.existsSync(dir)) await run2("git", ["worktree", "remove", "--force", "--force", dir], repoPath);
8522
8576
  const gone = rmTree(dir);
8523
8577
  await run2("git", ["worktree", "prune"], repoPath);
8524
8578
  return gone;
@@ -8537,8 +8591,8 @@ async function withReviewTree(run2, at, use, opts) {
8537
8591
  }
8538
8592
  function gitDirOf(dir) {
8539
8593
  try {
8540
- const m = /^gitdir:\s*(.+)$/m.exec(fs14.readFileSync(path17.join(dir, ".git"), "utf8"));
8541
- return m ? path17.resolve(dir, m[1].trim(), "..", "..") : null;
8594
+ const m = /^gitdir:\s*(.+)$/m.exec(fs15.readFileSync(path18.join(dir, ".git"), "utf8"));
8595
+ return m ? path18.resolve(dir, m[1].trim(), "..", "..") : null;
8542
8596
  } catch {
8543
8597
  return null;
8544
8598
  }
@@ -8550,19 +8604,19 @@ async function sweepReviewTrees(run2, opts = {}) {
8550
8604
  const failed = [];
8551
8605
  let names;
8552
8606
  try {
8553
- names = fs14.readdirSync(root, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== NO_HOOKS).map((e) => e.name);
8607
+ names = fs15.readdirSync(root, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== NO_HOOKS).map((e) => e.name);
8554
8608
  } catch {
8555
8609
  return { swept, failed };
8556
8610
  }
8557
8611
  for (const name of names) {
8558
- const dir = path17.join(root, name);
8612
+ const dir = path18.join(root, name);
8559
8613
  try {
8560
- if (opts.olderThanMs && now - fs14.statSync(dir).mtimeMs < opts.olderThanMs) continue;
8614
+ if (opts.olderThanMs && now - fs15.statSync(dir).mtimeMs < opts.olderThanMs) continue;
8561
8615
  } catch {
8562
8616
  continue;
8563
8617
  }
8564
8618
  const gitDir = gitDirOf(dir);
8565
- const gone = gitDir && fs14.existsSync(gitDir) ? await removeReviewTree(run2, gitDir, dir) : rmTree(dir);
8619
+ const gone = gitDir && fs15.existsSync(gitDir) ? await removeReviewTree(run2, gitDir, dir) : rmTree(dir);
8566
8620
  (gone ? swept : failed).push(name);
8567
8621
  }
8568
8622
  return { swept, failed };
@@ -8902,7 +8956,7 @@ function createReviewQueue(deps) {
8902
8956
  }
8903
8957
 
8904
8958
  // src/core/review/review-deps.ts
8905
- import fs15 from "fs";
8959
+ import fs16 from "fs";
8906
8960
  var AGENT_TIMEOUT_MS = 18e4;
8907
8961
  var CHECKOUT_AGENT_TIMEOUT_MS = 3e5;
8908
8962
  var TREE_SWEEP_MIN_AGE_MS = CHECKOUT_AGENT_TIMEOUT_MS + 5 * 6e4;
@@ -8985,7 +9039,7 @@ function realReviewRouteIo() {
8985
9039
  function realFixIo(opts) {
8986
9040
  return {
8987
9041
  lookUp: (r) => resolvePrToStart(r.url, loadConfig() ?? { repos: {}, groups: {} }, r.repo),
8988
- liveSessionOn: (alias, branch) => sessionOnBranch(loadHistory(), loadConfig(), alias, branch, { branchOf: checkedOutBranch, exists: (p) => fs15.existsSync(p) }),
9042
+ liveSessionOn: (alias, branch) => sessionOnBranch(loadHistory(), loadConfig(), alias, branch, { branchOf: checkedOutBranch, exists: (p) => fs16.existsSync(p) }),
8989
9043
  create: async (alias, branch, name) => {
8990
9044
  const config = loadConfig();
8991
9045
  if (!config) return { ok: false, error: "no config" };
@@ -9040,7 +9094,7 @@ function startReviewSweeps(opts) {
9040
9094
  }
9041
9095
 
9042
9096
  // src/core/diff/session-history.ts
9043
- import path18 from "path";
9097
+ import path19 from "path";
9044
9098
 
9045
9099
  // src/core/diff/diff-points.ts
9046
9100
  var SHA = /^[0-9a-f]{7,40}$/;
@@ -9125,8 +9179,8 @@ function historyKey(session, others) {
9125
9179
  }
9126
9180
  async function sessionHistory(session, others = []) {
9127
9181
  const key = historyKey(session, others);
9128
- const cached2 = key ? historyCache.get(key) : void 0;
9129
- if (cached2) return cached2;
9182
+ const cached3 = key ? historyCache.get(key) : void 0;
9183
+ if (cached3) return cached3;
9130
9184
  const commits = [];
9131
9185
  const spans = [];
9132
9186
  for (const root of session.paths) {
@@ -9136,12 +9190,12 @@ async function sessionHistory(session, others = []) {
9136
9190
  });
9137
9191
  if (diffArg === "HEAD") continue;
9138
9192
  const log = await g(["log", `-n${MAX_COMMITS2}`, "--format=%H%x1f%cI%x1f%s", `${diffArg}..HEAD`, "--"], root);
9139
- if (log.ok && log.out) commits.push(...parseLog(log.out, path18.basename(root)));
9193
+ if (log.ok && log.out) commits.push(...parseLog(log.out, path19.basename(root)));
9140
9194
  }
9141
9195
  for (const b of others) {
9142
9196
  const tip = await tipOf(b);
9143
9197
  if (!tip) continue;
9144
- const repo = path18.basename(b.path);
9198
+ const repo = path19.basename(b.path);
9145
9199
  const start = liveStart(b) ?? b.start;
9146
9200
  let list = [];
9147
9201
  let base;
@@ -9202,7 +9256,7 @@ function parseLog(stdout, repo) {
9202
9256
  return out;
9203
9257
  }
9204
9258
  function computeSessionRange(session, from, to) {
9205
- const paths = session.paths.map((p) => path18.resolve(p));
9259
+ const paths = session.paths.map((p) => path19.resolve(p));
9206
9260
  const refs = rangeRefs(paths, loadManifest(scopeHashForPaths(paths)).entries, from, to);
9207
9261
  if ("error" in refs) return refs;
9208
9262
  return { repos: refs.map((r) => ({ name: r.name, root: r.root, files: computeRangeDiff(r) })) };
@@ -9221,17 +9275,17 @@ async function sessionHistoryWire(session) {
9221
9275
  }
9222
9276
 
9223
9277
  // src/server/routes/revert-routes.ts
9224
- import path20 from "path";
9278
+ import path21 from "path";
9225
9279
  import { zValidator as zValidator8 } from "@hono/zod-validator";
9226
9280
  import { z as z7 } from "zod";
9227
9281
 
9228
9282
  // src/core/diff/revert.ts
9229
- import fs16 from "fs";
9230
- import path19 from "path";
9283
+ import fs17 from "fs";
9284
+ import path20 from "path";
9231
9285
  function inside(root, rel) {
9232
- const abs = path19.resolve(root, rel);
9233
- const back = path19.relative(path19.resolve(root), abs);
9234
- if (!back || back.startsWith("..") || path19.isAbsolute(back)) return null;
9286
+ const abs = path20.resolve(root, rel);
9287
+ const back = path20.relative(path20.resolve(root), abs);
9288
+ if (!back || back.startsWith("..") || path20.isAbsolute(back)) return null;
9235
9289
  return abs;
9236
9290
  }
9237
9291
  function inHead(root, rel) {
@@ -9241,7 +9295,7 @@ function removeNew(root, rel) {
9241
9295
  const abs = inside(root, rel);
9242
9296
  if (!abs) return { ok: false, status: 400, error: `path escapes the worktree: ${rel}` };
9243
9297
  git(["rm", "--cached", "-q", "--ignore-unmatch", "--", rel], root);
9244
- fs16.rmSync(abs, { force: true });
9298
+ fs17.rmSync(abs, { force: true });
9245
9299
  return null;
9246
9300
  }
9247
9301
  function revertFile(root, file) {
@@ -9344,8 +9398,8 @@ function mountRevertRoutes(app, opts) {
9344
9398
  if (!session) return c.json({ error: "unknown session" }, 404);
9345
9399
  const body = c.req.valid("json");
9346
9400
  const repo = opts.uncommitted(session).find((r) => r.name === body.repo);
9347
- const allowed = new Set(session.paths.map((p) => path20.resolve(p).toLowerCase()));
9348
- if (!repo || !allowed.has(path20.resolve(repo.root).toLowerCase())) {
9401
+ const allowed = new Set(session.paths.map((p) => path21.resolve(p).toLowerCase()));
9402
+ if (!repo || !allowed.has(path21.resolve(repo.root).toLowerCase())) {
9349
9403
  return c.json({ error: `unknown repo: ${body.repo}` }, 404);
9350
9404
  }
9351
9405
  const file = repo.files.find((f) => f.path === body.path);
@@ -9402,7 +9456,7 @@ function mountDevRoutes(app, opts) {
9402
9456
  }
9403
9457
 
9404
9458
  // src/server/routes/ci-routes.ts
9405
- import fs17 from "fs";
9459
+ import fs18 from "fs";
9406
9460
  var WAKE_PROMPT = NOTE_NUDGE;
9407
9461
  async function wakeForNote(id) {
9408
9462
  if (loadConfig()?.prWatch?.wakeClaude === false) return "off";
@@ -9423,7 +9477,7 @@ function mountCiRoutes(app, opts) {
9423
9477
  lookOnly: opts.lookOnly,
9424
9478
  sessions: () => {
9425
9479
  const now = Date.now();
9426
- return loadHistory().filter((s) => watchable(s, now, { exists: (p) => fs17.existsSync(p), lastWriteMs: lastConversationWriteMs })).map((session) => ({ id: sessionIdFor(session), session }));
9480
+ return loadHistory().filter((s) => watchable(s, now, { exists: (p) => fs18.existsSync(p), lastWriteMs: lastConversationWriteMs })).map((session) => ({ id: sessionIdFor(session), session }));
9427
9481
  },
9428
9482
  // Never-pushed branches can't have a PR: don't ask GitHub about them,
9429
9483
  // unless the watch already knows one (a merged PR whose branch is gone).
@@ -9487,8 +9541,8 @@ function mountCiRoutes(app, opts) {
9487
9541
  app.get("/api/sessions/:id/ci", async (c) => {
9488
9542
  const id = c.req.param("id");
9489
9543
  if (!findSession2(id)) return c.json({ error: "unknown session" }, 404);
9490
- const cached2 = watch.state(id);
9491
- if (cached2 && Date.now() - Date.parse(cached2.checkedAt) < FRESH_MS2) return c.json(cached2);
9544
+ const cached3 = watch.state(id);
9545
+ if (cached3 && Date.now() - Date.parse(cached3.checkedAt) < FRESH_MS2) return c.json(cached3);
9492
9546
  return c.json(await watch.refresh(id, { act: false }) ?? { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), repos: [] });
9493
9547
  });
9494
9548
  app.post("/api/sessions/:id/ci/fix", async (c) => {
@@ -9502,27 +9556,27 @@ function mountCiRoutes(app, opts) {
9502
9556
  }
9503
9557
 
9504
9558
  // src/core/diff/diffs-sweep.ts
9505
- import fs18 from "fs";
9506
- import path21 from "path";
9559
+ import fs19 from "fs";
9560
+ import path22 from "path";
9507
9561
  var SWEEP_AFTER_DAYS = 30;
9508
9562
  var DISPOSABLE = /\.(html|log)$/i;
9509
- function sweepOldDiffArtifacts(now = Date.now(), maxAgeDays = SWEEP_AFTER_DAYS, dir = path21.join(getConfigDir(), "diffs")) {
9563
+ function sweepOldDiffArtifacts(now = Date.now(), maxAgeDays = SWEEP_AFTER_DAYS, dir = path22.join(getConfigDir(), "diffs")) {
9510
9564
  const cutoff = now - maxAgeDays * 24 * 60 * 60 * 1e3;
9511
9565
  let removed = 0;
9512
9566
  let bytes = 0;
9513
9567
  let names;
9514
9568
  try {
9515
- names = fs18.readdirSync(dir);
9569
+ names = fs19.readdirSync(dir);
9516
9570
  } catch {
9517
9571
  return { removed, bytes };
9518
9572
  }
9519
9573
  for (const name of names) {
9520
9574
  if (!DISPOSABLE.test(name)) continue;
9521
- const file = path21.join(dir, name);
9575
+ const file = path22.join(dir, name);
9522
9576
  try {
9523
- const st = fs18.statSync(file);
9577
+ const st = fs19.statSync(file);
9524
9578
  if (!st.isFile() || st.mtimeMs >= cutoff) continue;
9525
- fs18.rmSync(file, { force: true });
9579
+ fs19.rmSync(file, { force: true });
9526
9580
  removed++;
9527
9581
  bytes += st.size;
9528
9582
  } catch {
@@ -10122,7 +10176,7 @@ var localReviewRow = () => null;
10122
10176
  function computeSessionDiff(s, base) {
10123
10177
  const resolved = s.paths.map((p) => resolveRepoDiff(p, base, s.baseBranches?.[p] ?? s.baseBranch));
10124
10178
  const repos = s.paths.map((p, i) => ({
10125
- name: path22.basename(p),
10179
+ name: path23.basename(p),
10126
10180
  root: p,
10127
10181
  resolvedBase: resolved[i].resolvedBase,
10128
10182
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -10173,7 +10227,7 @@ async function startWebServer(opts = {}) {
10173
10227
  let activityWatcher = null;
10174
10228
  if (!lean) {
10175
10229
  try {
10176
- const roots = activityRoots().filter((r) => fs19.existsSync(r));
10230
+ const roots = activityRoots().filter((r) => fs20.existsSync(r));
10177
10231
  if (roots.length > 0) {
10178
10232
  activityWatcher = createFsWatcher({
10179
10233
  roots,
@@ -10226,13 +10280,13 @@ async function startWebServer(opts = {}) {
10226
10280
  }, 500);
10227
10281
  }
10228
10282
  });
10229
- const repoNames = (s) => s.isGroup ? s.paths.map((p) => path22.basename(p)) : [s.target];
10283
+ const repoNames = (s) => s.isGroup ? s.paths.map((p) => path23.basename(p)) : [s.target];
10230
10284
  const diffStatFor = (id, s, hasStatus) => wantsDiffStat(s, hasStatus) ? diffStats.get(id, s.paths, repoNames(s)) : null;
10231
10285
  const archivedRow = createArchivedRows();
10232
10286
  app.get("/api/sessions", (c) => {
10233
10287
  const withArchived = c.req.query("archived") === "1";
10234
- const cached2 = withArchived ? allSessionsCache : sessionsCache;
10235
- if (cached2 && Date.now() - cached2.at <= SESSIONS_TTL_MS) return c.json(cached2.body);
10288
+ const cached3 = withArchived ? allSessionsCache : sessionsCache;
10289
+ if (cached3 && Date.now() - cached3.at <= SESSIONS_TTL_MS) return c.json(cached3.body);
10236
10290
  {
10237
10291
  const history = loadHistory();
10238
10292
  const shadow = shadowedSessions(history, branchCheckedOut);
@@ -10826,7 +10880,7 @@ async function startWebServer(opts = {}) {
10826
10880
  inTree: (s, names) => localTreeRun(s.paths, names, {
10827
10881
  readOnly: internalReadOnly,
10828
10882
  run: (prompt, cwd, deny) => runInternalReadOnly(prompt, cwd, LOCAL_TREE_TIMEOUT_MS, { lane: "localReviews", deny }),
10829
- exists: (dir) => fs19.existsSync(dir)
10883
+ exists: (dir) => fs20.existsSync(dir)
10830
10884
  }),
10831
10885
  rules: () => rulesWith(loadConfig()?.reviews?.rules),
10832
10886
  // Its project's and each of its repos' own points, with the ones for every review.
@@ -10866,7 +10920,7 @@ async function startWebServer(opts = {}) {
10866
10920
  updatesTimer?.unref?.();
10867
10921
  const desktopFile = desktopUpdatePath();
10868
10922
  const onDesktopUpdate = () => broadcast("updates-changed", { ts: Date.now() });
10869
- if (jobs) fs19.watchFile(desktopFile, { interval: 3e3 }, onDesktopUpdate);
10923
+ if (jobs) fs20.watchFile(desktopFile, { interval: 3e3 }, onDesktopUpdate);
10870
10924
  const usageWatcher = wireUsage(app, {
10871
10925
  broadcast,
10872
10926
  build: () => buildUsage(realUsageDeps()),
@@ -10947,7 +11001,7 @@ async function startWebServer(opts = {}) {
10947
11001
  if (timeFirst) clearTimeout(timeFirst);
10948
11002
  if (timeTimer) clearInterval(timeTimer);
10949
11003
  timeKeeper?.stop();
10950
- fs19.unwatchFile(desktopFile, onDesktopUpdate);
11004
+ fs20.unwatchFile(desktopFile, onDesktopUpdate);
10951
11005
  usageWatcher.stop();
10952
11006
  for (const t of conversationSyncs.values()) clearTimeout(t);
10953
11007
  clearTimeout(sweepTimer);
@@ -11011,11 +11065,11 @@ async function settleAgentHooks(io) {
11011
11065
  }
11012
11066
 
11013
11067
  // src/core/platform/autostart.ts
11014
- import fs20 from "fs";
11015
- import path23 from "path";
11068
+ import fs21 from "fs";
11069
+ import path24 from "path";
11016
11070
  function startupScriptPath() {
11017
11071
  if (process.platform !== "win32" || !process.env.APPDATA) return null;
11018
- return path23.join(process.env.APPDATA, "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "work-web.vbs");
11072
+ return path24.join(process.env.APPDATA, "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "work-web.vbs");
11019
11073
  }
11020
11074
  function vbsQuote(s) {
11021
11075
  return '"' + s.replace(/"/g, '""') + '"';
@@ -11033,11 +11087,11 @@ function setAutostart(enabled, workBin) {
11033
11087
  const file = startupScriptPath();
11034
11088
  if (!file) throw new Error("Autostart is only supported on Windows so far.");
11035
11089
  if (enabled) {
11036
- fs20.mkdirSync(path23.dirname(file), { recursive: true });
11037
- fs20.writeFileSync(file, buildStartupScript(process.execPath, workBin), "utf-8");
11090
+ fs21.mkdirSync(path24.dirname(file), { recursive: true });
11091
+ fs21.writeFileSync(file, buildStartupScript(process.execPath, workBin), "utf-8");
11038
11092
  } else {
11039
11093
  try {
11040
- fs20.unlinkSync(file);
11094
+ fs21.unlinkSync(file);
11041
11095
  } catch {
11042
11096
  }
11043
11097
  }
@@ -11054,14 +11108,14 @@ async function demoHostSubmit(url, review) {
11054
11108
  };
11055
11109
  return { ok: true, url: `${url}#pullrequestreview-1` };
11056
11110
  }
11057
- var hunk = (path25, lines, status = "modified") => {
11111
+ var hunk = (path26, lines, status = "modified") => {
11058
11112
  const added = lines.filter((l) => l.startsWith("+")).length;
11059
11113
  const deleted = lines.filter((l) => l.startsWith("-")).length;
11060
11114
  const context = lines.length - added - deleted;
11061
11115
  return [
11062
- `diff --git a/${path25} b/${path25}`,
11063
- ...status === "added" ? ["new file mode 100644", "index 0000000..1111111", "--- /dev/null"] : ["index 1111111..2222222 100644", `--- a/${path25}`],
11064
- `+++ b/${path25}`,
11116
+ `diff --git a/${path26} b/${path26}`,
11117
+ ...status === "added" ? ["new file mode 100644", "index 0000000..1111111", "--- /dev/null"] : ["index 1111111..2222222 100644", `--- a/${path26}`],
11118
+ `+++ b/${path26}`,
11065
11119
  `@@ -${status === "added" ? 0 : 1},${status === "added" ? 0 : context + deleted} +1,${context + added} @@`,
11066
11120
  ...lines
11067
11121
  ].join("\n");
@@ -11563,7 +11617,7 @@ function createDemoRepos(liveTargets) {
11563
11617
  /** GET /api/projects: what New worktree offers, as the real one reads config. */
11564
11618
  projects() {
11565
11619
  return {
11566
- singles: Object.entries(repos).map(([name, path25]) => ({ name, kind: "single", path: path25 })),
11620
+ singles: Object.entries(repos).map(([name, path26]) => ({ name, kind: "single", path: path26 })),
11567
11621
  groups: Object.entries(groups).map(([name, members]) => ({ name, kind: "group", members }))
11568
11622
  };
11569
11623
  },
@@ -11605,12 +11659,12 @@ function createDemoRepos(liveTargets) {
11605
11659
  }));
11606
11660
  return { roots: [root], repos: rows, groups: groupRows };
11607
11661
  },
11608
- enroll(alias, path25) {
11609
- if (!found2.some((f) => f.path === path25)) throw new DemoRepoError(`${path25} is not the top folder of a git repository`);
11610
- const problem = enrollProblem(alias, path25, config());
11662
+ enroll(alias, path26) {
11663
+ if (!found2.some((f) => f.path === path26)) throw new DemoRepoError(`${path26} is not the top folder of a git repository`);
11664
+ const problem = enrollProblem(alias, path26, config());
11611
11665
  if (problem) throw new DemoRepoError(problem);
11612
- repos[alias] = path25;
11613
- ignored.delete(path25);
11666
+ repos[alias] = path26;
11667
+ ignored.delete(path26);
11614
11668
  },
11615
11669
  remove(alias, force) {
11616
11670
  if (!(alias in repos)) throw new DemoRepoError(`no repo \u201C${alias}\u201D`);
@@ -11619,9 +11673,9 @@ function createDemoRepos(liveTargets) {
11619
11673
  delete repos[alias];
11620
11674
  for (const g2 of Object.keys(groups)) groups[g2] = groups[g2].filter((m) => m !== alias);
11621
11675
  },
11622
- ignore(path25, on) {
11623
- if (on) ignored.add(path25);
11624
- else ignored.delete(path25);
11676
+ ignore(path26, on) {
11677
+ if (on) ignored.add(path26);
11678
+ else ignored.delete(path26);
11625
11679
  },
11626
11680
  saveGroup(name, members, creating) {
11627
11681
  const problem = groupProblem(name, members, config(), { creating });
@@ -12920,15 +12974,15 @@ ${reply}\r
12920
12974
  if (refusal || !s) return { ok: false, status: refusal?.status ?? 404, error: refusal?.error ?? "unknown session" };
12921
12975
  s.repos.push({ name: alias, uncommitted: "", sinceBranch: "", published: false, pr: null });
12922
12976
  const from = base || "main";
12923
- const path25 = this.wire(s).paths[s.repos.length - 1];
12977
+ const path26 = this.wire(s).paths[s.repos.length - 1];
12924
12978
  s.comments.post({
12925
12979
  side: "general",
12926
12980
  status: "published",
12927
- body: addedRepoNote({ alias, path: path25, branch: s.branch, from, imported: true })
12981
+ body: addedRepoNote({ alias, path: path26, branch: s.branch, from, imported: true })
12928
12982
  });
12929
12983
  this.emit("comments-changed", { sessionId: id });
12930
12984
  this.changed();
12931
- return { ok: true, wire: { ok: true, path: path25, branch: s.branch, created: true, from, imported: true, warnings: [] } };
12985
+ return { ok: true, wire: { ok: true, path: path26, branch: s.branch, created: true, from, imported: true, warnings: [] } };
12932
12986
  }
12933
12987
  // -- CI (the PR watch, simulated) ------------------------------------------
12934
12988
  /** The Today digest, through the same builder as work web: the demo's
@@ -13506,20 +13560,20 @@ function demoCodeFiles(repos, group) {
13506
13560
  })
13507
13561
  };
13508
13562
  }
13509
- function demoCodeFile(repos, group, repo, path25) {
13563
+ function demoCodeFile(repos, group, repo, path26) {
13510
13564
  if (repo === "") {
13511
- if (!group || path25 !== "CLAUDE.md") return null;
13565
+ if (!group || path26 !== "CLAUDE.md") return null;
13512
13566
  const text2 = `# Group instructions
13513
13567
 
13514
13568
  Repos: ${repos.map((r2) => r2.name).join(", ")}.
13515
13569
  `;
13516
- return { repo, path: path25, size: text2.length, text: text2 };
13570
+ return { repo, path: path26, size: text2.length, text: text2 };
13517
13571
  }
13518
13572
  const r = repos.find((x) => x.name === repo);
13519
13573
  if (!r) return null;
13520
- const changed = r.changed.find((f) => f.path === path25 && f.status !== "deleted");
13521
- const text = changed ? newSide(changed) : COMMON[path25]?.replace(/\{repo\}/g, repo);
13522
- return text === void 0 ? null : { repo, path: path25, size: text.length, text };
13574
+ const changed = r.changed.find((f) => f.path === path26 && f.status !== "deleted");
13575
+ const text = changed ? newSide(changed) : COMMON[path26]?.replace(/\{repo\}/g, repo);
13576
+ return text === void 0 ? null : { repo, path: path26, size: text.length, text };
13523
13577
  }
13524
13578
  function demoCodeSearch(repos, group, query) {
13525
13579
  const q = query.trim();
@@ -13528,12 +13582,12 @@ function demoCodeSearch(repos, group, query) {
13528
13582
  const text = [];
13529
13583
  const fold = (x) => ignoresCase(q) ? x.toLowerCase() : x;
13530
13584
  for (const r of demoCodeFiles(repos, group).repos) {
13531
- for (const path25 of r.files) {
13532
- const lines = (demoCodeFile(repos, group, r.name, path25)?.text ?? "").split("\n");
13585
+ for (const path26 of r.files) {
13586
+ const lines = (demoCodeFile(repos, group, r.name, path26)?.text ?? "").split("\n");
13533
13587
  lines.forEach((line, i) => {
13534
- const d = declarationOf(path25, line);
13535
- if (d) symbols.push({ ...d, repo: r.name, path: path25, line: i + 1, text: line.trim() });
13536
- if (fold(line).includes(fold(q))) text.push({ repo: r.name, path: path25, line: i + 1, text: line });
13588
+ const d = declarationOf(path26, line);
13589
+ if (d) symbols.push({ ...d, repo: r.name, path: path26, line: i + 1, text: line.trim() });
13590
+ if (fold(line).includes(fold(q))) text.push({ repo: r.name, path: path26, line: i + 1, text: line });
13537
13591
  });
13538
13592
  }
13539
13593
  }
@@ -13816,13 +13870,13 @@ function createDemoSettings(repoPathOf) {
13816
13870
  };
13817
13871
  return {
13818
13872
  read,
13819
- async write(path25, value) {
13820
- const f = settingAt(path25);
13821
- if (!f) throw new SettingsError(`no setting ${path25}`, 404);
13873
+ async write(path26, value) {
13874
+ const f = settingAt(path26);
13875
+ if (!f) throw new SettingsError(`no setting ${path26}`, 404);
13822
13876
  const r = checkSetting(f, value);
13823
13877
  if (!r.ok) throw new SettingsError(`${f.label}: ${r.error}`);
13824
- if (r.value === null) delete values[path25];
13825
- else values[path25] = r.value;
13878
+ if (r.value === null) delete values[path26];
13879
+ else values[path26] = r.value;
13826
13880
  return read();
13827
13881
  },
13828
13882
  readRepo,
@@ -15051,16 +15105,16 @@ async function startDemoServer(opts) {
15051
15105
  }
15052
15106
 
15053
15107
  // src/core/platform/web-life.ts
15054
- import fs21 from "fs";
15055
- import path24 from "path";
15056
- var lifePath = () => path24.join(getConfigDir(), "web-life.json");
15108
+ import fs22 from "fs";
15109
+ import path25 from "path";
15110
+ var lifePath = () => path25.join(getConfigDir(), "web-life.json");
15057
15111
  function isLife(v) {
15058
15112
  const l = v;
15059
15113
  return !!l && typeof l === "object" && typeof l.pid === "number" && typeof l.version === "string" && typeof l.startedAt === "string" && typeof l.lastSeen === "string" && (l.ended === void 0 || typeof l.ended?.at === "string" && typeof l.ended?.how === "string");
15060
15114
  }
15061
15115
  function readWebLife() {
15062
15116
  try {
15063
- const v = JSON.parse(fs21.readFileSync(lifePath(), "utf-8"));
15117
+ const v = JSON.parse(fs22.readFileSync(lifePath(), "utf-8"));
15064
15118
  return isLife(v) ? v : null;
15065
15119
  } catch {
15066
15120
  return null;
@@ -15426,4 +15480,4 @@ export {
15426
15480
  stopExisting,
15427
15481
  webCommand
15428
15482
  };
15429
- //# sourceMappingURL=web-EC3KKH6E.js.map
15483
+ //# sourceMappingURL=web-Q672AIMZ.js.map