@moberg_hr/work-tree 1.11.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/bin.ts
4
4
  import fs46 from "fs";
5
- import path44 from "path";
5
+ import path45 from "path";
6
6
  import chalk27 from "chalk";
7
7
 
8
8
  // src/cli.ts
@@ -1397,20 +1397,44 @@ function resolveFromCwd(config, cwd) {
1397
1397
 
1398
1398
  // src/core/worktree.ts
1399
1399
  import fs13 from "fs";
1400
- import path12 from "path";
1400
+ import path13 from "path";
1401
1401
  import chalk5 from "chalk";
1402
1402
 
1403
1403
  // src/core/history.ts
1404
1404
  import fs11 from "fs";
1405
- import path10 from "path";
1405
+ import path11 from "path";
1406
1406
 
1407
1407
  // src/core/fs-safe.ts
1408
1408
  import fs8 from "fs";
1409
+ import path9 from "path";
1409
1410
  import lockfile from "proper-lockfile";
1411
+ function resolveLinkTarget(filePath) {
1412
+ let current = filePath;
1413
+ const seen = /* @__PURE__ */ new Set([current]);
1414
+ for (let i = 0; i < 32; i++) {
1415
+ let stat;
1416
+ try {
1417
+ stat = fs8.lstatSync(current);
1418
+ } catch {
1419
+ return current;
1420
+ }
1421
+ if (!stat.isSymbolicLink()) return current;
1422
+ const next = path9.resolve(path9.dirname(current), fs8.readlinkSync(current));
1423
+ if (seen.has(next)) return filePath;
1424
+ seen.add(next);
1425
+ current = next;
1426
+ }
1427
+ return filePath;
1428
+ }
1410
1429
  function atomicWriteFile(filePath, content) {
1411
- const tmpPath = `${filePath}.tmp-${process.pid}`;
1430
+ const target = resolveLinkTarget(filePath);
1431
+ const tmpPath = `${target}.tmp-${process.pid}`;
1412
1432
  fs8.writeFileSync(tmpPath, content, "utf-8");
1413
- fs8.renameSync(tmpPath, filePath);
1433
+ try {
1434
+ fs8.chmodSync(tmpPath, fs8.statSync(target).mode & 511);
1435
+ } catch {
1436
+ }
1437
+ fs8.renameSync(tmpPath, target);
1414
1438
  }
1415
1439
  function ensureFile(filePath, initialContent) {
1416
1440
  if (!fs8.existsSync(filePath)) {
@@ -1455,9 +1479,9 @@ function sleepSync(ms) {
1455
1479
  // src/core/claude-activity.ts
1456
1480
  import fs9 from "fs";
1457
1481
  import os4 from "os";
1458
- import path9 from "path";
1482
+ import path10 from "path";
1459
1483
  function encodeProjectDir(p) {
1460
- return path9.resolve(p).replace(/[^A-Za-z0-9]/g, "-");
1484
+ return path10.resolve(p).replace(/[^A-Za-z0-9]/g, "-");
1461
1485
  }
1462
1486
  function latestJsonlMtimeMs(projectDir) {
1463
1487
  let entries;
@@ -1470,7 +1494,7 @@ function latestJsonlMtimeMs(projectDir) {
1470
1494
  for (const name of entries) {
1471
1495
  if (!name.endsWith(".jsonl")) continue;
1472
1496
  try {
1473
- const stat = fs9.statSync(path9.join(projectDir, name));
1497
+ const stat = fs9.statSync(path10.join(projectDir, name));
1474
1498
  if (stat.mtimeMs > latest) latest = stat.mtimeMs;
1475
1499
  } catch {
1476
1500
  }
@@ -1481,7 +1505,7 @@ function claudeActiveWithin(activityMs, nowMs, windowMs) {
1481
1505
  return activityMs > 0 && nowMs - activityMs < windowMs;
1482
1506
  }
1483
1507
  function getClaudeActivityMs(launchPath) {
1484
- const dir = path9.join(
1508
+ const dir = path10.join(
1485
1509
  os4.homedir(),
1486
1510
  ".claude",
1487
1511
  "projects",
@@ -1489,10 +1513,13 @@ function getClaudeActivityMs(launchPath) {
1489
1513
  );
1490
1514
  return latestJsonlMtimeMs(dir);
1491
1515
  }
1516
+ function hasClaudeConversation(dir) {
1517
+ return getClaudeActivityMs(dir) > 0;
1518
+ }
1492
1519
  function getLaunchPaths(session) {
1493
1520
  if (!session.isGroup) return [...session.paths];
1494
1521
  const parents = /* @__PURE__ */ new Set();
1495
- for (const p of session.paths) parents.add(path9.dirname(p));
1522
+ for (const p of session.paths) parents.add(path10.dirname(p));
1496
1523
  return [...parents];
1497
1524
  }
1498
1525
  function effectiveLastAccessedAt(session) {
@@ -1507,10 +1534,10 @@ function effectiveLastAccessedAt(session) {
1507
1534
  function resolveResumeLaunch(session) {
1508
1535
  const existing = session.paths.filter((p) => fs9.existsSync(p));
1509
1536
  const first = existing[0] ?? session.paths[0];
1510
- const defaultPath = session.isGroup ? path9.dirname(first) : first;
1537
+ const defaultPath = session.isGroup ? path10.dirname(first) : first;
1511
1538
  const candidates = /* @__PURE__ */ new Set();
1512
1539
  if (session.isGroup) {
1513
- for (const p of existing) candidates.add(path9.dirname(p));
1540
+ for (const p of existing) candidates.add(path10.dirname(p));
1514
1541
  for (const p of existing) candidates.add(p);
1515
1542
  } else {
1516
1543
  for (const p of existing) candidates.add(p);
@@ -1540,7 +1567,7 @@ function readSessionActivity(session) {
1540
1567
  return { lastActivity: latest, state };
1541
1568
  }
1542
1569
  function claudeProjectsRoot() {
1543
- return path9.join(os4.homedir(), ".claude", "projects");
1570
+ return path10.join(os4.homedir(), ".claude", "projects");
1544
1571
  }
1545
1572
 
1546
1573
  // src/core/port-allocator.ts
@@ -1614,7 +1641,7 @@ async function allocateFreePort(seedKey, config, sessions, probe = isPortFree) {
1614
1641
 
1615
1642
  // src/core/history.ts
1616
1643
  function getHistoryPath() {
1617
- return path10.join(getConfigDir(), "history.json");
1644
+ return path11.join(getConfigDir(), "history.json");
1618
1645
  }
1619
1646
  function backupCorruptFile(historyPath, reason) {
1620
1647
  try {
@@ -1807,7 +1834,7 @@ async function mergeHydratedSessions(incoming) {
1807
1834
 
1808
1835
  // src/core/copy-files.ts
1809
1836
  import fs12 from "fs";
1810
- import path11 from "path";
1837
+ import path12 from "path";
1811
1838
  import { globSync } from "glob";
1812
1839
  var EXCLUDED_DIRS = ["bin", "obj", "node_modules", ".git"];
1813
1840
  function copyConfigFiles(repoPath, worktreePath, patterns) {
@@ -1815,10 +1842,10 @@ function copyConfigFiles(repoPath, worktreePath, patterns) {
1815
1842
  const normalized = pattern.replace(/\\/g, "/");
1816
1843
  if (normalized.startsWith(".claude/")) {
1817
1844
  const relativePath = normalized;
1818
- const sourcePath = path11.join(repoPath, relativePath);
1845
+ const sourcePath = path12.join(repoPath, relativePath);
1819
1846
  if (fs12.existsSync(sourcePath)) {
1820
- const destPath = path11.join(worktreePath, relativePath);
1821
- const destDir = path11.dirname(destPath);
1847
+ const destPath = path12.join(worktreePath, relativePath);
1848
+ const destDir = path12.dirname(destPath);
1822
1849
  fs12.mkdirSync(destDir, { recursive: true });
1823
1850
  fs12.copyFileSync(sourcePath, destPath);
1824
1851
  console.log(` Copied: ${relativePath}`);
@@ -1836,9 +1863,9 @@ function copyConfigFiles(repoPath, worktreePath, patterns) {
1836
1863
  if (parts.some((p) => EXCLUDED_DIRS.includes(p))) {
1837
1864
  continue;
1838
1865
  }
1839
- const sourcePath = path11.join(repoPath, match);
1840
- const destPath = path11.join(worktreePath, match);
1841
- const destDir = path11.dirname(destPath);
1866
+ const sourcePath = path12.join(repoPath, match);
1867
+ const destPath = path12.join(worktreePath, match);
1868
+ const destDir = path12.dirname(destPath);
1842
1869
  fs12.mkdirSync(destDir, { recursive: true });
1843
1870
  fs12.copyFileSync(sourcePath, destPath);
1844
1871
  console.log(` Copied: ${match}`);
@@ -1903,7 +1930,7 @@ function toBaseSpec(base) {
1903
1930
  }
1904
1931
 
1905
1932
  // src/core/worktree.ts
1906
- function pullExistingWorktree(worktreePath, branchName) {
1933
+ function pullLatestForBranch(worktreePath, branchName) {
1907
1934
  const upstream = git(
1908
1935
  ["rev-parse", "--abbrev-ref", `${branchName}@{upstream}`],
1909
1936
  worktreePath
@@ -1922,7 +1949,7 @@ function pullExistingWorktree(worktreePath, branchName) {
1922
1949
  if (firstErrLine) console.log(chalk5.gray(` ${firstErrLine}`));
1923
1950
  }
1924
1951
  }
1925
- function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch) {
1952
+ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch, pull = true) {
1926
1953
  debug("createSingleWorktree", { repoPath, worktreePath, branchName, baseBranch });
1927
1954
  if (fs13.existsSync(worktreePath)) {
1928
1955
  if (isGitRepo(worktreePath)) {
@@ -1931,7 +1958,7 @@ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBr
1931
1958
  console.log(
1932
1959
  chalk5.yellow(` Worktree already exists at: ${worktreePath}`)
1933
1960
  );
1934
- pullExistingWorktree(worktreePath, branchName);
1961
+ if (pull) pullLatestForBranch(worktreePath, branchName);
1935
1962
  return true;
1936
1963
  }
1937
1964
  }
@@ -1951,7 +1978,7 @@ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBr
1951
1978
  );
1952
1979
  return false;
1953
1980
  }
1954
- const parentDir = path12.dirname(worktreePath);
1981
+ const parentDir = path13.dirname(worktreePath);
1955
1982
  fs13.mkdirSync(parentDir, { recursive: true });
1956
1983
  git(["fetch", "--quiet"], repoPath);
1957
1984
  const baseRepoBranch = getCurrentBranch(repoPath);
@@ -2127,9 +2154,9 @@ function removeSingleWorktree(repoPath, worktreePath, branchName, force) {
2127
2154
  return false;
2128
2155
  }
2129
2156
  }
2130
- async function setupWorktree(targetName, branchName, config, base, jiraKey) {
2157
+ async function setupWorktree(targetName, branchName, config, base, jiraKey, opts = {}) {
2131
2158
  const spec = toBaseSpec(base);
2132
- debug("setupWorktree", { targetName, branchName, spec, jiraKey });
2159
+ debug("setupWorktree", { targetName, branchName, spec, jiraKey, opts });
2133
2160
  const target = resolveProjectTarget(targetName, config);
2134
2161
  if (!target) {
2135
2162
  debug("setupWorktree: target not found", targetName);
@@ -2137,13 +2164,13 @@ async function setupWorktree(targetName, branchName, config, base, jiraKey) {
2137
2164
  }
2138
2165
  const workTreeDirName = branchName.replace(/\//g, "-");
2139
2166
  if (target.isGroup) {
2140
- return setupGroupWorktree(target.name, target.repoAliases, branchName, workTreeDirName, config, spec, jiraKey);
2167
+ return setupGroupWorktree(target.name, target.repoAliases, branchName, workTreeDirName, config, spec, jiraKey, opts);
2141
2168
  } else {
2142
- return setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey);
2169
+ return setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey, opts);
2143
2170
  }
2144
2171
  }
2145
- async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDirName, config, spec, jiraKey) {
2146
- const groupWorktreePath = path12.join(config.worktreesRoot, groupName, workTreeDirName);
2172
+ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDirName, config, spec, jiraKey, opts = {}) {
2173
+ const groupWorktreePath = path13.join(config.worktreesRoot, groupName, workTreeDirName);
2147
2174
  if (!isEmptyBaseSpec(spec)) {
2148
2175
  const unknownAliases = baseSpecOverrideAliases(spec).filter(
2149
2176
  (a) => !repoAliases.includes(a)
@@ -2184,11 +2211,11 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
2184
2211
  const baseBranches = {};
2185
2212
  for (const alias of repoAliases) {
2186
2213
  const repoPath = config.repos[alias];
2187
- const repoName = path12.basename(repoPath);
2188
- const subWorktreePath = path12.join(groupWorktreePath, repoName);
2214
+ const repoName = path13.basename(repoPath);
2215
+ const subWorktreePath = path13.join(groupWorktreePath, repoName);
2189
2216
  const repoBase = baseForAlias(spec, alias);
2190
2217
  console.log(chalk5.cyan(`[${alias}] (${repoName}):`));
2191
- const success = createSingleWorktree(repoPath, subWorktreePath, branchName, config, repoBase);
2218
+ const success = createSingleWorktree(repoPath, subWorktreePath, branchName, config, repoBase, opts.pull !== false);
2192
2219
  if (success) {
2193
2220
  createdWorktrees.push({ repoPath, worktreePath: subWorktreePath });
2194
2221
  if (repoBase) baseBranches[subWorktreePath] = repoBase;
@@ -2209,8 +2236,8 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
2209
2236
  }
2210
2237
  }
2211
2238
  const configDir = getConfigDir();
2212
- const claudeMdSrc = path12.join(configDir, `${groupName}.claude.md`);
2213
- const claudeMdDest = path12.join(groupWorktreePath, "CLAUDE.md");
2239
+ const claudeMdSrc = path13.join(configDir, `${groupName}.claude.md`);
2240
+ const claudeMdDest = path13.join(groupWorktreePath, "CLAUDE.md");
2214
2241
  if (fs13.existsSync(claudeMdSrc)) {
2215
2242
  fs13.copyFileSync(claudeMdSrc, claudeMdDest);
2216
2243
  console.log("");
@@ -2238,10 +2265,10 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
2238
2265
  if (port !== void 0) console.log(chalk5.gray(`Dev-server port: ${port}`));
2239
2266
  return { launchDir: groupWorktreePath, paths: allPaths, isGroup: true, port };
2240
2267
  }
2241
- async function setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey) {
2268
+ async function setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey, opts = {}) {
2242
2269
  const repoPath = config.repos[targetName];
2243
- const repoName = path12.basename(repoPath);
2244
- let workTreePath = path12.join(config.worktreesRoot, repoName, workTreeDirName);
2270
+ const repoName = path13.basename(repoPath);
2271
+ let workTreePath = path13.join(config.worktreesRoot, repoName, workTreeDirName);
2245
2272
  const unknownAliases = baseSpecOverrideAliases(spec).filter((a) => a !== targetName);
2246
2273
  if (unknownAliases.length > 0) {
2247
2274
  console.error(
@@ -2256,7 +2283,7 @@ async function setupSingleWorktree(targetName, branchName, workTreeDirName, conf
2256
2283
  }
2257
2284
  const worktrees = parseWorktreeList(repoPath);
2258
2285
  const existing = worktrees.find(
2259
- (wt) => wt.branch === branchName && path12.resolve(wt.path) !== path12.resolve(repoPath)
2286
+ (wt) => wt.branch === branchName && path13.resolve(wt.path) !== path13.resolve(repoPath)
2260
2287
  );
2261
2288
  if (existing) {
2262
2289
  if (baseBranch) {
@@ -2265,9 +2292,9 @@ async function setupSingleWorktree(targetName, branchName, workTreeDirName, conf
2265
2292
  }
2266
2293
  console.log(`Worktree already exists at: ${existing.path}`);
2267
2294
  workTreePath = existing.path;
2268
- pullExistingWorktree(workTreePath, branchName);
2295
+ if (opts.pull !== false) pullLatestForBranch(workTreePath, branchName);
2269
2296
  } else {
2270
- const success = createSingleWorktree(repoPath, workTreePath, branchName, config, baseBranch);
2297
+ const success = createSingleWorktree(repoPath, workTreePath, branchName, config, baseBranch, opts.pull !== false);
2271
2298
  if (!success) return null;
2272
2299
  }
2273
2300
  const { port } = await upsertSessionWithPort(
@@ -2288,19 +2315,19 @@ function teardownWorktree(target, isGroup, branch, config, force = true) {
2288
2315
  const workTreeDirName = branch.replace(/\//g, "-");
2289
2316
  if (isGroup && config.groups[target]) {
2290
2317
  const aliases = config.groups[target];
2291
- const groupWorktreePath = path12.join(config.worktreesRoot, target, workTreeDirName);
2318
+ const groupWorktreePath = path13.join(config.worktreesRoot, target, workTreeDirName);
2292
2319
  let allRemoved = true;
2293
2320
  for (const alias of aliases) {
2294
2321
  const repoPath = config.repos[alias];
2295
2322
  if (!repoPath) continue;
2296
- const repoName = path12.basename(repoPath);
2297
- const subWorktreePath = path12.join(groupWorktreePath, repoName);
2323
+ const repoName = path13.basename(repoPath);
2324
+ const subWorktreePath = path13.join(groupWorktreePath, repoName);
2298
2325
  console.log(chalk5.cyan(`[${alias}] (${repoName}):`));
2299
2326
  if (!removeSingleWorktree(repoPath, subWorktreePath, branch, force)) {
2300
2327
  allRemoved = false;
2301
2328
  }
2302
2329
  }
2303
- const claudeMd = path12.join(groupWorktreePath, "CLAUDE.md");
2330
+ const claudeMd = path13.join(groupWorktreePath, "CLAUDE.md");
2304
2331
  try {
2305
2332
  if (fs13.existsSync(claudeMd)) fs13.unlinkSync(claudeMd);
2306
2333
  } catch {
@@ -2349,6 +2376,14 @@ var treeCommand = {
2349
2376
  describe: "Launch the AI tool with its skip-permissions flag (default: --dangerously-skip-permissions)",
2350
2377
  type: "boolean",
2351
2378
  default: false
2379
+ }).option("pull", {
2380
+ describe: "Pull latest changes when switching into an existing worktree or the base repo. Use --no-pull to skip.",
2381
+ type: "boolean",
2382
+ default: true
2383
+ }).option("fresh", {
2384
+ describe: "Start a new AI conversation instead of continuing the previous one for this directory",
2385
+ type: "boolean",
2386
+ default: false
2352
2387
  }).option("base", {
2353
2388
  describe: "Base branch to fork from instead of HEAD. Repeatable. Use a bare branch (--base dev) for all repos, or alias=branch (--base backend=dev --base frontend=feat/x) for per-repo bases in a group.",
2354
2389
  type: "string"
@@ -2374,6 +2409,8 @@ var treeCommand = {
2374
2409
  const here = argv.here;
2375
2410
  const open = argv.open;
2376
2411
  const unsafe = argv.unsafe;
2412
+ const pull = argv.pull;
2413
+ const fresh = argv.fresh;
2377
2414
  const setupOnly = argv["setup-only"];
2378
2415
  let baseSpec;
2379
2416
  try {
@@ -2397,6 +2434,19 @@ var treeCommand = {
2397
2434
  }
2398
2435
  }
2399
2436
  const config = ensureConfig();
2437
+ const launchTool = (dir, port) => {
2438
+ const tool = getAiTool(config);
2439
+ const resume = !fresh && hasClaudeConversation(dir);
2440
+ if (resume) {
2441
+ console.log(
2442
+ chalk6.gray(
2443
+ `Continuing the previous ${tool.cmd} conversation (--fresh starts a new one).`
2444
+ )
2445
+ );
2446
+ }
2447
+ console.log(`Starting ${tool.cmd}...`);
2448
+ launchAi(dir, tool, { unsafe, initialPrompt, resume }, port);
2449
+ };
2400
2450
  if (here) {
2401
2451
  if (targetName) {
2402
2452
  console.error("Cannot combine --here with an explicit target.");
@@ -2465,16 +2515,15 @@ var treeCommand = {
2465
2515
  console.log(chalk6.cyan(`Working on base repo: ${targetName}`));
2466
2516
  console.log(`Repo path: ${repoPath}`);
2467
2517
  const currentBranch = getCurrentBranch(repoPath) ?? "(detached)";
2518
+ if (pull && currentBranch && currentBranch !== "(detached)") {
2519
+ pullLatestForBranch(repoPath, currentBranch);
2520
+ }
2468
2521
  await upsertSession(targetName, false, currentBranch, [repoPath], jiraKey);
2469
2522
  if (open) openVSCode(repoPath);
2470
- if (!setupOnly) {
2471
- const tool = getAiTool(config);
2472
- console.log(`Starting ${tool.cmd}...`);
2473
- launchAi(repoPath, tool, { unsafe, initialPrompt });
2474
- }
2523
+ if (!setupOnly) launchTool(repoPath);
2475
2524
  return;
2476
2525
  }
2477
- const result = await setupWorktree(targetName, branchName, config, baseSpec, jiraKey);
2526
+ const result = await setupWorktree(targetName, branchName, config, baseSpec, jiraKey, { pull });
2478
2527
  if (!result) {
2479
2528
  process.exitCode = 1;
2480
2529
  return;
@@ -2485,11 +2534,7 @@ var treeCommand = {
2485
2534
  }
2486
2535
  }
2487
2536
  console.log(`Worktree path: ${result.launchDir}`);
2488
- if (!setupOnly) {
2489
- const tool = getAiTool(config);
2490
- console.log(`Starting ${tool.cmd}...`);
2491
- launchAi(result.launchDir, tool, { unsafe, initialPrompt }, result.port);
2492
- }
2537
+ if (!setupOnly) launchTool(result.launchDir, result.port);
2493
2538
  }
2494
2539
  };
2495
2540
 
@@ -2548,7 +2593,7 @@ var removeCommand = {
2548
2593
 
2549
2594
  // src/commands/list.ts
2550
2595
  import fs15 from "fs";
2551
- import path13 from "path";
2596
+ import path14 from "path";
2552
2597
  import chalk8 from "chalk";
2553
2598
  var listCommand = {
2554
2599
  command: "list [target]",
@@ -2616,7 +2661,7 @@ var listCommand = {
2616
2661
  }
2617
2662
  }
2618
2663
  for (const groupName of showGroups) {
2619
- const groupDir = path13.join(worktreesRoot, groupName);
2664
+ const groupDir = path14.join(worktreesRoot, groupName);
2620
2665
  if (!fs15.existsSync(groupDir)) continue;
2621
2666
  let branchDirs;
2622
2667
  try {
@@ -2634,12 +2679,12 @@ var listCommand = {
2634
2679
  );
2635
2680
  const repoAliases = config.groups[groupName] ?? [];
2636
2681
  for (const bdName of branchDirs) {
2637
- const bdPath = path13.join(groupDir, bdName);
2682
+ const bdPath = path14.join(groupDir, bdName);
2638
2683
  let actualBranch = null;
2639
2684
  for (const alias of repoAliases) {
2640
2685
  const repoPath = config.repos[alias];
2641
2686
  if (!repoPath) continue;
2642
- const rdPath = path13.join(bdPath, path13.basename(repoPath));
2687
+ const rdPath = path14.join(bdPath, path14.basename(repoPath));
2643
2688
  if (fs15.existsSync(rdPath)) {
2644
2689
  const branch = getCurrentBranch(rdPath);
2645
2690
  if (branch) {
@@ -2966,7 +3011,7 @@ import { checkbox } from "@inquirer/prompts";
2966
3011
 
2967
3012
  // src/core/prunable-scan.ts
2968
3013
  import fs19 from "fs";
2969
- import path14 from "path";
3014
+ import path15 from "path";
2970
3015
  import chalk12 from "chalk";
2971
3016
  function collectPrunable(config, options = {}) {
2972
3017
  const { fetch: fetch2 = true, print = true, includeSquash = false } = options;
@@ -2983,7 +3028,7 @@ function collectPrunable(config, options = {}) {
2983
3028
  }
2984
3029
  const groupCoveredKeys = /* @__PURE__ */ new Set();
2985
3030
  for (const [groupName, aliases] of Object.entries(config.groups)) {
2986
- const groupDir = path14.join(config.worktreesRoot, groupName);
3031
+ const groupDir = path15.join(config.worktreesRoot, groupName);
2987
3032
  if (!fs19.existsSync(groupDir)) continue;
2988
3033
  let branchDirs;
2989
3034
  try {
@@ -2992,7 +3037,7 @@ function collectPrunable(config, options = {}) {
2992
3037
  continue;
2993
3038
  }
2994
3039
  for (const branchDir of branchDirs) {
2995
- const branchDirPath = path14.join(groupDir, branchDir);
3040
+ const branchDirPath = path15.join(groupDir, branchDir);
2996
3041
  let branch;
2997
3042
  let allMerged = true;
2998
3043
  let groupHasChanges = false;
@@ -3006,8 +3051,8 @@ function collectPrunable(config, options = {}) {
3006
3051
  skipped = true;
3007
3052
  continue;
3008
3053
  }
3009
- const repoName = path14.basename(repoPath);
3010
- const subWorktreePath = path14.join(branchDirPath, repoName);
3054
+ const repoName = path15.basename(repoPath);
3055
+ const subWorktreePath = path15.join(branchDirPath, repoName);
3011
3056
  if (!fs19.existsSync(subWorktreePath)) {
3012
3057
  continue;
3013
3058
  }
@@ -3124,7 +3169,7 @@ async function removeSingleEntry(entry, force = true) {
3124
3169
  }
3125
3170
  async function removeGroupEntry(entry, config, force = true) {
3126
3171
  const workTreeDirName = entry.branch.replace(/\//g, "-");
3127
- const groupWorktreePath = path14.join(
3172
+ const groupWorktreePath = path15.join(
3128
3173
  config.worktreesRoot,
3129
3174
  entry.target,
3130
3175
  workTreeDirName
@@ -3134,7 +3179,7 @@ async function removeGroupEntry(entry, config, force = true) {
3134
3179
  );
3135
3180
  let allRemoved = true;
3136
3181
  for (const { alias, repoPath, worktreePath } of entry.repos) {
3137
- const repoName = path14.basename(repoPath);
3182
+ const repoName = path15.basename(repoPath);
3138
3183
  console.log(chalk12.cyan(` [${alias}] (${repoName}):`));
3139
3184
  const removed = removeSingleWorktree(repoPath, worktreePath, entry.branch, force);
3140
3185
  if (!removed) {
@@ -3144,7 +3189,7 @@ async function removeGroupEntry(entry, config, force = true) {
3144
3189
  if (allRemoved) {
3145
3190
  await removeSession(entry.target, entry.branch);
3146
3191
  }
3147
- const claudeMdInWorktree = path14.join(groupWorktreePath, "CLAUDE.md");
3192
+ const claudeMdInWorktree = path15.join(groupWorktreePath, "CLAUDE.md");
3148
3193
  if (fs19.existsSync(claudeMdInWorktree)) {
3149
3194
  fs19.unlinkSync(claudeMdInWorktree);
3150
3195
  }
@@ -3370,7 +3415,7 @@ var syncCommand = {
3370
3415
 
3371
3416
  // src/tui-ink/index.tsx
3372
3417
  import fs24 from "fs";
3373
- import path19 from "path";
3418
+ import path20 from "path";
3374
3419
  import { render } from "ink";
3375
3420
 
3376
3421
  // src/tui-ink/App.tsx
@@ -3378,7 +3423,7 @@ import { useState, useEffect, useRef, useCallback, useMemo } from "react";
3378
3423
  import { Box as Box5 } from "ink";
3379
3424
  import fs23 from "fs";
3380
3425
  import os6 from "os";
3381
- import path18 from "path";
3426
+ import path19 from "path";
3382
3427
  import { execFile as execFile4 } from "child_process";
3383
3428
  import spawn7 from "cross-spawn";
3384
3429
 
@@ -3592,10 +3637,10 @@ async function fetchJiraPane() {
3592
3637
 
3593
3638
  // src/core/tasks.ts
3594
3639
  import fs21 from "fs";
3595
- import path15 from "path";
3640
+ import path16 from "path";
3596
3641
  var EMPTY_STORE = { nextId: 1, tasks: [] };
3597
3642
  function getTasksPath() {
3598
- return path15.join(getConfigDir(), "tasks.json");
3643
+ return path16.join(getConfigDir(), "tasks.json");
3599
3644
  }
3600
3645
  function loadStore() {
3601
3646
  const p = getTasksPath();
@@ -3844,30 +3889,33 @@ var PtySession = class {
3844
3889
 
3845
3890
  // src/core/hook-server.ts
3846
3891
  import http from "http";
3847
- import path17 from "path";
3892
+ import path18 from "path";
3848
3893
 
3849
3894
  // src/core/settings-editor.ts
3850
3895
  import fs22 from "fs";
3851
- import path16 from "path";
3896
+ import path17 from "path";
3852
3897
  import os5 from "os";
3853
- var SETTINGS_PATH = path16.join(os5.homedir(), ".claude", "settings.json");
3898
+ function settingsPath() {
3899
+ return path17.join(os5.homedir(), ".claude", "settings.json");
3900
+ }
3854
3901
  var OWNER_TAG = "_workHookOwner";
3855
3902
  var PID_TAG = "_workHookPid";
3856
3903
  var LEGACY_TAGS = ["_workDash", "_work2Dash"];
3857
3904
  function readSettings() {
3858
3905
  try {
3859
- if (!fs22.existsSync(SETTINGS_PATH)) return {};
3860
- return JSON.parse(fs22.readFileSync(SETTINGS_PATH, "utf8"));
3906
+ const p = settingsPath();
3907
+ if (!fs22.existsSync(p)) return {};
3908
+ return JSON.parse(fs22.readFileSync(p, "utf8"));
3861
3909
  } catch {
3862
3910
  return {};
3863
3911
  }
3864
3912
  }
3865
3913
  function writeAtomic(s) {
3866
3914
  try {
3867
- fs22.mkdirSync(path16.dirname(SETTINGS_PATH), { recursive: true });
3868
- const tmp = `${SETTINGS_PATH}.tmp-${process.pid}-${Date.now()}`;
3869
- fs22.writeFileSync(tmp, JSON.stringify(s, null, 2), "utf-8");
3870
- fs22.renameSync(tmp, SETTINGS_PATH);
3915
+ const target = resolveLinkTarget(settingsPath());
3916
+ fs22.mkdirSync(path17.dirname(target), { recursive: true });
3917
+ atomicWriteFile(target, `${JSON.stringify(s, null, 2)}
3918
+ `);
3871
3919
  } catch {
3872
3920
  }
3873
3921
  }
@@ -4039,7 +4087,7 @@ function removeHttpHooksSync(owner) {
4039
4087
  editSettingsSync(mutateRemove(owner));
4040
4088
  }
4041
4089
  function normalizePath(p) {
4042
- return path17.resolve(p).toLowerCase();
4090
+ return path18.resolve(p).toLowerCase();
4043
4091
  }
4044
4092
 
4045
4093
  // src/core/notifier.ts
@@ -5116,20 +5164,8 @@ var DETACH_KEY = "";
5116
5164
  var TAB_KEY = " ";
5117
5165
  var RENDER_INTERVAL_MS = 50;
5118
5166
  var MOUSE_SGR_RE = /\x1b\[<(\d+);(\d+);(\d+)[Mm]/;
5119
- function hasClaudeConversation(dir) {
5120
- try {
5121
- const resolved = path18.resolve(dir);
5122
- const projectDir = resolved.replace(/[^a-zA-Z0-9-]/g, "-");
5123
- const claudeProjectPath = path18.join(os6.homedir(), ".claude", "projects", projectDir);
5124
- if (!fs23.existsSync(claudeProjectPath)) return false;
5125
- const files = fs23.readdirSync(claudeProjectPath);
5126
- return files.some((f) => f.endsWith(".jsonl"));
5127
- } catch {
5128
- return false;
5129
- }
5130
- }
5131
5167
  function ptyDedupKey(pty2) {
5132
- return path18.resolve(pty2.cwd).toLowerCase();
5168
+ return path19.resolve(pty2.cwd).toLowerCase();
5133
5169
  }
5134
5170
  function loadSessions() {
5135
5171
  const all = loadHistory();
@@ -5429,10 +5465,10 @@ function App({ unsafe, onExit }) {
5429
5465
  }
5430
5466
  }, [setScrollBack, renderTermAtScroll]);
5431
5467
  const findPtyByCwd = useCallback((cwd) => {
5432
- const normalized = path18.resolve(cwd).toLowerCase();
5468
+ const normalized = path19.resolve(cwd).toLowerCase();
5433
5469
  for (const pty2 of ptySessions.current.values()) {
5434
5470
  if (pty2.exited) continue;
5435
- if (normalized.startsWith(path18.resolve(pty2.cwd).toLowerCase())) return pty2;
5471
+ if (normalized.startsWith(path19.resolve(pty2.cwd).toLowerCase())) return pty2;
5436
5472
  }
5437
5473
  return void 0;
5438
5474
  }, []);
@@ -5508,13 +5544,13 @@ function App({ unsafe, onExit }) {
5508
5544
  notifiedSessionsRef.current
5509
5545
  );
5510
5546
  if (kind) {
5511
- notifyDesktop(path18.basename(pty2.cwd), kind, {
5547
+ notifyDesktop(path19.basename(pty2.cwd), kind, {
5512
5548
  enabled: config?.notifications === true
5513
5549
  });
5514
5550
  runStatusHooks(
5515
5551
  kind,
5516
5552
  pty2.cwd,
5517
- path18.basename(pty2.cwd),
5553
+ path19.basename(pty2.cwd),
5518
5554
  config?.statusHooks
5519
5555
  );
5520
5556
  }
@@ -5647,7 +5683,7 @@ function App({ unsafe, onExit }) {
5647
5683
  refreshSessions();
5648
5684
  return;
5649
5685
  }
5650
- const dir = s.isGroup ? path18.dirname(existing) : existing;
5686
+ const dir = s.isGroup ? path19.dirname(existing) : existing;
5651
5687
  const resume = hasClaudeConversation(dir);
5652
5688
  const tool = getAiTool(config ?? {});
5653
5689
  const pty2 = new PtySession(dir, termInner, contentHeight - 2, void 0, { tool, unsafe, resume, port: s.port });
@@ -5745,7 +5781,7 @@ function App({ unsafe, onExit }) {
5745
5781
  "",
5746
5782
  " - Ask if I want to proceed with the recommended approach, choose a different one, get more details, or make adjustments."
5747
5783
  ].join("\n");
5748
- promptFile = path18.join(os6.tmpdir(), `work-prompt-${Date.now()}.txt`);
5784
+ promptFile = path19.join(os6.tmpdir(), `work-prompt-${Date.now()}.txt`);
5749
5785
  fs23.writeFileSync(promptFile, prompt, "utf-8");
5750
5786
  }
5751
5787
  const setupArgs = ["tree", projectName, branchName, "--setup-only"];
@@ -5785,7 +5821,7 @@ function App({ unsafe, onExit }) {
5785
5821
  setStatusVersion((v) => v + 1);
5786
5822
  return;
5787
5823
  }
5788
- const launchDir = session.isGroup ? path18.dirname(existing) : existing;
5824
+ const launchDir = session.isGroup ? path19.dirname(existing) : existing;
5789
5825
  const tool = getAiTool(config);
5790
5826
  const aiPty = new PtySession(
5791
5827
  launchDir,
@@ -6360,7 +6396,7 @@ function App({ unsafe, onExit }) {
6360
6396
  setMessage("Session path no longer exists");
6361
6397
  return;
6362
6398
  }
6363
- const dir = s.isGroup ? path18.dirname(existing) : existing;
6399
+ const dir = s.isGroup ? path19.dirname(existing) : existing;
6364
6400
  const editor = config?.editor ?? "code";
6365
6401
  spawn7(editor, [dir], { detached: true, stdio: "ignore" }).unref();
6366
6402
  setMessage(`Opened in ${editor}: ${s.branch}`);
@@ -6545,7 +6581,7 @@ function crashLog(label2, err) {
6545
6581
  const msg = err instanceof Error ? err.stack || err.message : String(err);
6546
6582
  const line = `${(/* @__PURE__ */ new Date()).toISOString()} [CRASH] ${label2}: ${msg}
6547
6583
  `;
6548
- fs24.appendFileSync(path19.join(getConfigDir(), "debug.log"), line);
6584
+ fs24.appendFileSync(path20.join(getConfigDir(), "debug.log"), line);
6549
6585
  } catch {
6550
6586
  }
6551
6587
  }
@@ -6869,22 +6905,22 @@ import chalk17 from "chalk";
6869
6905
 
6870
6906
  // src/core/hydrate.ts
6871
6907
  import fs25 from "fs";
6872
- import path20 from "path";
6908
+ import path21 from "path";
6873
6909
  async function hydrateHistoryFromDisk(config) {
6874
- const worktreesRoot = path20.resolve(config.worktreesRoot);
6910
+ const worktreesRoot = path21.resolve(config.worktreesRoot);
6875
6911
  const folderNameToAlias = /* @__PURE__ */ new Map();
6876
6912
  for (const [alias, repoPath] of Object.entries(config.repos)) {
6877
- folderNameToAlias.set(path20.basename(repoPath), alias);
6913
+ folderNameToAlias.set(path21.basename(repoPath), alias);
6878
6914
  }
6879
6915
  const discovered = /* @__PURE__ */ new Map();
6880
6916
  for (const [alias, repoPath] of Object.entries(config.repos)) {
6881
6917
  if (!fs25.existsSync(repoPath)) continue;
6882
6918
  for (const entry of parseWorktreeList(repoPath)) {
6883
6919
  if (!entry.branch) continue;
6884
- if (path20.resolve(entry.path) === path20.resolve(repoPath)) continue;
6885
- const rel = path20.relative(worktreesRoot, entry.path);
6886
- if (!rel || rel.startsWith("..") || path20.isAbsolute(rel)) continue;
6887
- const parts = rel.split(path20.sep).filter(Boolean);
6920
+ if (path21.resolve(entry.path) === path21.resolve(repoPath)) continue;
6921
+ const rel = path21.relative(worktreesRoot, entry.path);
6922
+ if (!rel || rel.startsWith("..") || path21.isAbsolute(rel)) continue;
6923
+ const parts = rel.split(path21.sep).filter(Boolean);
6888
6924
  if (parts.length < 2) continue;
6889
6925
  const [first, second] = parts;
6890
6926
  const isGroup = Object.prototype.hasOwnProperty.call(config.groups, first);
@@ -6969,13 +7005,13 @@ var hydrateCommand = {
6969
7005
  // src/commands/diff.ts
6970
7006
  import fs36 from "fs";
6971
7007
  import os9 from "os";
6972
- import path31 from "path";
7008
+ import path32 from "path";
6973
7009
  import { spawn as childSpawn } from "child_process";
6974
7010
  import chalk21 from "chalk";
6975
7011
 
6976
7012
  // src/core/diff-pipeline.ts
6977
7013
  import fs28 from "fs";
6978
- import path23 from "path";
7014
+ import path24 from "path";
6979
7015
  import spawn9 from "cross-spawn";
6980
7016
 
6981
7017
  // src/core/diff-parse.ts
@@ -7124,7 +7160,7 @@ function stripPathPrefix(p) {
7124
7160
 
7125
7161
  // src/core/lcov.ts
7126
7162
  import fs26 from "fs";
7127
- import path21 from "path";
7163
+ import path22 from "path";
7128
7164
  function parseLcov(content) {
7129
7165
  const result = /* @__PURE__ */ new Map();
7130
7166
  let sf = null;
@@ -7183,8 +7219,8 @@ function parseLcov(content) {
7183
7219
  }
7184
7220
  function findLcov(root) {
7185
7221
  const candidates = [
7186
- path21.join(root, "coverage", "lcov.info"),
7187
- path21.join(root, "lcov.info")
7222
+ path22.join(root, "coverage", "lcov.info"),
7223
+ path22.join(root, "lcov.info")
7188
7224
  ];
7189
7225
  for (const c of candidates) {
7190
7226
  try {
@@ -7219,33 +7255,33 @@ function readParsedLcov(lcovPath) {
7219
7255
  return { parsed, mtimeMs };
7220
7256
  }
7221
7257
  function normRel(p) {
7222
- return path21.normalize(p).replace(/\\/g, "/").replace(/^\.\//, "");
7258
+ return path22.normalize(p).replace(/\\/g, "/").replace(/^\.\//, "");
7223
7259
  }
7224
7260
  function realRoot(root) {
7225
7261
  try {
7226
- return fs26.realpathSync(path21.resolve(root));
7262
+ return fs26.realpathSync(path22.resolve(root));
7227
7263
  } catch {
7228
- return path21.resolve(root);
7264
+ return path22.resolve(root);
7229
7265
  }
7230
7266
  }
7231
7267
  function canonicalize(absPath) {
7232
- const resolved = path21.resolve(absPath);
7268
+ const resolved = path22.resolve(absPath);
7233
7269
  let dir = resolved;
7234
7270
  const tail = [];
7235
7271
  for (; ; ) {
7236
7272
  try {
7237
7273
  const realDir = fs26.realpathSync(dir);
7238
- return tail.length ? path21.join(realDir, ...tail.reverse()) : realDir;
7274
+ return tail.length ? path22.join(realDir, ...tail.reverse()) : realDir;
7239
7275
  } catch {
7240
- const parent = path21.dirname(dir);
7276
+ const parent = path22.dirname(dir);
7241
7277
  if (parent === dir) return resolved;
7242
- tail.push(path21.basename(dir));
7278
+ tail.push(path22.basename(dir));
7243
7279
  dir = parent;
7244
7280
  }
7245
7281
  }
7246
7282
  }
7247
7283
  function relForAbsSf(absSf, canonRoot) {
7248
- return path21.relative(canonRoot, canonicalize(absSf));
7284
+ return path22.relative(canonRoot, canonicalize(absSf));
7249
7285
  }
7250
7286
  function coverageLookup(root, relPaths) {
7251
7287
  const out = /* @__PURE__ */ new Map();
@@ -7258,7 +7294,7 @@ function coverageLookup(root, relPaths) {
7258
7294
  const canonRoot = realRoot(root);
7259
7295
  const byRel = /* @__PURE__ */ new Map();
7260
7296
  for (const [sf, pct] of read.parsed) {
7261
- const rel = path21.isAbsolute(sf) ? relForAbsSf(sf, canonRoot) : sf;
7297
+ const rel = path22.isAbsolute(sf) ? relForAbsSf(sf, canonRoot) : sf;
7262
7298
  byRel.set(normRel(rel), pct);
7263
7299
  }
7264
7300
  for (const rp of relPaths) {
@@ -7271,12 +7307,12 @@ function coverageLookup(root, relPaths) {
7271
7307
  // src/core/git-tree-snapshot.ts
7272
7308
  import fs27 from "fs";
7273
7309
  import os7 from "os";
7274
- import path22 from "path";
7310
+ import path23 from "path";
7275
7311
  import crypto from "crypto";
7276
7312
  import spawn8 from "cross-spawn";
7277
7313
  function writeTempTree(repoRoot, opts = {}) {
7278
7314
  const includeWorkingTree = opts.includeWorkingTree ?? true;
7279
- const tmpIndex = path22.join(
7315
+ const tmpIndex = path23.join(
7280
7316
  os7.tmpdir(),
7281
7317
  `wd-tree-${process.pid}-${crypto.randomBytes(6).toString("hex")}.idx`
7282
7318
  );
@@ -7288,13 +7324,45 @@ function writeTempTree(repoRoot, opts = {}) {
7288
7324
  windowsHide: true,
7289
7325
  maxBuffer: 64 * 1024 * 1024
7290
7326
  });
7327
+ const seedFromRealIndex = () => {
7328
+ try {
7329
+ const out = spawn8.sync("git", ["rev-parse", "--git-path", "index"], {
7330
+ cwd: repoRoot,
7331
+ encoding: "utf-8",
7332
+ windowsHide: true
7333
+ }).stdout;
7334
+ if (!out) return false;
7335
+ const realIndex = path23.resolve(repoRoot, out.trim());
7336
+ if (!fs27.existsSync(realIndex)) return false;
7337
+ fs27.copyFileSync(realIndex, tmpIndex);
7338
+ const st = fs27.statSync(realIndex);
7339
+ fs27.utimesSync(tmpIndex, st.atime, st.mtime);
7340
+ const listed = run2(["ls-files", "-v"]);
7341
+ if (listed.status !== 0) {
7342
+ fs27.unlinkSync(tmpIndex);
7343
+ return false;
7344
+ }
7345
+ const flagged = (listed.stdout ?? "").split("\n").some((line) => {
7346
+ const tag2 = line.charAt(0);
7347
+ return tag2 === "S" || tag2 >= "a" && tag2 <= "z";
7348
+ });
7349
+ if (flagged) {
7350
+ fs27.unlinkSync(tmpIndex);
7351
+ return false;
7352
+ }
7353
+ return true;
7354
+ } catch {
7355
+ return false;
7356
+ }
7357
+ };
7291
7358
  try {
7292
7359
  const headSha = (spawn8.sync("git", ["rev-parse", "--verify", "HEAD"], {
7293
7360
  cwd: repoRoot,
7294
7361
  encoding: "utf-8",
7295
7362
  windowsHide: true
7296
7363
  }).stdout ?? "").trim() || null;
7297
- if (headSha) {
7364
+ const seeded = includeWorkingTree && seedFromRealIndex();
7365
+ if (!seeded && headSha) {
7298
7366
  const r = run2(["read-tree", "HEAD"]);
7299
7367
  if (r.status !== 0) return null;
7300
7368
  }
@@ -7321,12 +7389,12 @@ function isMarkdownPath(p) {
7321
7389
  return p !== "/dev/null" && MARKDOWN_EXT_RE.test(p);
7322
7390
  }
7323
7391
  function isInsideRoot(root, rel) {
7324
- const resolvedRoot = path23.resolve(root);
7325
- const resolvedTarget = path23.resolve(resolvedRoot, rel);
7326
- const r = path23.relative(resolvedRoot, resolvedTarget);
7392
+ const resolvedRoot = path24.resolve(root);
7393
+ const resolvedTarget = path24.resolve(resolvedRoot, rel);
7394
+ const r = path24.relative(resolvedRoot, resolvedTarget);
7327
7395
  if (r === "") return true;
7328
7396
  if (r.startsWith("..")) return false;
7329
- if (path23.isAbsolute(r)) return false;
7397
+ if (path24.isAbsolute(r)) return false;
7330
7398
  return true;
7331
7399
  }
7332
7400
  function readMarkdownContent(root, file, fromRef, toRef) {
@@ -7351,10 +7419,10 @@ function readMarkdownContent(root, file, fromRef, toRef) {
7351
7419
  if (file.status !== "deleted" && isMarkdownPath(file.newPath) && isInsideRoot(root, file.newPath)) {
7352
7420
  if (toRef === "working") {
7353
7421
  try {
7354
- const absPath = path23.join(root, file.newPath);
7355
- const realRoot2 = fs28.realpathSync(path23.resolve(root));
7422
+ const absPath = path24.join(root, file.newPath);
7423
+ const realRoot2 = fs28.realpathSync(path24.resolve(root));
7356
7424
  const realPath = fs28.realpathSync(absPath);
7357
- const sep = path23.sep;
7425
+ const sep = path24.sep;
7358
7426
  if (realPath === realRoot2 || realPath.startsWith(realRoot2 + sep)) {
7359
7427
  result.after = fs28.readFileSync(absPath, "utf-8");
7360
7428
  }
@@ -7384,7 +7452,7 @@ function isBinaryContent(buffer) {
7384
7452
  return false;
7385
7453
  }
7386
7454
  function synthesizeUntrackedDiff(root, relPath) {
7387
- const absPath = path23.join(root, relPath);
7455
+ const absPath = path24.join(root, relPath);
7388
7456
  let buffer;
7389
7457
  try {
7390
7458
  buffer = fs28.readFileSync(absPath);
@@ -7475,7 +7543,7 @@ function attachCoverage(root, files) {
7475
7543
  f.coverageMtimeMs = lcovMtimeMs;
7476
7544
  let srcMtimeMs = null;
7477
7545
  try {
7478
- srcMtimeMs = fs28.statSync(path23.join(root, f.path)).mtimeMs;
7546
+ srcMtimeMs = fs28.statSync(path24.join(root, f.path)).mtimeMs;
7479
7547
  } catch {
7480
7548
  srcMtimeMs = null;
7481
7549
  }
@@ -7543,7 +7611,7 @@ function computeRangeDiff(opts) {
7543
7611
 
7544
7612
  // src/core/repo-spec.ts
7545
7613
  import fs29 from "fs";
7546
- import path24 from "path";
7614
+ import path25 from "path";
7547
7615
  import os8 from "os";
7548
7616
  import crypto2 from "crypto";
7549
7617
  function scopeHashFor(keyPaths) {
@@ -7551,17 +7619,17 @@ function scopeHashFor(keyPaths) {
7551
7619
  return crypto2.createHash("sha1").update(key).digest("hex").slice(0, 12);
7552
7620
  }
7553
7621
  function stableDiffPath(keyPaths) {
7554
- const dir = path24.join(os8.homedir(), ".work", "diffs");
7622
+ const dir = path25.join(os8.homedir(), ".work", "diffs");
7555
7623
  fs29.mkdirSync(dir, { recursive: true });
7556
- return path24.join(dir, scopeHashFor(keyPaths));
7624
+ return path25.join(dir, scopeHashFor(keyPaths));
7557
7625
  }
7558
7626
 
7559
7627
  // src/core/diff-scope.ts
7560
7628
  import fs30 from "fs";
7561
- import path25 from "path";
7629
+ import path26 from "path";
7562
7630
  import chalk18 from "chalk";
7563
7631
  function normPath(p) {
7564
- return path25.resolve(p).replace(/\\/g, "/").toLowerCase();
7632
+ return path26.resolve(p).replace(/\\/g, "/").toLowerCase();
7565
7633
  }
7566
7634
  function realNorm(p) {
7567
7635
  try {
@@ -7585,29 +7653,29 @@ function resolveScope(cwd) {
7585
7653
  return {
7586
7654
  isGroup: true,
7587
7655
  session: s,
7588
- repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7589
- activeRepoName: path25.basename(p)
7656
+ repos: s.paths.map((rp) => ({ name: path26.basename(rp), root: rp })),
7657
+ activeRepoName: path26.basename(p)
7590
7658
  };
7591
7659
  }
7592
7660
  return {
7593
7661
  isGroup: false,
7594
7662
  session: s,
7595
- repos: [{ name: path25.basename(p), root: p }],
7596
- activeRepoName: path25.basename(p)
7663
+ repos: [{ name: path26.basename(p), root: p }],
7664
+ activeRepoName: path26.basename(p)
7597
7665
  };
7598
7666
  }
7599
7667
  }
7600
7668
  }
7601
7669
  for (const s of sessions) {
7602
7670
  if (!s.isGroup || s.paths.length === 0) continue;
7603
- const parents = s.paths.map((p) => normPath(path25.dirname(p)));
7671
+ const parents = s.paths.map((p) => normPath(path26.dirname(p)));
7604
7672
  const groupRoot = parents[0];
7605
7673
  if (!parents.every((par) => par === groupRoot)) continue;
7606
7674
  if (normCwd === groupRoot || normCwd.startsWith(groupRoot + "/")) {
7607
7675
  return {
7608
7676
  isGroup: true,
7609
7677
  session: s,
7610
- repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7678
+ repos: s.paths.map((rp) => ({ name: path26.basename(rp), root: rp })),
7611
7679
  activeRepoName: null
7612
7680
  };
7613
7681
  }
@@ -7616,8 +7684,8 @@ function resolveScope(cwd) {
7616
7684
  return {
7617
7685
  isGroup: false,
7618
7686
  session: null,
7619
- repos: [{ name: path25.basename(toplevel), root: toplevel }],
7620
- activeRepoName: path25.basename(toplevel)
7687
+ repos: [{ name: path26.basename(toplevel), root: toplevel }],
7688
+ activeRepoName: path26.basename(toplevel)
7621
7689
  };
7622
7690
  }
7623
7691
  function findAnyParentBranch(cwd) {
@@ -7801,7 +7869,7 @@ import { streamSSE } from "hono/streaming";
7801
7869
 
7802
7870
  // src/core/file-context.ts
7803
7871
  import fs31 from "fs";
7804
- import path26 from "path";
7872
+ import path27 from "path";
7805
7873
  import spawn10 from "cross-spawn";
7806
7874
  function readContextLines(opts) {
7807
7875
  const { root, relPath, ref } = opts;
@@ -7823,10 +7891,10 @@ function readContextLines(opts) {
7823
7891
  }
7824
7892
  function readWorkingTree(root, relPath) {
7825
7893
  try {
7826
- const absPath = path26.join(root, relPath);
7827
- const realRoot2 = fs31.realpathSync(path26.resolve(root));
7894
+ const absPath = path27.join(root, relPath);
7895
+ const realRoot2 = fs31.realpathSync(path27.resolve(root));
7828
7896
  const realPath = fs31.realpathSync(absPath);
7829
- const sep = path26.sep;
7897
+ const sep = path27.sep;
7830
7898
  if (realPath !== realRoot2 && !realPath.startsWith(realRoot2 + sep)) {
7831
7899
  return null;
7832
7900
  }
@@ -7848,7 +7916,7 @@ function readAtRef(root, ref, relPath) {
7848
7916
 
7849
7917
  // src/core/fs-watcher.ts
7850
7918
  import fs32 from "fs";
7851
- import path27 from "path";
7919
+ import path28 from "path";
7852
7920
  import chalk19 from "chalk";
7853
7921
  import chokidar from "chokidar";
7854
7922
  var IGNORED_DIRS = /* @__PURE__ */ new Set([
@@ -7874,7 +7942,7 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
7874
7942
  ]);
7875
7943
  function isIgnoredWatchPath(roots, filePath) {
7876
7944
  for (const root of roots) {
7877
- const rel = path27.relative(root, filePath).replace(/\\/g, "/");
7945
+ const rel = path28.relative(root, filePath).replace(/\\/g, "/");
7878
7946
  if (rel === "" || rel.startsWith("../")) continue;
7879
7947
  if (rel.split("/").some((seg) => IGNORED_DIRS.has(seg))) return true;
7880
7948
  }
@@ -7899,7 +7967,7 @@ function createFsWatcher(opts) {
7899
7967
  if (SUPPORTS_RECURSIVE_WATCH) {
7900
7968
  const watchers = opts.roots.map((root) => {
7901
7969
  const w = fs32.watch(root, { recursive: true }, (_event, filename) => {
7902
- if (filename && isIgnoredWatchPath([root], path27.join(root, filename.toString()))) {
7970
+ if (filename && isIgnoredWatchPath([root], path28.join(root, filename.toString()))) {
7903
7971
  return;
7904
7972
  }
7905
7973
  fire();
@@ -7938,29 +8006,29 @@ function createFsWatcher(opts) {
7938
8006
 
7939
8007
  // src/core/web-static.ts
7940
8008
  import fs33 from "fs";
7941
- import path28 from "path";
8009
+ import path29 from "path";
7942
8010
  import { fileURLToPath } from "url";
7943
8011
  function resolveWebRoot() {
7944
- const entryDir = path28.dirname(process.argv[1] ?? "");
7945
- const moduleDir = path28.dirname(fileURLToPath(import.meta.url));
8012
+ const entryDir = path29.dirname(process.argv[1] ?? "");
8013
+ const moduleDir = path29.dirname(fileURLToPath(import.meta.url));
7946
8014
  const candidates = [
7947
- path28.join(entryDir, "web"),
8015
+ path29.join(entryDir, "web"),
7948
8016
  // bundled: this module is inlined into dist/<bin>.js, so dist/web is a
7949
8017
  // sibling of the bundle. Works even when argv[1] is an npm bin symlink
7950
8018
  // (which is not realpath'd, so the entryDir candidate above misses).
7951
- path28.join(moduleDir, "web"),
8019
+ path29.join(moduleDir, "web"),
7952
8020
  // dev/tsx fallback: walk up from src/core to repo root then into dist/web.
7953
- path28.resolve(moduleDir, "../../dist/web")
8021
+ path29.resolve(moduleDir, "../../dist/web")
7954
8022
  ];
7955
8023
  for (const c of candidates) {
7956
- if (fs33.existsSync(path28.join(c, "index.html"))) return c;
8024
+ if (fs33.existsSync(path29.join(c, "index.html"))) return c;
7957
8025
  }
7958
8026
  return null;
7959
8027
  }
7960
8028
 
7961
8029
  // src/core/spa-handler.ts
7962
8030
  import fs34 from "fs";
7963
- import path29 from "path";
8031
+ import path30 from "path";
7964
8032
  var MIME = {
7965
8033
  ".html": "text/html; charset=utf-8",
7966
8034
  ".js": "application/javascript; charset=utf-8",
@@ -7974,9 +8042,9 @@ var MIME = {
7974
8042
  function readFile(root, relPath) {
7975
8043
  const clean = relPath.split("?")[0];
7976
8044
  const requested = clean === "/" ? "/index.html" : clean;
7977
- const filePath = path29.join(root, requested);
7978
- const norm = path29.normalize(filePath);
7979
- if (!norm.startsWith(path29.normalize(root))) return null;
8045
+ const filePath = path30.join(root, requested);
8046
+ const norm = path30.normalize(filePath);
8047
+ if (!norm.startsWith(path30.normalize(root))) return null;
7980
8048
  let stat;
7981
8049
  try {
7982
8050
  stat = fs34.statSync(norm);
@@ -7984,7 +8052,7 @@ function readFile(root, relPath) {
7984
8052
  return null;
7985
8053
  }
7986
8054
  if (!stat.isFile()) return null;
7987
- const ext = path29.extname(norm).toLowerCase();
8055
+ const ext = path30.extname(norm).toLowerCase();
7988
8056
  return { body: fs34.readFileSync(norm), ext };
7989
8057
  }
7990
8058
  function serveSpa(c, webRoot) {
@@ -8294,7 +8362,7 @@ function diffReviewSnapshot(snapshot, seen) {
8294
8362
 
8295
8363
  // src/core/static-renderer.ts
8296
8364
  import fs35 from "fs";
8297
- import path30 from "path";
8365
+ import path31 from "path";
8298
8366
  function buildDiff(specs, resolvedBase) {
8299
8367
  return {
8300
8368
  repos: specs.map((r) => ({
@@ -8310,7 +8378,7 @@ function renderStatic(opts) {
8310
8378
  if (!webRoot) {
8311
8379
  throw new Error("Could not find dist/web/. Run `npm run build` first.");
8312
8380
  }
8313
- const shellPath = path30.join(webRoot, "index.html");
8381
+ const shellPath = path31.join(webRoot, "index.html");
8314
8382
  let shell = fs35.readFileSync(shellPath, "utf-8");
8315
8383
  const uncommitted = buildDiff(opts.uncommitted, "HEAD");
8316
8384
  const branch = opts.branch ? buildDiff(opts.branch.specs, opts.branch.resolvedBase) : void 0;
@@ -8360,8 +8428,8 @@ function escapeForScriptTag(json) {
8360
8428
  }
8361
8429
  function readAsset(webRoot, urlPath) {
8362
8430
  const clean = urlPath.split("?")[0].replace(/^\//, "");
8363
- const full = path30.join(webRoot, clean);
8364
- if (!path30.normalize(full).startsWith(path30.normalize(webRoot))) return null;
8431
+ const full = path31.join(webRoot, clean);
8432
+ if (!path31.normalize(full).startsWith(path31.normalize(webRoot))) return null;
8365
8433
  try {
8366
8434
  return fs35.readFileSync(full, "utf-8");
8367
8435
  } catch {
@@ -8404,7 +8472,7 @@ async function runStop(repoSpecs) {
8404
8472
  }
8405
8473
  }
8406
8474
  function webUrlFilePath() {
8407
- return path31.join(os9.homedir(), ".work", "web.url");
8475
+ return path32.join(os9.homedir(), ".work", "web.url");
8408
8476
  }
8409
8477
  function resolveWorkBinPath(selfArgv1) {
8410
8478
  let real = selfArgv1;
@@ -8413,7 +8481,7 @@ function resolveWorkBinPath(selfArgv1) {
8413
8481
  } catch {
8414
8482
  }
8415
8483
  if (real.endsWith("wd-bin.js")) {
8416
- return path31.join(path31.dirname(real), "bin.js");
8484
+ return path32.join(path32.dirname(real), "bin.js");
8417
8485
  }
8418
8486
  return real;
8419
8487
  }
@@ -8450,7 +8518,7 @@ async function ensureWorkWebRunning() {
8450
8518
  }
8451
8519
  const workBin = resolveWorkBinPath(process.argv[1]);
8452
8520
  const out = fs36.openSync(
8453
- path31.join(os9.homedir(), ".work", "web-autostart.log"),
8521
+ path32.join(os9.homedir(), ".work", "web-autostart.log"),
8454
8522
  "a"
8455
8523
  );
8456
8524
  const child = childSpawn(
@@ -8792,19 +8860,19 @@ var diffCommand = {
8792
8860
  // src/commands/web.ts
8793
8861
  import fs41 from "fs";
8794
8862
  import os13 from "os";
8795
- import path41 from "path";
8863
+ import path42 from "path";
8796
8864
  import chalk23 from "chalk";
8797
8865
 
8798
8866
  // src/core/web-server.ts
8799
8867
  import fs40 from "fs";
8800
8868
  import os12 from "os";
8801
- import path40 from "path";
8869
+ import path41 from "path";
8802
8870
  import chalk22 from "chalk";
8803
8871
  import { Hono as Hono3 } from "hono";
8804
8872
  import { streamSSE as streamSSE3 } from "hono/streaming";
8805
8873
 
8806
8874
  // src/core/web-state.ts
8807
- import path32 from "path";
8875
+ import path33 from "path";
8808
8876
  import crypto4 from "crypto";
8809
8877
  import chokidar2 from "chokidar";
8810
8878
  function sessionIdFor(s) {
@@ -8825,7 +8893,7 @@ function subscribeSession(sessionId, onChange) {
8825
8893
  const watcher = chokidar2.watch(roots, {
8826
8894
  ignored: (filePath) => {
8827
8895
  for (const r of roots) {
8828
- const rel = path32.relative(r, filePath).replace(/\\/g, "/");
8896
+ const rel = path33.relative(r, filePath).replace(/\\/g, "/");
8829
8897
  if (rel === ".git" || rel.startsWith(".git/")) return true;
8830
8898
  }
8831
8899
  return false;
@@ -8940,16 +9008,16 @@ function disposeAllPtys() {
8940
9008
 
8941
9009
  // src/core/comment-file-store.ts
8942
9010
  import fs37 from "fs";
8943
- import path33 from "path";
9011
+ import path34 from "path";
8944
9012
  import os10 from "os";
8945
9013
  function commentsDir() {
8946
- return path33.join(os10.homedir(), ".work", "comments");
9014
+ return path34.join(os10.homedir(), ".work", "comments");
8947
9015
  }
8948
9016
  function ensureDir() {
8949
9017
  fs37.mkdirSync(commentsDir(), { recursive: true });
8950
9018
  }
8951
9019
  function commentsFileFor(sessionId) {
8952
- return path33.join(commentsDir(), `${sessionId}.json`);
9020
+ return path34.join(commentsDir(), `${sessionId}.json`);
8953
9021
  }
8954
9022
  function pathFor(sessionId) {
8955
9023
  return commentsFileFor(sessionId);
@@ -9043,11 +9111,11 @@ function clearCommentStoreCache() {
9043
9111
 
9044
9112
  // src/core/pending-delivery.ts
9045
9113
  import fs38 from "fs";
9046
- import path34 from "path";
9114
+ import path35 from "path";
9047
9115
  function pathFor2(sessionId) {
9048
9116
  return {
9049
9117
  comments: commentsFileFor(sessionId),
9050
- delivered: path34.join(commentsDir(), `${sessionId}.delivered.json`)
9118
+ delivered: path35.join(commentsDir(), `${sessionId}.delivered.json`)
9051
9119
  };
9052
9120
  }
9053
9121
  function readJson(filePath, fallback) {
@@ -9058,13 +9126,11 @@ function readJson(filePath, fallback) {
9058
9126
  }
9059
9127
  }
9060
9128
  function writeAtomic2(filePath, content) {
9061
- fs38.mkdirSync(path34.dirname(filePath), { recursive: true });
9062
- const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
9063
- fs38.writeFileSync(tmp, content, "utf-8");
9064
- fs38.renameSync(tmp, filePath);
9129
+ fs38.mkdirSync(path35.dirname(filePath), { recursive: true });
9130
+ atomicWriteFile(filePath, content);
9065
9131
  }
9066
9132
  function normalize(p) {
9067
- return path34.resolve(p).replace(/\\/g, "/").toLowerCase();
9133
+ return path35.resolve(p).replace(/\\/g, "/").toLowerCase();
9068
9134
  }
9069
9135
  function findSessionForCwd(cwd) {
9070
9136
  const norm = normalize(cwd);
@@ -9095,7 +9161,7 @@ function readPendingForSession(sessionId) {
9095
9161
  return comments.filter(isPendingFor(delivered));
9096
9162
  }
9097
9163
  function scopeStoreIdsForPaths(paths) {
9098
- const resolved = paths.map((p) => path34.resolve(p));
9164
+ const resolved = paths.map((p) => path35.resolve(p));
9099
9165
  const ids = /* @__PURE__ */ new Set();
9100
9166
  ids.add(`scope-${scopeHashFor(resolved)}`);
9101
9167
  for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);
@@ -9433,7 +9499,7 @@ function mountPanesRoutes(app, opts) {
9433
9499
  }
9434
9500
 
9435
9501
  // src/core/worktree-routes.ts
9436
- import path35 from "path";
9502
+ import path36 from "path";
9437
9503
  import { spawn as spawn11 } from "child_process";
9438
9504
  import { zValidator as zValidator4 } from "@hono/zod-validator";
9439
9505
  import { z as z3 } from "zod";
@@ -9557,7 +9623,7 @@ function mountWorktreeRoutes(app, opts) {
9557
9623
  const id = c.req.param("id");
9558
9624
  const session = findSession2(id);
9559
9625
  if (!session) return c.json({ error: "unknown session" }, 404);
9560
- const target = session.isGroup ? path35.dirname(session.paths[0]) : session.paths[0];
9626
+ const target = session.isGroup ? path36.dirname(session.paths[0]) : session.paths[0];
9561
9627
  try {
9562
9628
  const cmd = process.platform === "win32" ? "code.cmd" : "code";
9563
9629
  const child = spawn11(cmd, [target], {
@@ -9577,18 +9643,18 @@ function mountWorktreeRoutes(app, opts) {
9577
9643
  import { zValidator as zValidator5 } from "@hono/zod-validator";
9578
9644
  import { z as z4 } from "zod";
9579
9645
  import { EventEmitter } from "events";
9580
- import path39 from "path";
9646
+ import path40 from "path";
9581
9647
  import spawn14 from "cross-spawn";
9582
9648
 
9583
9649
  // src/core/checkpoint.ts
9584
9650
  import fs39 from "fs";
9585
9651
  import os11 from "os";
9586
- import path36 from "path";
9652
+ import path37 from "path";
9587
9653
  import spawn12 from "cross-spawn";
9588
9654
  function manifestPath(scopeHash) {
9589
- const dir = path36.join(os11.homedir(), ".work", "diffs");
9655
+ const dir = path37.join(os11.homedir(), ".work", "diffs");
9590
9656
  fs39.mkdirSync(dir, { recursive: true });
9591
- return path36.join(dir, `${scopeHash}.checkpoints.json`);
9657
+ return path37.join(dir, `${scopeHash}.checkpoints.json`);
9592
9658
  }
9593
9659
  function emptyManifest(scopeHash) {
9594
9660
  return { version: 1, scopeHash, entries: [] };
@@ -9864,7 +9930,7 @@ function clearCheckpoints(scopeHash, repoRoots) {
9864
9930
 
9865
9931
  // src/core/checkpoint-summary.ts
9866
9932
  import spawn13 from "cross-spawn";
9867
- import path37 from "path";
9933
+ import path38 from "path";
9868
9934
  var MAX_DIFF_CHARS = 6e3;
9869
9935
  var MAX_LABEL_CHARS = 80;
9870
9936
  function buildDelta(scopeHash, repos, id) {
@@ -9917,7 +9983,7 @@ function buildDelta(scopeHash, repos, id) {
9917
9983
  function heuristicLabel(files, added, deleted) {
9918
9984
  if (files.length === 0) return "no changes";
9919
9985
  if (files.length === 1) {
9920
- return `${path37.basename(files[0].path)} +${added} \u2212${deleted}`;
9986
+ return `${path38.basename(files[0].path)} +${added} \u2212${deleted}`;
9921
9987
  }
9922
9988
  return `${files.length} files \xB7 +${added} \u2212${deleted}`;
9923
9989
  }
@@ -9988,7 +10054,7 @@ async function summarizeCheckpoint(scopeHash, repos, id) {
9988
10054
  }
9989
10055
 
9990
10056
  // src/core/scope-manager.ts
9991
- import path38 from "path";
10057
+ import path39 from "path";
9992
10058
  import crypto5 from "crypto";
9993
10059
  var scopes = /* @__PURE__ */ new Map();
9994
10060
  function hashFor(paths) {
@@ -10005,7 +10071,7 @@ var ScopePathRejectedError = class extends Error {
10005
10071
  }
10006
10072
  };
10007
10073
  function normaliseForCompare(p) {
10008
- return path38.resolve(p).replace(/\\/g, "/").toLowerCase();
10074
+ return path39.resolve(p).replace(/\\/g, "/").toLowerCase();
10009
10075
  }
10010
10076
  function rejectedPaths(normalised) {
10011
10077
  const config = loadConfig();
@@ -10023,7 +10089,7 @@ function rejectedPaths(normalised) {
10023
10089
  });
10024
10090
  }
10025
10091
  function registerScope(paths, label2) {
10026
- const normalised = paths.map((p) => path38.resolve(p));
10092
+ const normalised = paths.map((p) => path39.resolve(p));
10027
10093
  const rejected = rejectedPaths(normalised);
10028
10094
  if (rejected.length > 0) throw new ScopePathRejectedError(rejected);
10029
10095
  const hash = hashFor(normalised);
@@ -10037,7 +10103,7 @@ function registerScope(paths, label2) {
10037
10103
  const scope = {
10038
10104
  hash,
10039
10105
  paths: normalised,
10040
- label: label2 ?? path38.basename(normalised[0]),
10106
+ label: label2 ?? path39.basename(normalised[0]),
10041
10107
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
10042
10108
  ended: false
10043
10109
  };
@@ -10387,7 +10453,7 @@ function mountScopeRoutes(app, opts) {
10387
10453
  const fromSha = fromEntry.repos[p] ?? "HEAD";
10388
10454
  const toSha = toEntry === void 0 ? "working" : toEntry.repos[p] ?? "HEAD";
10389
10455
  return {
10390
- name: path39.basename(p),
10456
+ name: path40.basename(p),
10391
10457
  root: p,
10392
10458
  files: computeRangeDiff({ root: p, fromRef: fromSha, toRef: toSha })
10393
10459
  };
@@ -10406,7 +10472,7 @@ function mountScopeRoutes(app, opts) {
10406
10472
  (p) => resolveRepoDiff(p, base, sessionBaseForPath(p))
10407
10473
  );
10408
10474
  const repos = scope.paths.map((p, i) => ({
10409
- name: path39.basename(p),
10475
+ name: path40.basename(p),
10410
10476
  root: p,
10411
10477
  resolvedBase: resolved[i].resolvedBase,
10412
10478
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -10437,7 +10503,7 @@ function mountScopeRoutes(app, opts) {
10437
10503
  if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {
10438
10504
  return c.json({ error: "bad path/start/end" }, 400);
10439
10505
  }
10440
- const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path39.basename(p) === repoName);
10506
+ const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path40.basename(p) === repoName);
10441
10507
  if (!root) return c.json({ error: "unknown repo" }, 404);
10442
10508
  const result = readContextLines({ root, relPath, start, end, ref });
10443
10509
  if (!result) return c.json({ error: "cannot read file" }, 400);
@@ -10733,7 +10799,7 @@ function computeSessionDiff(s, base) {
10733
10799
  (p) => resolveRepoDiff(p, base, s.baseBranches?.[p] ?? s.baseBranch)
10734
10800
  );
10735
10801
  const repos = s.paths.map((p, i) => ({
10736
- name: path40.basename(p),
10802
+ name: path41.basename(p),
10737
10803
  root: p,
10738
10804
  resolvedBase: resolved[i].resolvedBase,
10739
10805
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -10753,10 +10819,10 @@ async function startWebServer(opts = {}) {
10753
10819
  for (const cb of sseListeners) cb({ event, data });
10754
10820
  };
10755
10821
  const home = os12.homedir();
10756
- const historyPath = path40.join(home, ".work", "history.json");
10822
+ const historyPath = path41.join(home, ".work", "history.json");
10757
10823
  const onHistoryChange = () => broadcast("sessions-changed", { ts: Date.now() });
10758
10824
  fs40.watchFile(historyPath, { interval: 1e3 }, onHistoryChange);
10759
- const tasksPath = path40.join(home, ".work", "tasks.json");
10825
+ const tasksPath = path41.join(home, ".work", "tasks.json");
10760
10826
  const onTasksChange = () => broadcast("tasks-changed", { ts: Date.now() });
10761
10827
  fs40.watchFile(tasksPath, { interval: 1e3 }, onTasksChange);
10762
10828
  const projectsRoot = claudeProjectsRoot();
@@ -10901,10 +10967,10 @@ function info2(message) {
10901
10967
  process.stderr.write(message + "\n");
10902
10968
  }
10903
10969
  function urlFilePath() {
10904
- return path41.join(os13.homedir(), ".work", "web.url");
10970
+ return path42.join(os13.homedir(), ".work", "web.url");
10905
10971
  }
10906
10972
  function pidFilePath() {
10907
- return path41.join(os13.homedir(), ".work", "web.pid");
10973
+ return path42.join(os13.homedir(), ".work", "web.pid");
10908
10974
  }
10909
10975
  function isPidAlive(pid) {
10910
10976
  try {
@@ -11029,7 +11095,7 @@ var webCommand = {
11029
11095
  const lean = !!argv.lean || process.env.WORK_WEB_LEAN === "1";
11030
11096
  const handle = await startWebServer({ lean });
11031
11097
  try {
11032
- fs41.mkdirSync(path41.dirname(urlFilePath()), { recursive: true });
11098
+ fs41.mkdirSync(path42.dirname(urlFilePath()), { recursive: true });
11033
11099
  fs41.writeFileSync(urlFilePath(), handle.url);
11034
11100
  fs41.writeFileSync(pidFilePath(), String(process.pid));
11035
11101
  } catch {
@@ -11123,11 +11189,11 @@ var webCommand = {
11123
11189
  // src/commands/hook.ts
11124
11190
  import fs42 from "fs";
11125
11191
  import os14 from "os";
11126
- import path42 from "path";
11192
+ import path43 from "path";
11127
11193
  async function postToWeb(route, cwd) {
11128
11194
  let base;
11129
11195
  try {
11130
- base = fs42.readFileSync(path42.join(os14.homedir(), ".work", "web.url"), "utf-8").trim();
11196
+ base = fs42.readFileSync(path43.join(os14.homedir(), ".work", "web.url"), "utf-8").trim();
11131
11197
  } catch {
11132
11198
  return;
11133
11199
  }
@@ -11623,7 +11689,7 @@ var broadcastCommand = {
11623
11689
 
11624
11690
  // src/completions/index.ts
11625
11691
  import fs45 from "fs";
11626
- import path43 from "path";
11692
+ import path44 from "path";
11627
11693
  function completionHandler(current, argv, done) {
11628
11694
  const rawArgs = argv._;
11629
11695
  const args = rawArgs.slice(1, -1);
@@ -11736,18 +11802,18 @@ function completeRepoBranches(alias, current, config, done) {
11736
11802
  done(branches);
11737
11803
  }
11738
11804
  function completeGroupBranches(groupName, repoAliases, current, config, done) {
11739
- const groupDir = path43.join(config.worktreesRoot, groupName);
11805
+ const groupDir = path44.join(config.worktreesRoot, groupName);
11740
11806
  if (!fs45.existsSync(groupDir)) {
11741
11807
  done([]);
11742
11808
  return;
11743
11809
  }
11744
11810
  try {
11745
11811
  const branchDirs = fs45.readdirSync(groupDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => {
11746
- const bdPath = path43.join(groupDir, d.name);
11812
+ const bdPath = path44.join(groupDir, d.name);
11747
11813
  for (const alias of repoAliases) {
11748
11814
  const repoPath = config.repos[alias];
11749
11815
  if (!repoPath) continue;
11750
- const subPath = path43.join(bdPath, path43.basename(repoPath));
11816
+ const subPath = path44.join(bdPath, path44.basename(repoPath));
11751
11817
  if (fs45.existsSync(subPath)) {
11752
11818
  const branch = getCurrentBranch(subPath);
11753
11819
  if (branch) return branch;
@@ -11762,7 +11828,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
11762
11828
  }
11763
11829
 
11764
11830
  // src/version.ts
11765
- var VERSION = true ? "1.11.0" : "dev";
11831
+ var VERSION = true ? "1.16.0" : "dev";
11766
11832
 
11767
11833
  // src/cli.ts
11768
11834
  function showHelp() {
@@ -11860,7 +11926,7 @@ function handleFatalError(err) {
11860
11926
  if (err instanceof Error && err.message?.includes("pty that has already exited")) {
11861
11927
  try {
11862
11928
  fs46.appendFileSync(
11863
- path44.join(getConfigDir(), "debug.log"),
11929
+ path45.join(getConfigDir(), "debug.log"),
11864
11930
  `${(/* @__PURE__ */ new Date()).toISOString()} [WARN] Ignored async node-pty error: ${err.message}
11865
11931
  `
11866
11932
  );
@@ -11871,7 +11937,7 @@ function handleFatalError(err) {
11871
11937
  try {
11872
11938
  const msg = err instanceof Error ? err.stack || err.message : String(err);
11873
11939
  fs46.appendFileSync(
11874
- path44.join(getConfigDir(), "debug.log"),
11940
+ path45.join(getConfigDir(), "debug.log"),
11875
11941
  `${(/* @__PURE__ */ new Date()).toISOString()} [FATAL] handleFatalError: ${msg}
11876
11942
  `
11877
11943
  );