@moberg_hr/work-tree 1.8.0 → 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/bin.ts
4
4
  import fs45 from "fs";
5
- import path44 from "path";
5
+ import path42 from "path";
6
6
  import chalk27 from "chalk";
7
7
 
8
8
  // src/cli.ts
@@ -1488,6 +1488,28 @@ function effectiveLastAccessedAt(session) {
1488
1488
  }
1489
1489
  return new Date(bestMs).toISOString();
1490
1490
  }
1491
+ function resolveResumeLaunch(session) {
1492
+ const existing = session.paths.filter((p) => fs9.existsSync(p));
1493
+ const first = existing[0] ?? session.paths[0];
1494
+ const defaultPath = session.isGroup ? path9.dirname(first) : first;
1495
+ const candidates = /* @__PURE__ */ new Set();
1496
+ if (session.isGroup) {
1497
+ for (const p of existing) candidates.add(path9.dirname(p));
1498
+ for (const p of existing) candidates.add(p);
1499
+ } else {
1500
+ for (const p of existing) candidates.add(p);
1501
+ }
1502
+ let launchPath = defaultPath;
1503
+ let bestMs = 0;
1504
+ for (const c of candidates) {
1505
+ const ms = getClaudeActivityMs(c);
1506
+ if (ms > bestMs) {
1507
+ bestMs = ms;
1508
+ launchPath = c;
1509
+ }
1510
+ }
1511
+ return { launchPath, hasConversation: bestMs > 0 };
1512
+ }
1491
1513
  var ACTIVE_MS = 3e4;
1492
1514
  var OPEN_MS = 5 * 6e4;
