@moberg_hr/work-tree 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/wd-bin.js CHANGED
@@ -443,6 +443,17 @@ import fs3 from "fs";
443
443
  import path4 from "path";
444
444
  import spawn2 from "cross-spawn";
445
445
  import chalk from "chalk";
446
+
447
+ // src/core/internal-claude.ts
448
+ var INTERNAL_CLAUDE_ENV = "WORK_INTERNAL_CLAUDE";
449
+ function internalClaudeEnv() {
450
+ return { [INTERNAL_CLAUDE_ENV]: "1" };
451
+ }
452
+ function isInternalClaude() {
453
+ return process.env[INTERNAL_CLAUDE_ENV] === "1";
454
+ }
455
+
456
+ // src/core/claude-md.ts
446
457
  function generateGroupClaudeMd(groupName, repoAliases, config) {
447
458
  const outputPath = path4.join(getConfigDir(), `${groupName}.claude.md`);
448
459
  const promptParts = [];
@@ -499,7 +510,9 @@ function generateGroupClaudeMd(groupName, repoAliases, config) {
499
510
  input: prompt,
500
511
  encoding: "utf-8",
501
512
  stdio: ["pipe", "pipe", "pipe"],
502
- windowsHide: true
513
+ windowsHide: true,
514
+ // Internal call — don't trip work's checkpoint hooks (see internal-claude.ts).
515
+ env: { ...process.env, ...internalClaudeEnv() }
503
516
  });
504
517
  let content;
505
518
  if (result.status !== 0 || !result.stdout?.trim()) {
@@ -1888,6 +1901,25 @@ function toBaseSpec(base) {
1888
1901
  }
1889
1902
 
1890
1903
  // src/core/worktree.ts
1904
+ function pullExistingWorktree(worktreePath, branchName) {
1905
+ const upstream = git(
1906
+ ["rev-parse", "--abbrev-ref", `${branchName}@{upstream}`],
1907
+ worktreePath
1908
+ );
1909
+ if (upstream.exitCode !== 0) return;
1910
+ console.log(` Pulling latest changes for ${branchName}...`);
1911
+ git(["fetch", "--quiet"], worktreePath);
1912
+ const pull = git(["pull", "--quiet"], worktreePath);
1913
+ if (pull.exitCode !== 0) {
1914
+ console.log(
1915
+ chalk5.yellow(
1916
+ ` \u26A0 Could not pull '${branchName}' (uncommitted changes or conflicts). Worktree may be behind origin.`
1917
+ )
1918
+ );
1919
+ const firstErrLine = pull.stderr.split("\n")[0];
1920
+ if (firstErrLine) console.log(chalk5.gray(` ${firstErrLine}`));
1921
+ }
1922
+ }
1891
1923
  function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch) {
1892
1924
  debug("createSingleWorktree", { repoPath, worktreePath, branchName, baseBranch });
1893
1925
  if (fs13.existsSync(worktreePath)) {
@@ -1897,6 +1929,7 @@ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBr
1897
1929
  console.log(
1898
1930
  chalk5.yellow(` Worktree already exists at: ${worktreePath}`)
1899
1931
  );
1932
+ pullExistingWorktree(worktreePath, branchName);
1900
1933
  return true;
1901
1934
  }
1902
1935
  }
@@ -2230,6 +2263,7 @@ async function setupSingleWorktree(targetName, branchName, workTreeDirName, conf
2230
2263
  }
2231
2264
  console.log(`Worktree already exists at: ${existing.path}`);
2232
2265
  workTreePath = existing.path;
