@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/wd-bin.js CHANGED
@@ -1395,20 +1395,44 @@ function resolveFromCwd(config, cwd) {
1395
1395
 
1396
1396
  // src/core/worktree.ts
1397
1397
  import fs13 from "fs";
1398
- import path12 from "path";
1398
+ import path13 from "path";
1399
1399
  import chalk5 from "chalk";
1400
1400
 
1401
1401
  // src/core/history.ts
1402
1402
  import fs11 from "fs";
1403
- import path10 from "path";
1403
+ import path11 from "path";
1404
1404
 
1405
1405
  // src/core/fs-safe.ts
1406
1406
  import fs8 from "fs";
1407
+ import path9 from "path";
1407
1408
  import lockfile from "proper-lockfile";
1409
+ function resolveLinkTarget(filePath) {
1410
+ let current = filePath;
1411
+ const seen = /* @__PURE__ */ new Set([current]);
1412
+ for (let i = 0; i < 32; i++) {
1413
+ let stat;
1414
+ try {
1415
+ stat = fs8.lstatSync(current);
1416
+ } catch {
1417
+ return current;
1418
+ }
1419
+ if (!stat.isSymbolicLink()) return current;
1420
+ const next = path9.resolve(path9.dirname(current), fs8.readlinkSync(current));
1421
+ if (seen.has(next)) return filePath;
1422
+ seen.add(next);
1423
+ current = next;
1424
+ }
1425
+ return filePath;
1426
+ }
1408
1427
  function atomicWriteFile(filePath, content) {
1409
- const tmpPath = `${filePath}.tmp-${process.pid}`;
1428
+ const target = resolveLinkTarget(filePath);
1429
+ const tmpPath = `${target}.tmp-${process.pid}`;
1410
1430
  fs8.writeFileSync(tmpPath, content, "utf-8");
1411
- fs8.renameSync(tmpPath, filePath);
1431
+ try {
1432
+ fs8.chmodSync(tmpPath, fs8.statSync(target).mode & 511);
1433
+ } catch {
1434
+ }
1435
+ fs8.renameSync(tmpPath, target);
1412
1436
  }
1413
1437
  function ensureFile(filePath, initialContent) {
1414
1438
  if (!fs8.existsSync(filePath)) {
@@ -1453,9 +1477,9 @@ function sleepSync(ms) {
1453
1477
  // src/core/claude-activity.ts
1454
1478
  import fs9 from "fs";
1455
1479
  import os4 from "os";
1456
- import path9 from "path";
1480
+ import path10 from "path";
1457
1481
  function encodeProjectDir(p) {
1458
- return path9.resolve(p).replace(/[^A-Za-z0-9]/g, "-");
1482
+ return path10.resolve(p).replace(/[^A-Za-z0-9]/g, "-");
1459
1483
  }
1460
1484
  function latestJsonlMtimeMs(projectDir) {
1461
1485
  let entries;
@@ -1468,7 +1492,7 @@ function latestJsonlMtimeMs(projectDir) {
1468
1492
  for (const name of entries) {
1469
1493
  if (!name.endsWith(".jsonl")) continue;
1470
1494
  try {
1471
- const stat = fs9.statSync(path9.join(projectDir, name));
1495
+ const stat = fs9.statSync(path10.join(projectDir, name));
1472
1496
  if (stat.mtimeMs > latest) latest = stat.mtimeMs;
1473
1497
  } catch {
1474
1498
  }
@@ -1479,7 +1503,7 @@ function claudeActiveWithin(activityMs, nowMs, windowMs) {
1479
1503
  return activityMs > 0 && nowMs - activityMs < windowMs;
1480
1504
  }
1481
1505
  function getClaudeActivityMs(launchPath) {
1482
- const dir = path9.join(
1506
+ const dir = path10.join(
1483
1507
  os4.homedir(),
1484
1508
  ".claude",
1485
1509
  "projects",
@@ -1487,10 +1511,13 @@ function getClaudeActivityMs(launchPath) {
1487
1511
  );
1488
1512
  return latestJsonlMtimeMs(dir);
1489
1513
  }
1514
+ function hasClaudeConversation(dir) {
1515
+ return getClaudeActivityMs(dir) > 0;
1516
+ }
1490
1517
  function getLaunchPaths(session) {
1491
1518
  if (!session.isGroup) return [...session.paths];
1492
1519
  const parents = /* @__PURE__ */ new Set();
1493
- for (const p of session.paths) parents.add(path9.dirname(p));
1520
+ for (const p of session.paths) parents.add(path10.dirname(p));
1494
1521
  return [...parents];
1495
1522
  }
1496
1523
  function effectiveLastAccessedAt(session) {
@@ -1505,10 +1532,10 @@ function effectiveLastAccessedAt(session) {
1505
1532
  function resolveResumeLaunch(session) {
1506
1533
  const existing = session.paths.filter((p) => fs9.existsSync(p));
1507
1534
  const first = existing[0] ?? session.paths[0];
1508
- const defaultPath = session.isGroup ? path9.dirname(first) : first;
1535
+ const defaultPath = session.isGroup ? path10.dirname(first) : first;
1509
1536
  const candidates = /* @__PURE__ */ new Set();
1510
1537
  if (session.isGroup) {
1511
- for (const p of existing) candidates.add(path9.dirname(p));
1538
+ for (const p of existing) candidates.add(path10.dirname(p));
1512
1539
  for (const p of existing) candidates.add(p);
1513
1540
  } else {
1514
1541
  for (const p of existing) candidates.add(p);
@@ -1538,7 +1565,7 @@ function readSessionActivity(session) {
1538
1565
  return { lastActivity: latest, state };
1539
1566
  }
1540
1567
  function claudeProjectsRoot() {
1541
- return path9.join(os4.homedir(), ".claude", "projects");
1568
+ return path10.join(os4.homedir(), ".claude", "projects");
1542
1569
  }
1543
1570
 
1544
1571
  // src/core/port-allocator.ts
@@ -1612,7 +1639,7 @@ async function allocateFreePort(seedKey, config, sessions, probe = isPortFree) {
1612
1639
 
1613
1640
  // src/core/history.ts
1614
1641
  function getHistoryPath() {
1615
- return path10.join(getConfigDir(), "history.json");
1642
+ return path11.join(getConfigDir(), "history.json");
1616
1643
  }
1617
1644
  function backupCorruptFile(historyPath, reason) {
1618
1645
  try {
@@ -1805,7 +1832,7 @@ async function mergeHydratedSessions(incoming) {
1805
1832
 
1806
1833
  // src/core/copy-files.ts
1807
1834
  import fs12 from "fs";
1808
- import path11 from "path";
1835
+ import path12 from "path";
1809
1836
  import { globSync } from "glob";
1810
1837
  var EXCLUDED_DIRS = ["bin", "obj", "node_modules", ".git"];
1811
1838
  function copyConfigFiles(repoPath, worktreePath, patterns) {
@@ -1813,10 +1840,10 @@ function copyConfigFiles(repoPath, worktreePath, patterns) {
1813
1840
  const normalized = pattern.replace(/\\/g, "/");
1814
1841
  if (normalized.startsWith(".claude/")) {
1815
1842
  const relativePath = normalized;
1816
- const sourcePath = path11.join(repoPath, relativePath);
1843
+ const sourcePath = path12.join(repoPath, relativePath);
1817
1844
  if (fs12.existsSync(sourcePath)) {
1818
- const destPath = path11.join(worktreePath, relativePath);
1819
- const destDir = path11.dirname(destPath);
1845
+ const destPath = path12.join(worktreePath, relativePath);
1846
+ const destDir = path12.dirname(destPath);
1820
1847
  fs12.mkdirSync(destDir, { recursive: true });
1821
1848
  fs12.copyFileSync(sourcePath, destPath);
1822
1849
  console.log(` Copied: ${relativePath}`);
@@ -1834,9 +1861,9 @@ function copyConfigFiles(repoPath, worktreePath, patterns) {
1834
1861
  if (parts.some((p) => EXCLUDED_DIRS.includes(p))) {
1835
1862
  continue;
1836
1863
  }
1837
- const sourcePath = path11.join(repoPath, match);
1838
- const destPath = path11.join(worktreePath, match);
1839
- const destDir = path11.dirname(destPath);
1864
+ const sourcePath = path12.join(repoPath, match);
1865
+ const destPath = path12.join(worktreePath, match);
1866
+ const destDir = path12.dirname(destPath);
1840
1867
  fs12.mkdirSync(destDir, { recursive: true });
1841
1868
  fs12.copyFileSync(sourcePath, destPath);
1842
1869
  console.log(` Copied: ${match}`);
@@ -1901,7 +1928,7 @@ function toBaseSpec(base) {
1901
1928
  }
1902
1929
 
1903
1930
  // src/core/worktree.ts
1904
- function pullExistingWorktree(worktreePath, branchName) {
1931
+ function pullLatestForBranch(worktreePath, branchName) {
1905
1932
  const upstream = git(
1906
1933
  ["rev-parse", "--abbrev-ref", `${branchName}@{upstream}`],
1907
1934
  worktreePath
@@ -1920,7 +1947,7 @@ function pullExistingWorktree(worktreePath, branchName) {
1920
1947
  if (firstErrLine) console.log(chalk5.gray(` ${firstErrLine}`));
1921
1948
  }
1922
1949
  }
1923
- function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch) {
1950
+ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch, pull = true) {
1924
1951
  debug("createSingleWorktree", { repoPath, worktreePath, branchName, baseBranch });
1925
1952
  if (fs13.existsSync(worktreePath)) {
1926
1953
  if (isGitRepo(worktreePath)) {
@@ -1929,7 +1956,7 @@ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBr
1929
1956
  console.log(
1930
1957
  chalk5.yellow(` Worktree already exists at: ${worktreePath}`)
1931
1958
  );
1932
- pullExistingWorktree(worktreePath, branchName);
1959
+ if (pull) pullLatestForBranch(worktreePath, branchName);
1933
1960
  return true;
1934
1961
  }
1935
1962
  }
@@ -1949,7 +1976,7 @@ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBr
1949
1976
  );
1950
1977
  return false;
1951
1978
  }
1952
- const parentDir = path12.dirname(worktreePath);
1979
+ const parentDir = path13.dirname(worktreePath);
1953
1980
  fs13.mkdirSync(parentDir, { recursive: true });
1954
1981
  git(["fetch", "--quiet"], repoPath);
1955
1982
  const baseRepoBranch = getCurrentBranch(repoPath);
@@ -2125,9 +2152,9 @@ function removeSingleWorktree(repoPath, worktreePath, branchName, force) {
2125
2152
  return false;
2126
2153
  }
2127
2154
  }
2128
- async function setupWorktree(targetName, branchName, config, base, jiraKey) {
2155
+ async function setupWorktree(targetName, branchName, config, base, jiraKey, opts = {}) {
2129
2156
  const spec = toBaseSpec(base);
2130
- debug("setupWorktree", { targetName, branchName, spec, jiraKey });
2157
+ debug("setupWorktree", { targetName, branchName, spec, jiraKey, opts });
2131
2158
  const target = resolveProjectTarget(targetName, config);
2132
2159
  if (!target) {
2133
2160
  debug("setupWorktree: target not found", targetName);
@@ -2135,13 +2162,13 @@ async function setupWorktree(targetName, branchName, config, base, jiraKey) {
2135
2162
  }
2136
2163
  const workTreeDirName = branchName.replace(/\//g, "-");
2137
2164
  if (target.isGroup) {
2138
- return setupGroupWorktree(target.name, target.repoAliases, branchName, workTreeDirName, config, spec, jiraKey);
2165
+ return setupGroupWorktree(target.name, target.repoAliases, branchName, workTreeDirName, config, spec, jiraKey, opts);
2139
2166
  } else {
2140
- return setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey);
2167
+ return setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey, opts);
2141
2168
  }
2142
2169
  }
2143
- async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDirName, config, spec, jiraKey) {
2144
- const groupWorktreePath = path12.join(config.worktreesRoot, groupName, workTreeDirName);
2170
+ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDirName, config, spec, jiraKey, opts = {}) {
2171
+ const groupWorktreePath = path13.join(config.worktreesRoot, groupName, workTreeDirName);
2145
2172
  if (!isEmptyBaseSpec(spec)) {
2146
2173
  const unknownAliases = baseSpecOverrideAliases(spec).filter(
2147
2174
  (a) => !repoAliases.includes(a)
@@ -2182,11 +2209,11 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
2182
2209
  const baseBranches = {};
2183
2210
  for (const alias of repoAliases) {
2184
2211
  const repoPath = config.repos[alias];
2185
- const repoName = path12.basename(repoPath);
2186
- const subWorktreePath = path12.join(groupWorktreePath, repoName);
2212
+ const repoName = path13.basename(repoPath);
2213
+ const subWorktreePath = path13.join(groupWorktreePath, repoName);
2187
2214
  const repoBase = baseForAlias(spec, alias);
2188
2215
  console.log(chalk5.cyan(`[${alias}] (${repoName}):`));
2189
- const success = createSingleWorktree(repoPath, subWorktreePath, branchName, config, repoBase);
2216
+ const success = createSingleWorktree(repoPath, subWorktreePath, branchName, config, repoBase, opts.pull !== false);
2190
2217
  if (success) {
2191
2218
  createdWorktrees.push({ repoPath, worktreePath: subWorktreePath });
2192
2219
  if (repoBase) baseBranches[subWorktreePath] = repoBase;
@@ -2207,8 +2234,8 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
2207
2234
  }
2208
2235
  }
2209
2236
  const configDir = getConfigDir();
2210
- const claudeMdSrc = path12.join(configDir, `${groupName}.claude.md`);
2211
- const claudeMdDest = path12.join(groupWorktreePath, "CLAUDE.md");
2237
+ const claudeMdSrc = path13.join(configDir, `${groupName}.claude.md`);
2238
+ const claudeMdDest = path13.join(groupWorktreePath, "CLAUDE.md");
2212
2239
  if (fs13.existsSync(claudeMdSrc)) {
2213
2240
  fs13.copyFileSync(claudeMdSrc, claudeMdDest);
2214
2241
  console.log("");
@@ -2236,10 +2263,10 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
2236
2263
  if (port !== void 0) console.log(chalk5.gray(`Dev-server port: ${port}`));
2237
2264
  return { launchDir: groupWorktreePath, paths: allPaths, isGroup: true, port };
2238
2265
  }
2239
- async function setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey) {
2266
+ async function setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey, opts = {}) {
2240
2267
  const repoPath = config.repos[targetName];
2241
- const repoName = path12.basename(repoPath);
2242
- let workTreePath = path12.join(config.worktreesRoot, repoName, workTreeDirName);
2268
+ const repoName = path13.basename(repoPath);
2269
+ let workTreePath = path13.join(config.worktreesRoot, repoName, workTreeDirName);
2243
2270
  const unknownAliases = baseSpecOverrideAliases(spec).filter((a) => a !== targetName);
2244
2271
  if (unknownAliases.length > 0) {
2245
2272
  console.error(
@@ -2254,7 +2281,7 @@ async function setupSingleWorktree(targetName, branchName, workTreeDirName, conf
2254
2281
  }
2255
2282
  const worktrees = parseWorktreeList(repoPath);
2256
2283
  const existing = worktrees.find(
2257
- (wt) => wt.branch === branchName && path12.resolve(wt.path) !== path12.resolve(repoPath)
2284
+ (wt) => wt.branch === branchName && path13.resolve(wt.path) !== path13.resolve(repoPath)
2258
2285
  );
2259
2286
  if (existing) {
2260
2287
  if (baseBranch) {
@@ -2263,9 +2290,9 @@ async function setupSingleWorktree(targetName, branchName, workTreeDirName, conf
2263
2290
  }
2264
2291
  console.log(`Worktree already exists at: ${existing.path}`);
2265
2292
  workTreePath = existing.path;
2266
- pullExistingWorktree(workTreePath, branchName);
2293
+ if (opts.pull !== false) pullLatestForBranch(workTreePath, branchName);
2267
2294
  } else {
2268
- const success = createSingleWorktree(repoPath, workTreePath, branchName, config, baseBranch);
2295
+ const success = createSingleWorktree(repoPath, workTreePath, branchName, config, baseBranch, opts.pull !== false);
2269
2296
  if (!success) return null;
2270
2297
  }
2271
2298
  const { port } = await upsertSessionWithPort(
@@ -2286,19 +2313,19 @@ function teardownWorktree(target, isGroup, branch, config, force = true) {
2286
2313
  const workTreeDirName = branch.replace(/\//g, "-");
2287
2314
  if (isGroup && config.groups[target]) {
2288
2315
  const aliases = config.groups[target];
2289
- const groupWorktreePath = path12.join(config.worktreesRoot, target, workTreeDirName);
2316
+ const groupWorktreePath = path13.join(config.worktreesRoot, target, workTreeDirName);
2290
2317
  let allRemoved = true;
2291
2318
  for (const alias of aliases) {
2292
2319
  const repoPath = config.repos[alias];
2293
2320
  if (!repoPath) continue;
2294
- const repoName = path12.basename(repoPath);
2295
- const subWorktreePath = path12.join(groupWorktreePath, repoName);
2321
+ const repoName = path13.basename(repoPath);
2322
+ const subWorktreePath = path13.join(groupWorktreePath, repoName);
2296
2323
  console.log(chalk5.cyan(`[${alias}] (${repoName}):`));
2297
2324
  if (!removeSingleWorktree(repoPath, subWorktreePath, branch, force)) {
2298
2325
  allRemoved = false;
2299
2326
  }
2300
2327
  }
2301
- const claudeMd = path12.join(groupWorktreePath, "CLAUDE.md");
2328
+ const claudeMd = path13.join(groupWorktreePath, "CLAUDE.md");
2302
2329
  try {
2303
2330
  if (fs13.existsSync(claudeMd)) fs13.unlinkSync(claudeMd);
2304
2331
  } catch {
@@ -2347,6 +2374,14 @@ var treeCommand = {
2347
2374
  describe: "Launch the AI tool with its skip-permissions flag (default: --dangerously-skip-permissions)",
2348
2375
  type: "boolean",
2349
2376
  default: false
2377
+ }).option("pull", {
2378
+ describe: "Pull latest changes when switching into an existing worktree or the base repo. Use --no-pull to skip.",
2379
+ type: "boolean",
2380
+ default: true
2381
+ }).option("fresh", {
2382
+ describe: "Start a new AI conversation instead of continuing the previous one for this directory",
2383
+ type: "boolean",
2384
+ default: false
2350
2385
  }).option("base", {
2351
2386
  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.",
2352
2387
  type: "string"
@@ -2372,6 +2407,8 @@ var treeCommand = {
2372
2407
  const here = argv.here;
2373
2408
  const open = argv.open;
2374
2409
  const unsafe = argv.unsafe;
2410
+ const pull = argv.pull;
2411
+ const fresh = argv.fresh;
2375
2412
  const setupOnly = argv["setup-only"];
2376
2413
  let baseSpec;
2377
2414
  try {
@@ -2395,6 +2432,19 @@ var treeCommand = {
2395
2432
  }
2396
2433
  }
2397
2434
  const config = ensureConfig();
2435
+ const launchTool = (dir, port) => {
2436
+ const tool = getAiTool(config);
2437
+ const resume = !fresh && hasClaudeConversation(dir);
2438
+ if (resume) {
2439
+ console.log(
2440
+ chalk6.gray(
2441
+ `Continuing the previous ${tool.cmd} conversation (--fresh starts a new one).`
2442
+ )
2443
+ );
2444
+ }
2445
+ console.log(`Starting ${tool.cmd}...`);
2446
+ launchAi(dir, tool, { unsafe, initialPrompt, resume }, port);
2447
+ };
2398
2448
  if (here) {
2399
2449
  if (targetName) {
2400
2450
  console.error("Cannot combine --here with an explicit target.");
@@ -2463,16 +2513,15 @@ var treeCommand = {
2463
2513
  console.log(chalk6.cyan(`Working on base repo: ${targetName}`));
2464
2514
  console.log(`Repo path: ${repoPath}`);
2465
2515
  const currentBranch = getCurrentBranch(repoPath) ?? "(detached)";
2516
+ if (pull && currentBranch && currentBranch !== "(detached)") {
2517
+ pullLatestForBranch(repoPath, currentBranch);
2518
+ }
2466
2519
  await upsertSession(targetName, false, currentBranch, [repoPath], jiraKey);
2467
2520
  if (open) openVSCode(repoPath);
2468
- if (!setupOnly) {
2469
- const tool = getAiTool(config);
2470
- console.log(`Starting ${tool.cmd}...`);
2471
- launchAi(repoPath, tool, { unsafe, initialPrompt });
2472
- }
2521
+ if (!setupOnly) launchTool(repoPath);
2473
2522
  return;
2474
2523
  }
2475
- const result = await setupWorktree(targetName, branchName, config, baseSpec, jiraKey);
2524
+ const result = await setupWorktree(targetName, branchName, config, baseSpec, jiraKey, { pull });
2476
2525
  if (!result) {
2477
2526
  process.exitCode = 1;
2478
2527
  return;
@@ -2483,11 +2532,7 @@ var treeCommand = {
2483
2532
  }
2484
2533
  }
2485
2534
  console.log(`Worktree path: ${result.launchDir}`);
2486
- if (!setupOnly) {
2487
- const tool = getAiTool(config);
2488
- console.log(`Starting ${tool.cmd}...`);
2489
- launchAi(result.launchDir, tool, { unsafe, initialPrompt }, result.port);
2490
- }
2535
+ if (!setupOnly) launchTool(result.launchDir, result.port);
2491
2536
  }
2492
2537
  };
2493
2538
 
@@ -2546,7 +2591,7 @@ var removeCommand = {
2546
2591
 
2547
2592
  // src/commands/list.ts
2548
2593
  import fs15 from "fs";
2549
- import path13 from "path";
2594
+ import path14 from "path";
2550
2595
  import chalk8 from "chalk";
2551
2596
  var listCommand = {
2552
2597
  command: "list [target]",
@@ -2614,7 +2659,7 @@ var listCommand = {
2614
2659
  }
2615
2660
  }
2616
2661
  for (const groupName of showGroups) {
2617
- const groupDir = path13.join(worktreesRoot, groupName);
2662
+ const groupDir = path14.join(worktreesRoot, groupName);
2618
2663
  if (!fs15.existsSync(groupDir)) continue;
2619
2664
  let branchDirs;
2620
2665
  try {
@@ -2632,12 +2677,12 @@ var listCommand = {
2632
2677
  );
2633
2678
  const repoAliases = config.groups[groupName] ?? [];
2634
2679
  for (const bdName of branchDirs) {
2635
- const bdPath = path13.join(groupDir, bdName);
2680
+ const bdPath = path14.join(groupDir, bdName);
2636
2681
  let actualBranch = null;
2637
2682
  for (const alias of repoAliases) {
2638
2683
  const repoPath = config.repos[alias];
2639
2684
  if (!repoPath) continue;
2640
- const rdPath = path13.join(bdPath, path13.basename(repoPath));
2685
+ const rdPath = path14.join(bdPath, path14.basename(repoPath));
2641
2686
  if (fs15.existsSync(rdPath)) {
2642
2687
  const branch = getCurrentBranch(rdPath);
2643
2688
  if (branch) {
@@ -2964,7 +3009,7 @@ import { checkbox } from "@inquirer/prompts";
2964
3009
 
2965
3010
  // src/core/prunable-scan.ts
2966
3011
  import fs19 from "fs";
2967
- import path14 from "path";
3012
+ import path15 from "path";
2968
3013
  import chalk12 from "chalk";
2969
3014
  function collectPrunable(config, options = {}) {
2970
3015
  const { fetch: fetch2 = true, print = true, includeSquash = false } = options;
@@ -2981,7 +3026,7 @@ function collectPrunable(config, options = {}) {
2981
3026
  }
2982
3027
  const groupCoveredKeys = /* @__PURE__ */ new Set();
2983
3028
  for (const [groupName, aliases] of Object.entries(config.groups)) {
2984
- const groupDir = path14.join(config.worktreesRoot, groupName);
3029
+ const groupDir = path15.join(config.worktreesRoot, groupName);
2985
3030
  if (!fs19.existsSync(groupDir)) continue;
2986
3031
  let branchDirs;
2987
3032
  try {
@@ -2990,7 +3035,7 @@ function collectPrunable(config, options = {}) {
2990
3035
  continue;
2991
3036
  }
2992
3037
  for (const branchDir of branchDirs) {
2993
- const branchDirPath = path14.join(groupDir, branchDir);
3038
+ const branchDirPath = path15.join(groupDir, branchDir);
2994
3039
  let branch;
2995
3040
  let allMerged = true;
2996
3041
  let groupHasChanges = false;
@@ -3004,8 +3049,8 @@ function collectPrunable(config, options = {}) {
3004
3049
  skipped = true;
3005
3050
  continue;
3006
3051
  }
3007
- const repoName = path14.basename(repoPath);
3008
- const subWorktreePath = path14.join(branchDirPath, repoName);
3052
+ const repoName = path15.basename(repoPath);
3053
+ const subWorktreePath = path15.join(branchDirPath, repoName);
3009
3054
  if (!fs19.existsSync(subWorktreePath)) {
3010
3055
  continue;
3011
3056
  }
@@ -3122,7 +3167,7 @@ async function removeSingleEntry(entry, force = true) {
3122
3167
  }
3123
3168
  async function removeGroupEntry(entry, config, force = true) {
3124
3169
  const workTreeDirName = entry.branch.replace(/\//g, "-");
3125
- const groupWorktreePath = path14.join(
3170
+ const groupWorktreePath = path15.join(
3126
3171
  config.worktreesRoot,
3127
3172
  entry.target,
3128
3173
  workTreeDirName
@@ -3132,7 +3177,7 @@ async function removeGroupEntry(entry, config, force = true) {
3132
3177
  );
3133
3178
  let allRemoved = true;
3134
3179
  for (const { alias, repoPath, worktreePath } of entry.repos) {
3135
- const repoName = path14.basename(repoPath);
3180
+ const repoName = path15.basename(repoPath);
3136
3181
  console.log(chalk12.cyan(` [${alias}] (${repoName}):`));
3137
3182
  const removed = removeSingleWorktree(repoPath, worktreePath, entry.branch, force);
3138
3183
  if (!removed) {
@@ -3142,7 +3187,7 @@ async function removeGroupEntry(entry, config, force = true) {
3142
3187
  if (allRemoved) {
3143
3188
  await removeSession(entry.target, entry.branch);
3144
3189
  }
3145
- const claudeMdInWorktree = path14.join(groupWorktreePath, "CLAUDE.md");
3190
+ const claudeMdInWorktree = path15.join(groupWorktreePath, "CLAUDE.md");
3146
3191
  if (fs19.existsSync(claudeMdInWorktree)) {
3147
3192
  fs19.unlinkSync(claudeMdInWorktree);
3148
3193
  }
@@ -3368,7 +3413,7 @@ var syncCommand = {
3368
3413
 
3369
3414
  // src/tui-ink/index.tsx
3370
3415
  import fs24 from "fs";
3371
- import path19 from "path";
3416
+ import path20 from "path";
3372
3417
  import { render } from "ink";
3373
3418
 
3374
3419
  // src/tui-ink/App.tsx
@@ -3376,7 +3421,7 @@ import { useState, useEffect, useRef, useCallback, useMemo } from "react";
3376
3421
  import { Box as Box5 } from "ink";
3377
3422
  import fs23 from "fs";
3378
3423
  import os6 from "os";
3379
- import path18 from "path";
3424
+ import path19 from "path";
3380
3425
  import { execFile as execFile4 } from "child_process";
3381
3426
  import spawn7 from "cross-spawn";
3382
3427
 
@@ -3590,10 +3635,10 @@ async function fetchJiraPane() {
3590
3635
 
3591
3636
  // src/core/tasks.ts
3592
3637
  import fs21 from "fs";
3593
- import path15 from "path";
3638
+ import path16 from "path";
3594
3639
  var EMPTY_STORE = { nextId: 1, tasks: [] };
3595
3640
  function getTasksPath() {
3596
- return path15.join(getConfigDir(), "tasks.json");
3641
+ return path16.join(getConfigDir(), "tasks.json");
3597
3642
  }
3598
3643
  function loadStore() {
3599
3644
  const p = getTasksPath();
@@ -3842,30 +3887,33 @@ var PtySession = class {
3842
3887
 
3843
3888
  // src/core/hook-server.ts
3844
3889
  import http from "http";
3845
- import path17 from "path";
3890
+ import path18 from "path";
3846
3891
 
3847
3892
  // src/core/settings-editor.ts
3848
3893
  import fs22 from "fs";
3849
- import path16 from "path";
3894
+ import path17 from "path";
3850
3895
  import os5 from "os";
3851
- var SETTINGS_PATH = path16.join(os5.homedir(), ".claude", "settings.json");
3896
+ function settingsPath() {
3897
+ return path17.join(os5.homedir(), ".claude", "settings.json");
3898
+ }
3852
3899
  var OWNER_TAG = "_workHookOwner";
3853
3900
  var PID_TAG = "_workHookPid";
3854
3901
  var LEGACY_TAGS = ["_workDash", "_work2Dash"];
3855
3902
  function readSettings() {
3856
3903
  try {
3857
- if (!fs22.existsSync(SETTINGS_PATH)) return {};
3858
- return JSON.parse(fs22.readFileSync(SETTINGS_PATH, "utf8"));
3904
+ const p = settingsPath();
3905
+ if (!fs22.existsSync(p)) return {};
3906
+ return JSON.parse(fs22.readFileSync(p, "utf8"));
3859
3907
  } catch {
3860
3908
  return {};
3861
3909
  }
3862
3910
  }
3863
3911
  function writeAtomic(s) {
3864
3912
  try {
3865
- fs22.mkdirSync(path16.dirname(SETTINGS_PATH), { recursive: true });
3866
- const tmp = `${SETTINGS_PATH}.tmp-${process.pid}-${Date.now()}`;
3867
- fs22.writeFileSync(tmp, JSON.stringify(s, null, 2), "utf-8");
3868
- fs22.renameSync(tmp, SETTINGS_PATH);
3913
+ const target = resolveLinkTarget(settingsPath());
3914
+ fs22.mkdirSync(path17.dirname(target), { recursive: true });
3915
+ atomicWriteFile(target, `${JSON.stringify(s, null, 2)}
3916
+ `);
3869
3917
  } catch {
3870
3918
  }
3871
3919
  }
@@ -4037,7 +4085,7 @@ function removeHttpHooksSync(owner) {
4037
4085
  editSettingsSync(mutateRemove(owner));
4038
4086
  }
4039
4087
  function normalizePath(p) {
4040
- return path17.resolve(p).toLowerCase();
4088
+ return path18.resolve(p).toLowerCase();
4041
4089
  }
4042
4090
 
4043
4091
  // src/core/notifier.ts
@@ -5114,20 +5162,8 @@ var DETACH_KEY = "";
5114
5162
  var TAB_KEY = " ";
5115
5163
  var RENDER_INTERVAL_MS = 50;
5116
5164
  var MOUSE_SGR_RE = /\x1b\[<(\d+);(\d+);(\d+)[Mm]/;
5117
- function hasClaudeConversation(dir) {
5118
- try {
5119
- const resolved = path18.resolve(dir);
5120
- const projectDir = resolved.replace(/[^a-zA-Z0-9-]/g, "-");
5121
- const claudeProjectPath = path18.join(os6.homedir(), ".claude", "projects", projectDir);
5122
- if (!fs23.existsSync(claudeProjectPath)) return false;
5123
- const files = fs23.readdirSync(claudeProjectPath);
5124
- return files.some((f) => f.endsWith(".jsonl"));
5125
- } catch {
5126
- return false;
5127
- }
5128
- }
5129
5165
  function ptyDedupKey(pty2) {
5130
- return path18.resolve(pty2.cwd).toLowerCase();
5166
+ return path19.resolve(pty2.cwd).toLowerCase();
5131
5167
  }
5132
5168
  function loadSessions() {
5133
5169
  const all = loadHistory();
@@ -5427,10 +5463,10 @@ function App({ unsafe, onExit }) {
5427
5463
  }
5428
5464
  }, [setScrollBack, renderTermAtScroll]);
5429
5465
  const findPtyByCwd = useCallback((cwd) => {
5430
- const normalized = path18.resolve(cwd).toLowerCase();
5466
+ const normalized = path19.resolve(cwd).toLowerCase();
5431
5467
  for (const pty2 of ptySessions.current.values()) {
5432
5468
  if (pty2.exited) continue;
5433
- if (normalized.startsWith(path18.resolve(pty2.cwd).toLowerCase())) return pty2;
5469
+ if (normalized.startsWith(path19.resolve(pty2.cwd).toLowerCase())) return pty2;
5434
5470
  }
5435
5471
  return void 0;
5436
5472
  }, []);
@@ -5506,13 +5542,13 @@ function App({ unsafe, onExit }) {
5506
5542
  notifiedSessionsRef.current
5507
5543
  );
5508
5544
  if (kind) {
5509
- notifyDesktop(path18.basename(pty2.cwd), kind, {
5545
+ notifyDesktop(path19.basename(pty2.cwd), kind, {
5510
5546
  enabled: config?.notifications === true
5511
5547
  });
5512
5548
  runStatusHooks(
5513
5549
  kind,
5514
5550
  pty2.cwd,
5515
- path18.basename(pty2.cwd),
5551
+ path19.basename(pty2.cwd),
5516
5552
  config?.statusHooks
5517
5553
  );
5518
5554
  }
@@ -5645,7 +5681,7 @@ function App({ unsafe, onExit }) {
5645
5681
  refreshSessions();
5646
5682
  return;
5647
5683
  }
5648
- const dir = s.isGroup ? path18.dirname(existing) : existing;
5684
+ const dir = s.isGroup ? path19.dirname(existing) : existing;
5649
5685
  const resume = hasClaudeConversation(dir);
5650
5686
  const tool = getAiTool(config ?? {});
5651
5687
  const pty2 = new PtySession(dir, termInner, contentHeight - 2, void 0, { tool, unsafe, resume, port: s.port });
@@ -5743,7 +5779,7 @@ function App({ unsafe, onExit }) {
5743
5779
  "",
5744
5780
  " - Ask if I want to proceed with the recommended approach, choose a different one, get more details, or make adjustments."
5745
5781
  ].join("\n");
5746
- promptFile = path18.join(os6.tmpdir(), `work-prompt-${Date.now()}.txt`);
5782
+ promptFile = path19.join(os6.tmpdir(), `work-prompt-${Date.now()}.txt`);
5747
5783
  fs23.writeFileSync(promptFile, prompt, "utf-8");
5748
5784
  }
5749
5785
  const setupArgs = ["tree", projectName, branchName, "--setup-only"];
@@ -5783,7 +5819,7 @@ function App({ unsafe, onExit }) {
5783
5819
  setStatusVersion((v) => v + 1);
5784
5820
  return;
5785
5821
  }
5786
- const launchDir = session.isGroup ? path18.dirname(existing) : existing;
5822
+ const launchDir = session.isGroup ? path19.dirname(existing) : existing;
5787
5823
  const tool = getAiTool(config);
5788
5824
  const aiPty = new PtySession(
5789
5825
  launchDir,
@@ -6358,7 +6394,7 @@ function App({ unsafe, onExit }) {
6358
6394
  setMessage("Session path no longer exists");
6359
6395
  return;
6360
6396
  }
6361
- const dir = s.isGroup ? path18.dirname(existing) : existing;
6397
+ const dir = s.isGroup ? path19.dirname(existing) : existing;
6362
6398
  const editor = config?.editor ?? "code";
6363
6399
  spawn7(editor, [dir], { detached: true, stdio: "ignore" }).unref();
6364
6400
  setMessage(`Opened in ${editor}: ${s.branch}`);
@@ -6543,7 +6579,7 @@ function crashLog(label2, err) {
6543
6579
  const msg = err instanceof Error ? err.stack || err.message : String(err);
6544
6580
  const line = `${(/* @__PURE__ */ new Date()).toISOString()} [CRASH] ${label2}: ${msg}
6545
6581
  `;
6546
- fs24.appendFileSync(path19.join(getConfigDir(), "debug.log"), line);
6582
+ fs24.appendFileSync(path20.join(getConfigDir(), "debug.log"), line);
6547
6583
  } catch {
6548
6584
  }
6549
6585
  }
@@ -6867,22 +6903,22 @@ import chalk17 from "chalk";
6867
6903
 
6868
6904
  // src/core/hydrate.ts
6869
6905
  import fs25 from "fs";
6870
- import path20 from "path";
6906
+ import path21 from "path";
6871
6907
  async function hydrateHistoryFromDisk(config) {
6872
- const worktreesRoot = path20.resolve(config.worktreesRoot);
6908
+ const worktreesRoot = path21.resolve(config.worktreesRoot);
6873
6909
  const folderNameToAlias = /* @__PURE__ */ new Map();
6874
6910
  for (const [alias, repoPath] of Object.entries(config.repos)) {
6875
- folderNameToAlias.set(path20.basename(repoPath), alias);
6911
+ folderNameToAlias.set(path21.basename(repoPath), alias);
6876
6912
  }
6877
6913
  const discovered = /* @__PURE__ */ new Map();
6878
6914
  for (const [alias, repoPath] of Object.entries(config.repos)) {
6879
6915
  if (!fs25.existsSync(repoPath)) continue;
6880
6916
  for (const entry of parseWorktreeList(repoPath)) {
6881
6917
  if (!entry.branch) continue;
6882
- if (path20.resolve(entry.path) === path20.resolve(repoPath)) continue;
6883
- const rel = path20.relative(worktreesRoot, entry.path);
6884
- if (!rel || rel.startsWith("..") || path20.isAbsolute(rel)) continue;
6885
- const parts = rel.split(path20.sep).filter(Boolean);
6918
+ if (path21.resolve(entry.path) === path21.resolve(repoPath)) continue;
6919
+ const rel = path21.relative(worktreesRoot, entry.path);
6920
+ if (!rel || rel.startsWith("..") || path21.isAbsolute(rel)) continue;
6921
+ const parts = rel.split(path21.sep).filter(Boolean);
6886
6922
  if (parts.length < 2) continue;
6887
6923
  const [first, second] = parts;
6888
6924
  const isGroup = Object.prototype.hasOwnProperty.call(config.groups, first);
@@ -6967,13 +7003,13 @@ var hydrateCommand = {
6967
7003
  // src/commands/diff.ts
6968
7004
  import fs36 from "fs";
6969
7005
  import os9 from "os";
6970
- import path31 from "path";
7006
+ import path32 from "path";
6971
7007
  import { spawn as childSpawn } from "child_process";
6972
7008
  import chalk21 from "chalk";
6973
7009
 
6974
7010
  // src/core/diff-pipeline.ts
6975
7011
  import fs28 from "fs";
6976
- import path23 from "path";
7012
+ import path24 from "path";
6977
7013
  import spawn9 from "cross-spawn";
6978
7014
 
6979
7015
  // src/core/diff-parse.ts
@@ -7122,7 +7158,7 @@ function stripPathPrefix(p) {
7122
7158
 
7123
7159
  // src/core/lcov.ts
7124
7160
  import fs26 from "fs";
7125
- import path21 from "path";
7161
+ import path22 from "path";
7126
7162
  function parseLcov(content) {
7127
7163
  const result = /* @__PURE__ */ new Map();
7128
7164
  let sf = null;
@@ -7181,8 +7217,8 @@ function parseLcov(content) {
7181
7217
  }
7182
7218
  function findLcov(root) {
7183
7219
  const candidates = [
7184
- path21.join(root, "coverage", "lcov.info"),
7185
- path21.join(root, "lcov.info")
7220
+ path22.join(root, "coverage", "lcov.info"),
7221
+ path22.join(root, "lcov.info")
7186
7222
  ];
7187
7223
  for (const c of candidates) {
7188
7224
  try {
@@ -7217,33 +7253,33 @@ function readParsedLcov(lcovPath) {
7217
7253
  return { parsed, mtimeMs };
7218
7254
  }
7219
7255
  function normRel(p) {
7220
- return path21.normalize(p).replace(/\\/g, "/").replace(/^\.\//, "");
7256
+ return path22.normalize(p).replace(/\\/g, "/").replace(/^\.\//, "");
7221
7257
  }
7222
7258
  function realRoot(root) {
7223
7259
  try {
7224
- return fs26.realpathSync(path21.resolve(root));
7260
+ return fs26.realpathSync(path22.resolve(root));
7225
7261
  } catch {
7226
- return path21.resolve(root);
7262
+ return path22.resolve(root);
7227
7263
  }
7228
7264
  }
7229
7265
  function canonicalize(absPath) {
7230
- const resolved = path21.resolve(absPath);
7266
+ const resolved = path22.resolve(absPath);
7231
7267
  let dir = resolved;
7232
7268
  const tail = [];
7233
7269
  for (; ; ) {
7234
7270
  try {
7235
7271
  const realDir = fs26.realpathSync(dir);
7236
- return tail.length ? path21.join(realDir, ...tail.reverse()) : realDir;
7272
+ return tail.length ? path22.join(realDir, ...tail.reverse()) : realDir;
7237
7273
  } catch {
7238
- const parent = path21.dirname(dir);
7274
+ const parent = path22.dirname(dir);
7239
7275
  if (parent === dir) return resolved;
7240
- tail.push(path21.basename(dir));
7276
+ tail.push(path22.basename(dir));
7241
7277
  dir = parent;
7242
7278
  }
7243
7279
  }
7244
7280
  }
7245
7281
  function relForAbsSf(absSf, canonRoot) {
7246
- return path21.relative(canonRoot, canonicalize(absSf));
7282
+ return path22.relative(canonRoot, canonicalize(absSf));
7247
7283
  }
7248
7284
  function coverageLookup(root, relPaths) {
7249
7285
  const out = /* @__PURE__ */ new Map();
@@ -7256,7 +7292,7 @@ function coverageLookup(root, relPaths) {
7256
7292
  const canonRoot = realRoot(root);
7257
7293
  const byRel = /* @__PURE__ */ new Map();
7258
7294
  for (const [sf, pct] of read.parsed) {
7259
- const rel = path21.isAbsolute(sf) ? relForAbsSf(sf, canonRoot) : sf;
7295
+ const rel = path22.isAbsolute(sf) ? relForAbsSf(sf, canonRoot) : sf;
7260
7296
  byRel.set(normRel(rel), pct);
7261
7297
  }
7262
7298
  for (const rp of relPaths) {
@@ -7269,12 +7305,12 @@ function coverageLookup(root, relPaths) {
7269
7305
  // src/core/git-tree-snapshot.ts
7270
7306
  import fs27 from "fs";
7271
7307
  import os7 from "os";
7272
- import path22 from "path";
7308
+ import path23 from "path";
7273
7309
  import crypto from "crypto";
7274
7310
  import spawn8 from "cross-spawn";
7275
7311
  function writeTempTree(repoRoot, opts = {}) {
7276
7312
  const includeWorkingTree = opts.includeWorkingTree ?? true;
7277
- const tmpIndex = path22.join(
7313
+ const tmpIndex = path23.join(
7278
7314
  os7.tmpdir(),
7279
7315
  `wd-tree-${process.pid}-${crypto.randomBytes(6).toString("hex")}.idx`
7280
7316
  );
@@ -7286,13 +7322,45 @@ function writeTempTree(repoRoot, opts = {}) {
7286
7322
  windowsHide: true,
7287
7323
  maxBuffer: 64 * 1024 * 1024
7288
7324
  });
7325
+ const seedFromRealIndex = () => {
7326
+ try {
7327
+ const out = spawn8.sync("git", ["rev-parse", "--git-path", "index"], {
7328
+ cwd: repoRoot,
7329
+ encoding: "utf-8",
7330
+ windowsHide: true
7331
+ }).stdout;
7332
+ if (!out) return false;
7333
+ const realIndex = path23.resolve(repoRoot, out.trim());
7334
+ if (!fs27.existsSync(realIndex)) return false;
7335
+ fs27.copyFileSync(realIndex, tmpIndex);
7336
+ const st = fs27.statSync(realIndex);
7337
+ fs27.utimesSync(tmpIndex, st.atime, st.mtime);
7338
+ const listed = run2(["ls-files", "-v"]);
7339
+ if (listed.status !== 0) {
7340
+ fs27.unlinkSync(tmpIndex);
7341
+ return false;
7342
+ }
7343
+ const flagged = (listed.stdout ?? "").split("\n").some((line) => {
7344
+ const tag2 = line.charAt(0);
7345
+ return tag2 === "S" || tag2 >= "a" && tag2 <= "z";
7346
+ });
7347
+ if (flagged) {
7348
+ fs27.unlinkSync(tmpIndex);
7349
+ return false;
7350
+ }
7351
+ return true;
7352
+ } catch {
7353
+ return false;
7354
+ }
7355
+ };
7289
7356
  try {
7290
7357
  const headSha = (spawn8.sync("git", ["rev-parse", "--verify", "HEAD"], {
7291
7358
  cwd: repoRoot,
7292
7359
  encoding: "utf-8",
7293
7360
  windowsHide: true
7294
7361
  }).stdout ?? "").trim() || null;
7295
- if (headSha) {
7362
+ const seeded = includeWorkingTree && seedFromRealIndex();
7363
+ if (!seeded && headSha) {
7296
7364
  const r = run2(["read-tree", "HEAD"]);
7297
7365
  if (r.status !== 0) return null;
7298
7366
  }
@@ -7319,12 +7387,12 @@ function isMarkdownPath(p) {
7319
7387
  return p !== "/dev/null" && MARKDOWN_EXT_RE.test(p);
7320
7388
  }
7321
7389
  function isInsideRoot(root, rel) {
7322
- const resolvedRoot = path23.resolve(root);
7323
- const resolvedTarget = path23.resolve(resolvedRoot, rel);
7324
- const r = path23.relative(resolvedRoot, resolvedTarget);
7390
+ const resolvedRoot = path24.resolve(root);
7391
+ const resolvedTarget = path24.resolve(resolvedRoot, rel);
7392
+ const r = path24.relative(resolvedRoot, resolvedTarget);
7325
7393
  if (r === "") return true;
7326
7394
  if (r.startsWith("..")) return false;
7327
- if (path23.isAbsolute(r)) return false;
7395
+ if (path24.isAbsolute(r)) return false;
7328
7396
  return true;
7329
7397
  }
7330
7398
  function readMarkdownContent(root, file, fromRef, toRef) {
@@ -7349,10 +7417,10 @@ function readMarkdownContent(root, file, fromRef, toRef) {
7349
7417
  if (file.status !== "deleted" && isMarkdownPath(file.newPath) && isInsideRoot(root, file.newPath)) {
7350
7418
  if (toRef === "working") {
7351
7419
  try {
7352
- const absPath = path23.join(root, file.newPath);
7353
- const realRoot2 = fs28.realpathSync(path23.resolve(root));
7420
+ const absPath = path24.join(root, file.newPath);
7421
+ const realRoot2 = fs28.realpathSync(path24.resolve(root));
7354
7422
  const realPath = fs28.realpathSync(absPath);
7355
- const sep = path23.sep;
7423
+ const sep = path24.sep;
7356
7424
  if (realPath === realRoot2 || realPath.startsWith(realRoot2 + sep)) {
7357
7425
  result.after = fs28.readFileSync(absPath, "utf-8");
7358
7426
  }
@@ -7382,7 +7450,7 @@ function isBinaryContent(buffer) {
7382
7450
  return false;
7383
7451
  }
7384
7452
  function synthesizeUntrackedDiff(root, relPath) {
7385
- const absPath = path23.join(root, relPath);
7453
+ const absPath = path24.join(root, relPath);
7386
7454
  let buffer;
7387
7455
  try {
7388
7456
  buffer = fs28.readFileSync(absPath);
@@ -7473,7 +7541,7 @@ function attachCoverage(root, files) {
7473
7541
  f.coverageMtimeMs = lcovMtimeMs;
7474
7542
  let srcMtimeMs = null;
7475
7543
  try {
7476
- srcMtimeMs = fs28.statSync(path23.join(root, f.path)).mtimeMs;
7544
+ srcMtimeMs = fs28.statSync(path24.join(root, f.path)).mtimeMs;
7477
7545
  } catch {
7478
7546
  srcMtimeMs = null;
7479
7547
  }
@@ -7541,7 +7609,7 @@ function computeRangeDiff(opts) {
7541
7609
 
7542
7610
  // src/core/repo-spec.ts
7543
7611
  import fs29 from "fs";
7544
- import path24 from "path";
7612
+ import path25 from "path";
7545
7613
  import os8 from "os";
7546
7614
  import crypto2 from "crypto";
7547
7615
  function scopeHashFor(keyPaths) {
@@ -7549,17 +7617,17 @@ function scopeHashFor(keyPaths) {
7549
7617
  return crypto2.createHash("sha1").update(key).digest("hex").slice(0, 12);
7550
7618
  }
7551
7619
  function stableDiffPath(keyPaths) {
7552
- const dir = path24.join(os8.homedir(), ".work", "diffs");
7620
+ const dir = path25.join(os8.homedir(), ".work", "diffs");
7553
7621
  fs29.mkdirSync(dir, { recursive: true });
7554
- return path24.join(dir, scopeHashFor(keyPaths));
7622
+ return path25.join(dir, scopeHashFor(keyPaths));
7555
7623
  }
7556
7624
 
7557
7625
  // src/core/diff-scope.ts
7558
7626
  import fs30 from "fs";
7559
- import path25 from "path";
7627
+ import path26 from "path";
7560
7628
  import chalk18 from "chalk";
7561
7629
  function normPath(p) {
7562
- return path25.resolve(p).replace(/\\/g, "/").toLowerCase();
7630
+ return path26.resolve(p).replace(/\\/g, "/").toLowerCase();
7563
7631
  }
7564
7632
  function realNorm(p) {
7565
7633
  try {
@@ -7583,29 +7651,29 @@ function resolveScope(cwd) {
7583
7651
  return {
7584
7652
  isGroup: true,
7585
7653
  session: s,
7586
- repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7587
- activeRepoName: path25.basename(p)
7654
+ repos: s.paths.map((rp) => ({ name: path26.basename(rp), root: rp })),
7655
+ activeRepoName: path26.basename(p)
7588
7656
  };
7589
7657
  }
7590
7658
  return {
7591
7659
  isGroup: false,
7592
7660
  session: s,
7593
- repos: [{ name: path25.basename(p), root: p }],
7594
- activeRepoName: path25.basename(p)
7661
+ repos: [{ name: path26.basename(p), root: p }],
7662
+ activeRepoName: path26.basename(p)
7595
7663
  };
7596
7664
  }
7597
7665
  }
7598
7666
  }
7599
7667
  for (const s of sessions) {
7600
7668
  if (!s.isGroup || s.paths.length === 0) continue;
7601
- const parents = s.paths.map((p) => normPath(path25.dirname(p)));
7669
+ const parents = s.paths.map((p) => normPath(path26.dirname(p)));
7602
7670
  const groupRoot = parents[0];
7603
7671
  if (!parents.every((par) => par === groupRoot)) continue;
7604
7672
  if (normCwd === groupRoot || normCwd.startsWith(groupRoot + "/")) {
7605
7673
  return {
7606
7674
  isGroup: true,
7607
7675
  session: s,
7608
- repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7676
+ repos: s.paths.map((rp) => ({ name: path26.basename(rp), root: rp })),
7609
7677
  activeRepoName: null
7610
7678
  };
7611
7679
  }
@@ -7614,8 +7682,8 @@ function resolveScope(cwd) {
7614
7682
  return {
7615
7683
  isGroup: false,
7616
7684
  session: null,
7617
- repos: [{ name: path25.basename(toplevel), root: toplevel }],
7618
- activeRepoName: path25.basename(toplevel)
7685
+ repos: [{ name: path26.basename(toplevel), root: toplevel }],
7686
+ activeRepoName: path26.basename(toplevel)
7619
7687
  };
7620
7688
  }
7621
7689
  function findAnyParentBranch(cwd) {
@@ -7799,7 +7867,7 @@ import { streamSSE } from "hono/streaming";
7799
7867
 
7800
7868
  // src/core/file-context.ts
7801
7869
  import fs31 from "fs";
7802
- import path26 from "path";
7870
+ import path27 from "path";
7803
7871
  import spawn10 from "cross-spawn";
7804
7872
  function readContextLines(opts) {
7805
7873
  const { root, relPath, ref } = opts;
@@ -7821,10 +7889,10 @@ function readContextLines(opts) {
7821
7889
  }
7822
7890
  function readWorkingTree(root, relPath) {
7823
7891
  try {
7824
- const absPath = path26.join(root, relPath);
7825
- const realRoot2 = fs31.realpathSync(path26.resolve(root));
7892
+ const absPath = path27.join(root, relPath);
7893
+ const realRoot2 = fs31.realpathSync(path27.resolve(root));
7826
7894
  const realPath = fs31.realpathSync(absPath);
7827
- const sep = path26.sep;
7895
+ const sep = path27.sep;
7828
7896
  if (realPath !== realRoot2 && !realPath.startsWith(realRoot2 + sep)) {
7829
7897
  return null;
7830
7898
  }
@@ -7846,7 +7914,7 @@ function readAtRef(root, ref, relPath) {
7846
7914
 
7847
7915
  // src/core/fs-watcher.ts
7848
7916
  import fs32 from "fs";
7849
- import path27 from "path";
7917
+ import path28 from "path";
7850
7918
  import chalk19 from "chalk";
7851
7919
  import chokidar from "chokidar";
7852
7920
  var IGNORED_DIRS = /* @__PURE__ */ new Set([
@@ -7872,7 +7940,7 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
7872
7940
  ]);
7873
7941
  function isIgnoredWatchPath(roots, filePath) {
7874
7942
  for (const root of roots) {
7875
- const rel = path27.relative(root, filePath).replace(/\\/g, "/");
7943
+ const rel = path28.relative(root, filePath).replace(/\\/g, "/");
7876
7944
  if (rel === "" || rel.startsWith("../")) continue;
7877
7945
  if (rel.split("/").some((seg) => IGNORED_DIRS.has(seg))) return true;
7878
7946
  }
@@ -7897,7 +7965,7 @@ function createFsWatcher(opts) {
7897
7965
  if (SUPPORTS_RECURSIVE_WATCH) {
7898
7966
  const watchers = opts.roots.map((root) => {
7899
7967
  const w = fs32.watch(root, { recursive: true }, (_event, filename) => {
7900
- if (filename && isIgnoredWatchPath([root], path27.join(root, filename.toString()))) {
7968
+ if (filename && isIgnoredWatchPath([root], path28.join(root, filename.toString()))) {
7901
7969
  return;
7902
7970
  }
7903
7971
  fire();
@@ -7936,29 +8004,29 @@ function createFsWatcher(opts) {
7936
8004
 
7937
8005
  // src/core/web-static.ts
7938
8006
  import fs33 from "fs";
7939
- import path28 from "path";
8007
+ import path29 from "path";
7940
8008
  import { fileURLToPath } from "url";
7941
8009
  function resolveWebRoot() {
7942
- const entryDir = path28.dirname(process.argv[1] ?? "");
7943
- const moduleDir = path28.dirname(fileURLToPath(import.meta.url));
8010
+ const entryDir = path29.dirname(process.argv[1] ?? "");
8011
+ const moduleDir = path29.dirname(fileURLToPath(import.meta.url));
7944
8012
  const candidates = [
7945
- path28.join(entryDir, "web"),
8013
+ path29.join(entryDir, "web"),
7946
8014
  // bundled: this module is inlined into dist/<bin>.js, so dist/web is a
7947
8015
  // sibling of the bundle. Works even when argv[1] is an npm bin symlink
7948
8016
  // (which is not realpath'd, so the entryDir candidate above misses).
7949
- path28.join(moduleDir, "web"),
8017
+ path29.join(moduleDir, "web"),
7950
8018
  // dev/tsx fallback: walk up from src/core to repo root then into dist/web.
7951
- path28.resolve(moduleDir, "../../dist/web")
8019
+ path29.resolve(moduleDir, "../../dist/web")
7952
8020
  ];
7953
8021
  for (const c of candidates) {
7954
- if (fs33.existsSync(path28.join(c, "index.html"))) return c;
8022
+ if (fs33.existsSync(path29.join(c, "index.html"))) return c;
7955
8023
  }
7956
8024
  return null;
7957
8025
  }
7958
8026
 
7959
8027
  // src/core/spa-handler.ts
7960
8028
  import fs34 from "fs";
7961
- import path29 from "path";
8029
+ import path30 from "path";
7962
8030
  var MIME = {
7963
8031
  ".html": "text/html; charset=utf-8",
7964
8032
  ".js": "application/javascript; charset=utf-8",
@@ -7972,9 +8040,9 @@ var MIME = {
7972
8040
  function readFile(root, relPath) {
7973
8041
  const clean = relPath.split("?")[0];
7974
8042
  const requested = clean === "/" ? "/index.html" : clean;
7975
- const filePath = path29.join(root, requested);
7976
- const norm = path29.normalize(filePath);
7977
- if (!norm.startsWith(path29.normalize(root))) return null;
8043
+ const filePath = path30.join(root, requested);
8044
+ const norm = path30.normalize(filePath);
8045
+ if (!norm.startsWith(path30.normalize(root))) return null;
7978
8046
  let stat;
7979
8047
  try {
7980
8048
  stat = fs34.statSync(norm);
@@ -7982,7 +8050,7 @@ function readFile(root, relPath) {
7982
8050
  return null;
7983
8051
  }
7984
8052
  if (!stat.isFile()) return null;
7985
- const ext = path29.extname(norm).toLowerCase();
8053
+ const ext = path30.extname(norm).toLowerCase();
7986
8054
  return { body: fs34.readFileSync(norm), ext };
7987
8055
  }
7988
8056
  function serveSpa(c, webRoot) {
@@ -8292,7 +8360,7 @@ function diffReviewSnapshot(snapshot, seen) {
8292
8360
 
8293
8361
  // src/core/static-renderer.ts
8294
8362
  import fs35 from "fs";
8295
- import path30 from "path";
8363
+ import path31 from "path";
8296
8364
  function buildDiff(specs, resolvedBase) {
8297
8365
  return {
8298
8366
  repos: specs.map((r) => ({
@@ -8308,7 +8376,7 @@ function renderStatic(opts) {
8308
8376
  if (!webRoot) {
8309
8377
  throw new Error("Could not find dist/web/. Run `npm run build` first.");
8310
8378
  }
8311
- const shellPath = path30.join(webRoot, "index.html");
8379
+ const shellPath = path31.join(webRoot, "index.html");
8312
8380
  let shell = fs35.readFileSync(shellPath, "utf-8");
8313
8381
  const uncommitted = buildDiff(opts.uncommitted, "HEAD");
8314
8382
  const branch = opts.branch ? buildDiff(opts.branch.specs, opts.branch.resolvedBase) : void 0;
@@ -8358,8 +8426,8 @@ function escapeForScriptTag(json) {
8358
8426
  }
8359
8427
  function readAsset(webRoot, urlPath) {
8360
8428
  const clean = urlPath.split("?")[0].replace(/^\//, "");
8361
- const full = path30.join(webRoot, clean);
8362
- if (!path30.normalize(full).startsWith(path30.normalize(webRoot))) return null;
8429
+ const full = path31.join(webRoot, clean);
8430
+ if (!path31.normalize(full).startsWith(path31.normalize(webRoot))) return null;
8363
8431
  try {
8364
8432
  return fs35.readFileSync(full, "utf-8");
8365
8433
  } catch {
@@ -8402,7 +8470,7 @@ async function runStop(repoSpecs) {
8402
8470
  }
8403
8471
  }
8404
8472
  function webUrlFilePath() {
8405
- return path31.join(os9.homedir(), ".work", "web.url");
8473
+ return path32.join(os9.homedir(), ".work", "web.url");
8406
8474
  }
8407
8475
  function resolveWorkBinPath(selfArgv1) {
8408
8476
  let real = selfArgv1;
@@ -8411,7 +8479,7 @@ function resolveWorkBinPath(selfArgv1) {
8411
8479
  } catch {
8412
8480
  }
8413
8481
  if (real.endsWith("wd-bin.js")) {
8414
- return path31.join(path31.dirname(real), "bin.js");
8482
+ return path32.join(path32.dirname(real), "bin.js");
8415
8483
  }
8416
8484
  return real;
8417
8485
  }
@@ -8448,7 +8516,7 @@ async function ensureWorkWebRunning() {
8448
8516
  }
8449
8517
  const workBin = resolveWorkBinPath(process.argv[1]);
8450
8518
  const out = fs36.openSync(
8451
- path31.join(os9.homedir(), ".work", "web-autostart.log"),
8519
+ path32.join(os9.homedir(), ".work", "web-autostart.log"),
8452
8520
  "a"
8453
8521
  );
8454
8522
  const child = childSpawn(
@@ -8790,19 +8858,19 @@ var diffCommand = {
8790
8858
  // src/commands/web.ts
8791
8859
  import fs41 from "fs";
8792
8860
  import os13 from "os";
8793
- import path41 from "path";
8861
+ import path42 from "path";
8794
8862
  import chalk23 from "chalk";
8795
8863
 
8796
8864
  // src/core/web-server.ts
8797
8865
  import fs40 from "fs";
8798
8866
  import os12 from "os";
8799
- import path40 from "path";
8867
+ import path41 from "path";
8800
8868
  import chalk22 from "chalk";
8801
8869
  import { Hono as Hono3 } from "hono";
8802
8870
  import { streamSSE as streamSSE3 } from "hono/streaming";
8803
8871
 
8804
8872
  // src/core/web-state.ts
8805
- import path32 from "path";
8873
+ import path33 from "path";
8806
8874
  import crypto4 from "crypto";
8807
8875
  import chokidar2 from "chokidar";
8808
8876
  function sessionIdFor(s) {
@@ -8823,7 +8891,7 @@ function subscribeSession(sessionId, onChange) {
8823
8891
  const watcher = chokidar2.watch(roots, {
8824
8892
  ignored: (filePath) => {
8825
8893
  for (const r of roots) {
8826
- const rel = path32.relative(r, filePath).replace(/\\/g, "/");
8894
+ const rel = path33.relative(r, filePath).replace(/\\/g, "/");
8827
8895
  if (rel === ".git" || rel.startsWith(".git/")) return true;
8828
8896
  }
8829
8897
  return false;
@@ -8938,16 +9006,16 @@ function disposeAllPtys() {
8938
9006
 
8939
9007
  // src/core/comment-file-store.ts
8940
9008
  import fs37 from "fs";
8941
- import path33 from "path";
9009
+ import path34 from "path";
8942
9010
  import os10 from "os";
8943
9011
  function commentsDir() {
8944
- return path33.join(os10.homedir(), ".work", "comments");
9012
+ return path34.join(os10.homedir(), ".work", "comments");
8945
9013
  }
8946
9014
  function ensureDir() {
8947
9015
  fs37.mkdirSync(commentsDir(), { recursive: true });
8948
9016
  }
8949
9017
  function commentsFileFor(sessionId) {
8950
- return path33.join(commentsDir(), `${sessionId}.json`);
9018
+ return path34.join(commentsDir(), `${sessionId}.json`);
8951
9019
  }
8952
9020
  function pathFor(sessionId) {
8953
9021
  return commentsFileFor(sessionId);
@@ -9041,11 +9109,11 @@ function clearCommentStoreCache() {
9041
9109
 
9042
9110
  // src/core/pending-delivery.ts
9043
9111
  import fs38 from "fs";
9044
- import path34 from "path";
9112
+ import path35 from "path";
9045
9113
  function pathFor2(sessionId) {
9046
9114
  return {
9047
9115
  comments: commentsFileFor(sessionId),
9048
- delivered: path34.join(commentsDir(), `${sessionId}.delivered.json`)
9116
+ delivered: path35.join(commentsDir(), `${sessionId}.delivered.json`)
9049
9117
  };
9050
9118
  }
9051
9119
  function readJson(filePath, fallback) {
@@ -9056,13 +9124,11 @@ function readJson(filePath, fallback) {
9056
9124
  }
9057
9125
  }
9058
9126
  function writeAtomic2(filePath, content) {
9059
- fs38.mkdirSync(path34.dirname(filePath), { recursive: true });
9060
- const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
9061
- fs38.writeFileSync(tmp, content, "utf-8");
9062
- fs38.renameSync(tmp, filePath);
9127
+ fs38.mkdirSync(path35.dirname(filePath), { recursive: true });
9128
+ atomicWriteFile(filePath, content);
9063
9129
  }
9064
9130
  function normalize(p) {
9065
- return path34.resolve(p).replace(/\\/g, "/").toLowerCase();
9131
+ return path35.resolve(p).replace(/\\/g, "/").toLowerCase();
9066
9132
  }
9067
9133
  function findSessionForCwd(cwd) {
9068
9134
  const norm = normalize(cwd);
@@ -9093,7 +9159,7 @@ function readPendingForSession(sessionId) {
9093
9159
  return comments.filter(isPendingFor(delivered));
9094
9160
  }
9095
9161
  function scopeStoreIdsForPaths(paths) {
9096
- const resolved = paths.map((p) => path34.resolve(p));
9162
+ const resolved = paths.map((p) => path35.resolve(p));
9097
9163
  const ids = /* @__PURE__ */ new Set();
9098
9164
  ids.add(`scope-${scopeHashFor(resolved)}`);
9099
9165
  for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);
@@ -9431,7 +9497,7 @@ function mountPanesRoutes(app, opts) {
9431
9497
  }
9432
9498
 
9433
9499
  // src/core/worktree-routes.ts
9434
- import path35 from "path";
9500
+ import path36 from "path";
9435
9501
  import { spawn as spawn11 } from "child_process";
9436
9502
  import { zValidator as zValidator4 } from "@hono/zod-validator";
9437
9503
  import { z as z3 } from "zod";
@@ -9555,7 +9621,7 @@ function mountWorktreeRoutes(app, opts) {
9555
9621
  const id = c.req.param("id");
9556
9622
  const session = findSession2(id);
9557
9623
  if (!session) return c.json({ error: "unknown session" }, 404);
9558
- const target = session.isGroup ? path35.dirname(session.paths[0]) : session.paths[0];
9624
+ const target = session.isGroup ? path36.dirname(session.paths[0]) : session.paths[0];
9559
9625
  try {
9560
9626
  const cmd = process.platform === "win32" ? "code.cmd" : "code";
9561
9627
  const child = spawn11(cmd, [target], {
@@ -9575,18 +9641,18 @@ function mountWorktreeRoutes(app, opts) {
9575
9641
  import { zValidator as zValidator5 } from "@hono/zod-validator";
9576
9642
  import { z as z4 } from "zod";
9577
9643
  import { EventEmitter } from "events";
9578
- import path39 from "path";
9644
+ import path40 from "path";
9579
9645
  import spawn14 from "cross-spawn";
9580
9646
 
9581
9647
  // src/core/checkpoint.ts
9582
9648
  import fs39 from "fs";
9583
9649
  import os11 from "os";
9584
- import path36 from "path";
9650
+ import path37 from "path";
9585
9651
  import spawn12 from "cross-spawn";
9586
9652
  function manifestPath(scopeHash) {
9587
- const dir = path36.join(os11.homedir(), ".work", "diffs");
9653
+ const dir = path37.join(os11.homedir(), ".work", "diffs");
9588
9654
  fs39.mkdirSync(dir, { recursive: true });
9589
- return path36.join(dir, `${scopeHash}.checkpoints.json`);
9655
+ return path37.join(dir, `${scopeHash}.checkpoints.json`);
9590
9656
  }
9591
9657
  function emptyManifest(scopeHash) {
9592
9658
  return { version: 1, scopeHash, entries: [] };
@@ -9862,7 +9928,7 @@ function clearCheckpoints(scopeHash, repoRoots) {
9862
9928
 
9863
9929
  // src/core/checkpoint-summary.ts
9864
9930
  import spawn13 from "cross-spawn";
9865
- import path37 from "path";
9931
+ import path38 from "path";
9866
9932
  var MAX_DIFF_CHARS = 6e3;
9867
9933
  var MAX_LABEL_CHARS = 80;
9868
9934
  function buildDelta(scopeHash, repos, id) {
@@ -9915,7 +9981,7 @@ function buildDelta(scopeHash, repos, id) {
9915
9981
  function heuristicLabel(files, added, deleted) {
9916
9982
  if (files.length === 0) return "no changes";
9917
9983
  if (files.length === 1) {
9918
- return `${path37.basename(files[0].path)} +${added} \u2212${deleted}`;
9984
+ return `${path38.basename(files[0].path)} +${added} \u2212${deleted}`;
9919
9985
  }
9920
9986
  return `${files.length} files \xB7 +${added} \u2212${deleted}`;
9921
9987
  }
@@ -9986,7 +10052,7 @@ async function summarizeCheckpoint(scopeHash, repos, id) {
9986
10052
  }
9987
10053
 
9988
10054
  // src/core/scope-manager.ts
9989
- import path38 from "path";
10055
+ import path39 from "path";
9990
10056
  import crypto5 from "crypto";
9991
10057
  var scopes = /* @__PURE__ */ new Map();
9992
10058
  function hashFor(paths) {
@@ -10003,7 +10069,7 @@ var ScopePathRejectedError = class extends Error {
10003
10069
  }
10004
10070
  };
10005
10071
  function normaliseForCompare(p) {
10006
- return path38.resolve(p).replace(/\\/g, "/").toLowerCase();
10072
+ return path39.resolve(p).replace(/\\/g, "/").toLowerCase();
10007
10073
  }
10008
10074
  function rejectedPaths(normalised) {
10009
10075
  const config = loadConfig();
@@ -10021,7 +10087,7 @@ function rejectedPaths(normalised) {
10021
10087
  });
10022
10088
  }
10023
10089
  function registerScope(paths, label2) {
10024
- const normalised = paths.map((p) => path38.resolve(p));
10090
+ const normalised = paths.map((p) => path39.resolve(p));
10025
10091
  const rejected = rejectedPaths(normalised);
10026
10092
  if (rejected.length > 0) throw new ScopePathRejectedError(rejected);
10027
10093
  const hash = hashFor(normalised);
@@ -10035,7 +10101,7 @@ function registerScope(paths, label2) {
10035
10101
  const scope = {
10036
10102
  hash,
10037
10103
  paths: normalised,
10038
- label: label2 ?? path38.basename(normalised[0]),
10104
+ label: label2 ?? path39.basename(normalised[0]),
10039
10105
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
10040
10106
  ended: false
10041
10107
  };
@@ -10385,7 +10451,7 @@ function mountScopeRoutes(app, opts) {
10385
10451
  const fromSha = fromEntry.repos[p] ?? "HEAD";
10386
10452
  const toSha = toEntry === void 0 ? "working" : toEntry.repos[p] ?? "HEAD";
10387
10453
  return {
10388
- name: path39.basename(p),
10454
+ name: path40.basename(p),
10389
10455
  root: p,
10390
10456
  files: computeRangeDiff({ root: p, fromRef: fromSha, toRef: toSha })
10391
10457
  };
@@ -10404,7 +10470,7 @@ function mountScopeRoutes(app, opts) {
10404
10470
  (p) => resolveRepoDiff(p, base, sessionBaseForPath(p))
10405
10471
  );
10406
10472
  const repos = scope.paths.map((p, i) => ({
10407
- name: path39.basename(p),
10473
+ name: path40.basename(p),
10408
10474
  root: p,
10409
10475
  resolvedBase: resolved[i].resolvedBase,
10410
10476
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -10435,7 +10501,7 @@ function mountScopeRoutes(app, opts) {
10435
10501
  if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {
10436
10502
  return c.json({ error: "bad path/start/end" }, 400);
10437
10503
  }
10438
- const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path39.basename(p) === repoName);
10504
+ const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path40.basename(p) === repoName);
10439
10505
  if (!root) return c.json({ error: "unknown repo" }, 404);
10440
10506
  const result = readContextLines({ root, relPath, start, end, ref });
10441
10507
  if (!result) return c.json({ error: "cannot read file" }, 400);
@@ -10731,7 +10797,7 @@ function computeSessionDiff(s, base) {
10731
10797
  (p) => resolveRepoDiff(p, base, s.baseBranches?.[p] ?? s.baseBranch)
10732
10798
  );
10733
10799
  const repos = s.paths.map((p, i) => ({
10734
- name: path40.basename(p),
10800
+ name: path41.basename(p),
10735
10801
  root: p,
10736
10802
  resolvedBase: resolved[i].resolvedBase,
10737
10803
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -10751,10 +10817,10 @@ async function startWebServer(opts = {}) {
10751
10817
  for (const cb of sseListeners) cb({ event, data });
10752
10818
  };
10753
10819
  const home = os12.homedir();
10754
- const historyPath = path40.join(home, ".work", "history.json");
10820
+ const historyPath = path41.join(home, ".work", "history.json");
10755
10821
  const onHistoryChange = () => broadcast("sessions-changed", { ts: Date.now() });
10756
10822
  fs40.watchFile(historyPath, { interval: 1e3 }, onHistoryChange);
10757
- const tasksPath = path40.join(home, ".work", "tasks.json");
10823
+ const tasksPath = path41.join(home, ".work", "tasks.json");
10758
10824
  const onTasksChange = () => broadcast("tasks-changed", { ts: Date.now() });
10759
10825
  fs40.watchFile(tasksPath, { interval: 1e3 }, onTasksChange);
10760
10826
  const projectsRoot = claudeProjectsRoot();
@@ -10899,10 +10965,10 @@ function info2(message) {
10899
10965
  process.stderr.write(message + "\n");
10900
10966
  }
10901
10967
  function urlFilePath() {
10902
- return path41.join(os13.homedir(), ".work", "web.url");
10968
+ return path42.join(os13.homedir(), ".work", "web.url");
10903
10969
  }
10904
10970
  function pidFilePath() {
10905
- return path41.join(os13.homedir(), ".work", "web.pid");
10971
+ return path42.join(os13.homedir(), ".work", "web.pid");
10906
10972
  }
10907
10973
  function isPidAlive(pid) {
10908
10974
  try {
@@ -11027,7 +11093,7 @@ var webCommand = {
11027
11093
  const lean = !!argv.lean || process.env.WORK_WEB_LEAN === "1";
11028
11094
  const handle = await startWebServer({ lean });
11029
11095
  try {
11030
- fs41.mkdirSync(path41.dirname(urlFilePath()), { recursive: true });
11096
+ fs41.mkdirSync(path42.dirname(urlFilePath()), { recursive: true });
11031
11097
  fs41.writeFileSync(urlFilePath(), handle.url);
11032
11098
  fs41.writeFileSync(pidFilePath(), String(process.pid));
11033
11099
  } catch {
@@ -11121,11 +11187,11 @@ var webCommand = {
11121
11187
  // src/commands/hook.ts
11122
11188
  import fs42 from "fs";
11123
11189
  import os14 from "os";
11124
- import path42 from "path";
11190
+ import path43 from "path";
11125
11191
  async function postToWeb(route, cwd) {
11126
11192
  let base;
11127
11193
  try {
11128
- base = fs42.readFileSync(path42.join(os14.homedir(), ".work", "web.url"), "utf-8").trim();
11194
+ base = fs42.readFileSync(path43.join(os14.homedir(), ".work", "web.url"), "utf-8").trim();
11129
11195
  } catch {
11130
11196
  return;
11131
11197
  }
@@ -11621,7 +11687,7 @@ var broadcastCommand = {
11621
11687
 
11622
11688
  // src/completions/index.ts
11623
11689
  import fs45 from "fs";
11624
- import path43 from "path";
11690
+ import path44 from "path";
11625
11691
  function completionHandler(current, argv, done) {
11626
11692
  const rawArgs = argv._;
11627
11693
  const args = rawArgs.slice(1, -1);
@@ -11734,18 +11800,18 @@ function completeRepoBranches(alias, current, config, done) {
11734
11800
  done(branches);
11735
11801
  }
11736
11802
  function completeGroupBranches(groupName, repoAliases, current, config, done) {
11737
- const groupDir = path43.join(config.worktreesRoot, groupName);
11803
+ const groupDir = path44.join(config.worktreesRoot, groupName);
11738
11804
  if (!fs45.existsSync(groupDir)) {
11739
11805
  done([]);
11740
11806
  return;
11741
11807
  }
11742
11808
  try {
11743
11809
  const branchDirs = fs45.readdirSync(groupDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => {
11744
- const bdPath = path43.join(groupDir, d.name);
11810
+ const bdPath = path44.join(groupDir, d.name);
11745
11811
  for (const alias of repoAliases) {
11746
11812
  const repoPath = config.repos[alias];
11747
11813
  if (!repoPath) continue;
11748
- const subPath = path43.join(bdPath, path43.basename(repoPath));
11814
+ const subPath = path44.join(bdPath, path44.basename(repoPath));
11749
11815
  if (fs45.existsSync(subPath)) {
11750
11816
  const branch = getCurrentBranch(subPath);
11751
11817
  if (branch) return branch;
@@ -11760,7 +11826,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
11760
11826
  }
11761
11827
 
11762
11828
  // src/version.ts
11763
- var VERSION = true ? "1.11.0" : "dev";
11829
+ var VERSION = true ? "1.16.0" : "dev";
11764
11830
 
11765
11831
  // src/cli.ts
11766
11832
  function showHelp() {