1493
1515
  function readSessionActivity(session) {
@@ -2747,7 +2769,6 @@ function printSessionStatus(session) {
2747
2769
 
2748
2770
  // src/commands/recent.ts
2749
2771
  import fs17 from "fs";
2750
- import path14 from "path";
2751
2772
  import chalk10 from "chalk";
2752
2773
  import { select as select2 } from "@inquirer/prompts";
2753
2774
  var recentCommand = {
@@ -2805,12 +2826,19 @@ var recentCommand = {
2805
2826
  process.exitCode = 1;
2806
2827
  return;
2807
2828
  }
2808
- const launchPath = choice.isGroup ? path14.dirname(firstExisting) : firstExisting;
2829
+ const { launchPath, hasConversation } = resolveResumeLaunch(choice);
2809
2830
  await upsertSession(choice.target, choice.isGroup, choice.branch, choice.paths);
2810
2831
  const tool = getAiTool(config);
2811
2832
  console.log(chalk10.cyan(`Resuming in: ${launchPath}`));
2833
+ if (!hasConversation) {
2834
+ console.log(
2835
+ chalk10.yellow(
2836
+ `No prior ${tool.cmd} conversation found for this worktree \u2014 starting a fresh session.`
2837
+ )
2838
+ );
2839
+ }
2812
2840
  console.log(`Starting ${tool.cmd}...`);
2813
- launchAi(launchPath, tool, { unsafe, resume: true }, choice.port);
2841
+ launchAi(launchPath, tool, { unsafe, resume: hasConversation }, choice.port);
2814
2842
  return;
2815
2843
  }
2816
2844
  console.log("");
@@ -2837,7 +2865,6 @@ var recentCommand = {
2837
2865
 
2838
2866
  // src/commands/resume.ts
2839
2867
  import fs18 from "fs";
2840
- import path15 from "path";
2841
2868
  import chalk11 from "chalk";
2842
2869
  import { select as select3 } from "@inquirer/prompts";
2843
2870
  var resumeCommand = {
@@ -2880,12 +2907,19 @@ var resumeCommand = {
2880
2907
  process.exitCode = 1;
2881
2908
  return;
2882
2909
  }
2883
- const launchPath = choice.isGroup ? path15.dirname(firstExisting) : firstExisting;
2910
+ const { launchPath, hasConversation } = resolveResumeLaunch(choice);
2884
2911
  await upsertSession(choice.target, choice.isGroup, choice.branch, choice.paths);
2885
2912
  const tool = getAiTool(config);
2886
2913
  console.log(chalk11.cyan(`Resuming in: ${launchPath}`));
2914
+ if (!hasConversation) {
2915
+ console.log(
2916
+ chalk11.yellow(
2917
+ `No prior ${tool.cmd} conversation found for this worktree \u2014 starting a fresh session.`
2918
+ )
2919
+ );
2920
+ }
2887
2921
  console.log(`Starting ${tool.cmd}...`);
2888
- launchAi(launchPath, tool, { unsafe, resume: true }, choice.port);
2922
+ launchAi(launchPath, tool, { unsafe, resume: hasConversation }, choice.port);
2889
2923
  }
2890
2924
  };
2891
2925
 
@@ -2895,7 +2929,7 @@ import { checkbox } from "@inquirer/prompts";
2895
2929
 
2896
2930
  // src/core/prunable-scan.ts
2897
2931
  import fs19 from "fs";
2898
- import path16 from "path";
2932
+ import path14 from "path";
2899
2933
  import chalk12 from "chalk";
2900
2934
  function collectPrunable(config, options = {}) {
2901
2935
  const { fetch: fetch2 = true, print = true, includeSquash = false } = options;
@@ -2912,7 +2946,7 @@ function collectPrunable(config, options = {}) {
2912
2946
  }
2913
2947
  const groupCoveredKeys = /* @__PURE__ */ new Set();
2914
2948
  for (const [groupName, aliases] of Object.entries(config.groups)) {
2915
- const groupDir = path16.join(config.worktreesRoot, groupName);
2949
+ const groupDir = path14.join(config.worktreesRoot, groupName);
2916
2950
  if (!fs19.existsSync(groupDir)) continue;
2917
2951
  let branchDirs;
2918
2952
  try {
@@ -2921,7 +2955,7 @@ function collectPrunable(config, options = {}) {
2921
2955
  continue;
2922
2956
  }
2923
2957
  for (const branchDir of branchDirs) {
2924
- const branchDirPath = path16.join(groupDir, branchDir);
2958
+ const branchDirPath = path14.join(groupDir, branchDir);
2925
2959
  let branch;
2926
2960
  let allMerged = true;
2927
2961
  let groupHasChanges = false;
@@ -2935,8 +2969,8 @@ function collectPrunable(config, options = {}) {
2935
2969
  skipped = true;
2936
2970
  continue;
2937
2971
  }
2938
- const repoName = path16.basename(repoPath);
2939
- const subWorktreePath = path16.join(branchDirPath, repoName);
2972
+ const repoName = path14.basename(repoPath);
2973
+ const subWorktreePath = path14.join(branchDirPath, repoName);
2940
2974
  if (!fs19.existsSync(subWorktreePath)) {
2941
2975
  continue;
2942
2976
  }
@@ -3053,7 +3087,7 @@ async function removeSingleEntry(entry, force = true) {
3053
3087
  }
3054
3088
  async function removeGroupEntry(entry, config, force = true) {
3055
3089
  const workTreeDirName = entry.branch.replace(/\//g, "-");
3056
- const groupWorktreePath = path16.join(
3090
+ const groupWorktreePath = path14.join(
3057
3091
  config.worktreesRoot,
3058
3092
  entry.target,
3059
3093
  workTreeDirName
@@ -3063,7 +3097,7 @@ async function removeGroupEntry(entry, config, force = true) {
3063
3097
  );
3064
3098
  let allRemoved = true;
3065
3099
  for (const { alias, repoPath, worktreePath } of entry.repos) {
3066
- const repoName = path16.basename(repoPath);
3100
+ const repoName = path14.basename(repoPath);
3067
3101
  console.log(chalk12.cyan(` [${alias}] (${repoName}):`));
3068
3102
  const removed = removeSingleWorktree(repoPath, worktreePath, entry.branch, force);
3069
3103
  if (!removed) {
@@ -3073,7 +3107,7 @@ async function removeGroupEntry(entry, config, force = true) {
3073
3107
  if (allRemoved) {
3074
3108
  await removeSession(entry.target, entry.branch);
3075
3109
  }
3076
- const claudeMdInWorktree = path16.join(groupWorktreePath, "CLAUDE.md");
3110
+ const claudeMdInWorktree = path14.join(groupWorktreePath, "CLAUDE.md");
3077
3111
  if (fs19.existsSync(claudeMdInWorktree)) {
3078
3112
  fs19.unlinkSync(claudeMdInWorktree);
3079
3113
  }
@@ -3299,7 +3333,7 @@ var syncCommand = {
3299
3333
 
3300
3334
  // src/tui-ink/index.tsx
3301
3335
  import fs24 from "fs";
3302
- import path21 from "path";
3336
+ import path19 from "path";
3303
3337
  import { render } from "ink";
3304
3338
 
3305
3339
  // src/tui-ink/App.tsx
@@ -3307,7 +3341,7 @@ import { useState, useEffect, useRef, useCallback, useMemo } from "react";
3307
3341
  import { Box as Box5 } from "ink";
3308
3342
  import fs23 from "fs";
3309
3343
  import os6 from "os";
3310
- import path20 from "path";
3344
+ import path18 from "path";
3311
3345
  import { execFile as execFile4 } from "child_process";
3312
3346
  import spawn7 from "cross-spawn";
3313
3347
 
@@ -3521,10 +3555,10 @@ async function fetchJiraPane() {
3521
3555
 
3522
3556
  // src/core/tasks.ts
3523
3557
  import fs21 from "fs";
3524
- import path17 from "path";
3558
+ import path15 from "path";
3525
3559
  var EMPTY_STORE = { nextId: 1, tasks: [] };
3526
3560
  function getTasksPath() {
3527
- return path17.join(getConfigDir(), "tasks.json");
3561
+ return path15.join(getConfigDir(), "tasks.json");
3528
3562
  }
3529
3563
  function loadStore() {
3530
3564
  const p = getTasksPath();
@@ -3773,13 +3807,13 @@ var PtySession = class {
3773
3807
 
3774
3808
  // src/core/hook-server.ts
3775
3809
  import http from "http";
3776
- import path19 from "path";
3810
+ import path17 from "path";
3777
3811
 
3778
3812
  // src/core/settings-editor.ts
3779
3813
  import fs22 from "fs";
3780
- import path18 from "path";
3814
+ import path16 from "path";
3781
3815
  import os5 from "os";
3782
- var SETTINGS_PATH = path18.join(os5.homedir(), ".claude", "settings.json");
3816
+ var SETTINGS_PATH = path16.join(os5.homedir(), ".claude", "settings.json");
3783
3817
  var OWNER_TAG = "_workHookOwner";
3784
3818
  var PID_TAG = "_workHookPid";
3785
3819
  var LEGACY_TAGS = ["_workDash", "_work2Dash"];
@@ -3793,7 +3827,7 @@ function readSettings() {
3793
3827
  }
3794
3828
  function writeAtomic(s) {
3795
3829
  try {
3796
- fs22.mkdirSync(path18.dirname(SETTINGS_PATH), { recursive: true });
3830
+ fs22.mkdirSync(path16.dirname(SETTINGS_PATH), { recursive: true });
3797
3831
  const tmp = `${SETTINGS_PATH}.tmp-${process.pid}-${Date.now()}`;
3798
3832
  fs22.writeFileSync(tmp, JSON.stringify(s, null, 2), "utf-8");
3799
3833
  fs22.renameSync(tmp, SETTINGS_PATH);
@@ -3968,7 +4002,7 @@ function removeHttpHooksSync(owner) {
3968
4002
  editSettingsSync(mutateRemove(owner));
3969
4003
  }
3970
4004
  function normalizePath(p) {
3971
- return path19.resolve(p).toLowerCase();
4005
+ return path17.resolve(p).toLowerCase();
3972
4006
  }
3973
4007
 
3974
4008
  // src/core/notifier.ts
@@ -5047,9 +5081,9 @@ var RENDER_INTERVAL_MS = 50;
5047
5081
  var MOUSE_SGR_RE = /\x1b\[<(\d+);(\d+);(\d+)[Mm]/;
5048
5082
  function hasClaudeConversation(dir) {
5049
5083
  try {
5050
- const resolved = path20.resolve(dir);
5084
+ const resolved = path18.resolve(dir);
5051
5085
  const projectDir = resolved.replace(/[^a-zA-Z0-9-]/g, "-");
5052
- const claudeProjectPath = path20.join(os6.homedir(), ".claude", "projects", projectDir);
5086
+ const claudeProjectPath = path18.join(os6.homedir(), ".claude", "projects", projectDir);
5053
5087
  if (!fs23.existsSync(claudeProjectPath)) return false;
5054
5088
  const files = fs23.readdirSync(claudeProjectPath);
5055
5089
  return files.some((f) => f.endsWith(".jsonl"));
@@ -5058,7 +5092,7 @@ function hasClaudeConversation(dir) {
5058
5092
  }
5059
5093
  }
5060
5094
  function ptyDedupKey(pty2) {
5061
- return path20.resolve(pty2.cwd).toLowerCase();
5095
+ return path18.resolve(pty2.cwd).toLowerCase();
5062
5096
  }
5063
5097
  function loadSessions() {
5064
5098
  const all = loadHistory();
@@ -5352,10 +5386,10 @@ function App({ unsafe, onExit }) {
5352
5386
  }
5353
5387
  }, [setScrollBack, renderTermAtScroll]);
5354
5388
  const findPtyByCwd = useCallback((cwd) => {
5355
- const normalized = path20.resolve(cwd).toLowerCase();
5389
+ const normalized = path18.resolve(cwd).toLowerCase();
5356
5390
  for (const pty2 of ptySessions.current.values()) {
5357
5391
  if (pty2.exited) continue;
5358
- if (normalized.startsWith(path20.resolve(pty2.cwd).toLowerCase())) return pty2;
5392
+ if (normalized.startsWith(path18.resolve(pty2.cwd).toLowerCase())) return pty2;
5359
5393
  }
5360
5394
  return void 0;
5361
5395
  }, []);
@@ -5431,13 +5465,13 @@ function App({ unsafe, onExit }) {
5431
5465
  notifiedSessionsRef.current
5432
5466
  );
5433
5467
  if (kind) {
5434
- notifyDesktop(path20.basename(pty2.cwd), kind, {
5468
+ notifyDesktop(path18.basename(pty2.cwd), kind, {
5435
5469
  enabled: config?.notifications === true
5436
5470
  });
5437
5471
  runStatusHooks(
5438
5472
  kind,
5439
5473
  pty2.cwd,
5440
- path20.basename(pty2.cwd),
5474
+ path18.basename(pty2.cwd),
5441
5475
  config?.statusHooks
5442
5476
  );
5443
5477
  }
@@ -5570,7 +5604,7 @@ function App({ unsafe, onExit }) {
5570
5604
  refreshSessions();
5571
5605
  return;
5572
5606
  }
5573
- const dir = s.isGroup ? path20.dirname(existing) : existing;
5607
+ const dir = s.isGroup ? path18.dirname(existing) : existing;
5574
5608
  const resume = hasClaudeConversation(dir);
5575
5609
  const tool = getAiTool(config ?? {});
5576
5610
  const pty2 = new PtySession(dir, termInner, contentHeight - 2, void 0, { tool, unsafe, resume, port: s.port });
@@ -5668,7 +5702,7 @@ function App({ unsafe, onExit }) {
5668
5702
  "",
5669
5703
  " - Ask if I want to proceed with the recommended approach, choose a different one, get more details, or make adjustments."
5670
5704
  ].join("\n");
5671
- promptFile = path20.join(os6.tmpdir(), `work-prompt-${Date.now()}.txt`);
5705
+ promptFile = path18.join(os6.tmpdir(), `work-prompt-${Date.now()}.txt`);
5672
5706
  fs23.writeFileSync(promptFile, prompt, "utf-8");
5673
5707
  }
5674
5708
  const setupArgs = ["tree", projectName, branchName, "--setup-only"];
@@ -5708,7 +5742,7 @@ function App({ unsafe, onExit }) {
5708
5742
  setStatusVersion((v) => v + 1);
5709
5743
  return;
5710
5744
  }
5711
- const launchDir = session.isGroup ? path20.dirname(existing) : existing;
5745
+ const launchDir = session.isGroup ? path18.dirname(existing) : existing;
5712
5746
  const tool = getAiTool(config);
5713
5747
  const aiPty = new PtySession(
5714
5748
  launchDir,
@@ -6283,7 +6317,7 @@ function App({ unsafe, onExit }) {
6283
6317
  setMessage("Session path no longer exists");
6284
6318
  return;
6285
6319
  }
6286
- const dir = s.isGroup ? path20.dirname(existing) : existing;
6320
+ const dir = s.isGroup ? path18.dirname(existing) : existing;
6287
6321
  const editor = config?.editor ?? "code";
6288
6322
  spawn7(editor, [dir], { detached: true, stdio: "ignore" }).unref();
6289
6323
  setMessage(`Opened in ${editor}: ${s.branch}`);
@@ -6468,7 +6502,7 @@ function crashLog(label2, err) {
6468
6502
  const msg = err instanceof Error ? err.stack || err.message : String(err);
6469
6503
  const line = `${(/* @__PURE__ */ new Date()).toISOString()} [CRASH] ${label2}: ${msg}
6470
6504
  `;
6471
- fs24.appendFileSync(path21.join(getConfigDir(), "debug.log"), line);
6505
+ fs24.appendFileSync(path19.join(getConfigDir(), "debug.log"), line);
6472
6506
  } catch {
6473
6507
  }
6474
6508
  }
@@ -6792,22 +6826,22 @@ import chalk17 from "chalk";
6792
6826
 
6793
6827
  // src/core/hydrate.ts
6794
6828
  import fs25 from "fs";
6795
- import path22 from "path";
6829
+ import path20 from "path";
6796
6830
  async function hydrateHistoryFromDisk(config) {
6797
- const worktreesRoot = path22.resolve(config.worktreesRoot);
6831
+ const worktreesRoot = path20.resolve(config.worktreesRoot);
6798
6832
  const folderNameToAlias = /* @__PURE__ */ new Map();
6799
6833
  for (const [alias, repoPath] of Object.entries(config.repos)) {
6800
- folderNameToAlias.set(path22.basename(repoPath), alias);
6834
+ folderNameToAlias.set(path20.basename(repoPath), alias);
6801
6835
  }
6802
6836
  const discovered = /* @__PURE__ */ new Map();
6803
6837
  for (const [alias, repoPath] of Object.entries(config.repos)) {
6804
6838
  if (!fs25.existsSync(repoPath)) continue;
6805
6839
  for (const entry of parseWorktreeList(repoPath)) {
6806
6840
  if (!entry.branch) continue;
6807
- if (path22.resolve(entry.path) === path22.resolve(repoPath)) continue;
6808
- const rel = path22.relative(worktreesRoot, entry.path);
6809
- if (!rel || rel.startsWith("..") || path22.isAbsolute(rel)) continue;
6810
- const parts = rel.split(path22.sep).filter(Boolean);
6841
+ if (path20.resolve(entry.path) === path20.resolve(repoPath)) continue;
6842
+ const rel = path20.relative(worktreesRoot, entry.path);
6843
+ if (!rel || rel.startsWith("..") || path20.isAbsolute(rel)) continue;
6844
+ const parts = rel.split(path20.sep).filter(Boolean);
6811
6845
  if (parts.length < 2) continue;
6812
6846
  const [first, second] = parts;
6813
6847
  const isGroup = Object.prototype.hasOwnProperty.call(config.groups, first);
@@ -6892,13 +6926,13 @@ var hydrateCommand = {
6892
6926
  // src/commands/diff.ts
6893
6927
  import fs36 from "fs";
6894
6928
  import os9 from "os";
6895
- import path33 from "path";
6929
+ import path31 from "path";
6896
6930
  import { spawn as childSpawn } from "child_process";
6897
6931
  import chalk21 from "chalk";
6898
6932
 
6899
6933
  // src/core/diff-pipeline.ts
6900
6934
  import fs28 from "fs";
6901
- import path25 from "path";
6935
+ import path23 from "path";
6902
6936
  import spawn9 from "cross-spawn";
6903
6937
 
6904
6938
  // src/core/diff-parse.ts
@@ -7047,7 +7081,7 @@ function stripPathPrefix(p) {
7047
7081
 
7048
7082
  // src/core/lcov.ts
7049
7083
  import fs26 from "fs";
7050
- import path23 from "path";
7084
+ import path21 from "path";
7051
7085
  function parseLcov(content) {
7052
7086
  const result = /* @__PURE__ */ new Map();
7053
7087
  let sf = null;
@@ -7106,8 +7140,8 @@ function parseLcov(content) {
7106
7140
  }
7107
7141
  function findLcov(root) {
7108
7142
  const candidates = [
7109
- path23.join(root, "coverage", "lcov.info"),
7110
- path23.join(root, "lcov.info")
7143
+ path21.join(root, "coverage", "lcov.info"),
7144
+ path21.join(root, "lcov.info")
7111
7145
  ];
7112
7146
  for (const c of candidates) {
7113
7147
  try {
@@ -7142,33 +7176,33 @@ function readParsedLcov(lcovPath) {
7142
7176
  return { parsed, mtimeMs };
7143
7177
  }
7144
7178
  function normRel(p) {
7145
- return path23.normalize(p).replace(/\\/g, "/").replace(/^\.\//, "");
7179
+ return path21.normalize(p).replace(/\\/g, "/").replace(/^\.\//, "");
7146
7180
  }
7147
7181
  function realRoot(root) {
7148
7182
  try {
7149
- return fs26.realpathSync(path23.resolve(root));
7183
+ return fs26.realpathSync(path21.resolve(root));
7150
7184
  } catch {
7151
- return path23.resolve(root);
7185
+ return path21.resolve(root);
7152
7186
  }
7153
7187
  }
7154
7188
  function canonicalize(absPath) {
7155
- const resolved = path23.resolve(absPath);
7189
+ const resolved = path21.resolve(absPath);
7156
7190
  let dir = resolved;
7157
7191
  const tail = [];
7158
7192
  for (; ; ) {
7159
7193
  try {
7160
7194
  const realDir = fs26.realpathSync(dir);
7161
- return tail.length ? path23.join(realDir, ...tail.reverse()) : realDir;
7195
+ return tail.length ? path21.join(realDir, ...tail.reverse()) : realDir;
7162
7196
  } catch {
7163
- const parent = path23.dirname(dir);
7197
+ const parent = path21.dirname(dir);
7164
7198
  if (parent === dir) return resolved;
7165
- tail.push(path23.basename(dir));
7199
+ tail.push(path21.basename(dir));
7166
7200
  dir = parent;
7167
7201
  }
7168
7202
  }
7169
7203
  }
7170
7204
  function relForAbsSf(absSf, canonRoot) {
7171
- return path23.relative(canonRoot, canonicalize(absSf));
7205
+ return path21.relative(canonRoot, canonicalize(absSf));
7172
7206
  }
7173
7207
  function coverageLookup(root, relPaths) {
7174
7208
  const out = /* @__PURE__ */ new Map();
@@ -7181,7 +7215,7 @@ function coverageLookup(root, relPaths) {
7181
7215
  const canonRoot = realRoot(root);
7182
7216
  const byRel = /* @__PURE__ */ new Map();
7183
7217
  for (const [sf, pct] of read.parsed) {
7184
- const rel = path23.isAbsolute(sf) ? relForAbsSf(sf, canonRoot) : sf;
7218
+ const rel = path21.isAbsolute(sf) ? relForAbsSf(sf, canonRoot) : sf;
7185
7219
  byRel.set(normRel(rel), pct);
7186
7220
  }
7187
7221
  for (const rp of relPaths) {
@@ -7194,12 +7228,12 @@ function coverageLookup(root, relPaths) {
7194
7228
  // src/core/git-tree-snapshot.ts
7195
7229
  import fs27 from "fs";
7196
7230
  import os7 from "os";
7197
- import path24 from "path";
7231
+ import path22 from "path";
7198
7232
  import crypto from "crypto";
7199
7233
  import spawn8 from "cross-spawn";
7200
7234
  function writeTempTree(repoRoot, opts = {}) {
7201
7235
  const includeWorkingTree = opts.includeWorkingTree ?? true;
7202
- const tmpIndex = path24.join(
7236
+ const tmpIndex = path22.join(
7203
7237
  os7.tmpdir(),
7204
7238
  `wd-tree-${process.pid}-${crypto.randomBytes(6).toString("hex")}.idx`
7205
7239
  );
@@ -7244,12 +7278,12 @@ function isMarkdownPath(p) {
7244
7278
  return p !== "/dev/null" && MARKDOWN_EXT_RE.test(p);
7245
7279
  }
7246
7280
  function isInsideRoot(root, rel) {
7247
- const resolvedRoot = path25.resolve(root);
7248
- const resolvedTarget = path25.resolve(resolvedRoot, rel);
7249
- const r = path25.relative(resolvedRoot, resolvedTarget);
7281
+ const resolvedRoot = path23.resolve(root);
7282
+ const resolvedTarget = path23.resolve(resolvedRoot, rel);
7283
+ const r = path23.relative(resolvedRoot, resolvedTarget);
7250
7284
  if (r === "") return true;
7251
7285
  if (r.startsWith("..")) return false;
7252
- if (path25.isAbsolute(r)) return false;
7286
+ if (path23.isAbsolute(r)) return false;
7253
7287
  return true;
7254
7288
  }
7255
7289
  function readMarkdownContent(root, file, fromRef, toRef) {
@@ -7274,10 +7308,10 @@ function readMarkdownContent(root, file, fromRef, toRef) {
7274
7308
  if (file.status !== "deleted" && isMarkdownPath(file.newPath) && isInsideRoot(root, file.newPath)) {
7275
7309
  if (toRef === "working") {
7276
7310
  try {
7277
- const absPath = path25.join(root, file.newPath);
7278
- const realRoot2 = fs28.realpathSync(path25.resolve(root));
7311
+ const absPath = path23.join(root, file.newPath);
7312
+ const realRoot2 = fs28.realpathSync(path23.resolve(root));
7279
7313
  const realPath = fs28.realpathSync(absPath);
7280
- const sep = path25.sep;
7314
+ const sep = path23.sep;
7281
7315
  if (realPath === realRoot2 || realPath.startsWith(realRoot2 + sep)) {
7282
7316
  result.after = fs28.readFileSync(absPath, "utf-8");
7283
7317
  }
@@ -7307,7 +7341,7 @@ function isBinaryContent(buffer) {
7307
7341
  return false;
7308
7342
  }
7309
7343
  function synthesizeUntrackedDiff(root, relPath) {
7310
- const absPath = path25.join(root, relPath);
7344
+ const absPath = path23.join(root, relPath);
7311
7345
  let buffer;
7312
7346
  try {
7313
7347
  buffer = fs28.readFileSync(absPath);
@@ -7398,7 +7432,7 @@ function attachCoverage(root, files) {
7398
7432
  f.coverageMtimeMs = lcovMtimeMs;
7399
7433
  let srcMtimeMs = null;
7400
7434
  try {
7401
- srcMtimeMs = fs28.statSync(path25.join(root, f.path)).mtimeMs;
7435
+ srcMtimeMs = fs28.statSync(path23.join(root, f.path)).mtimeMs;
7402
7436
  } catch {
7403
7437
  srcMtimeMs = null;
7404
7438
  }
@@ -7466,7 +7500,7 @@ function computeRangeDiff(opts) {
7466
7500
 
7467
7501
  // src/core/repo-spec.ts
7468
7502
  import fs29 from "fs";
7469
- import path26 from "path";
7503
+ import path24 from "path";
7470
7504
  import os8 from "os";
7471
7505
  import crypto2 from "crypto";
7472
7506
  function scopeHashFor(keyPaths) {
@@ -7474,21 +7508,21 @@ function scopeHashFor(keyPaths) {
7474
7508
  return crypto2.createHash("sha1").update(key).digest("hex").slice(0, 12);
7475
7509
  }
7476
7510
  function stableDiffPath(keyPaths) {
7477
- const dir = path26.join(os8.homedir(), ".work", "diffs");
7511
+ const dir = path24.join(os8.homedir(), ".work", "diffs");
7478
7512
  fs29.mkdirSync(dir, { recursive: true });
7479
- return path26.join(dir, scopeHashFor(keyPaths));
7513
+ return path24.join(dir, scopeHashFor(keyPaths));
7480
7514
  }
7481
7515
 
7482
7516
  // src/core/diff-scope.ts
7483
7517
  import fs30 from "fs";
7484
- import path27 from "path";
7518
+ import path25 from "path";
7485
7519
  import chalk18 from "chalk";
7486
7520
  function normPath(p) {
7487
- return path27.resolve(p).replace(/\\/g, "/").toLowerCase();
7521
+ return path25.resolve(p).replace(/\\/g, "/").toLowerCase();
7488
7522
  }
7489
7523
  function realNorm(p) {
7490
7524
  try {
7491
- return normPath(fs30.realpathSync(p));
7525
+ return normPath(fs30.realpathSync.native(p));
7492
7526
  } catch {
7493
7527
  return normPath(p);
7494
7528
  }
@@ -7508,29 +7542,29 @@ function resolveScope(cwd) {
7508
7542
  return {
7509
7543
  isGroup: true,
7510
7544
  session: s,
7511
- repos: s.paths.map((rp) => ({ name: path27.basename(rp), root: rp })),
7512
- activeRepoName: path27.basename(p)
7545
+ repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7546
+ activeRepoName: path25.basename(p)
7513
7547
  };
7514
7548
  }
7515
7549
  return {
7516
7550
  isGroup: false,
7517
7551
  session: s,
7518
- repos: [{ name: path27.basename(p), root: p }],
7519
- activeRepoName: path27.basename(p)
7552
+ repos: [{ name: path25.basename(p), root: p }],
7553
+ activeRepoName: path25.basename(p)
7520
7554
  };
7521
7555
  }
7522
7556
  }
7523
7557
  }
7524
7558
  for (const s of sessions) {
7525
7559
  if (!s.isGroup || s.paths.length === 0) continue;
7526
- const parents = s.paths.map((p) => normPath(path27.dirname(p)));
7560
+ const parents = s.paths.map((p) => normPath(path25.dirname(p)));
7527
7561
  const groupRoot = parents[0];
7528
7562
  if (!parents.every((par) => par === groupRoot)) continue;
7529
7563
  if (normCwd === groupRoot || normCwd.startsWith(groupRoot + "/")) {
7530
7564
  return {
7531
7565
  isGroup: true,
7532
7566
  session: s,
7533
- repos: s.paths.map((rp) => ({ name: path27.basename(rp), root: rp })),
7567
+ repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7534
7568
  activeRepoName: null
7535
7569
  };
7536
7570
  }
@@ -7539,8 +7573,8 @@ function resolveScope(cwd) {
7539
7573
  return {
7540
7574
  isGroup: false,
7541
7575
  session: null,
7542
- repos: [{ name: path27.basename(toplevel), root: toplevel }],
7543
- activeRepoName: path27.basename(toplevel)
7576
+ repos: [{ name: path25.basename(toplevel), root: toplevel }],
7577
+ activeRepoName: path25.basename(toplevel)
7544
7578
  };
7545
7579
  }
7546
7580
  function findAnyParentBranch(cwd) {
@@ -7716,7 +7750,7 @@ import { streamSSE } from "hono/streaming";
7716
7750
 
7717
7751
  // src/core/file-context.ts
7718
7752
  import fs31 from "fs";
7719
- import path28 from "path";
7753
+ import path26 from "path";
7720
7754
  import spawn10 from "cross-spawn";
7721
7755
  function readContextLines(opts) {
7722
7756
  const { root, relPath, ref } = opts;
@@ -7738,10 +7772,10 @@ function readContextLines(opts) {
7738
7772
  }
7739
7773
  function readWorkingTree(root, relPath) {
7740
7774
  try {
7741
- const absPath = path28.join(root, relPath);
7742
- const realRoot2 = fs31.realpathSync(path28.resolve(root));
7775
+ const absPath = path26.join(root, relPath);
7776
+ const realRoot2 = fs31.realpathSync(path26.resolve(root));
7743
7777
  const realPath = fs31.realpathSync(absPath);
7744
- const sep = path28.sep;
7778
+ const sep = path26.sep;
7745
7779
  if (realPath !== realRoot2 && !realPath.startsWith(realRoot2 + sep)) {
7746
7780
  return null;
7747
7781
  }
@@ -7763,7 +7797,7 @@ function readAtRef(root, ref, relPath) {
7763
7797
 
7764
7798
  // src/core/fs-watcher.ts
7765
7799
  import fs32 from "fs";
7766
- import path29 from "path";
7800
+ import path27 from "path";
7767
7801
  import chalk19 from "chalk";
7768
7802
  import chokidar from "chokidar";
7769
7803
  var IGNORED_DIRS = /* @__PURE__ */ new Set([
@@ -7789,7 +7823,7 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
7789
7823
  ]);
7790
7824
  function isIgnoredWatchPath(roots, filePath) {
7791
7825
  for (const root of roots) {
7792
- const rel = path29.relative(root, filePath).replace(/\\/g, "/");
7826
+ const rel = path27.relative(root, filePath).replace(/\\/g, "/");
7793
7827
  if (rel === "" || rel.startsWith("../")) continue;
7794
7828
  if (rel.split("/").some((seg) => IGNORED_DIRS.has(seg))) return true;
7795
7829
  }
@@ -7814,7 +7848,7 @@ function createFsWatcher(opts) {
7814
7848
  if (SUPPORTS_RECURSIVE_WATCH) {
7815
7849
  const watchers = opts.roots.map((root) => {
7816
7850
  const w = fs32.watch(root, { recursive: true }, (_event, filename) => {
7817
- if (filename && isIgnoredWatchPath([root], path29.join(root, filename.toString()))) {
7851
+ if (filename && isIgnoredWatchPath([root], path27.join(root, filename.toString()))) {
7818
7852
  return;
7819
7853
  }
7820
7854
  fire();
@@ -7853,29 +7887,29 @@ function createFsWatcher(opts) {
7853
7887
 
7854
7888
  // src/core/web-static.ts
7855
7889
  import fs33 from "fs";
7856
- import path30 from "path";
7890
+ import path28 from "path";
7857
7891
  import { fileURLToPath } from "url";
7858
7892
  function resolveWebRoot() {
7859
- const entryDir = path30.dirname(process.argv[1] ?? "");
7860
- const moduleDir = path30.dirname(fileURLToPath(import.meta.url));
7893
+ const entryDir = path28.dirname(process.argv[1] ?? "");
7894
+ const moduleDir = path28.dirname(fileURLToPath(import.meta.url));
7861
7895
  const candidates = [
7862
- path30.join(entryDir, "web"),
7896
+ path28.join(entryDir, "web"),
7863
7897
  // bundled: this module is inlined into dist/<bin>.js, so dist/web is a
7864
7898
  // sibling of the bundle. Works even when argv[1] is an npm bin symlink
7865
7899
  // (which is not realpath'd, so the entryDir candidate above misses).
7866
- path30.join(moduleDir, "web"),
7900
+ path28.join(moduleDir, "web"),
7867
7901
  // dev/tsx fallback: walk up from src/core to repo root then into dist/web.
7868
- path30.resolve(moduleDir, "../../dist/web")
7902
+ path28.resolve(moduleDir, "../../dist/web")
7869
7903
  ];
7870
7904
  for (const c of candidates) {
7871
- if (fs33.existsSync(path30.join(c, "index.html"))) return c;
7905
+ if (fs33.existsSync(path28.join(c, "index.html"))) return c;
7872
7906
  }
7873
7907
  return null;
7874
7908
  }
7875
7909
 
7876
7910
  // src/core/spa-handler.ts
7877
7911
  import fs34 from "fs";
7878
- import path31 from "path";
7912
+ import path29 from "path";
7879
7913
  var MIME = {
7880
7914
  ".html": "text/html; charset=utf-8",
7881
7915
  ".js": "application/javascript; charset=utf-8",
@@ -7889,9 +7923,9 @@ var MIME = {
7889
7923
  function readFile(root, relPath) {
7890
7924
  const clean = relPath.split("?")[0];
7891
7925
  const requested = clean === "/" ? "/index.html" : clean;
7892
- const filePath = path31.join(root, requested);
7893
- const norm = path31.normalize(filePath);
7894
- if (!norm.startsWith(path31.normalize(root))) return null;
7926
+ const filePath = path29.join(root, requested);
7927
+ const norm = path29.normalize(filePath);
7928
+ if (!norm.startsWith(path29.normalize(root))) return null;
7895
7929
  let stat;
7896
7930
  try {
7897
7931
  stat = fs34.statSync(norm);
@@ -7899,7 +7933,7 @@ function readFile(root, relPath) {
7899
7933
  return null;
7900
7934
  }
7901
7935
  if (!stat.isFile()) return null;
7902
- const ext = path31.extname(norm).toLowerCase();
7936
+ const ext = path29.extname(norm).toLowerCase();
7903
7937
  return { body: fs34.readFileSync(norm), ext };
7904
7938
  }
7905
7939
  function serveSpa(c, webRoot) {
@@ -8194,7 +8228,7 @@ function diffReviewSnapshot(snapshot, seen) {
8194
8228
 
8195
8229
  // src/core/static-renderer.ts
8196
8230
  import fs35 from "fs";
8197
- import path32 from "path";
8231
+ import path30 from "path";
8198
8232
  function buildDiff(specs, resolvedBase) {
8199
8233
  return {
8200
8234
  repos: specs.map((r) => ({
@@ -8210,7 +8244,7 @@ function renderStatic(opts) {
8210
8244
  if (!webRoot) {
8211
8245
  throw new Error("Could not find dist/web/. Run `npm run build` first.");
8212
8246
  }
8213
- const shellPath = path32.join(webRoot, "index.html");
8247
+ const shellPath = path30.join(webRoot, "index.html");
8214
8248
  let shell = fs35.readFileSync(shellPath, "utf-8");
8215
8249
  const uncommitted = buildDiff(opts.uncommitted, "HEAD");
8216
8250
  const branch = opts.branch ? buildDiff(opts.branch.specs, opts.branch.resolvedBase) : void 0;
@@ -8260,8 +8294,8 @@ function escapeForScriptTag(json) {
8260
8294
  }
8261
8295
  function readAsset(webRoot, urlPath) {
8262
8296
  const clean = urlPath.split("?")[0].replace(/^\//, "");
8263
- const full = path32.join(webRoot, clean);
8264
- if (!path32.normalize(full).startsWith(path32.normalize(webRoot))) return null;
8297
+ const full = path30.join(webRoot, clean);
8298
+ if (!path30.normalize(full).startsWith(path30.normalize(webRoot))) return null;
8265
8299
  try {
8266
8300
  return fs35.readFileSync(full, "utf-8");
8267
8301
  } catch {
@@ -8304,7 +8338,7 @@ async function runStop(repoSpecs) {
8304
8338
  }
8305
8339
  }
8306
8340
  function webUrlFilePath() {
8307
- return path33.join(os9.homedir(), ".work", "web.url");
8341
+ return path31.join(os9.homedir(), ".work", "web.url");
8308
8342
  }
8309
8343
  function resolveWorkBinPath(selfArgv1) {
8310
8344
  let real = selfArgv1;
@@ -8313,7 +8347,7 @@ function resolveWorkBinPath(selfArgv1) {
8313
8347
  } catch {
8314
8348
  }
8315
8349
  if (real.endsWith("wd-bin.js")) {
8316
- return path33.join(path33.dirname(real), "bin.js");
8350
+ return path31.join(path31.dirname(real), "bin.js");
8317
8351
  }
8318
8352
  return real;
8319
8353
  }
@@ -8325,12 +8359,32 @@ function readWebUrl() {
8325
8359
  return null;
8326
8360
  }
8327
8361
  }
8362
+ async function webServerResponds(url, timeoutMs = 1500) {
8363
+ try {
8364
+ const ctrl = new AbortController();
8365
+ const timer = setTimeout(() => ctrl.abort(), timeoutMs);
8366
+ try {
8367
+ const res = await fetch(`${url}api/context`, { signal: ctrl.signal });
8368
+ return res.ok;
8369
+ } finally {
8370
+ clearTimeout(timer);
8371
+ }
8372
+ } catch {
8373
+ return false;
8374
+ }
8375
+ }
8328
8376
  async function ensureWorkWebRunning() {
8329
8377
  const existing = readWebUrl();
8330
- if (existing) return existing;
8378
+ if (existing) {
8379
+ if (await webServerResponds(existing)) return existing;
8380
+ try {
8381
+ fs36.unlinkSync(webUrlFilePath());
8382
+ } catch {
8383
+ }
8384
+ }
8331
8385
  const workBin = resolveWorkBinPath(process.argv[1]);
8332
8386
  const out = fs36.openSync(
8333
- path33.join(os9.homedir(), ".work", "web-autostart.log"),
8387
+ path31.join(os9.homedir(), ".work", "web-autostart.log"),
8334
8388
  "a"
8335
8389
  );
8336
8390
  const child = childSpawn(
@@ -8672,19 +8726,19 @@ var diffCommand = {
8672
8726
  // src/commands/web.ts
8673
8727
  import fs41 from "fs";
8674
8728
  import os13 from "os";
8675
- import path42 from "path";
8729
+ import path40 from "path";
8676
8730
  import chalk23 from "chalk";
8677
8731
 
8678
8732
  // src/core/web-server.ts
8679
8733
  import fs40 from "fs";
8680
8734
  import os12 from "os";
8681
- import path41 from "path";
8735
+ import path39 from "path";
8682
8736
  import chalk22 from "chalk";
8683
8737
  import { Hono as Hono3 } from "hono";
8684
8738
  import { streamSSE as streamSSE3 } from "hono/streaming";
8685
8739
 
8686
8740
  // src/core/web-state.ts
8687
- import path34 from "path";
8741
+ import path32 from "path";
8688
8742
  import crypto4 from "crypto";
8689
8743
  import chokidar2 from "chokidar";
8690
8744
  function sessionIdFor(s) {
@@ -8705,7 +8759,7 @@ function subscribeSession(sessionId, onChange) {
8705
8759
  const watcher = chokidar2.watch(roots, {
8706
8760
  ignored: (filePath) => {
8707
8761
  for (const r of roots) {
8708
- const rel = path34.relative(r, filePath).replace(/\\/g, "/");
8762
+ const rel = path32.relative(r, filePath).replace(/\\/g, "/");
8709
8763
  if (rel === ".git" || rel.startsWith(".git/")) return true;
8710
8764
  }
8711
8765
  return false;
@@ -8820,16 +8874,16 @@ function disposeAllPtys() {
8820
8874
 
8821
8875
  // src/core/comment-file-store.ts
8822
8876
  import fs37 from "fs";
8823
- import path35 from "path";
8877
+ import path33 from "path";
8824
8878
  import os10 from "os";
8825
8879
  function commentsDir() {
8826
- return path35.join(os10.homedir(), ".work", "comments");
8880
+ return path33.join(os10.homedir(), ".work", "comments");
8827
8881
  }
8828
8882
  function ensureDir() {
8829
8883
  fs37.mkdirSync(commentsDir(), { recursive: true });
8830
8884
  }
8831
8885
  function commentsFileFor(sessionId) {
8832
- return path35.join(commentsDir(), `${sessionId}.json`);
8886
+ return path33.join(commentsDir(), `${sessionId}.json`);
8833
8887
  }
8834
8888
  function pathFor(sessionId) {
8835
8889
  return commentsFileFor(sessionId);
@@ -8909,11 +8963,11 @@ function clearCommentStoreCache() {
8909
8963
 
8910
8964
  // src/core/pending-delivery.ts
8911
8965
  import fs38 from "fs";
8912
- import path36 from "path";
8966
+ import path34 from "path";
8913
8967
  function pathFor2(sessionId) {
8914
8968
  return {
8915
8969
  comments: commentsFileFor(sessionId),
8916
- delivered: path36.join(commentsDir(), `${sessionId}.delivered.json`)
8970
+ delivered: path34.join(commentsDir(), `${sessionId}.delivered.json`)
8917
8971
  };
8918
8972
  }
8919
8973
  function readJson(filePath, fallback) {
@@ -8924,13 +8978,13 @@ function readJson(filePath, fallback) {
8924
8978
  }
8925
8979
  }
8926
8980
  function writeAtomic2(filePath, content) {
8927
- fs38.mkdirSync(path36.dirname(filePath), { recursive: true });
8981
+ fs38.mkdirSync(path34.dirname(filePath), { recursive: true });
8928
8982
  const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
8929
8983
  fs38.writeFileSync(tmp, content, "utf-8");
8930
8984
  fs38.renameSync(tmp, filePath);
8931
8985
  }
8932
8986
  function normalize(p) {
8933
- return path36.resolve(p).replace(/\\/g, "/").toLowerCase();
8987
+ return path34.resolve(p).replace(/\\/g, "/").toLowerCase();
8934
8988
  }
8935
8989
  function findSessionForCwd(cwd) {
8936
8990
  const norm = normalize(cwd);
@@ -8961,7 +9015,7 @@ function readPendingForSession(sessionId) {
8961
9015
  return comments.filter(isPendingFor(delivered));
8962
9016
  }
8963
9017
  function scopeStoreIdsForPaths(paths) {
8964
- const resolved = paths.map((p) => path36.resolve(p));
9018
+ const resolved = paths.map((p) => path34.resolve(p));
8965
9019
  const ids = /* @__PURE__ */ new Set();
8966
9020
  ids.add(`scope-${scopeHashFor(resolved)}`);
8967
9021
  for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);
@@ -9284,7 +9338,7 @@ function mountPanesRoutes(app, opts) {
9284
9338
  }
9285
9339
 
9286
9340
  // src/core/worktree-routes.ts
9287
- import path37 from "path";
9341
+ import path35 from "path";
9288
9342
  import { spawn as spawn11 } from "child_process";
9289
9343
  import { zValidator as zValidator4 } from "@hono/zod-validator";
9290
9344
  import { z as z3 } from "zod";
@@ -9408,7 +9462,7 @@ function mountWorktreeRoutes(app, opts) {
9408
9462
  const id = c.req.param("id");
9409
9463
  const session = findSession2(id);
9410
9464
  if (!session) return c.json({ error: "unknown session" }, 404);
9411
- const target = session.isGroup ? path37.dirname(session.paths[0]) : session.paths[0];
9465
+ const target = session.isGroup ? path35.dirname(session.paths[0]) : session.paths[0];
9412
9466
  try {
9413
9467
  const cmd = process.platform === "win32" ? "code.cmd" : "code";
9414
9468
  const child = spawn11(cmd, [target], {
@@ -9428,18 +9482,18 @@ function mountWorktreeRoutes(app, opts) {
9428
9482
  import { zValidator as zValidator5 } from "@hono/zod-validator";
9429
9483
  import { z as z4 } from "zod";
9430
9484
  import { EventEmitter } from "events";
9431
- import path40 from "path";
9485
+ import path38 from "path";
9432
9486
  import spawn13 from "cross-spawn";
9433
9487
 
9434
9488
  // src/core/checkpoint.ts
9435
9489
  import fs39 from "fs";
9436
9490
  import os11 from "os";
9437
- import path38 from "path";
9491
+ import path36 from "path";
9438
9492
  import spawn12 from "cross-spawn";
9439
9493
  function manifestPath(scopeHash) {
9440
- const dir = path38.join(os11.homedir(), ".work", "diffs");
9494
+ const dir = path36.join(os11.homedir(), ".work", "diffs");
9441
9495
  fs39.mkdirSync(dir, { recursive: true });
9442
- return path38.join(dir, `${scopeHash}.checkpoints.json`);
9496
+ return path36.join(dir, `${scopeHash}.checkpoints.json`);
9443
9497
  }
9444
9498
  function emptyManifest(scopeHash) {
9445
9499
  return { version: 1, scopeHash, entries: [] };
@@ -9580,7 +9634,7 @@ function clearCheckpoints(scopeHash, repoRoots) {
9580
9634
  }
9581
9635
 
9582
9636
  // src/core/scope-manager.ts
9583
- import path39 from "path";
9637
+ import path37 from "path";
9584
9638
  import crypto5 from "crypto";
9585
9639
  var scopes = /* @__PURE__ */ new Map();
9586
9640
  function hashFor(paths) {
@@ -9597,7 +9651,7 @@ var ScopePathRejectedError = class extends Error {
9597
9651
  }
9598
9652
  };
9599
9653
  function normaliseForCompare(p) {
9600
- return path39.resolve(p).replace(/\\/g, "/").toLowerCase();
9654
+ return path37.resolve(p).replace(/\\/g, "/").toLowerCase();
9601
9655
  }
9602
9656
  function rejectedPaths(normalised) {
9603
9657
  const config = loadConfig();
@@ -9615,7 +9669,7 @@ function rejectedPaths(normalised) {
9615
9669
  });
9616
9670
  }
9617
9671
  function registerScope(paths, label2) {
9618
- const normalised = paths.map((p) => path39.resolve(p));
9672
+ const normalised = paths.map((p) => path37.resolve(p));
9619
9673
  const rejected = rejectedPaths(normalised);
9620
9674
  if (rejected.length > 0) throw new ScopePathRejectedError(rejected);
9621
9675
  const hash = hashFor(normalised);
@@ -9629,7 +9683,7 @@ function registerScope(paths, label2) {
9629
9683
  const scope = {
9630
9684
  hash,
9631
9685
  paths: normalised,
9632
- label: label2 ?? path39.basename(normalised[0]),
9686
+ label: label2 ?? path37.basename(normalised[0]),
9633
9687
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
9634
9688
  ended: false
9635
9689
  };
@@ -9826,7 +9880,7 @@ function mountScopeRoutes(app, opts) {
9826
9880
  const fromSha = fromEntry.repos[p] ?? "HEAD";
9827
9881
  const toSha = toEntry === void 0 ? "working" : toEntry.repos[p] ?? "HEAD";
9828
9882
  return {
9829
- name: path40.basename(p),
9883
+ name: path38.basename(p),
9830
9884
  root: p,
9831
9885
  files: computeRangeDiff({ root: p, fromRef: fromSha, toRef: toSha })
9832
9886
  };
@@ -9844,7 +9898,7 @@ function mountScopeRoutes(app, opts) {
9844
9898
  (p) => resolveRepoDiff(p, base, sessionBaseForPath(p))
9845
9899
  );
9846
9900
  const repos = scope.paths.map((p, i) => ({
9847
- name: path40.basename(p),
9901
+ name: path38.basename(p),
9848
9902
  root: p,
9849
9903
  resolvedBase: resolved[i].resolvedBase,
9850
9904
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -9874,7 +9928,7 @@ function mountScopeRoutes(app, opts) {
9874
9928
  if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {
9875
9929
  return c.json({ error: "bad path/start/end" }, 400);
9876
9930
  }
9877
- const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path40.basename(p) === repoName);
9931
+ const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path38.basename(p) === repoName);
9878
9932
  if (!root) return c.json({ error: "unknown repo" }, 404);
9879
9933
  const result = readContextLines({ root, relPath, start, end, ref });
9880
9934
  if (!result) return c.json({ error: "cannot read file" }, 400);
@@ -10112,7 +10166,7 @@ function computeSessionDiff(s, base) {
10112
10166
  (p) => resolveRepoDiff(p, base, s.baseBranches?.[p] ?? s.baseBranch)
10113
10167
  );
10114
10168
  const repos = s.paths.map((p, i) => ({
10115
- name: path41.basename(p),
10169
+ name: path39.basename(p),
10116
10170
  root: p,
10117
10171
  resolvedBase: resolved[i].resolvedBase,
10118
10172
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -10132,10 +10186,10 @@ async function startWebServer(opts = {}) {
10132
10186
  for (const cb of sseListeners) cb({ event, data });
10133
10187
  };
10134
10188
  const home = os12.homedir();
10135
- const historyPath = path41.join(home, ".work", "history.json");
10189
+ const historyPath = path39.join(home, ".work", "history.json");
10136
10190
  const onHistoryChange = () => broadcast("sessions-changed", { ts: Date.now() });
10137
10191
  fs40.watchFile(historyPath, { interval: 1e3 }, onHistoryChange);
10138
- const tasksPath = path41.join(home, ".work", "tasks.json");
10192
+ const tasksPath = path39.join(home, ".work", "tasks.json");
10139
10193
  const onTasksChange = () => broadcast("tasks-changed", { ts: Date.now() });
10140
10194
  fs40.watchFile(tasksPath, { interval: 1e3 }, onTasksChange);
10141
10195
  const projectsRoot = claudeProjectsRoot();
@@ -10280,10 +10334,10 @@ function info2(message) {
10280
10334
  process.stderr.write(message + "\n");
10281
10335
  }
10282
10336
  function urlFilePath() {
10283
- return path42.join(os13.homedir(), ".work", "web.url");
10337
+ return path40.join(os13.homedir(), ".work", "web.url");
10284
10338
  }
10285
10339
  function pidFilePath() {
10286
- return path42.join(os13.homedir(), ".work", "web.pid");
10340
+ return path40.join(os13.homedir(), ".work", "web.pid");
10287
10341
  }
10288
10342
  function isPidAlive(pid) {
10289
10343
  try {
@@ -10408,7 +10462,7 @@ var webCommand = {
10408
10462
  const lean = !!argv.lean || process.env.WORK_WEB_LEAN === "1";
10409
10463
  const handle = await startWebServer({ lean });
10410
10464
  try {
10411
- fs41.mkdirSync(path42.dirname(urlFilePath()), { recursive: true });
10465
+ fs41.mkdirSync(path40.dirname(urlFilePath()), { recursive: true });
10412
10466
  fs41.writeFileSync(urlFilePath(), handle.url);
10413
10467
  fs41.writeFileSync(pidFilePath(), String(process.pid));
10414
10468
  } catch {
@@ -10946,7 +11000,7 @@ var broadcastCommand = {
10946
11000
 
10947
11001
  // src/completions/index.ts
10948
11002
  import fs44 from "fs";
10949
- import path43 from "path";
11003
+ import path41 from "path";
10950
11004
  function completionHandler(current, argv, done) {
10951
11005
  const rawArgs = argv._;
10952
11006
  const args = rawArgs.slice(1, -1);
@@ -11059,18 +11113,18 @@ function completeRepoBranches(alias, current, config, done) {
11059
11113
  done(branches);
11060
11114
  }
11061
11115
  function completeGroupBranches(groupName, repoAliases, current, config, done) {
11062
- const groupDir = path43.join(config.worktreesRoot, groupName);
11116
+ const groupDir = path41.join(config.worktreesRoot, groupName);
11063
11117
  if (!fs44.existsSync(groupDir)) {
11064
11118
  done([]);
11065
11119
  return;
11066
11120
  }
11067
11121
  try {
11068
11122
  const branchDirs = fs44.readdirSync(groupDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => {
11069
- const bdPath = path43.join(groupDir, d.name);
11123
+ const bdPath = path41.join(groupDir, d.name);
11070
11124
  for (const alias of repoAliases) {
11071
11125
  const repoPath = config.repos[alias];
11072
11126
  if (!repoPath) continue;
11073
- const subPath = path43.join(bdPath, path43.basename(repoPath));
11127
+ const subPath = path41.join(bdPath, path41.basename(repoPath));
11074
11128
  if (fs44.existsSync(subPath)) {
11075
11129
  const branch = getCurrentBranch(subPath);
11076
11130
  if (branch) return branch;
@@ -11085,7 +11139,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
11085
11139
  }
11086
11140
 
11087
11141
  // src/version.ts
11088
- var VERSION = true ? "1.8.0" : "dev";
11142
+ var VERSION = true ? "1.8.5" : "dev";
11089
11143
 
11090
11144
  // src/cli.ts
11091
11145
  function showHelp() {
@@ -11183,7 +11237,7 @@ function handleFatalError(err) {
11183
11237
  if (err instanceof Error && err.message?.includes("pty that has already exited")) {
11184
11238
  try {
11185
11239
  fs45.appendFileSync(
11186
- path44.join(getConfigDir(), "debug.log"),
11240
+ path42.join(getConfigDir(), "debug.log"),
11187
11241
  `${(/* @__PURE__ */ new Date()).toISOString()} [WARN] Ignored async node-pty error: ${err.message}
11188
11242
  `
11189
11243
  );
@@ -11194,7 +11248,7 @@ function handleFatalError(err) {
11194
11248
  try {
11195
11249
  const msg = err instanceof Error ? err.stack || err.message : String(err);
11196
11250
  fs45.appendFileSync(
11197
- path44.join(getConfigDir(), "debug.log"),
11251
+ path42.join(getConfigDir(), "debug.log"),
11198
11252
  `${(/* @__PURE__ */ new Date()).toISOString()} [FATAL] handleFatalError: ${msg}
11199
11253
  `
11200
11254
  );