@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/wd-bin.js CHANGED
@@ -1486,6 +1486,28 @@ function effectiveLastAccessedAt(session) {
1486
1486
  }
1487
1487
  return new Date(bestMs).toISOString();
1488
1488
  }
1489
+ function resolveResumeLaunch(session) {
1490
+ const existing = session.paths.filter((p) => fs9.existsSync(p));
1491
+ const first = existing[0] ?? session.paths[0];
1492
+ const defaultPath = session.isGroup ? path9.dirname(first) : first;
1493
+ const candidates = /* @__PURE__ */ new Set();
1494
+ if (session.isGroup) {
1495
+ for (const p of existing) candidates.add(path9.dirname(p));
1496
+ for (const p of existing) candidates.add(p);
1497
+ } else {
1498
+ for (const p of existing) candidates.add(p);
1499
+ }
1500
+ let launchPath = defaultPath;
1501
+ let bestMs = 0;
1502
+ for (const c of candidates) {
1503
+ const ms = getClaudeActivityMs(c);
1504
+ if (ms > bestMs) {
1505
+ bestMs = ms;
1506
+ launchPath = c;
1507
+ }
1508
+ }
1509
+ return { launchPath, hasConversation: bestMs > 0 };
1510
+ }
1489
1511
  var ACTIVE_MS = 3e4;
1490
1512
  var OPEN_MS = 5 * 6e4;