2266
+ pullExistingWorktree(workTreePath, branchName);
2233
2267
  } else {
2234
2268
  const success = createSingleWorktree(repoPath, workTreePath, branchName, config, baseBranch);
2235
2269
  if (!success) return null;
@@ -5128,7 +5162,13 @@ function generateSlug(summary) {
5128
5162
  const child = execFile4(
5129
5163
  "claude",
5130
5164
  ["-p", "--model", "haiku"],
5131
- { encoding: "utf-8", timeout: 1e4, windowsHide: true },
5165
+ {
5166
+ encoding: "utf-8",
5167
+ timeout: 1e4,
5168
+ windowsHide: true,
5169
+ // Internal call — don't trip work's checkpoint hooks (see internal-claude.ts).
5170
+ env: { ...process.env, ...internalClaudeEnv() }
5171
+ },
5132
5172
  (err, stdout) => {
5133
5173
  const result = stdout?.trim().toLowerCase().replace(/[^a-z0-9-]/g, "").replace(/^-|-$/g, "");
5134
5174
  resolve(result || fallback);
@@ -8982,6 +9022,14 @@ function getCommentFileStore(sessionId) {
8982
9022
  },
8983
9023
  reload() {
8984
9024
  reloadInner();
9025
+ },
9026
+ clearAll() {
9027
+ return lockedMutate(() => {
9028
+ const list = inner.list();
9029
+ const n = list.length;
9030
+ list.length = 0;
9031
+ return { value: n, persisted: n > 0 };
9032
+ });
8985
9033
  }
8986
9034
  };
8987
9035
  cache.set(sessionId, store);
@@ -9657,6 +9705,106 @@ async function takeCheckpoint(scopeHash, repos, opts = {}) {
9657
9705
  return entry;
9658
9706
  });
9659
9707
  }
9708
+ async function updateCheckpoint(scopeHash, repos, id) {
9709
+ const file = manifestPath(scopeHash);
9710
+ ensureFile(file, JSON.stringify(emptyManifest(scopeHash), null, 2));
9711
+ return withFileLock(file, () => {
9712
+ const manifest = loadManifest(scopeHash);
9713
+ const entry = manifest.entries.find((e) => e.id === id);
9714
+ if (!entry) return { status: "missing" };
9715
+ const refName = `refs/wd/${scopeHash}/${id}`;
9716
+ const restoreRefs = () => {
9717
+ for (const repo of repos) {
9718
+ const old = entry.repos[repo.name] ?? null;
9719
+ if (old) {
9720
+ spawn12.sync("git", ["update-ref", refName, old], {
9721
+ cwd: repo.root,
9722
+ encoding: "utf-8",
9723
+ windowsHide: true
9724
+ });
9725
+ } else {
9726
+ spawn12.sync("git", ["update-ref", "-d", refName], {
9727
+ cwd: repo.root,
9728
+ encoding: "utf-8",
9729
+ windowsHide: true
9730
+ });
9731
+ }
9732
+ }
9733
+ };
9734
+ const captured = {};
9735
+ for (const repo of repos) {
9736
+ captured[repo.name] = snapshotRepo(repo.root, scopeHash, id, true);
9737
+ }
9738
+ if (repos.some((r) => captured[r.name] === null)) {
9739
+ restoreRefs();
9740
+ return { status: "missing" };
9741
+ }
9742
+ const treeOf = (root, commitSha) => {
9743
+ if (!commitSha) return null;
9744
+ const r = spawn12.sync("git", ["rev-parse", `${commitSha}^{tree}`], {
9745
+ cwd: root,
9746
+ encoding: "utf-8",
9747
+ windowsHide: true
9748
+ });
9749
+ if (r.status !== 0 || typeof r.stdout !== "string") return null;
9750
+ return r.stdout.trim() || null;
9751
+ };
9752
+ const unchanged = repos.every((repo) => {
9753
+ const curTree = treeOf(repo.root, captured[repo.name]);
9754
+ const prevTree = treeOf(repo.root, entry.repos[repo.name] ?? null);
9755
+ return curTree !== null && curTree === prevTree;
9756
+ });
9757
+ if (unchanged) {
9758
+ restoreRefs();
9759
+ return { status: "unchanged" };
9760
+ }
9761
+ entry.repos = captured;
9762
+ entry.ts = (/* @__PURE__ */ new Date()).toISOString();
9763
+ delete entry.label;
9764
+ atomicWriteFile(file, JSON.stringify(manifest, null, 2));
9765
+ return { status: "updated", entry };
9766
+ });
9767
+ }
9768
+ async function resetBaseline(scopeHash, repos) {
9769
+ const file = manifestPath(scopeHash);
9770
+ ensureFile(file, JSON.stringify(emptyManifest(scopeHash), null, 2));
9771
+ return withFileLock(file, () => {
9772
+ const prevIds = loadManifest(scopeHash).entries.map((e) => e.id);
9773
+ const captured = {};
9774
+ for (const repo of repos) {
9775
+ captured[repo.name] = snapshotRepo(repo.root, scopeHash, 0, false);
9776
+ }
9777
+ const delRef = (id) => {
9778
+ for (const repo of repos) {
9779
+ spawn12.sync("git", ["update-ref", "-d", `refs/wd/${scopeHash}/${id}`], {
9780
+ cwd: repo.root,
9781
+ encoding: "utf-8",
9782
+ windowsHide: true
9783
+ });
9784
+ }
9785
+ };
9786
+ if (repos.some((r) => captured[r.name] === null)) {
9787
+ delRef(0);
9788
+ return null;
9789
+ }
9790
+ for (const id of prevIds) {
9791
+ if (id !== 0) delRef(id);
9792
+ }
9793
+ const entry = {
9794
+ id: 0,
9795
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
9796
+ label: "Initial",
9797
+ repos: captured
9798
+ };
9799
+ const manifest = {
9800
+ version: 1,
9801
+ scopeHash,
9802
+ entries: [entry]
9803
+ };
9804
+ atomicWriteFile(file, JSON.stringify(manifest, null, 2));
9805
+ return entry;
9806
+ });
9807
+ }
9660
9808
  async function setCheckpointLabel(scopeHash, id, label2) {
9661
9809
  const file = manifestPath(scopeHash);
9662
9810
  ensureFile(file, JSON.stringify(emptyManifest(scopeHash), null, 2));
@@ -9668,6 +9816,29 @@ async function setCheckpointLabel(scopeHash, id, label2) {
9668
9816
  atomicWriteFile(file, JSON.stringify(manifest, null, 2));
9669
9817
  });
9670
9818
  }
