@moberg_hr/work-tree 1.11.0 → 1.15.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
  );
@@ -7321,12 +7357,12 @@ function isMarkdownPath(p) {
7321
7357
  return p !== "/dev/null" && MARKDOWN_EXT_RE.test(p);
7322
7358
  }
7323
7359
  function isInsideRoot(root, rel) {
7324
- const resolvedRoot = path23.resolve(root);
7325
- const resolvedTarget = path23.resolve(resolvedRoot, rel);
7326
- const r = path23.relative(resolvedRoot, resolvedTarget);
7360
+ const resolvedRoot = path24.resolve(root);
7361
+ const resolvedTarget = path24.resolve(resolvedRoot, rel);
7362
+ const r = path24.relative(resolvedRoot, resolvedTarget);
7327
7363
  if (r === "") return true;
7328
7364
  if (r.startsWith("..")) return false;
7329
- if (path23.isAbsolute(r)) return false;
7365
+ if (path24.isAbsolute(r)) return false;
7330
7366
  return true;
7331
7367
  }
7332
7368
  function readMarkdownContent(root, file, fromRef, toRef) {
@@ -7351,10 +7387,10 @@ function readMarkdownContent(root, file, fromRef, toRef) {
7351
7387
  if (file.status !== "deleted" && isMarkdownPath(file.newPath) && isInsideRoot(root, file.newPath)) {
7352
7388
  if (toRef === "working") {
7353
7389
  try {
7354
- const absPath = path23.join(root, file.newPath);
7355
- const realRoot2 = fs28.realpathSync(path23.resolve(root));
7390
+ const absPath = path24.join(root, file.newPath);
7391
+ const realRoot2 = fs28.realpathSync(path24.resolve(root));
7356
7392
  const realPath = fs28.realpathSync(absPath);
7357
- const sep = path23.sep;
7393
+ const sep = path24.sep;
7358
7394
  if (realPath === realRoot2 || realPath.startsWith(realRoot2 + sep)) {
7359
7395
  result.after = fs28.readFileSync(absPath, "utf-8");
7360
7396
  }
@@ -7384,7 +7420,7 @@ function isBinaryContent(buffer) {
7384
7420
  return false;
7385
7421
  }
7386
7422
  function synthesizeUntrackedDiff(root, relPath) {
7387
- const absPath = path23.join(root, relPath);
7423
+ const absPath = path24.join(root, relPath);
7388
7424
  let buffer;
7389
7425
  try {
7390
7426
  buffer = fs28.readFileSync(absPath);
@@ -7475,7 +7511,7 @@ function attachCoverage(root, files) {
7475
7511
  f.coverageMtimeMs = lcovMtimeMs;
7476
7512
  let srcMtimeMs = null;
7477
7513
  try {
7478
- srcMtimeMs = fs28.statSync(path23.join(root, f.path)).mtimeMs;
7514
+ srcMtimeMs = fs28.statSync(path24.join(root, f.path)).mtimeMs;
7479
7515
  } catch {
7480
7516
  srcMtimeMs = null;
7481
7517
  }
@@ -7543,7 +7579,7 @@ function computeRangeDiff(opts) {
7543
7579
 
7544
7580
  // src/core/repo-spec.ts
7545
7581
  import fs29 from "fs";
7546
- import path24 from "path";
7582
+ import path25 from "path";
7547
7583
  import os8 from "os";
7548
7584
  import crypto2 from "crypto";
7549
7585
  function scopeHashFor(keyPaths) {
@@ -7551,17 +7587,17 @@ function scopeHashFor(keyPaths) {
7551
7587
  return crypto2.createHash("sha1").update(key).digest("hex").slice(0, 12);
7552
7588
  }
7553
7589
  function stableDiffPath(keyPaths) {
7554
- const dir = path24.join(os8.homedir(), ".work", "diffs");
7590
+ const dir = path25.join(os8.homedir(), ".work", "diffs");
7555
7591
  fs29.mkdirSync(dir, { recursive: true });
7556
- return path24.join(dir, scopeHashFor(keyPaths));
7592
+ return path25.join(dir, scopeHashFor(keyPaths));
7557
7593
  }
7558
7594
 
7559
7595
  // src/core/diff-scope.ts
7560
7596
  import fs30 from "fs";
7561
- import path25 from "path";
7597
+ import path26 from "path";
7562
7598
  import chalk18 from "chalk";
7563
7599
  function normPath(p) {
7564
- return path25.resolve(p).replace(/\\/g, "/").toLowerCase();
7600
+ return path26.resolve(p).replace(/\\/g, "/").toLowerCase();
7565
7601
  }
7566
7602
  function realNorm(p) {
7567
7603
  try {
@@ -7585,29 +7621,29 @@ function resolveScope(cwd) {
7585
7621
  return {
7586
7622
  isGroup: true,
7587
7623
  session: s,
7588
- repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7589
- activeRepoName: path25.basename(p)
7624
+ repos: s.paths.map((rp) => ({ name: path26.basename(rp), root: rp })),
7625
+ activeRepoName: path26.basename(p)
7590
7626
  };
7591
7627
  }
7592
7628
  return {
7593
7629
  isGroup: false,
7594
7630
  session: s,
7595
- repos: [{ name: path25.basename(p), root: p }],
7596
- activeRepoName: path25.basename(p)
7631
+ repos: [{ name: path26.basename(p), root: p }],
7632
+ activeRepoName: path26.basename(p)
7597
7633
  };
7598
7634
  }
7599
7635
  }
7600
7636
  }
7601
7637
  for (const s of sessions) {
7602
7638
  if (!s.isGroup || s.paths.length === 0) continue;
7603
- const parents = s.paths.map((p) => normPath(path25.dirname(p)));
7639
+ const parents = s.paths.map((p) => normPath(path26.dirname(p)));
7604
7640
  const groupRoot = parents[0];
7605
7641
  if (!parents.every((par) => par === groupRoot)) continue;
7606
7642
  if (normCwd === groupRoot || normCwd.startsWith(groupRoot + "/")) {
7607
7643
  return {
7608
7644
  isGroup: true,
7609
7645
  session: s,
7610
- repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7646
+ repos: s.paths.map((rp) => ({ name: path26.basename(rp), root: rp })),
7611
7647
  activeRepoName: null
7612
7648
  };
7613
7649
  }
@@ -7616,8 +7652,8 @@ function resolveScope(cwd) {
7616
7652
  return {
7617
7653
  isGroup: false,
7618
7654
  session: null,
7619
- repos: [{ name: path25.basename(toplevel), root: toplevel }],
7620
- activeRepoName: path25.basename(toplevel)
7655
+ repos: [{ name: path26.basename(toplevel), root: toplevel }],
7656
+ activeRepoName: path26.basename(toplevel)
7621
7657
  };
7622
7658
  }
7623
7659
  function findAnyParentBranch(cwd) {
@@ -7801,7 +7837,7 @@ import { streamSSE } from "hono/streaming";
7801
7837
 
7802
7838
  // src/core/file-context.ts
7803
7839
  import fs31 from "fs";
7804
- import path26 from "path";
7840
+ import path27 from "path";
7805
7841
  import spawn10 from "cross-spawn";
7806
7842
  function readContextLines(opts) {
7807
7843
  const { root, relPath, ref } = opts;
@@ -7823,10 +7859,10 @@ function readContextLines(opts) {
7823
7859
  }
7824
7860
  function readWorkingTree(root, relPath) {
7825
7861
  try {
7826
- const absPath = path26.join(root, relPath);
7827
- const realRoot2 = fs31.realpathSync(path26.resolve(root));
7862
+ const absPath = path27.join(root, relPath);
7863
+ const realRoot2 = fs31.realpathSync(path27.resolve(root));
7828
7864
  const realPath = fs31.realpathSync(absPath);
7829
- const sep = path26.sep;
7865
+ const sep = path27.sep;
7830
7866
  if (realPath !== realRoot2 && !realPath.startsWith(realRoot2 + sep)) {
7831
7867
  return null;
7832
7868
  }
@@ -7848,7 +7884,7 @@ function readAtRef(root, ref, relPath) {
7848
7884
 
7849
7885
  // src/core/fs-watcher.ts
7850
7886
  import fs32 from "fs";
7851
- import path27 from "path";
7887
+ import path28 from "path";
7852
7888
  import chalk19 from "chalk";
7853
7889
  import chokidar from "chokidar";
7854
7890
  var IGNORED_DIRS = /* @__PURE__ */ new Set([
@@ -7874,7 +7910,7 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
7874
7910
  ]);
7875
7911
  function isIgnoredWatchPath(roots, filePath) {
7876
7912
  for (const root of roots) {
7877
- const rel = path27.relative(root, filePath).replace(/\\/g, "/");
7913
+ const rel = path28.relative(root, filePath).replace(/\\/g, "/");
7878
7914
  if (rel === "" || rel.startsWith("../")) continue;
7879
7915
  if (rel.split("/").some((seg) => IGNORED_DIRS.has(seg))) return true;
7880
7916
  }
@@ -7899,7 +7935,7 @@ function createFsWatcher(opts) {
7899
7935
  if (SUPPORTS_RECURSIVE_WATCH) {
7900
7936
  const watchers = opts.roots.map((root) => {
7901
7937
  const w = fs32.watch(root, { recursive: true }, (_event, filename) => {
7902
- if (filename && isIgnoredWatchPath([root], path27.join(root, filename.toString()))) {
7938
+ if (filename && isIgnoredWatchPath([root], path28.join(root, filename.toString()))) {
7903
7939
  return;
7904
7940
  }
7905
7941
  fire();
@@ -7938,29 +7974,29 @@ function createFsWatcher(opts) {
7938
7974
 
7939
7975
  // src/core/web-static.ts
7940
7976
  import fs33 from "fs";
7941
- import path28 from "path";
7977
+ import path29 from "path";
7942
7978
  import { fileURLToPath } from "url";
7943
7979
  function resolveWebRoot() {
7944
- const entryDir = path28.dirname(process.argv[1] ?? "");
7945
- const moduleDir = path28.dirname(fileURLToPath(import.meta.url));
7980
+ const entryDir = path29.dirname(process.argv[1] ?? "");
7981
+ const moduleDir = path29.dirname(fileURLToPath(import.meta.url));
7946
7982
  const candidates = [
7947
- path28.join(entryDir, "web"),
7983
+ path29.join(entryDir, "web"),
7948
7984
  // bundled: this module is inlined into dist/<bin>.js, so dist/web is a
7949
7985
  // sibling of the bundle. Works even when argv[1] is an npm bin symlink
7950
7986
  // (which is not realpath'd, so the entryDir candidate above misses).
7951
- path28.join(moduleDir, "web"),
7987
+ path29.join(moduleDir, "web"),
7952
7988
  // dev/tsx fallback: walk up from src/core to repo root then into dist/web.
7953
- path28.resolve(moduleDir, "../../dist/web")
7989
+ path29.resolve(moduleDir, "../../dist/web")
7954
7990
  ];
7955
7991
  for (const c of candidates) {
7956
- if (fs33.existsSync(path28.join(c, "index.html"))) return c;
7992
+ if (fs33.existsSync(path29.join(c, "index.html"))) return c;
7957
7993
  }
7958
7994
  return null;
7959
7995
  }
7960
7996
 
7961
7997
  // src/core/spa-handler.ts
7962
7998
  import fs34 from "fs";
7963
- import path29 from "path";
7999
+ import path30 from "path";
7964
8000
  var MIME = {
7965
8001
  ".html": "text/html; charset=utf-8",
7966
8002
  ".js": "application/javascript; charset=utf-8",
@@ -7974,9 +8010,9 @@ var MIME = {
7974
8010
  function readFile(root, relPath) {
7975
8011
  const clean = relPath.split("?")[0];
7976
8012
  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;
8013
+ const filePath = path30.join(root, requested);
8014
+ const norm = path30.normalize(filePath);
8015
+ if (!norm.startsWith(path30.normalize(root))) return null;
7980
8016
  let stat;
7981
8017
  try {
7982
8018
  stat = fs34.statSync(norm);
@@ -7984,7 +8020,7 @@ function readFile(root, relPath) {
7984
8020
  return null;
7985
8021
  }
7986
8022
  if (!stat.isFile()) return null;
7987
- const ext = path29.extname(norm).toLowerCase();
8023
+ const ext = path30.extname(norm).toLowerCase();
7988
8024
  return { body: fs34.readFileSync(norm), ext };
7989
8025
  }
7990
8026
  function serveSpa(c, webRoot) {
@@ -8294,7 +8330,7 @@ function diffReviewSnapshot(snapshot, seen) {
8294
8330
 
8295
8331
  // src/core/static-renderer.ts
8296
8332
  import fs35 from "fs";
8297
- import path30 from "path";
8333
+ import path31 from "path";
8298
8334
  function buildDiff(specs, resolvedBase) {
8299
8335
  return {
8300
8336
  repos: specs.map((r) => ({
@@ -8310,7 +8346,7 @@ function renderStatic(opts) {
8310
8346
  if (!webRoot) {
8311
8347
  throw new Error("Could not find dist/web/. Run `npm run build` first.");
8312
8348
  }
8313
- const shellPath = path30.join(webRoot, "index.html");
8349
+ const shellPath = path31.join(webRoot, "index.html");
8314
8350
  let shell = fs35.readFileSync(shellPath, "utf-8");
8315
8351
  const uncommitted = buildDiff(opts.uncommitted, "HEAD");
8316
8352
  const branch = opts.branch ? buildDiff(opts.branch.specs, opts.branch.resolvedBase) : void 0;
@@ -8360,8 +8396,8 @@ function escapeForScriptTag(json) {
8360
8396
  }
8361
8397
  function readAsset(webRoot, urlPath) {
8362
8398
  const clean = urlPath.split("?")[0].replace(/^\//, "");
8363
- const full = path30.join(webRoot, clean);
8364
- if (!path30.normalize(full).startsWith(path30.normalize(webRoot))) return null;
8399
+ const full = path31.join(webRoot, clean);
8400
+ if (!path31.normalize(full).startsWith(path31.normalize(webRoot))) return null;
8365
8401
  try {
8366
8402
  return fs35.readFileSync(full, "utf-8");
8367
8403
  } catch {
@@ -8404,7 +8440,7 @@ async function runStop(repoSpecs) {
8404
8440
  }
8405
8441
  }
8406
8442
  function webUrlFilePath() {
8407
- return path31.join(os9.homedir(), ".work", "web.url");
8443
+ return path32.join(os9.homedir(), ".work", "web.url");
8408
8444
  }
8409
8445
  function resolveWorkBinPath(selfArgv1) {
8410
8446
  let real = selfArgv1;
@@ -8413,7 +8449,7 @@ function resolveWorkBinPath(selfArgv1) {
8413
8449
  } catch {
8414
8450
  }
8415
8451
  if (real.endsWith("wd-bin.js")) {
8416
- return path31.join(path31.dirname(real), "bin.js");
8452
+ return path32.join(path32.dirname(real), "bin.js");
8417
8453
  }
8418
8454
  return real;
8419
8455
  }
@@ -8450,7 +8486,7 @@ async function ensureWorkWebRunning() {
8450
8486
  }
8451
8487
  const workBin = resolveWorkBinPath(process.argv[1]);
8452
8488
  const out = fs36.openSync(
8453
- path31.join(os9.homedir(), ".work", "web-autostart.log"),
8489
+ path32.join(os9.homedir(), ".work", "web-autostart.log"),
8454
8490
  "a"
8455
8491
  );
8456
8492
  const child = childSpawn(
@@ -8792,19 +8828,19 @@ var diffCommand = {
8792
8828
  // src/commands/web.ts
8793
8829
  import fs41 from "fs";
8794
8830
  import os13 from "os";
8795
- import path41 from "path";
8831
+ import path42 from "path";
8796
8832
  import chalk23 from "chalk";
8797
8833
 
8798
8834
  // src/core/web-server.ts
8799
8835
  import fs40 from "fs";
8800
8836
  import os12 from "os";
8801
- import path40 from "path";
8837
+ import path41 from "path";
8802
8838
  import chalk22 from "chalk";
8803
8839
  import { Hono as Hono3 } from "hono";
8804
8840
  import { streamSSE as streamSSE3 } from "hono/streaming";
8805
8841
 
8806
8842
  // src/core/web-state.ts
8807
- import path32 from "path";
8843
+ import path33 from "path";
8808
8844
  import crypto4 from "crypto";
8809
8845
  import chokidar2 from "chokidar";
8810
8846
  function sessionIdFor(s) {
@@ -8825,7 +8861,7 @@ function subscribeSession(sessionId, onChange) {
8825
8861
  const watcher = chokidar2.watch(roots, {
8826
8862
  ignored: (filePath) => {
8827
8863
  for (const r of roots) {
8828
- const rel = path32.relative(r, filePath).replace(/\\/g, "/");
8864
+ const rel = path33.relative(r, filePath).replace(/\\/g, "/");
8829
8865
  if (rel === ".git" || rel.startsWith(".git/")) return true;
8830
8866
  }
8831
8867
  return false;
@@ -8940,16 +8976,16 @@ function disposeAllPtys() {
8940
8976
 
8941
8977
  // src/core/comment-file-store.ts
8942
8978
  import fs37 from "fs";
8943
- import path33 from "path";
8979
+ import path34 from "path";
8944
8980
  import os10 from "os";
8945
8981
  function commentsDir() {
8946
- return path33.join(os10.homedir(), ".work", "comments");
8982
+ return path34.join(os10.homedir(), ".work", "comments");
8947
8983
  }
8948
8984
  function ensureDir() {
8949
8985
  fs37.mkdirSync(commentsDir(), { recursive: true });
8950
8986
  }
8951
8987
  function commentsFileFor(sessionId) {
8952
- return path33.join(commentsDir(), `${sessionId}.json`);
8988
+ return path34.join(commentsDir(), `${sessionId}.json`);
8953
8989
  }
8954
8990
  function pathFor(sessionId) {
8955
8991
  return commentsFileFor(sessionId);
@@ -9043,11 +9079,11 @@ function clearCommentStoreCache() {
9043
9079
 
9044
9080
  // src/core/pending-delivery.ts
9045
9081
  import fs38 from "fs";
9046
- import path34 from "path";
9082
+ import path35 from "path";
9047
9083
  function pathFor2(sessionId) {
9048
9084
  return {
9049
9085
  comments: commentsFileFor(sessionId),
9050
- delivered: path34.join(commentsDir(), `${sessionId}.delivered.json`)
9086
+ delivered: path35.join(commentsDir(), `${sessionId}.delivered.json`)
9051
9087
  };
9052
9088
  }
9053
9089
  function readJson(filePath, fallback) {
@@ -9058,13 +9094,11 @@ function readJson(filePath, fallback) {
9058
9094
  }
9059
9095
  }
9060
9096
  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);
9097
+ fs38.mkdirSync(path35.dirname(filePath), { recursive: true });
9098
+ atomicWriteFile(filePath, content);
9065
9099
  }
9066
9100
  function normalize(p) {
9067
- return path34.resolve(p).replace(/\\/g, "/").toLowerCase();
9101
+ return path35.resolve(p).replace(/\\/g, "/").toLowerCase();
9068
9102
  }
9069
9103
  function findSessionForCwd(cwd) {
9070
9104
  const norm = normalize(cwd);
@@ -9095,7 +9129,7 @@ function readPendingForSession(sessionId) {
9095
9129
  return comments.filter(isPendingFor(delivered));
9096
9130
  }
9097
9131
  function scopeStoreIdsForPaths(paths) {
9098
- const resolved = paths.map((p) => path34.resolve(p));
9132
+ const resolved = paths.map((p) => path35.resolve(p));
9099
9133
  const ids = /* @__PURE__ */ new Set();
9100
9134
  ids.add(`scope-${scopeHashFor(resolved)}`);
9101
9135
  for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);
@@ -9433,7 +9467,7 @@ function mountPanesRoutes(app, opts) {
9433
9467
  }
9434
9468
 
9435
9469
  // src/core/worktree-routes.ts
9436
- import path35 from "path";
9470
+ import path36 from "path";
9437
9471
  import { spawn as spawn11 } from "child_process";
9438
9472
  import { zValidator as zValidator4 } from "@hono/zod-validator";
9439
9473
  import { z as z3 } from "zod";
@@ -9557,7 +9591,7 @@ function mountWorktreeRoutes(app, opts) {
9557
9591
  const id = c.req.param("id");
9558
9592
  const session = findSession2(id);
9559
9593
  if (!session) return c.json({ error: "unknown session" }, 404);
9560
- const target = session.isGroup ? path35.dirname(session.paths[0]) : session.paths[0];
9594
+ const target = session.isGroup ? path36.dirname(session.paths[0]) : session.paths[0];
9561
9595
  try {
9562
9596
  const cmd = process.platform === "win32" ? "code.cmd" : "code";
9563
9597
  const child = spawn11(cmd, [target], {
@@ -9577,18 +9611,18 @@ function mountWorktreeRoutes(app, opts) {
9577
9611
  import { zValidator as zValidator5 } from "@hono/zod-validator";
9578
9612
  import { z as z4 } from "zod";
9579
9613
  import { EventEmitter } from "events";
9580
- import path39 from "path";
9614
+ import path40 from "path";
9581
9615
  import spawn14 from "cross-spawn";
9582
9616
 
9583
9617
  // src/core/checkpoint.ts
9584
9618
  import fs39 from "fs";
9585
9619
  import os11 from "os";
9586
- import path36 from "path";
9620
+ import path37 from "path";
9587
9621
  import spawn12 from "cross-spawn";
9588
9622
  function manifestPath(scopeHash) {
9589
- const dir = path36.join(os11.homedir(), ".work", "diffs");
9623
+ const dir = path37.join(os11.homedir(), ".work", "diffs");
9590
9624
  fs39.mkdirSync(dir, { recursive: true });
9591
- return path36.join(dir, `${scopeHash}.checkpoints.json`);
9625
+ return path37.join(dir, `${scopeHash}.checkpoints.json`);
9592
9626
  }
9593
9627
  function emptyManifest(scopeHash) {
9594
9628
  return { version: 1, scopeHash, entries: [] };
@@ -9864,7 +9898,7 @@ function clearCheckpoints(scopeHash, repoRoots) {
9864
9898
 
9865
9899
  // src/core/checkpoint-summary.ts
9866
9900
  import spawn13 from "cross-spawn";
9867
- import path37 from "path";
9901
+ import path38 from "path";
9868
9902
  var MAX_DIFF_CHARS = 6e3;
9869
9903
  var MAX_LABEL_CHARS = 80;
9870
9904
  function buildDelta(scopeHash, repos, id) {
@@ -9917,7 +9951,7 @@ function buildDelta(scopeHash, repos, id) {
9917
9951
  function heuristicLabel(files, added, deleted) {
9918
9952
  if (files.length === 0) return "no changes";
9919
9953
  if (files.length === 1) {
9920
- return `${path37.basename(files[0].path)} +${added} \u2212${deleted}`;
9954
+ return `${path38.basename(files[0].path)} +${added} \u2212${deleted}`;
9921
9955
  }
9922
9956
  return `${files.length} files \xB7 +${added} \u2212${deleted}`;
9923
9957
  }
@@ -9988,7 +10022,7 @@ async function summarizeCheckpoint(scopeHash, repos, id) {
9988
10022
  }
9989
10023
 
9990
10024
  // src/core/scope-manager.ts
9991
- import path38 from "path";
10025
+ import path39 from "path";
9992
10026
  import crypto5 from "crypto";
9993
10027
  var scopes = /* @__PURE__ */ new Map();
9994
10028
  function hashFor(paths) {
@@ -10005,7 +10039,7 @@ var ScopePathRejectedError = class extends Error {
10005
10039
  }
10006
10040
  };
10007
10041
  function normaliseForCompare(p) {
10008
- return path38.resolve(p).replace(/\\/g, "/").toLowerCase();
10042
+ return path39.resolve(p).replace(/\\/g, "/").toLowerCase();
10009
10043
  }
10010
10044
  function rejectedPaths(normalised) {
10011
10045
  const config = loadConfig();
@@ -10023,7 +10057,7 @@ function rejectedPaths(normalised) {
10023
10057
  });
10024
10058
  }
10025
10059
  function registerScope(paths, label2) {
10026
- const normalised = paths.map((p) => path38.resolve(p));
10060
+ const normalised = paths.map((p) => path39.resolve(p));
10027
10061
  const rejected = rejectedPaths(normalised);
10028
10062
  if (rejected.length > 0) throw new ScopePathRejectedError(rejected);
10029
10063
  const hash = hashFor(normalised);
@@ -10037,7 +10071,7 @@ function registerScope(paths, label2) {
10037
10071
  const scope = {
10038
10072
  hash,
10039
10073
  paths: normalised,
10040
- label: label2 ?? path38.basename(normalised[0]),
10074
+ label: label2 ?? path39.basename(normalised[0]),
10041
10075
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
10042
10076
  ended: false
10043
10077
  };
@@ -10387,7 +10421,7 @@ function mountScopeRoutes(app, opts) {
10387
10421
  const fromSha = fromEntry.repos[p] ?? "HEAD";
10388
10422
  const toSha = toEntry === void 0 ? "working" : toEntry.repos[p] ?? "HEAD";
10389
10423
  return {
10390
- name: path39.basename(p),
10424
+ name: path40.basename(p),
10391
10425
  root: p,
10392
10426
  files: computeRangeDiff({ root: p, fromRef: fromSha, toRef: toSha })
10393
10427
  };
@@ -10406,7 +10440,7 @@ function mountScopeRoutes(app, opts) {
10406
10440
  (p) => resolveRepoDiff(p, base, sessionBaseForPath(p))
10407
10441
  );
10408
10442
  const repos = scope.paths.map((p, i) => ({
10409
- name: path39.basename(p),
10443
+ name: path40.basename(p),
10410
10444
  root: p,
10411
10445
  resolvedBase: resolved[i].resolvedBase,
10412
10446
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -10437,7 +10471,7 @@ function mountScopeRoutes(app, opts) {
10437
10471
  if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {
10438
10472
  return c.json({ error: "bad path/start/end" }, 400);
10439
10473
  }
10440
- const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path39.basename(p) === repoName);
10474
+ const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path40.basename(p) === repoName);
10441
10475
  if (!root) return c.json({ error: "unknown repo" }, 404);
10442
10476
  const result = readContextLines({ root, relPath, start, end, ref });
10443
10477
  if (!result) return c.json({ error: "cannot read file" }, 400);
@@ -10733,7 +10767,7 @@ function computeSessionDiff(s, base) {
10733
10767
  (p) => resolveRepoDiff(p, base, s.baseBranches?.[p] ?? s.baseBranch)
10734
10768
  );
10735
10769
  const repos = s.paths.map((p, i) => ({
10736
- name: path40.basename(p),
10770
+ name: path41.basename(p),
10737
10771
  root: p,
10738
10772
  resolvedBase: resolved[i].resolvedBase,
10739
10773
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -10753,10 +10787,10 @@ async function startWebServer(opts = {}) {
10753
10787
  for (const cb of sseListeners) cb({ event, data });
10754
10788
  };
10755
10789
  const home = os12.homedir();
10756
- const historyPath = path40.join(home, ".work", "history.json");
10790
+ const historyPath = path41.join(home, ".work", "history.json");
10757
10791
  const onHistoryChange = () => broadcast("sessions-changed", { ts: Date.now() });
10758
10792
  fs40.watchFile(historyPath, { interval: 1e3 }, onHistoryChange);
10759
- const tasksPath = path40.join(home, ".work", "tasks.json");
10793
+ const tasksPath = path41.join(home, ".work", "tasks.json");
10760
10794
  const onTasksChange = () => broadcast("tasks-changed", { ts: Date.now() });
10761
10795
  fs40.watchFile(tasksPath, { interval: 1e3 }, onTasksChange);
10762
10796
  const projectsRoot = claudeProjectsRoot();
@@ -10901,10 +10935,10 @@ function info2(message) {
10901
10935
  process.stderr.write(message + "\n");
10902
10936
  }
10903
10937
  function urlFilePath() {
10904
- return path41.join(os13.homedir(), ".work", "web.url");
10938
+ return path42.join(os13.homedir(), ".work", "web.url");
10905
10939
  }
10906
10940
  function pidFilePath() {
10907
- return path41.join(os13.homedir(), ".work", "web.pid");
10941
+ return path42.join(os13.homedir(), ".work", "web.pid");
10908
10942
  }
10909
10943
  function isPidAlive(pid) {
10910
10944
  try {
@@ -11029,7 +11063,7 @@ var webCommand = {
11029
11063
  const lean = !!argv.lean || process.env.WORK_WEB_LEAN === "1";
11030
11064
  const handle = await startWebServer({ lean });
11031
11065
  try {
11032
- fs41.mkdirSync(path41.dirname(urlFilePath()), { recursive: true });
11066
+ fs41.mkdirSync(path42.dirname(urlFilePath()), { recursive: true });
11033
11067
  fs41.writeFileSync(urlFilePath(), handle.url);
11034
11068
  fs41.writeFileSync(pidFilePath(), String(process.pid));
11035
11069
  } catch {
@@ -11123,11 +11157,11 @@ var webCommand = {
11123
11157
  // src/commands/hook.ts
11124
11158
  import fs42 from "fs";
11125
11159
  import os14 from "os";
11126
- import path42 from "path";
11160
+ import path43 from "path";
11127
11161
  async function postToWeb(route, cwd) {
11128
11162
  let base;
11129
11163
  try {
11130
- base = fs42.readFileSync(path42.join(os14.homedir(), ".work", "web.url"), "utf-8").trim();
11164
+ base = fs42.readFileSync(path43.join(os14.homedir(), ".work", "web.url"), "utf-8").trim();
11131
11165
  } catch {
11132
11166
  return;
11133
11167
  }
@@ -11623,7 +11657,7 @@ var broadcastCommand = {
11623
11657
 
11624
11658
  // src/completions/index.ts
11625
11659
  import fs45 from "fs";
11626
- import path43 from "path";
11660
+ import path44 from "path";
11627
11661
  function completionHandler(current, argv, done) {
11628
11662
  const rawArgs = argv._;
11629
11663
  const args = rawArgs.slice(1, -1);
@@ -11736,18 +11770,18 @@ function completeRepoBranches(alias, current, config, done) {
11736
11770
  done(branches);
11737
11771
  }
11738
11772
  function completeGroupBranches(groupName, repoAliases, current, config, done) {
11739
- const groupDir = path43.join(config.worktreesRoot, groupName);
11773
+ const groupDir = path44.join(config.worktreesRoot, groupName);
11740
11774
  if (!fs45.existsSync(groupDir)) {
11741
11775
  done([]);
11742
11776
  return;
11743
11777
  }
11744
11778
  try {
11745
11779
  const branchDirs = fs45.readdirSync(groupDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => {
11746
- const bdPath = path43.join(groupDir, d.name);
11780
+ const bdPath = path44.join(groupDir, d.name);
11747
11781
  for (const alias of repoAliases) {
11748
11782
  const repoPath = config.repos[alias];
11749
11783
  if (!repoPath) continue;
11750
- const subPath = path43.join(bdPath, path43.basename(repoPath));
11784
+ const subPath = path44.join(bdPath, path44.basename(repoPath));
11751
11785
  if (fs45.existsSync(subPath)) {
11752
11786
  const branch = getCurrentBranch(subPath);
11753
11787
  if (branch) return branch;
@@ -11762,7 +11796,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
11762
11796
  }
11763
11797
 
11764
11798
  // src/version.ts
11765
- var VERSION = true ? "1.11.0" : "dev";
11799
+ var VERSION = true ? "1.15.0" : "dev";
11766
11800
 
11767
11801
  // src/cli.ts
11768
11802
  function showHelp() {
@@ -11860,7 +11894,7 @@ function handleFatalError(err) {
11860
11894
  if (err instanceof Error && err.message?.includes("pty that has already exited")) {
11861
11895
  try {
11862
11896
  fs46.appendFileSync(
11863
- path44.join(getConfigDir(), "debug.log"),
11897
+ path45.join(getConfigDir(), "debug.log"),
11864
11898
  `${(/* @__PURE__ */ new Date()).toISOString()} [WARN] Ignored async node-pty error: ${err.message}
11865
11899
  `
11866
11900
  );
@@ -11871,7 +11905,7 @@ function handleFatalError(err) {
11871
11905
  try {
11872
11906
  const msg = err instanceof Error ? err.stack || err.message : String(err);
11873
11907
  fs46.appendFileSync(
11874
- path44.join(getConfigDir(), "debug.log"),
11908
+ path45.join(getConfigDir(), "debug.log"),
11875
11909
  `${(/* @__PURE__ */ new Date()).toISOString()} [FATAL] handleFatalError: ${msg}
11876
11910
  `
11877
11911
  );