1491
1513
  function readSessionActivity(session) {
@@ -2745,7 +2767,6 @@ function printSessionStatus(session) {
2745
2767
 
2746
2768
  // src/commands/recent.ts
2747
2769
  import fs17 from "fs";
2748
- import path14 from "path";
2749
2770
  import chalk10 from "chalk";
2750
2771
  import { select as select2 } from "@inquirer/prompts";
2751
2772
  var recentCommand = {
@@ -2803,12 +2824,19 @@ var recentCommand = {
2803
2824
  process.exitCode = 1;
2804
2825
  return;
2805
2826
  }
2806
- const launchPath = choice.isGroup ? path14.dirname(firstExisting) : firstExisting;
2827
+ const { launchPath, hasConversation } = resolveResumeLaunch(choice);
2807
2828
  await upsertSession(choice.target, choice.isGroup, choice.branch, choice.paths);
2808
2829
  const tool = getAiTool(config);
2809
2830
  console.log(chalk10.cyan(`Resuming in: ${launchPath}`));
2831
+ if (!hasConversation) {
2832
+ console.log(
2833
+ chalk10.yellow(
2834
+ `No prior ${tool.cmd} conversation found for this worktree \u2014 starting a fresh session.`
2835
+ )
2836
+ );
2837
+ }
2810
2838
  console.log(`Starting ${tool.cmd}...`);
2811
- launchAi(launchPath, tool, { unsafe, resume: true }, choice.port);
2839
+ launchAi(launchPath, tool, { unsafe, resume: hasConversation }, choice.port);
2812
2840
  return;
2813
2841
  }
2814
2842
  console.log("");
@@ -2835,7 +2863,6 @@ var recentCommand = {
2835
2863
 
2836
2864
  // src/commands/resume.ts
2837
2865
  import fs18 from "fs";
2838
- import path15 from "path";
2839
2866
  import chalk11 from "chalk";
2840
2867
  import { select as select3 } from "@inquirer/prompts";
2841
2868
  var resumeCommand = {
@@ -2878,12 +2905,19 @@ var resumeCommand = {
2878
2905
  process.exitCode = 1;
2879
2906
  return;
2880
2907
  }
2881
- const launchPath = choice.isGroup ? path15.dirname(firstExisting) : firstExisting;
2908
+ const { launchPath, hasConversation } = resolveResumeLaunch(choice);
2882
2909
  await upsertSession(choice.target, choice.isGroup, choice.branch, choice.paths);
2883
2910
  const tool = getAiTool(config);
2884
2911
  console.log(chalk11.cyan(`Resuming in: ${launchPath}`));
2912
+ if (!hasConversation) {
2913
+ console.log(
2914
+ chalk11.yellow(
2915
+ `No prior ${tool.cmd} conversation found for this worktree \u2014 starting a fresh session.`
2916
+ )
2917
+ );
2918
+ }
2885
2919
  console.log(`Starting ${tool.cmd}...`);
2886
- launchAi(launchPath, tool, { unsafe, resume: true }, choice.port);
2920
+ launchAi(launchPath, tool, { unsafe, resume: hasConversation }, choice.port);
2887
2921
  }
2888
2922
  };
2889
2923
 
@@ -2893,7 +2927,7 @@ import { checkbox } from "@inquirer/prompts";
2893
2927
 
2894
2928
  // src/core/prunable-scan.ts
2895
2929
  import fs19 from "fs";
2896
- import path16 from "path";
2930
+ import path14 from "path";
2897
2931
  import chalk12 from "chalk";
2898
2932
  function collectPrunable(config, options = {}) {
2899
2933
  const { fetch: fetch2 = true, print = true, includeSquash = false } = options;
@@ -2910,7 +2944,7 @@ function collectPrunable(config, options = {}) {
2910
2944
  }
2911
2945
  const groupCoveredKeys = /* @__PURE__ */ new Set();
2912
2946
  for (const [groupName, aliases] of Object.entries(config.groups)) {
2913
- const groupDir = path16.join(config.worktreesRoot, groupName);
2947
+ const groupDir = path14.join(config.worktreesRoot, groupName);
2914
2948
  if (!fs19.existsSync(groupDir)) continue;
2915
2949
  let branchDirs;
2916
2950
  try {
@@ -2919,7 +2953,7 @@ function collectPrunable(config, options = {}) {
2919
2953
  continue;
2920
2954
  }
2921
2955
  for (const branchDir of branchDirs) {
2922
- const branchDirPath = path16.join(groupDir, branchDir);
2956
+ const branchDirPath = path14.join(groupDir, branchDir);
2923
2957
  let branch;
2924
2958
  let allMerged = true;
2925
2959
  let groupHasChanges = false;
@@ -2933,8 +2967,8 @@ function collectPrunable(config, options = {}) {
2933
2967
  skipped = true;
2934
2968
  continue;
2935
2969
  }
2936
- const repoName = path16.basename(repoPath);
2937
- const subWorktreePath = path16.join(branchDirPath, repoName);
2970
+ const repoName = path14.basename(repoPath);
2971
+ const subWorktreePath = path14.join(branchDirPath, repoName);
2938
2972
  if (!fs19.existsSync(subWorktreePath)) {
2939
2973
  continue;
2940
2974
  }
@@ -3051,7 +3085,7 @@ async function removeSingleEntry(entry, force = true) {
3051
3085
  }
3052
3086
  async function removeGroupEntry(entry, config, force = true) {
3053
3087
  const workTreeDirName = entry.branch.replace(/\//g, "-");
3054
- const groupWorktreePath = path16.join(
3088
+ const groupWorktreePath = path14.join(
3055
3089
  config.worktreesRoot,
3056
3090
  entry.target,
3057
3091
  workTreeDirName
@@ -3061,7 +3095,7 @@ async function removeGroupEntry(entry, config, force = true) {
3061
3095
  );
3062
3096
  let allRemoved = true;
3063
3097
  for (const { alias, repoPath, worktreePath } of entry.repos) {
3064
- const repoName = path16.basename(repoPath);
3098
+ const repoName = path14.basename(repoPath);
3065
3099
  console.log(chalk12.cyan(` [${alias}] (${repoName}):`));
3066
3100
  const removed = removeSingleWorktree(repoPath, worktreePath, entry.branch, force);
3067
3101
  if (!removed) {
@@ -3071,7 +3105,7 @@ async function removeGroupEntry(entry, config, force = true) {
3071
3105
  if (allRemoved) {
3072
3106
  await removeSession(entry.target, entry.branch);
3073
3107
  }
3074
- const claudeMdInWorktree = path16.join(groupWorktreePath, "CLAUDE.md");
3108
+ const claudeMdInWorktree = path14.join(groupWorktreePath, "CLAUDE.md");
3075
3109
  if (fs19.existsSync(claudeMdInWorktree)) {
3076
3110
  fs19.unlinkSync(claudeMdInWorktree);
3077
3111
  }
@@ -3297,7 +3331,7 @@ var syncCommand = {
3297
3331
 
3298
3332
  // src/tui-ink/index.tsx
3299
3333
  import fs24 from "fs";
3300
- import path21 from "path";
3334
+ import path19 from "path";
3301
3335
  import { render } from "ink";
3302
3336
 
3303
3337
  // src/tui-ink/App.tsx
@@ -3305,7 +3339,7 @@ import { useState, useEffect, useRef, useCallback, useMemo } from "react";
3305
3339
  import { Box as Box5 } from "ink";
3306
3340
  import fs23 from "fs";
3307
3341
  import os6 from "os";
3308
- import path20 from "path";
3342
+ import path18 from "path";
3309
3343
  import { execFile as execFile4 } from "child_process";
3310
3344
  import spawn7 from "cross-spawn";
3311
3345
 
@@ -3519,10 +3553,10 @@ async function fetchJiraPane() {
3519
3553
 
3520
3554
  // src/core/tasks.ts
3521
3555
  import fs21 from "fs";
3522
- import path17 from "path";
3556
+ import path15 from "path";
3523
3557
  var EMPTY_STORE = { nextId: 1, tasks: [] };
3524
3558
  function getTasksPath() {
3525
- return path17.join(getConfigDir(), "tasks.json");
3559
+ return path15.join(getConfigDir(), "tasks.json");
3526
3560
  }
3527
3561
  function loadStore() {
3528
3562
  const p = getTasksPath();
@@ -3771,13 +3805,13 @@ var PtySession = class {
3771
3805
 
3772
3806
  // src/core/hook-server.ts
3773
3807
  import http from "http";
3774
- import path19 from "path";
3808
+ import path17 from "path";
3775
3809
 
3776
3810
  // src/core/settings-editor.ts
3777
3811
  import fs22 from "fs";
3778
- import path18 from "path";
3812
+ import path16 from "path";
3779
3813
  import os5 from "os";
3780
- var SETTINGS_PATH = path18.join(os5.homedir(), ".claude", "settings.json");
3814
+ var SETTINGS_PATH = path16.join(os5.homedir(), ".claude", "settings.json");
3781
3815
  var OWNER_TAG = "_workHookOwner";
3782
3816
  var PID_TAG = "_workHookPid";
3783
3817
  var LEGACY_TAGS = ["_workDash", "_work2Dash"];
@@ -3791,7 +3825,7 @@ function readSettings() {
3791
3825
  }
3792
3826
  function writeAtomic(s) {
3793
3827
  try {
3794
- fs22.mkdirSync(path18.dirname(SETTINGS_PATH), { recursive: true });
3828
+ fs22.mkdirSync(path16.dirname(SETTINGS_PATH), { recursive: true });
3795
3829
  const tmp = `${SETTINGS_PATH}.tmp-${process.pid}-${Date.now()}`;
3796
3830
  fs22.writeFileSync(tmp, JSON.stringify(s, null, 2), "utf-8");
3797
3831
  fs22.renameSync(tmp, SETTINGS_PATH);
@@ -3966,7 +4000,7 @@ function removeHttpHooksSync(owner) {
3966
4000
  editSettingsSync(mutateRemove(owner));
3967
4001
  }
3968
4002
  function normalizePath(p) {
3969
- return path19.resolve(p).toLowerCase();
4003
+ return path17.resolve(p).toLowerCase();
3970
4004
  }
3971
4005
 
3972
4006
  // src/core/notifier.ts
@@ -5045,9 +5079,9 @@ var RENDER_INTERVAL_MS = 50;
5045
5079
  var MOUSE_SGR_RE = /\x1b\[<(\d+);(\d+);(\d+)[Mm]/;
5046
5080
  function hasClaudeConversation(dir) {
5047
5081
  try {
5048
- const resolved = path20.resolve(dir);
5082
+ const resolved = path18.resolve(dir);
5049
5083
  const projectDir = resolved.replace(/[^a-zA-Z0-9-]/g, "-");
5050
- const claudeProjectPath = path20.join(os6.homedir(), ".claude", "projects", projectDir);
5084
+ const claudeProjectPath = path18.join(os6.homedir(), ".claude", "projects", projectDir);
5051
5085
  if (!fs23.existsSync(claudeProjectPath)) return false;
5052
5086
  const files = fs23.readdirSync(claudeProjectPath);
5053
5087
  return files.some((f) => f.endsWith(".jsonl"));
@@ -5056,7 +5090,7 @@ function hasClaudeConversation(dir) {
5056
5090
  }
5057
5091
  }
5058
5092
  function ptyDedupKey(pty2) {
5059
- return path20.resolve(pty2.cwd).toLowerCase();
5093
+ return path18.resolve(pty2.cwd).toLowerCase();
5060
5094
  }
5061
5095
  function loadSessions() {
5062
5096
  const all = loadHistory();
@@ -5350,10 +5384,10 @@ function App({ unsafe, onExit }) {
5350
5384
  }
5351
5385
  }, [setScrollBack, renderTermAtScroll]);
5352
5386
  const findPtyByCwd = useCallback((cwd) => {
5353
- const normalized = path20.resolve(cwd).toLowerCase();
5387
+ const normalized = path18.resolve(cwd).toLowerCase();
5354
5388
  for (const pty2 of ptySessions.current.values()) {
5355
5389
  if (pty2.exited) continue;
5356
- if (normalized.startsWith(path20.resolve(pty2.cwd).toLowerCase())) return pty2;
5390
+ if (normalized.startsWith(path18.resolve(pty2.cwd).toLowerCase())) return pty2;
5357
5391
  }
5358
5392
  return void 0;
5359
5393
  }, []);
@@ -5429,13 +5463,13 @@ function App({ unsafe, onExit }) {
5429
5463
  notifiedSessionsRef.current
5430
5464
  );
5431
5465
  if (kind) {
5432
- notifyDesktop(path20.basename(pty2.cwd), kind, {
5466
+ notifyDesktop(path18.basename(pty2.cwd), kind, {
5433
5467
  enabled: config?.notifications === true
5434
5468
  });
5435
5469
  runStatusHooks(
5436
5470
  kind,
5437
5471
  pty2.cwd,
5438
- path20.basename(pty2.cwd),
5472
+ path18.basename(pty2.cwd),
5439
5473
  config?.statusHooks
5440
5474
  );
5441
5475
  }
@@ -5568,7 +5602,7 @@ function App({ unsafe, onExit }) {
5568
5602
  refreshSessions();
5569
5603
  return;
5570
5604
  }
5571
- const dir = s.isGroup ? path20.dirname(existing) : existing;
5605
+ const dir = s.isGroup ? path18.dirname(existing) : existing;
5572
5606
  const resume = hasClaudeConversation(dir);
5573
5607
  const tool = getAiTool(config ?? {});
5574
5608
  const pty2 = new PtySession(dir, termInner, contentHeight - 2, void 0, { tool, unsafe, resume, port: s.port });
@@ -5666,7 +5700,7 @@ function App({ unsafe, onExit }) {
5666
5700
  "",
5667
5701
  " - Ask if I want to proceed with the recommended approach, choose a different one, get more details, or make adjustments."
5668
5702
  ].join("\n");
5669
- promptFile = path20.join(os6.tmpdir(), `work-prompt-${Date.now()}.txt`);
5703
+ promptFile = path18.join(os6.tmpdir(), `work-prompt-${Date.now()}.txt`);
5670
5704
  fs23.writeFileSync(promptFile, prompt, "utf-8");
5671
5705
  }
5672
5706
  const setupArgs = ["tree", projectName, branchName, "--setup-only"];
@@ -5706,7 +5740,7 @@ function App({ unsafe, onExit }) {
5706
5740
  setStatusVersion((v) => v + 1);
5707
5741
  return;
5708
5742
  }
5709
- const launchDir = session.isGroup ? path20.dirname(existing) : existing;
5743
+ const launchDir = session.isGroup ? path18.dirname(existing) : existing;
5710
5744
  const tool = getAiTool(config);
5711
5745
  const aiPty = new PtySession(
5712
5746
  launchDir,
@@ -6281,7 +6315,7 @@ function App({ unsafe, onExit }) {
6281
6315
  setMessage("Session path no longer exists");
6282
6316
  return;
6283
6317
  }
6284
- const dir = s.isGroup ? path20.dirname(existing) : existing;
6318
+ const dir = s.isGroup ? path18.dirname(existing) : existing;
6285
6319
  const editor = config?.editor ?? "code";
6286
6320
  spawn7(editor, [dir], { detached: true, stdio: "ignore" }).unref();
6287
6321
  setMessage(`Opened in ${editor}: ${s.branch}`);
@@ -6466,7 +6500,7 @@ function crashLog(label2, err) {
6466
6500
  const msg = err instanceof Error ? err.stack || err.message : String(err);
6467
6501
  const line = `${(/* @__PURE__ */ new Date()).toISOString()} [CRASH] ${label2}: ${msg}
6468
6502
  `;
6469
- fs24.appendFileSync(path21.join(getConfigDir(), "debug.log"), line);
6503
+ fs24.appendFileSync(path19.join(getConfigDir(), "debug.log"), line);
6470
6504
  } catch {
6471
6505
  }
6472
6506
  }
@@ -6790,22 +6824,22 @@ import chalk17 from "chalk";
6790
6824
 
6791
6825
  // src/core/hydrate.ts
6792
6826
  import fs25 from "fs";
6793
- import path22 from "path";
6827
+ import path20 from "path";
6794
6828
  async function hydrateHistoryFromDisk(config) {
6795
- const worktreesRoot = path22.resolve(config.worktreesRoot);
6829
+ const worktreesRoot = path20.resolve(config.worktreesRoot);
6796
6830
  const folderNameToAlias = /* @__PURE__ */ new Map();
6797
6831
  for (const [alias, repoPath] of Object.entries(config.repos)) {
6798
- folderNameToAlias.set(path22.basename(repoPath), alias);
6832
+ folderNameToAlias.set(path20.basename(repoPath), alias);
6799
6833
  }
6800
6834
  const discovered = /* @__PURE__ */ new Map();
6801
6835
  for (const [alias, repoPath] of Object.entries(config.repos)) {
6802
6836
  if (!fs25.existsSync(repoPath)) continue;
6803
6837
  for (const entry of parseWorktreeList(repoPath)) {
6804
6838
  if (!entry.branch) continue;
6805
- if (path22.resolve(entry.path) === path22.resolve(repoPath)) continue;
6806
- const rel = path22.relative(worktreesRoot, entry.path);
6807
- if (!rel || rel.startsWith("..") || path22.isAbsolute(rel)) continue;
6808
- const parts = rel.split(path22.sep).filter(Boolean);
6839
+ if (path20.resolve(entry.path) === path20.resolve(repoPath)) continue;
6840
+ const rel = path20.relative(worktreesRoot, entry.path);
6841
+ if (!rel || rel.startsWith("..") || path20.isAbsolute(rel)) continue;
6842
+ const parts = rel.split(path20.sep).filter(Boolean);
6809
6843
  if (parts.length < 2) continue;
6810
6844
  const [first, second] = parts;
6811
6845
  const isGroup = Object.prototype.hasOwnProperty.call(config.groups, first);
@@ -6890,13 +6924,13 @@ var hydrateCommand = {
6890
6924
  // src/commands/diff.ts
6891
6925
  import fs36 from "fs";
6892
6926
  import os9 from "os";
6893
- import path33 from "path";
6927
+ import path31 from "path";
6894
6928
  import { spawn as childSpawn } from "child_process";
6895
6929
  import chalk21 from "chalk";
6896
6930
 
6897
6931
  // src/core/diff-pipeline.ts
6898
6932
  import fs28 from "fs";
6899
- import path25 from "path";
6933
+ import path23 from "path";
6900
6934
  import spawn9 from "cross-spawn";
6901
6935
 
6902
6936
  // src/core/diff-parse.ts
@@ -7045,7 +7079,7 @@ function stripPathPrefix(p) {
7045
7079
 
7046
7080
  // src/core/lcov.ts
7047
7081
  import fs26 from "fs";
7048
- import path23 from "path";
7082
+ import path21 from "path";
7049
7083
  function parseLcov(content) {
7050
7084
  const result = /* @__PURE__ */ new Map();
7051
7085
  let sf = null;
@@ -7104,8 +7138,8 @@ function parseLcov(content) {
7104
7138
  }
7105
7139
  function findLcov(root) {
7106
7140
  const candidates = [
7107
- path23.join(root, "coverage", "lcov.info"),
7108
- path23.join(root, "lcov.info")
7141
+ path21.join(root, "coverage", "lcov.info"),
7142
+ path21.join(root, "lcov.info")
7109
7143
  ];
7110
7144
  for (const c of candidates) {
7111
7145
  try {
@@ -7140,33 +7174,33 @@ function readParsedLcov(lcovPath) {
7140
7174
  return { parsed, mtimeMs };
7141
7175
  }
7142
7176
  function normRel(p) {
7143
- return path23.normalize(p).replace(/\\/g, "/").replace(/^\.\//, "");
7177
+ return path21.normalize(p).replace(/\\/g, "/").replace(/^\.\//, "");
7144
7178
  }
7145
7179
  function realRoot(root) {
7146
7180
  try {
7147
- return fs26.realpathSync(path23.resolve(root));
7181
+ return fs26.realpathSync(path21.resolve(root));
7148
7182
  } catch {
7149
- return path23.resolve(root);
7183
+ return path21.resolve(root);
7150
7184
  }
7151
7185
  }
7152
7186
  function canonicalize(absPath) {
7153
- const resolved = path23.resolve(absPath);
7187
+ const resolved = path21.resolve(absPath);
7154
7188
  let dir = resolved;
7155
7189
  const tail = [];
7156
7190
  for (; ; ) {
7157
7191
  try {
7158
7192
  const realDir = fs26.realpathSync(dir);
7159
- return tail.length ? path23.join(realDir, ...tail.reverse()) : realDir;
7193
+ return tail.length ? path21.join(realDir, ...tail.reverse()) : realDir;
7160
7194
  } catch {
7161
- const parent = path23.dirname(dir);
7195
+ const parent = path21.dirname(dir);
7162
7196
  if (parent === dir) return resolved;
7163
- tail.push(path23.basename(dir));
7197
+ tail.push(path21.basename(dir));
7164
7198
  dir = parent;
7165
7199
  }
7166
7200
  }
7167
7201
  }
7168
7202
  function relForAbsSf(absSf, canonRoot) {
7169
- return path23.relative(canonRoot, canonicalize(absSf));
7203
+ return path21.relative(canonRoot, canonicalize(absSf));
7170
7204
  }
7171
7205
  function coverageLookup(root, relPaths) {
7172
7206
  const out = /* @__PURE__ */ new Map();
@@ -7179,7 +7213,7 @@ function coverageLookup(root, relPaths) {
7179
7213
  const canonRoot = realRoot(root);
7180
7214
  const byRel = /* @__PURE__ */ new Map();
7181
7215
  for (const [sf, pct] of read.parsed) {
7182
- const rel = path23.isAbsolute(sf) ? relForAbsSf(sf, canonRoot) : sf;
7216
+ const rel = path21.isAbsolute(sf) ? relForAbsSf(sf, canonRoot) : sf;
7183
7217
  byRel.set(normRel(rel), pct);
7184
7218
  }
7185
7219
  for (const rp of relPaths) {
@@ -7192,12 +7226,12 @@ function coverageLookup(root, relPaths) {
7192
7226
  // src/core/git-tree-snapshot.ts
7193
7227
  import fs27 from "fs";
7194
7228
  import os7 from "os";
7195
- import path24 from "path";
7229
+ import path22 from "path";
7196
7230
  import crypto from "crypto";
7197
7231
  import spawn8 from "cross-spawn";
7198
7232
  function writeTempTree(repoRoot, opts = {}) {
7199
7233
  const includeWorkingTree = opts.includeWorkingTree ?? true;
7200
- const tmpIndex = path24.join(
7234
+ const tmpIndex = path22.join(
7201
7235
  os7.tmpdir(),
7202
7236
  `wd-tree-${process.pid}-${crypto.randomBytes(6).toString("hex")}.idx`
7203
7237
  );
@@ -7242,12 +7276,12 @@ function isMarkdownPath(p) {
7242
7276
  return p !== "/dev/null" && MARKDOWN_EXT_RE.test(p);
7243
7277
  }
7244
7278
  function isInsideRoot(root, rel) {
7245
- const resolvedRoot = path25.resolve(root);
7246
- const resolvedTarget = path25.resolve(resolvedRoot, rel);
7247
- const r = path25.relative(resolvedRoot, resolvedTarget);
7279
+ const resolvedRoot = path23.resolve(root);
7280
+ const resolvedTarget = path23.resolve(resolvedRoot, rel);
7281
+ const r = path23.relative(resolvedRoot, resolvedTarget);
7248
7282
  if (r === "") return true;
7249
7283
  if (r.startsWith("..")) return false;
7250
- if (path25.isAbsolute(r)) return false;
7284
+ if (path23.isAbsolute(r)) return false;
7251
7285
  return true;
7252
7286
  }
7253
7287
  function readMarkdownContent(root, file, fromRef, toRef) {
@@ -7272,10 +7306,10 @@ function readMarkdownContent(root, file, fromRef, toRef) {
7272
7306
  if (file.status !== "deleted" && isMarkdownPath(file.newPath) && isInsideRoot(root, file.newPath)) {
7273
7307
  if (toRef === "working") {
7274
7308
  try {
7275
- const absPath = path25.join(root, file.newPath);
7276
- const realRoot2 = fs28.realpathSync(path25.resolve(root));
7309
+ const absPath = path23.join(root, file.newPath);
7310
+ const realRoot2 = fs28.realpathSync(path23.resolve(root));
7277
7311
  const realPath = fs28.realpathSync(absPath);
7278
- const sep = path25.sep;
7312
+ const sep = path23.sep;
7279
7313
  if (realPath === realRoot2 || realPath.startsWith(realRoot2 + sep)) {
7280
7314
  result.after = fs28.readFileSync(absPath, "utf-8");
7281
7315
  }
@@ -7305,7 +7339,7 @@ function isBinaryContent(buffer) {
7305
7339
  return false;
7306
7340
  }
7307
7341
  function synthesizeUntrackedDiff(root, relPath) {
7308
- const absPath = path25.join(root, relPath);
7342
+ const absPath = path23.join(root, relPath);
7309
7343
  let buffer;
7310
7344
  try {
7311
7345
  buffer = fs28.readFileSync(absPath);
@@ -7396,7 +7430,7 @@ function attachCoverage(root, files) {
7396
7430
  f.coverageMtimeMs = lcovMtimeMs;
7397
7431
  let srcMtimeMs = null;
7398
7432
  try {
7399
- srcMtimeMs = fs28.statSync(path25.join(root, f.path)).mtimeMs;
7433
+ srcMtimeMs = fs28.statSync(path23.join(root, f.path)).mtimeMs;
7400
7434
  } catch {
7401
7435
  srcMtimeMs = null;
7402
7436
  }
@@ -7464,7 +7498,7 @@ function computeRangeDiff(opts) {
7464
7498
 
7465
7499
  // src/core/repo-spec.ts
7466
7500
  import fs29 from "fs";
7467
- import path26 from "path";
7501
+ import path24 from "path";
7468
7502
  import os8 from "os";
7469
7503
  import crypto2 from "crypto";
7470
7504
  function scopeHashFor(keyPaths) {
@@ -7472,21 +7506,21 @@ function scopeHashFor(keyPaths) {
7472
7506
  return crypto2.createHash("sha1").update(key).digest("hex").slice(0, 12);
7473
7507
  }
7474
7508
  function stableDiffPath(keyPaths) {
7475
- const dir = path26.join(os8.homedir(), ".work", "diffs");
7509
+ const dir = path24.join(os8.homedir(), ".work", "diffs");
7476
7510
  fs29.mkdirSync(dir, { recursive: true });
7477
- return path26.join(dir, scopeHashFor(keyPaths));
7511
+ return path24.join(dir, scopeHashFor(keyPaths));
7478
7512
  }
7479
7513
 
7480
7514
  // src/core/diff-scope.ts
7481
7515
  import fs30 from "fs";
7482
- import path27 from "path";
7516
+ import path25 from "path";
7483
7517
  import chalk18 from "chalk";
7484
7518
  function normPath(p) {
7485
- return path27.resolve(p).replace(/\\/g, "/").toLowerCase();
7519
+ return path25.resolve(p).replace(/\\/g, "/").toLowerCase();
7486
7520
  }
7487
7521
  function realNorm(p) {
7488
7522
  try {
7489
- return normPath(fs30.realpathSync(p));
7523
+ return normPath(fs30.realpathSync.native(p));
7490
7524
  } catch {
7491
7525
  return normPath(p);
7492
7526
  }
@@ -7506,29 +7540,29 @@ function resolveScope(cwd) {
7506
7540
  return {
7507
7541
  isGroup: true,
7508
7542
  session: s,
7509
- repos: s.paths.map((rp) => ({ name: path27.basename(rp), root: rp })),
7510
- activeRepoName: path27.basename(p)
7543
+ repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7544
+ activeRepoName: path25.basename(p)
7511
7545
  };
7512
7546
  }
7513
7547
  return {
7514
7548
  isGroup: false,
7515
7549
  session: s,
7516
- repos: [{ name: path27.basename(p), root: p }],
7517
- activeRepoName: path27.basename(p)
7550
+ repos: [{ name: path25.basename(p), root: p }],
7551
+ activeRepoName: path25.basename(p)
7518
7552
  };
7519
7553
  }
7520
7554
  }
7521
7555
  }
7522
7556
  for (const s of sessions) {
7523
7557
  if (!s.isGroup || s.paths.length === 0) continue;
7524
- const parents = s.paths.map((p) => normPath(path27.dirname(p)));
7558
+ const parents = s.paths.map((p) => normPath(path25.dirname(p)));
7525
7559
  const groupRoot = parents[0];
7526
7560
  if (!parents.every((par) => par === groupRoot)) continue;
7527
7561
  if (normCwd === groupRoot || normCwd.startsWith(groupRoot + "/")) {
7528
7562
  return {
7529
7563
  isGroup: true,
7530
7564
  session: s,
7531
- repos: s.paths.map((rp) => ({ name: path27.basename(rp), root: rp })),
7565
+ repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
7532
7566
  activeRepoName: null
7533
7567
  };
7534
7568
  }
@@ -7537,8 +7571,8 @@ function resolveScope(cwd) {
7537
7571
  return {
7538
7572
  isGroup: false,
7539
7573
  session: null,
7540
- repos: [{ name: path27.basename(toplevel), root: toplevel }],
7541
- activeRepoName: path27.basename(toplevel)
7574
+ repos: [{ name: path25.basename(toplevel), root: toplevel }],
7575
+ activeRepoName: path25.basename(toplevel)
7542
7576
  };
7543
7577
  }
7544
7578
  function findAnyParentBranch(cwd) {
@@ -7714,7 +7748,7 @@ import { streamSSE } from "hono/streaming";
7714
7748
 
7715
7749
  // src/core/file-context.ts
7716
7750
  import fs31 from "fs";
7717
- import path28 from "path";
7751
+ import path26 from "path";
7718
7752
  import spawn10 from "cross-spawn";
7719
7753
  function readContextLines(opts) {
7720
7754
  const { root, relPath, ref } = opts;
@@ -7736,10 +7770,10 @@ function readContextLines(opts) {
7736
7770
  }
7737
7771
  function readWorkingTree(root, relPath) {
7738
7772
  try {
7739
- const absPath = path28.join(root, relPath);
7740
- const realRoot2 = fs31.realpathSync(path28.resolve(root));
7773
+ const absPath = path26.join(root, relPath);
7774
+ const realRoot2 = fs31.realpathSync(path26.resolve(root));
7741
7775
  const realPath = fs31.realpathSync(absPath);
7742
- const sep = path28.sep;
7776
+ const sep = path26.sep;
7743
7777
  if (realPath !== realRoot2 && !realPath.startsWith(realRoot2 + sep)) {
7744
7778
  return null;
7745
7779
  }
@@ -7761,7 +7795,7 @@ function readAtRef(root, ref, relPath) {
7761
7795
 
7762
7796
  // src/core/fs-watcher.ts
7763
7797
  import fs32 from "fs";
7764
- import path29 from "path";
7798
+ import path27 from "path";
7765
7799
  import chalk19 from "chalk";
7766
7800
  import chokidar from "chokidar";
7767
7801
  var IGNORED_DIRS = /* @__PURE__ */ new Set([
@@ -7787,7 +7821,7 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
7787
7821
  ]);
7788
7822
  function isIgnoredWatchPath(roots, filePath) {
7789
7823
  for (const root of roots) {
7790
- const rel = path29.relative(root, filePath).replace(/\\/g, "/");
7824
+ const rel = path27.relative(root, filePath).replace(/\\/g, "/");
7791
7825
  if (rel === "" || rel.startsWith("../")) continue;
7792
7826
  if (rel.split("/").some((seg) => IGNORED_DIRS.has(seg))) return true;
7793
7827
  }
@@ -7812,7 +7846,7 @@ function createFsWatcher(opts) {
7812
7846
  if (SUPPORTS_RECURSIVE_WATCH) {
7813
7847
  const watchers = opts.roots.map((root) => {
7814
7848
  const w = fs32.watch(root, { recursive: true }, (_event, filename) => {
7815
- if (filename && isIgnoredWatchPath([root], path29.join(root, filename.toString()))) {
7849
+ if (filename && isIgnoredWatchPath([root], path27.join(root, filename.toString()))) {
7816
7850
  return;
7817
7851
  }
7818
7852
  fire();
@@ -7851,29 +7885,29 @@ function createFsWatcher(opts) {
7851
7885
 
7852
7886
  // src/core/web-static.ts
7853
7887
  import fs33 from "fs";
7854
- import path30 from "path";
7888
+ import path28 from "path";
7855
7889
  import { fileURLToPath } from "url";
7856
7890
  function resolveWebRoot() {
7857
- const entryDir = path30.dirname(process.argv[1] ?? "");
7858
- const moduleDir = path30.dirname(fileURLToPath(import.meta.url));
7891
+ const entryDir = path28.dirname(process.argv[1] ?? "");
7892
+ const moduleDir = path28.dirname(fileURLToPath(import.meta.url));
7859
7893
  const candidates = [
7860
- path30.join(entryDir, "web"),
7894
+ path28.join(entryDir, "web"),
7861
7895
  // bundled: this module is inlined into dist/<bin>.js, so dist/web is a
7862
7896
  // sibling of the bundle. Works even when argv[1] is an npm bin symlink
7863
7897
  // (which is not realpath'd, so the entryDir candidate above misses).
7864
- path30.join(moduleDir, "web"),
7898
+ path28.join(moduleDir, "web"),
7865
7899
  // dev/tsx fallback: walk up from src/core to repo root then into dist/web.
7866
- path30.resolve(moduleDir, "../../dist/web")
7900
+ path28.resolve(moduleDir, "../../dist/web")
7867
7901
  ];
7868
7902
  for (const c of candidates) {
7869
- if (fs33.existsSync(path30.join(c, "index.html"))) return c;
7903
+ if (fs33.existsSync(path28.join(c, "index.html"))) return c;
7870
7904
  }
7871
7905
  return null;
7872
7906
  }
7873
7907
 
7874
7908
  // src/core/spa-handler.ts
7875
7909
  import fs34 from "fs";
7876
- import path31 from "path";
7910
+ import path29 from "path";
7877
7911
  var MIME = {
7878
7912
  ".html": "text/html; charset=utf-8",
7879
7913
  ".js": "application/javascript; charset=utf-8",
@@ -7887,9 +7921,9 @@ var MIME = {
7887
7921
  function readFile(root, relPath) {
7888
7922
  const clean = relPath.split("?")[0];
7889
7923
  const requested = clean === "/" ? "/index.html" : clean;
7890
- const filePath = path31.join(root, requested);
7891
- const norm = path31.normalize(filePath);
7892
- if (!norm.startsWith(path31.normalize(root))) return null;
7924
+ const filePath = path29.join(root, requested);
7925
+ const norm = path29.normalize(filePath);
7926
+ if (!norm.startsWith(path29.normalize(root))) return null;
7893
7927
  let stat;
7894
7928
  try {
7895
7929
  stat = fs34.statSync(norm);
@@ -7897,7 +7931,7 @@ function readFile(root, relPath) {
7897
7931
  return null;
7898
7932
  }
7899
7933
  if (!stat.isFile()) return null;
7900
- const ext = path31.extname(norm).toLowerCase();
7934
+ const ext = path29.extname(norm).toLowerCase();
7901
7935
  return { body: fs34.readFileSync(norm), ext };
7902
7936
  }
7903
7937
  function serveSpa(c, webRoot) {
@@ -8192,7 +8226,7 @@ function diffReviewSnapshot(snapshot, seen) {
8192
8226
 
8193
8227
  // src/core/static-renderer.ts
8194
8228
  import fs35 from "fs";
8195
- import path32 from "path";
8229
+ import path30 from "path";
8196
8230
  function buildDiff(specs, resolvedBase) {
8197
8231
  return {
8198
8232
  repos: specs.map((r) => ({
@@ -8208,7 +8242,7 @@ function renderStatic(opts) {
8208
8242
  if (!webRoot) {
8209
8243
  throw new Error("Could not find dist/web/. Run `npm run build` first.");
8210
8244
  }
8211
- const shellPath = path32.join(webRoot, "index.html");
8245
+ const shellPath = path30.join(webRoot, "index.html");
8212
8246
  let shell = fs35.readFileSync(shellPath, "utf-8");
8213
8247
  const uncommitted = buildDiff(opts.uncommitted, "HEAD");
8214
8248
  const branch = opts.branch ? buildDiff(opts.branch.specs, opts.branch.resolvedBase) : void 0;
@@ -8258,8 +8292,8 @@ function escapeForScriptTag(json) {
8258
8292
  }
8259
8293
  function readAsset(webRoot, urlPath) {
8260
8294
  const clean = urlPath.split("?")[0].replace(/^\//, "");
8261
- const full = path32.join(webRoot, clean);
8262
- if (!path32.normalize(full).startsWith(path32.normalize(webRoot))) return null;
8295
+ const full = path30.join(webRoot, clean);
8296
+ if (!path30.normalize(full).startsWith(path30.normalize(webRoot))) return null;
8263
8297
  try {
8264
8298
  return fs35.readFileSync(full, "utf-8");
8265
8299
  } catch {
@@ -8302,7 +8336,7 @@ async function runStop(repoSpecs) {
8302
8336
  }
8303
8337
  }
8304
8338
  function webUrlFilePath() {
8305
- return path33.join(os9.homedir(), ".work", "web.url");
8339
+ return path31.join(os9.homedir(), ".work", "web.url");
8306
8340
  }
8307
8341
  function resolveWorkBinPath(selfArgv1) {
8308
8342
  let real = selfArgv1;
@@ -8311,7 +8345,7 @@ function resolveWorkBinPath(selfArgv1) {
8311
8345
  } catch {
8312
8346
  }
8313
8347
  if (real.endsWith("wd-bin.js")) {
8314
- return path33.join(path33.dirname(real), "bin.js");
8348
+ return path31.join(path31.dirname(real), "bin.js");
8315
8349
  }
8316
8350
  return real;
8317
8351
  }
@@ -8323,12 +8357,32 @@ function readWebUrl() {
8323
8357
  return null;
8324
8358
  }
8325
8359
  }
8360
+ async function webServerResponds(url, timeoutMs = 1500) {
8361
+ try {
8362
+ const ctrl = new AbortController();
8363
+ const timer = setTimeout(() => ctrl.abort(), timeoutMs);
8364
+ try {
8365
+ const res = await fetch(`${url}api/context`, { signal: ctrl.signal });
8366
+ return res.ok;
8367
+ } finally {
8368
+ clearTimeout(timer);
8369
+ }
8370
+ } catch {
8371
+ return false;
8372
+ }
8373
+ }
8326
8374
  async function ensureWorkWebRunning() {
8327
8375
  const existing = readWebUrl();
8328
- if (existing) return existing;
8376
+ if (existing) {
8377
+ if (await webServerResponds(existing)) return existing;
8378
+ try {
8379
+ fs36.unlinkSync(webUrlFilePath());
8380
+ } catch {
8381
+ }
8382
+ }
8329
8383
  const workBin = resolveWorkBinPath(process.argv[1]);
8330
8384
  const out = fs36.openSync(
8331
- path33.join(os9.homedir(), ".work", "web-autostart.log"),
8385
+ path31.join(os9.homedir(), ".work", "web-autostart.log"),
8332
8386
  "a"
8333
8387
  );
8334
8388
  const child = childSpawn(
@@ -8670,19 +8724,19 @@ var diffCommand = {
8670
8724
  // src/commands/web.ts
8671
8725
  import fs41 from "fs";
8672
8726
  import os13 from "os";
8673
- import path42 from "path";
8727
+ import path40 from "path";
8674
8728
  import chalk23 from "chalk";
8675
8729
 
8676
8730
  // src/core/web-server.ts
8677
8731
  import fs40 from "fs";
8678
8732
  import os12 from "os";
8679
- import path41 from "path";
8733
+ import path39 from "path";
8680
8734
  import chalk22 from "chalk";
8681
8735
  import { Hono as Hono3 } from "hono";
8682
8736
  import { streamSSE as streamSSE3 } from "hono/streaming";
8683
8737
 
8684
8738
  // src/core/web-state.ts
8685
- import path34 from "path";
8739
+ import path32 from "path";
8686
8740
  import crypto4 from "crypto";
8687
8741
  import chokidar2 from "chokidar";
8688
8742
  function sessionIdFor(s) {
@@ -8703,7 +8757,7 @@ function subscribeSession(sessionId, onChange) {
8703
8757
  const watcher = chokidar2.watch(roots, {
8704
8758
  ignored: (filePath) => {
8705
8759
  for (const r of roots) {
8706
- const rel = path34.relative(r, filePath).replace(/\\/g, "/");
8760
+ const rel = path32.relative(r, filePath).replace(/\\/g, "/");
8707
8761
  if (rel === ".git" || rel.startsWith(".git/")) return true;
8708
8762
  }
8709
8763
  return false;
@@ -8818,16 +8872,16 @@ function disposeAllPtys() {
8818
8872
 
8819
8873
  // src/core/comment-file-store.ts
8820
8874
  import fs37 from "fs";
8821
- import path35 from "path";
8875
+ import path33 from "path";
8822
8876
  import os10 from "os";
8823
8877
  function commentsDir() {
8824
- return path35.join(os10.homedir(), ".work", "comments");
8878
+ return path33.join(os10.homedir(), ".work", "comments");
8825
8879
  }
8826
8880
  function ensureDir() {
8827
8881
  fs37.mkdirSync(commentsDir(), { recursive: true });
8828
8882
  }
8829
8883
  function commentsFileFor(sessionId) {
8830
- return path35.join(commentsDir(), `${sessionId}.json`);
8884
+ return path33.join(commentsDir(), `${sessionId}.json`);
8831
8885
  }
8832
8886
  function pathFor(sessionId) {
8833
8887
  return commentsFileFor(sessionId);
@@ -8907,11 +8961,11 @@ function clearCommentStoreCache() {
8907
8961
 
8908
8962
  // src/core/pending-delivery.ts
8909
8963
  import fs38 from "fs";
8910
- import path36 from "path";
8964
+ import path34 from "path";
8911
8965
  function pathFor2(sessionId) {
8912
8966
  return {
8913
8967
  comments: commentsFileFor(sessionId),
8914
- delivered: path36.join(commentsDir(), `${sessionId}.delivered.json`)
8968
+ delivered: path34.join(commentsDir(), `${sessionId}.delivered.json`)
8915
8969
  };
8916
8970
  }
8917
8971
  function readJson(filePath, fallback) {
@@ -8922,13 +8976,13 @@ function readJson(filePath, fallback) {
8922
8976
  }
8923
8977
  }
8924
8978
  function writeAtomic2(filePath, content) {
8925
- fs38.mkdirSync(path36.dirname(filePath), { recursive: true });
8979
+ fs38.mkdirSync(path34.dirname(filePath), { recursive: true });
8926
8980
  const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
8927
8981
  fs38.writeFileSync(tmp, content, "utf-8");
8928
8982
  fs38.renameSync(tmp, filePath);
8929
8983
  }
8930
8984
  function normalize(p) {
8931
- return path36.resolve(p).replace(/\\/g, "/").toLowerCase();
8985
+ return path34.resolve(p).replace(/\\/g, "/").toLowerCase();
8932
8986
  }
8933
8987
  function findSessionForCwd(cwd) {
8934
8988
  const norm = normalize(cwd);
@@ -8959,7 +9013,7 @@ function readPendingForSession(sessionId) {
8959
9013
  return comments.filter(isPendingFor(delivered));
8960
9014
  }
8961
9015
  function scopeStoreIdsForPaths(paths) {
8962
- const resolved = paths.map((p) => path36.resolve(p));
9016
+ const resolved = paths.map((p) => path34.resolve(p));
8963
9017
  const ids = /* @__PURE__ */ new Set();
8964
9018
  ids.add(`scope-${scopeHashFor(resolved)}`);
8965
9019
  for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);
@@ -9282,7 +9336,7 @@ function mountPanesRoutes(app, opts) {
9282
9336
  }
9283
9337
 
9284
9338
  // src/core/worktree-routes.ts
9285
- import path37 from "path";
9339
+ import path35 from "path";
9286
9340
  import { spawn as spawn11 } from "child_process";
9287
9341
  import { zValidator as zValidator4 } from "@hono/zod-validator";
9288
9342
  import { z as z3 } from "zod";
@@ -9406,7 +9460,7 @@ function mountWorktreeRoutes(app, opts) {
9406
9460
  const id = c.req.param("id");
9407
9461
  const session = findSession2(id);
9408
9462
  if (!session) return c.json({ error: "unknown session" }, 404);
9409
- const target = session.isGroup ? path37.dirname(session.paths[0]) : session.paths[0];
9463
+ const target = session.isGroup ? path35.dirname(session.paths[0]) : session.paths[0];
9410
9464
  try {
9411
9465
  const cmd = process.platform === "win32" ? "code.cmd" : "code";
9412
9466
  const child = spawn11(cmd, [target], {
@@ -9426,18 +9480,18 @@ function mountWorktreeRoutes(app, opts) {
9426
9480
  import { zValidator as zValidator5 } from "@hono/zod-validator";
9427
9481
  import { z as z4 } from "zod";
9428
9482
  import { EventEmitter } from "events";
9429
- import path40 from "path";
9483
+ import path38 from "path";
9430
9484
  import spawn13 from "cross-spawn";
9431
9485
 
9432
9486
  // src/core/checkpoint.ts
9433
9487
  import fs39 from "fs";
9434
9488
  import os11 from "os";
9435
- import path38 from "path";
9489
+ import path36 from "path";
9436
9490
  import spawn12 from "cross-spawn";
9437
9491
  function manifestPath(scopeHash) {
9438
- const dir = path38.join(os11.homedir(), ".work", "diffs");
9492
+ const dir = path36.join(os11.homedir(), ".work", "diffs");
9439
9493
  fs39.mkdirSync(dir, { recursive: true });
9440
- return path38.join(dir, `${scopeHash}.checkpoints.json`);
9494
+ return path36.join(dir, `${scopeHash}.checkpoints.json`);
9441
9495
  }
9442
9496
  function emptyManifest(scopeHash) {
9443
9497
  return { version: 1, scopeHash, entries: [] };
@@ -9578,7 +9632,7 @@ function clearCheckpoints(scopeHash, repoRoots) {
9578
9632
  }
9579
9633
 
9580
9634
  // src/core/scope-manager.ts
9581
- import path39 from "path";
9635
+ import path37 from "path";
9582
9636
  import crypto5 from "crypto";
9583
9637
  var scopes = /* @__PURE__ */ new Map();
9584
9638
  function hashFor(paths) {
@@ -9595,7 +9649,7 @@ var ScopePathRejectedError = class extends Error {
9595
9649
  }
9596
9650
  };
9597
9651
  function normaliseForCompare(p) {
9598
- return path39.resolve(p).replace(/\\/g, "/").toLowerCase();
9652
+ return path37.resolve(p).replace(/\\/g, "/").toLowerCase();
9599
9653
  }
9600
9654
  function rejectedPaths(normalised) {
9601
9655
  const config = loadConfig();
@@ -9613,7 +9667,7 @@ function rejectedPaths(normalised) {
9613
9667
  });
9614
9668
  }
9615
9669
  function registerScope(paths, label2) {
9616
- const normalised = paths.map((p) => path39.resolve(p));
9670
+ const normalised = paths.map((p) => path37.resolve(p));
9617
9671
  const rejected = rejectedPaths(normalised);
9618
9672
  if (rejected.length > 0) throw new ScopePathRejectedError(rejected);
9619
9673
  const hash = hashFor(normalised);
@@ -9627,7 +9681,7 @@ function registerScope(paths, label2) {
9627
9681
  const scope = {
9628
9682
  hash,
9629
9683
  paths: normalised,
9630
- label: label2 ?? path39.basename(normalised[0]),
9684
+ label: label2 ?? path37.basename(normalised[0]),
9631
9685
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
9632
9686
  ended: false
9633
9687
  };
@@ -9824,7 +9878,7 @@ function mountScopeRoutes(app, opts) {
9824
9878
  const fromSha = fromEntry.repos[p] ?? "HEAD";
9825
9879
  const toSha = toEntry === void 0 ? "working" : toEntry.repos[p] ?? "HEAD";
9826
9880
  return {
9827
- name: path40.basename(p),
9881
+ name: path38.basename(p),
9828
9882
  root: p,
9829
9883
  files: computeRangeDiff({ root: p, fromRef: fromSha, toRef: toSha })
9830
9884
  };
@@ -9842,7 +9896,7 @@ function mountScopeRoutes(app, opts) {
9842
9896
  (p) => resolveRepoDiff(p, base, sessionBaseForPath(p))
9843
9897
  );
9844
9898
  const repos = scope.paths.map((p, i) => ({
9845
- name: path40.basename(p),
9899
+ name: path38.basename(p),
9846
9900
  root: p,
9847
9901
  resolvedBase: resolved[i].resolvedBase,
9848
9902
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -9872,7 +9926,7 @@ function mountScopeRoutes(app, opts) {
9872
9926
  if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {
9873
9927
  return c.json({ error: "bad path/start/end" }, 400);
9874
9928
  }
9875
- const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path40.basename(p) === repoName);
9929
+ const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path38.basename(p) === repoName);
9876
9930
  if (!root) return c.json({ error: "unknown repo" }, 404);
9877
9931
  const result = readContextLines({ root, relPath, start, end, ref });
9878
9932
  if (!result) return c.json({ error: "cannot read file" }, 400);
@@ -10110,7 +10164,7 @@ function computeSessionDiff(s, base) {
10110
10164
  (p) => resolveRepoDiff(p, base, s.baseBranches?.[p] ?? s.baseBranch)
10111
10165
  );
10112
10166
  const repos = s.paths.map((p, i) => ({
10113
- name: path41.basename(p),
10167
+ name: path39.basename(p),
10114
10168
  root: p,
10115
10169
  resolvedBase: resolved[i].resolvedBase,
10116
10170
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -10130,10 +10184,10 @@ async function startWebServer(opts = {}) {
10130
10184
  for (const cb of sseListeners) cb({ event, data });
10131
10185
  };
10132
10186
  const home = os12.homedir();
10133
- const historyPath = path41.join(home, ".work", "history.json");
10187
+ const historyPath = path39.join(home, ".work", "history.json");
10134
10188
  const onHistoryChange = () => broadcast("sessions-changed", { ts: Date.now() });
10135
10189
  fs40.watchFile(historyPath, { interval: 1e3 }, onHistoryChange);
10136
- const tasksPath = path41.join(home, ".work", "tasks.json");
10190
+ const tasksPath = path39.join(home, ".work", "tasks.json");
10137
10191
  const onTasksChange = () => broadcast("tasks-changed", { ts: Date.now() });
10138
10192
  fs40.watchFile(tasksPath, { interval: 1e3 }, onTasksChange);
10139
10193
  const projectsRoot = claudeProjectsRoot();
@@ -10278,10 +10332,10 @@ function info2(message) {
10278
10332
  process.stderr.write(message + "\n");
10279
10333
  }
10280
10334
  function urlFilePath() {
10281
- return path42.join(os13.homedir(), ".work", "web.url");
10335
+ return path40.join(os13.homedir(), ".work", "web.url");
10282
10336
  }
10283
10337
  function pidFilePath() {
10284
- return path42.join(os13.homedir(), ".work", "web.pid");
10338
+ return path40.join(os13.homedir(), ".work", "web.pid");
10285
10339
  }
10286
10340
  function isPidAlive(pid) {
10287
10341
  try {
@@ -10406,7 +10460,7 @@ var webCommand = {
10406
10460
  const lean = !!argv.lean || process.env.WORK_WEB_LEAN === "1";
10407
10461
  const handle = await startWebServer({ lean });
10408
10462
  try {
10409
- fs41.mkdirSync(path42.dirname(urlFilePath()), { recursive: true });
10463
+ fs41.mkdirSync(path40.dirname(urlFilePath()), { recursive: true });
10410
10464
  fs41.writeFileSync(urlFilePath(), handle.url);
10411
10465
  fs41.writeFileSync(pidFilePath(), String(process.pid));
10412
10466
  } catch {
@@ -10944,7 +10998,7 @@ var broadcastCommand = {
10944
10998
 
10945
10999
  // src/completions/index.ts
10946
11000
  import fs44 from "fs";
10947
- import path43 from "path";
11001
+ import path41 from "path";
10948
11002
  function completionHandler(current, argv, done) {
10949
11003
  const rawArgs = argv._;
10950
11004
  const args = rawArgs.slice(1, -1);
@@ -11057,18 +11111,18 @@ function completeRepoBranches(alias, current, config, done) {
11057
11111
  done(branches);
11058
11112
  }
11059
11113
  function completeGroupBranches(groupName, repoAliases, current, config, done) {
11060
- const groupDir = path43.join(config.worktreesRoot, groupName);
11114
+ const groupDir = path41.join(config.worktreesRoot, groupName);
11061
11115
  if (!fs44.existsSync(groupDir)) {
11062
11116
  done([]);
11063
11117
  return;
11064
11118
  }
11065
11119
  try {
11066
11120
  const branchDirs = fs44.readdirSync(groupDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => {
11067
- const bdPath = path43.join(groupDir, d.name);
11121
+ const bdPath = path41.join(groupDir, d.name);
11068
11122
  for (const alias of repoAliases) {
11069
11123
  const repoPath = config.repos[alias];
11070
11124
  if (!repoPath) continue;
11071
- const subPath = path43.join(bdPath, path43.basename(repoPath));
11125
+ const subPath = path41.join(bdPath, path41.basename(repoPath));
11072
11126
  if (fs44.existsSync(subPath)) {
11073
11127
  const branch = getCurrentBranch(subPath);
11074
11128
  if (branch) return branch;
@@ -11083,7 +11137,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
11083
11137
  }
11084
11138
 
11085
11139
  // src/version.ts
11086
- var VERSION = true ? "1.8.0" : "dev";
11140
+ var VERSION = true ? "1.8.5" : "dev";
11087
11141
 
11088
11142
  // src/cli.ts
11089
11143
  function showHelp() {