9819
+ function headAdvancedSinceInitial(scopeHash, repos) {
9820
+ const manifest = loadManifest(scopeHash);
9821
+ const initial = manifest.entries.find((e) => e.id === 0);
9822
+ if (!initial) return false;
9823
+ const treeOf = (root, rev) => {
9824
+ const r = spawn12.sync("git", ["rev-parse", `${rev}^{tree}`], {
9825
+ cwd: root,
9826
+ encoding: "utf-8",
9827
+ windowsHide: true
9828
+ });
9829
+ if (r.status !== 0 || typeof r.stdout !== "string") return null;
9830
+ return r.stdout.trim() || null;
9831
+ };
9832
+ return repos.some((repo) => {
9833
+ const headTree = treeOf(repo.root, "HEAD");
9834
+ if (headTree === null) return false;
9835
+ const baselineSha = initial.repos[repo.name];
9836
+ if (!baselineSha) return true;
9837
+ const baselineTree = treeOf(repo.root, baselineSha);
9838
+ if (baselineTree === null) return false;
9839
+ return baselineTree !== headTree;
9840
+ });
9841
+ }
9671
9842
  function clearCheckpoints(scopeHash, repoRoots) {
9672
9843
  const manifest = loadManifest(scopeHash);
9673
9844
  for (const root of repoRoots) {
@@ -9761,7 +9932,10 @@ function runClaude(prompt, timeoutMs = 25e3) {
9761
9932
  try {
9762
9933
  child = spawn13("claude", ["-p"], {
9763
9934
  stdio: ["pipe", "pipe", "ignore"],
9764
- windowsHide: true
9935
+ windowsHide: true,
9936
+ // Tag as internal so this naming run doesn't recursively trip work's
9937
+ // own UserPromptSubmit/Stop checkpoint hooks (see internal-claude.ts).
9938
+ env: { ...process.env, ...internalClaudeEnv() }
9765
9939
  });
9766
9940
  } catch {
9767
9941
  finish(null);
@@ -9880,6 +10054,12 @@ function markScopeEnded(hash) {
9880
10054
  entry.scope.ended = true;
9881
10055
  return true;
9882
10056
  }
10057
+ function reviveScope(hash) {
10058
+ const entry = scopes.get(hash);
10059
+ if (!entry || !entry.scope.ended) return false;
10060
+ entry.scope.ended = false;
10061
+ return true;
10062
+ }
9883
10063
  function getScope(hash) {
9884
10064
  return scopes.get(hash)?.scope ?? null;
9885
10065
  }
@@ -9951,6 +10131,8 @@ import { streamSSE as streamSSE2 } from "hono/streaming";
9951
10131
  function mountScopeRoutes(app, opts) {
9952
10132
  const checkpointWatched = /* @__PURE__ */ new Set();
9953
10133
  const lastStatus = /* @__PURE__ */ new Map();
10134
+ const liveCheckpoint = /* @__PURE__ */ new Map();
10135
+ const summarizing = /* @__PURE__ */ new Set();
9954
10136
  const snapshotTimers = /* @__PURE__ */ new Map();
9955
10137
  const CHECKPOINT_SETTLE_MS = 4e3;
9956
10138
  const CLAUDE_SESSION_MS = 5 * 6e4;
@@ -9968,9 +10150,38 @@ function mountScopeRoutes(app, opts) {
9968
10150
  }
9969
10151
  const scopeBus = new EventEmitter();
9970
10152
  scopeBus.setMaxListeners(0);
10153
+ function emitCommentsChanged(payload) {
10154
+ opts.broadcast("comments-changed", payload);
10155
+ scopeBus.emit("comments-changed", payload);
10156
+ }
9971
10157
  function scopeRepos(scopePaths) {
9972
10158
  return scopePaths.map((p) => ({ name: p, root: p }));
9973
10159
  }
10160
+ function ensureSummary(scope, id) {
10161
+ if (id === 0) return;
10162
+ const key = `${scope.hash}:${id}`;
10163
+ if (summarizing.has(key)) return;
10164
+ summarizing.add(key);
10165
+ summarizeCheckpoint(scope.hash, scopeRepos(scope.paths), id).then((label2) => setCheckpointLabel(scope.hash, id, label2)).then(() => {
10166
+ const payload = { scopeHash: scope.hash, id };
10167
+ opts.broadcast("checkpoints-changed", payload);
10168
+ scopeBus.emit("checkpoints-changed", payload);
10169
+ }).catch(() => {
10170
+ }).finally(() => summarizing.delete(key));
10171
+ }
10172
+ async function rebaselineIfHeadAdvanced(hash, paths) {
10173
+ const repos = scopeRepos(paths);
10174
+ if (!headAdvancedSinceInitial(hash, repos)) return false;
10175
+ liveCheckpoint.delete(hash);
10176
+ lastStatus.delete(hash);
10177
+ const entry = await resetBaseline(hash, repos).catch(() => null);
10178
+ if (entry) {
10179
+ const payload = { scopeHash: hash, id: entry.id };
10180
+ opts.broadcast("checkpoints-changed", payload);
10181
+ scopeBus.emit("checkpoints-changed", payload);
10182
+ }
10183
+ return true;
10184
+ }
9974
10185
  app.post(
9975
10186
  "/api/scopes",
9976
10187
  zValidator5(
@@ -9984,6 +10195,12 @@ function mountScopeRoutes(app, opts) {
9984
10195
  const { paths, label: label2 } = c.req.valid("json");
9985
10196
  try {
9986
10197
  const scope = registerScope(paths, label2);
10198
+ if (reviveScope(scope.hash)) {
10199
+ const cleared = commentStore(scope.hash).clearAll();
10200
+ if (cleared > 0) {
10201
+ emitCommentsChanged({ scopeHash: scope.hash });
10202
+ }
10203
+ }
9987
10204
  opts.broadcast("scopes-changed", { hash: scope.hash });
9988
10205
  const announceCheckpoint = (entry) => {
9989
10206
  const payload = { scopeHash: scope.hash, id: entry.id };
@@ -9996,6 +10213,10 @@ function mountScopeRoutes(app, opts) {
9996
10213
  }).catch((err) => {
9997
10214
  console.error("[checkpoint] initial snapshot failed:", err);
9998
10215
  });
10216
+ } else {
10217
+ rebaselineIfHeadAdvanced(scope.hash, scope.paths).catch((err) => {
10218
+ console.error("[checkpoint] re-baseline failed:", err);
10219
+ });
9999
10220
  }
10000
10221
  if (!checkpointWatched.has(scope.hash)) {
10001
10222
  checkpointWatched.add(scope.hash);
@@ -10015,8 +10236,11 @@ function mountScopeRoutes(app, opts) {
10015
10236
  lastStatus.set(hash, fp);
10016
10237
  } catch {
10017
10238
  }
10018
- takeCheckpoint(hash, scopeRepos(scope.paths)).then((entry) => {
10019
- if (entry) announceCheckpoint(entry);
10239
+ rebaselineIfHeadAdvanced(hash, scope.paths).then(() => takeCheckpoint(hash, scopeRepos(scope.paths))).then((entry) => {
10240
+ if (entry) {
10241
+ announceCheckpoint(entry);
10242
+ ensureSummary(scope, entry.id);
10243
+ }
10020
10244
  }).catch((err) => {
10021
10245
  console.error("[checkpoint] auto-snapshot failed:", err);
10022
10246
  });
@@ -10049,19 +10273,55 @@ function mountScopeRoutes(app, opts) {
10049
10273
  const matched = scopesForCwd(cwd);
10050
10274
  let snapshotted = 0;
10051
10275
  for (const s of matched) {
10052
- const entry = await takeCheckpoint(s.hash, scopeRepos(s.paths)).catch(
10053
- () => null
10054
- );
10276
+ await rebaselineIfHeadAdvanced(s.hash, s.paths);
10277
+ const liveId = liveCheckpoint.get(s.hash);
10278
+ let entry = null;
10279
+ if (liveId !== void 0) {
10280
+ const res = await updateCheckpoint(
10281
+ s.hash,
10282
+ scopeRepos(s.paths),
10283
+ liveId
10284
+ ).catch(() => ({ status: "missing" }));
10285
+ if (res.status === "updated") {
10286
+ entry = res.entry;
10287
+ } else if (res.status === "missing") {
10288
+ liveCheckpoint.delete(s.hash);
10289
+ }
10290
+ }
10291
+ if (entry === null && !liveCheckpoint.has(s.hash)) {
10292
+ const appended = await takeCheckpoint(
10293
+ s.hash,
10294
+ scopeRepos(s.paths)
10295
+ ).catch(() => null);
10296
+ if (appended) {
10297
+ entry = appended;
10298
+ liveCheckpoint.set(s.hash, appended.id);
10299
+ }
10300
+ }
10055
10301
  if (entry) {
10056
10302
  const payload = { scopeHash: s.hash, id: entry.id };
10057
10303
  opts.broadcast("checkpoints-changed", payload);
10058
10304
  scopeBus.emit("checkpoints-changed", payload);
10305
+ ensureSummary(s, entry.id);
10059
10306
  snapshotted++;
10060
10307
  }
10061
10308
  }
10062
10309
  return c.json({ ok: true, scopes: matched.length, snapshotted });
10063
10310
  }
10064
10311
  );
10312
+ app.post(
10313
+ "/api/checkpoint/seal",
10314
+ zValidator5("json", z4.object({ cwd: z4.string().min(1) })),
10315
+ (c) => {
10316
+ const { cwd } = c.req.valid("json");
10317
+ const matched = scopesForCwd(cwd);
10318
+ let sealed = 0;
10319
+ for (const s of matched) {
10320
+ if (liveCheckpoint.delete(s.hash)) sealed++;
10321
+ }
10322
+ return c.json({ ok: true, scopes: matched.length, sealed });
10323
+ }
10324
+ );
10065
10325
  app.delete("/api/scopes/:hash", (c) => {
10066
10326
  const hash = c.req.param("hash");
10067
10327
  const scope = getScope(hash);
@@ -10069,6 +10329,10 @@ function mountScopeRoutes(app, opts) {
10069
10329
  const ok = removeScope(hash);
10070
10330
  checkpointWatched.delete(hash);
10071
10331
  lastStatus.delete(hash);
10332
+ liveCheckpoint.delete(hash);
10333
+ for (const key of summarizing) {
10334
+ if (key.startsWith(`${hash}:`)) summarizing.delete(key);
10335
+ }
10072
10336
  const pendingTimer = snapshotTimers.get(hash);
10073
10337
  if (pendingTimer) {
10074
10338
  clearTimeout(pendingTimer);
@@ -10222,7 +10486,7 @@ function mountScopeRoutes(app, opts) {
10222
10486
  const store = commentStore(scope.hash);
10223
10487
  try {
10224
10488
  const comment = store.post(c.req.valid("json"));
10225
- opts.broadcast("comments-changed", {
10489
+ emitCommentsChanged({
10226
10490
  scopeHash: scope.hash,
10227
10491
  id: comment.id
10228
10492
  });
@@ -10238,7 +10502,7 @@ function mountScopeRoutes(app, opts) {
10238
10502
  const store = commentStore(scope.hash);
10239
10503
  const removed = store.remove(c.req.param("cid"));
10240
10504
  if (removed) {
10241
- opts.broadcast("comments-changed", {
10505
+ emitCommentsChanged({
10242
10506
  scopeHash: scope.hash,
10243
10507
  deleted: c.req.param("cid")
10244
10508
  });
@@ -10257,7 +10521,7 @@ function mountScopeRoutes(app, opts) {
10257
10521
  c.req.valid("json").resolved
10258
10522
  );
10259
10523
  if (updated) {
10260
- opts.broadcast("comments-changed", {
10524
+ emitCommentsChanged({
10261
10525
  scopeHash: scope.hash,
10262
10526
  id: updated.id
10263
10527
  });
@@ -10273,7 +10537,7 @@ function mountScopeRoutes(app, opts) {
10273
10537
  if (!scope) return c.json({ error: "unknown scope" }, 404);
10274
10538
  const store = commentStore(scope.hash);
10275
10539
  const result = store.submit(c.req.valid("json").summary);
10276
- opts.broadcast("comments-changed", {
10540
+ emitCommentsChanged({
10277
10541
  scopeHash: scope.hash,
10278
10542
  submittedCount: result.drafts.length
10279
10543
  });
@@ -10289,7 +10553,7 @@ function mountScopeRoutes(app, opts) {
10289
10553
  const store = commentStore(scope.hash);
10290
10554
  const discarded = store.discardDrafts();
10291
10555
  if (discarded > 0) {
10292
- opts.broadcast("comments-changed", { scopeHash: scope.hash });
10556
+ emitCommentsChanged({ scopeHash: scope.hash });
10293
10557
  }
10294
10558
  return c.json({ discarded, comments: store.snapshot() });
10295
10559
  });
@@ -10299,7 +10563,9 @@ function mountScopeRoutes(app, opts) {
10299
10563
  const store = commentStore(scope.hash);
10300
10564
  const count = store.list().length;
10301
10565
  markScopeEnded(scope.hash);
10302
- opts.broadcast("review-done", { scopeHash: scope.hash, count });
10566
+ const payload = { scopeHash: scope.hash, count };
10567
+ opts.broadcast("review-done", payload);
10568
+ scopeBus.emit("review-done", payload);
10303
10569
  return c.json({ ok: true, count });
10304
10570
  });
10305
10571
  app.get("/api/scopes/:hash/events", (c) => {
@@ -10322,11 +10588,31 @@ function mountScopeRoutes(app, opts) {
10322
10588
  });
10323
10589
  };
10324
10590
  scopeBus.on("checkpoints-changed", onCheckpoint);
10591
+ const onComments = (payload) => {
10592
+ if (payload.scopeHash !== scope.hash) return;
10593
+ stream.writeSSE({
10594
+ event: "comments-changed",
10595
+ data: JSON.stringify(payload)
10596
+ }).catch(() => {
10597
+ });
10598
+ };
10599
+ scopeBus.on("comments-changed", onComments);
10600
+ const onDone = (payload) => {
10601
+ if (payload.scopeHash !== scope.hash) return;
10602
+ stream.writeSSE({
10603
+ event: "review-done",
10604
+ data: JSON.stringify(payload)
10605
+ }).catch(() => {
10606
+ });
10607
+ };
10608
+ scopeBus.on("review-done", onDone);
10325
10609
  await stream.writeSSE({ event: "connected", data: "" });
10326
10610
  await new Promise((resolve) => {
10327
10611
  stream.onAbort(() => {
10328
10612
  unsubscribe?.();
10329
10613
  scopeBus.off("checkpoints-changed", onCheckpoint);
10614
+ scopeBus.off("comments-changed", onComments);
10615
+ scopeBus.off("review-done", onDone);
10330
10616
  resolve();
10331
10617
  });
10332
10618
  });
@@ -10777,6 +11063,13 @@ var webCommand = {
10777
11063
  timeoutSec: 5
10778
11064
  }).catch(() => {
10779
11065
  });
11066
+ await installCommandHook({
11067
+ owner: "web-checkpoint",
11068
+ event: "UserPromptSubmit",
11069
+ command: "work hook checkpoint-seal",
11070
+ timeoutSec: 5
11071
+ }).catch(() => {
11072
+ });
10780
11073
  const shutdown = () => {
10781
11074
  info2(chalk23.gray("\nStopping work web."));
10782
11075
  try {
@@ -10801,6 +11094,10 @@ var webCommand = {
10801
11094
  removeCommandHookSync("web-checkpoint", "Stop");
10802
11095
  } catch {
10803
11096
  }
11097
+ try {
11098
+ removeCommandHookSync("web-checkpoint", "UserPromptSubmit");
11099
+ } catch {
11100
+ }
10804
11101
  handle.stop();
10805
11102
  process.exit(0);
10806
11103
  };
@@ -10825,7 +11122,7 @@ var webCommand = {
10825
11122
  import fs42 from "fs";
10826
11123
  import os14 from "os";
10827
11124
  import path42 from "path";
10828
- async function triggerCheckpoint(cwd) {
11125
+ async function postToWeb(route, cwd) {
10829
11126
  let base;
10830
11127
  try {
10831
11128
  base = fs42.readFileSync(path42.join(os14.homedir(), ".work", "web.url"), "utf-8").trim();
@@ -10836,7 +11133,7 @@ async function triggerCheckpoint(cwd) {
10836
11133
  const controller = new AbortController();
10837
11134
  const timer = setTimeout(() => controller.abort(), 3e3);
10838
11135
  try {
10839
- await fetch(`${base}api/checkpoint`, {
11136
+ await fetch(`${base}${route}`, {
10840
11137
  method: "POST",
10841
11138
  headers: { "Content-Type": "application/json" },
10842
11139
  body: JSON.stringify({ cwd }),
@@ -10896,15 +11193,20 @@ var hookCommand = {
10896
11193
  // hidden — humans don't call this directly
10897
11194
  builder: (y) => y.positional("event", {
10898
11195
  type: "string",
10899
- choices: ["prompt-submit", "stop", "checkpoint"],
11196
+ choices: ["prompt-submit", "stop", "checkpoint", "checkpoint-seal"],
10900
11197
  describe: "Hook event name"
10901
11198
  }),
10902
11199
  handler: async (argv) => {
11200
+ if (isInternalClaude()) return;
10903
11201
  const event = argv.event;
10904
11202
  const payload = await readStdinJson();
10905
11203
  const cwd = payload.cwd ?? process.cwd();
10906
11204
  if (event === "checkpoint") {
10907
- await triggerCheckpoint(cwd);
11205
+ await postToWeb("api/checkpoint", cwd);
11206
+ return;
11207
+ }
11208
+ if (event === "checkpoint-seal") {
11209
+ await postToWeb("api/checkpoint/seal", cwd);
10908
11210
  return;
10909
11211
  }
10910
11212
  const result = computeHookOutput({ event, cwd });
@@ -11458,7 +11760,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
11458
11760
  }
11459
11761
 
11460
11762
  // src/version.ts
11461
- var VERSION = true ? "1.9.0" : "dev";
11763
+ var VERSION = true ? "1.11.0" : "dev";
11462
11764
 
11463
11765
  // src/cli.ts
11464
11766
  function showHelp() {