@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.
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "work-tree",
3
+ "description": "Claude Code skills shipped with the work-tree CLI (work / wd)",
4
+ "owner": {
5
+ "name": "Moberg HR",
6
+ "url": "https://github.com/moberghr"
7
+ },
8
+ "plugins": [
9
+ {
10
+ "name": "work-tree",
11
+ "description": "Skills for the work-tree CLI — wd-review drives interactive `wd -c` browser diff reviews",
12
+ "version": "1.9.1",
13
+ "source": "./plugins/work-tree",
14
+ "category": "productivity",
15
+ "tags": ["git", "worktree", "diff", "review"]
16
+ }
17
+ ]
18
+ }
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  **A cross-platform TypeScript CLI that turns git worktrees into a parallel-development cockpit. Spin up isolated workspaces per branch across one or many repos, auto-launch Claude Code (or any AI CLI), and orchestrate everything — PRs, Jira issues, local tasks, diffs, and reviews — from a terminal dashboard or a single browser tab.**
8
8
 
9
- [![Version](https://img.shields.io/badge/version-1.5.0-blue.svg)](https://github.com/moberghr/cli-work-tree-manager/releases)
9
+ [![npm](https://img.shields.io/npm/v/@moberg_hr/work-tree?color=cb3837&logo=npm&label=npm)](https://www.npmjs.com/package/@moberg_hr/work-tree)
10
10
  [![Website](https://img.shields.io/badge/website-moberghr.github.io-6d28d9.svg)](https://moberghr.github.io/cli-work-tree-manager/)
11
11
  [![Node](https://img.shields.io/badge/node-%E2%89%A518-339933.svg)](https://nodejs.org/)
12
12
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
@@ -42,6 +42,11 @@ Work is the missing layer between `git worktree` and your AI assistant. Every br
42
42
 
43
43
  ```bash
44
44
  # 1. Install (Node 18+, Git required)
45
+
46
+ # Option A — Homebrew (macOS / Linux)
47
+ brew install moberghr/work-tree/work # provides `work` and `wd`
48
+
49
+ # Option B — from source
45
50
  git clone https://github.com/moberghr/cli-work-tree-manager work
46
51
  cd work
47
52
  npm install
@@ -316,7 +321,14 @@ Other features in review mode:
316
321
  - **General comments** — a top-of-page composer for review notes that aren't tied to any line.
317
322
  - **Stable scope hash** — keep one tab open across repeated `wd` / `wd -c` invocations for the same worktree.
318
323
 
319
- When running standalone (no `work web`), the live URL is published to `~/.work/diffs/latest-review.url` so any local tool can find it without scraping stdout. A ready-made Claude Code skill ships with the repo at `.claude/skills/wd-review/SKILL.md` — drop it into `~/.claude/skills/` and say *"review my changes with wd"* in any Claude session to drive the loop.
324
+ When running standalone (no `work web`), the live URL is published to `~/.work/diffs/latest-review.url` so any local tool can find it without scraping stdout. A ready-made Claude Code skill ships as the `work-tree` plugin (`plugins/work-tree/skills/wd-review/SKILL.md`) — installing the npm package auto-registers the plugin marketplace and installs the plugin when the `claude` CLI is present. To add it manually from the Moberg plugin marketplace:
325
+
326
+ ```bash
327
+ /plugin marketplace add moberghr/moberg-plugins
328
+ /plugin install work-tree@moberg-plugins
329
+ ```
330
+
331
+ Then say *"review my changes with wd"* in any Claude session to drive the loop.
320
332
 
321
333
  ---
322
334
 
@@ -557,7 +569,7 @@ MIT — see [LICENSE](LICENSE).
557
569
 
558
570
  <div align="center">
559
571
 
560
- **Work — Git Worktree Manager** v1.5.0 · [Moberg d.o.o.](https://www.moberg.hr)
572
+ **Work — Git Worktree Manager** · [Moberg d.o.o.](https://www.moberg.hr)
561
573
 
562
574
  Built for engineers who run more than one branch at a time.
563
575
 
package/dist/bin.js CHANGED
@@ -445,6 +445,17 @@ import fs3 from "fs";
445
445
  import path4 from "path";
446
446
  import spawn2 from "cross-spawn";
447
447
  import chalk from "chalk";
448
+
449
+ // src/core/internal-claude.ts
450
+ var INTERNAL_CLAUDE_ENV = "WORK_INTERNAL_CLAUDE";
451
+ function internalClaudeEnv() {
452
+ return { [INTERNAL_CLAUDE_ENV]: "1" };
453
+ }
454
+ function isInternalClaude() {
455
+ return process.env[INTERNAL_CLAUDE_ENV] === "1";
456
+ }
457
+
458
+ // src/core/claude-md.ts
448
459
  function generateGroupClaudeMd(groupName, repoAliases, config) {
449
460
  const outputPath = path4.join(getConfigDir(), `${groupName}.claude.md`);
450
461
  const promptParts = [];
@@ -501,7 +512,9 @@ function generateGroupClaudeMd(groupName, repoAliases, config) {
501
512
  input: prompt,
502
513
  encoding: "utf-8",
503
514
  stdio: ["pipe", "pipe", "pipe"],
504
- windowsHide: true
515
+ windowsHide: true,
516
+ // Internal call — don't trip work's checkpoint hooks (see internal-claude.ts).
517
+ env: { ...process.env, ...internalClaudeEnv() }
505
518
  });
506
519
  let content;
507
520
  if (result.status !== 0 || !result.stdout?.trim()) {
@@ -1890,6 +1903,25 @@ function toBaseSpec(base) {
1890
1903
  }
1891
1904
 
1892
1905
  // src/core/worktree.ts
1906
+ function pullExistingWorktree(worktreePath, branchName) {
1907
+ const upstream = git(
1908
+ ["rev-parse", "--abbrev-ref", `${branchName}@{upstream}`],
1909
+ worktreePath
1910
+ );
1911
+ if (upstream.exitCode !== 0) return;
1912
+ console.log(` Pulling latest changes for ${branchName}...`);
1913
+ git(["fetch", "--quiet"], worktreePath);
1914
+ const pull = git(["pull", "--quiet"], worktreePath);
1915
+ if (pull.exitCode !== 0) {
1916
+ console.log(
1917
+ chalk5.yellow(
1918
+ ` \u26A0 Could not pull '${branchName}' (uncommitted changes or conflicts). Worktree may be behind origin.`
1919
+ )
1920
+ );
1921
+ const firstErrLine = pull.stderr.split("\n")[0];
1922
+ if (firstErrLine) console.log(chalk5.gray(` ${firstErrLine}`));
1923
+ }
1924
+ }
1893
1925
  function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch) {
1894
1926
  debug("createSingleWorktree", { repoPath, worktreePath, branchName, baseBranch });
1895
1927
  if (fs13.existsSync(worktreePath)) {
@@ -1899,6 +1931,7 @@ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBr
1899
1931
  console.log(
1900
1932
  chalk5.yellow(` Worktree already exists at: ${worktreePath}`)
1901
1933
  );
1934
+ pullExistingWorktree(worktreePath, branchName);
1902
1935
  return true;
1903
1936
  }
1904
1937
  }
@@ -2232,6 +2265,7 @@ async function setupSingleWorktree(targetName, branchName, workTreeDirName, conf
2232
2265
  }
2233
2266
  console.log(`Worktree already exists at: ${existing.path}`);
2234
2267
  workTreePath = existing.path;
2268
+ pullExistingWorktree(workTreePath, branchName);
2235
2269
  } else {
2236
2270
  const success = createSingleWorktree(repoPath, workTreePath, branchName, config, baseBranch);
2237
2271
  if (!success) return null;
@@ -5130,7 +5164,13 @@ function generateSlug(summary) {
5130
5164
  const child = execFile4(
5131
5165
  "claude",
5132
5166
  ["-p", "--model", "haiku"],
5133
- { encoding: "utf-8", timeout: 1e4, windowsHide: true },
5167
+ {
5168
+ encoding: "utf-8",
5169
+ timeout: 1e4,
5170
+ windowsHide: true,
5171
+ // Internal call — don't trip work's checkpoint hooks (see internal-claude.ts).
5172
+ env: { ...process.env, ...internalClaudeEnv() }
5173
+ },
5134
5174
  (err, stdout) => {
5135
5175
  const result = stdout?.trim().toLowerCase().replace(/[^a-z0-9-]/g, "").replace(/^-|-$/g, "");
5136
5176
  resolve(result || fallback);
@@ -8984,6 +9024,14 @@ function getCommentFileStore(sessionId) {
8984
9024
  },
8985
9025
  reload() {
8986
9026
  reloadInner();
9027
+ },
9028
+ clearAll() {
9029
+ return lockedMutate(() => {
9030
+ const list = inner.list();
9031
+ const n = list.length;
9032
+ list.length = 0;
9033
+ return { value: n, persisted: n > 0 };
9034
+ });
8987
9035
  }
8988
9036
  };
8989
9037
  cache.set(sessionId, store);
@@ -9659,6 +9707,106 @@ async function takeCheckpoint(scopeHash, repos, opts = {}) {
9659
9707
  return entry;
9660
9708
  });
9661
9709
  }
9710
+ async function updateCheckpoint(scopeHash, repos, id) {
9711
+ const file = manifestPath(scopeHash);
9712
+ ensureFile(file, JSON.stringify(emptyManifest(scopeHash), null, 2));
9713
+ return withFileLock(file, () => {
9714
+ const manifest = loadManifest(scopeHash);
9715
+ const entry = manifest.entries.find((e) => e.id === id);
9716
+ if (!entry) return { status: "missing" };
9717
+ const refName = `refs/wd/${scopeHash}/${id}`;
9718
+ const restoreRefs = () => {
9719
+ for (const repo of repos) {
9720
+ const old = entry.repos[repo.name] ?? null;
9721
+ if (old) {
9722
+ spawn12.sync("git", ["update-ref", refName, old], {
9723
+ cwd: repo.root,
9724
+ encoding: "utf-8",
9725
+ windowsHide: true
9726
+ });
9727
+ } else {
9728
+ spawn12.sync("git", ["update-ref", "-d", refName], {
9729
+ cwd: repo.root,
9730
+ encoding: "utf-8",
9731
+ windowsHide: true
9732
+ });
9733
+ }
9734
+ }
9735
+ };
9736
+ const captured = {};
9737
+ for (const repo of repos) {
9738
+ captured[repo.name] = snapshotRepo(repo.root, scopeHash, id, true);
9739
+ }
9740
+ if (repos.some((r) => captured[r.name] === null)) {
9741
+ restoreRefs();
9742
+ return { status: "missing" };
9743
+ }
9744
+ const treeOf = (root, commitSha) => {
9745
+ if (!commitSha) return null;
9746
+ const r = spawn12.sync("git", ["rev-parse", `${commitSha}^{tree}`], {
9747
+ cwd: root,
9748
+ encoding: "utf-8",
9749
+ windowsHide: true
9750
+ });
9751
+ if (r.status !== 0 || typeof r.stdout !== "string") return null;
9752
+ return r.stdout.trim() || null;
9753
+ };
9754
+ const unchanged = repos.every((repo) => {
9755
+ const curTree = treeOf(repo.root, captured[repo.name]);
9756
+ const prevTree = treeOf(repo.root, entry.repos[repo.name] ?? null);
9757
+ return curTree !== null && curTree === prevTree;
9758
+ });
9759
+ if (unchanged) {
9760
+ restoreRefs();
9761
+ return { status: "unchanged" };
9762
+ }
9763
+ entry.repos = captured;
9764
+ entry.ts = (/* @__PURE__ */ new Date()).toISOString();
9765
+ delete entry.label;
9766
+ atomicWriteFile(file, JSON.stringify(manifest, null, 2));
9767
+ return { status: "updated", entry };
9768
+ });
9769
+ }
9770
+ async function resetBaseline(scopeHash, repos) {
9771
+ const file = manifestPath(scopeHash);
9772
+ ensureFile(file, JSON.stringify(emptyManifest(scopeHash), null, 2));
9773
+ return withFileLock(file, () => {
9774
+ const prevIds = loadManifest(scopeHash).entries.map((e) => e.id);
9775
+ const captured = {};
9776
+ for (const repo of repos) {
9777
+ captured[repo.name] = snapshotRepo(repo.root, scopeHash, 0, false);
9778
+ }
9779
+ const delRef = (id) => {
9780
+ for (const repo of repos) {
9781
+ spawn12.sync("git", ["update-ref", "-d", `refs/wd/${scopeHash}/${id}`], {
9782
+ cwd: repo.root,
9783
+ encoding: "utf-8",
9784
+ windowsHide: true
9785
+ });
9786
+ }
9787
+ };
9788
+ if (repos.some((r) => captured[r.name] === null)) {
9789
+ delRef(0);
9790
+ return null;
9791
+ }
9792
+ for (const id of prevIds) {
9793
+ if (id !== 0) delRef(id);
9794
+ }
9795
+ const entry = {
9796
+ id: 0,
9797
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
9798
+ label: "Initial",
9799
+ repos: captured
9800
+ };
9801
+ const manifest = {
9802
+ version: 1,
9803
+ scopeHash,
9804
+ entries: [entry]
9805
+ };
9806
+ atomicWriteFile(file, JSON.stringify(manifest, null, 2));
9807
+ return entry;
9808
+ });
9809
+ }
9662
9810
  async function setCheckpointLabel(scopeHash, id, label2) {
9663
9811
  const file = manifestPath(scopeHash);
9664
9812
  ensureFile(file, JSON.stringify(emptyManifest(scopeHash), null, 2));
@@ -9670,6 +9818,29 @@ async function setCheckpointLabel(scopeHash, id, label2) {
9670
9818
  atomicWriteFile(file, JSON.stringify(manifest, null, 2));
9671
9819
  });
9672
9820
  }
9821
+ function headAdvancedSinceInitial(scopeHash, repos) {
9822
+ const manifest = loadManifest(scopeHash);
9823
+ const initial = manifest.entries.find((e) => e.id === 0);
9824
+ if (!initial) return false;
9825
+ const treeOf = (root, rev) => {
9826
+ const r = spawn12.sync("git", ["rev-parse", `${rev}^{tree}`], {
9827
+ cwd: root,
9828
+ encoding: "utf-8",
9829
+ windowsHide: true
9830
+ });
9831
+ if (r.status !== 0 || typeof r.stdout !== "string") return null;
9832
+ return r.stdout.trim() || null;
9833
+ };
9834
+ return repos.some((repo) => {
9835
+ const headTree = treeOf(repo.root, "HEAD");
9836
+ if (headTree === null) return false;
9837
+ const baselineSha = initial.repos[repo.name];
9838
+ if (!baselineSha) return true;
9839
+ const baselineTree = treeOf(repo.root, baselineSha);
9840
+ if (baselineTree === null) return false;
9841
+ return baselineTree !== headTree;
9842
+ });
9843
+ }
9673
9844
  function clearCheckpoints(scopeHash, repoRoots) {
9674
9845
  const manifest = loadManifest(scopeHash);
9675
9846
  for (const root of repoRoots) {
@@ -9763,7 +9934,10 @@ function runClaude(prompt, timeoutMs = 25e3) {
9763
9934
  try {
9764
9935
  child = spawn13("claude", ["-p"], {
9765
9936
  stdio: ["pipe", "pipe", "ignore"],
9766
- windowsHide: true
9937
+ windowsHide: true,
9938
+ // Tag as internal so this naming run doesn't recursively trip work's
9939
+ // own UserPromptSubmit/Stop checkpoint hooks (see internal-claude.ts).
9940
+ env: { ...process.env, ...internalClaudeEnv() }
9767
9941
  });
9768
9942
  } catch {
9769
9943
  finish(null);
@@ -9882,6 +10056,12 @@ function markScopeEnded(hash) {
9882
10056
  entry.scope.ended = true;
9883
10057
  return true;
9884
10058
  }
10059
+ function reviveScope(hash) {
10060
+ const entry = scopes.get(hash);
10061
+ if (!entry || !entry.scope.ended) return false;
10062
+ entry.scope.ended = false;
10063
+ return true;
10064
+ }
9885
10065
  function getScope(hash) {
9886
10066
  return scopes.get(hash)?.scope ?? null;
9887
10067
  }
@@ -9953,6 +10133,8 @@ import { streamSSE as streamSSE2 } from "hono/streaming";
9953
10133
  function mountScopeRoutes(app, opts) {
9954
10134
  const checkpointWatched = /* @__PURE__ */ new Set();
9955
10135
  const lastStatus = /* @__PURE__ */ new Map();
10136
+ const liveCheckpoint = /* @__PURE__ */ new Map();
10137
+ const summarizing = /* @__PURE__ */ new Set();
9956
10138
  const snapshotTimers = /* @__PURE__ */ new Map();
9957
10139
  const CHECKPOINT_SETTLE_MS = 4e3;
9958
10140
  const CLAUDE_SESSION_MS = 5 * 6e4;
@@ -9970,9 +10152,38 @@ function mountScopeRoutes(app, opts) {
9970
10152
  }
9971
10153
  const scopeBus = new EventEmitter();
9972
10154
  scopeBus.setMaxListeners(0);
10155
+ function emitCommentsChanged(payload) {
10156
+ opts.broadcast("comments-changed", payload);
10157
+ scopeBus.emit("comments-changed", payload);
10158
+ }
9973
10159
  function scopeRepos(scopePaths) {
9974
10160
  return scopePaths.map((p) => ({ name: p, root: p }));
9975
10161
  }
10162
+ function ensureSummary(scope, id) {
10163
+ if (id === 0) return;
10164
+ const key = `${scope.hash}:${id}`;
10165
+ if (summarizing.has(key)) return;
10166
+ summarizing.add(key);
10167
+ summarizeCheckpoint(scope.hash, scopeRepos(scope.paths), id).then((label2) => setCheckpointLabel(scope.hash, id, label2)).then(() => {
10168
+ const payload = { scopeHash: scope.hash, id };
10169
+ opts.broadcast("checkpoints-changed", payload);
10170
+ scopeBus.emit("checkpoints-changed", payload);
10171
+ }).catch(() => {
10172
+ }).finally(() => summarizing.delete(key));
10173
+ }
10174
+ async function rebaselineIfHeadAdvanced(hash, paths) {
10175
+ const repos = scopeRepos(paths);
10176
+ if (!headAdvancedSinceInitial(hash, repos)) return false;
10177
+ liveCheckpoint.delete(hash);
10178
+ lastStatus.delete(hash);
10179
+ const entry = await resetBaseline(hash, repos).catch(() => null);
10180
+ if (entry) {
10181
+ const payload = { scopeHash: hash, id: entry.id };
10182
+ opts.broadcast("checkpoints-changed", payload);
10183
+ scopeBus.emit("checkpoints-changed", payload);
10184
+ }
10185
+ return true;
10186
+ }
9976
10187
  app.post(
9977
10188
  "/api/scopes",
9978
10189
  zValidator5(
@@ -9986,6 +10197,12 @@ function mountScopeRoutes(app, opts) {
9986
10197
  const { paths, label: label2 } = c.req.valid("json");
9987
10198
  try {
9988
10199
  const scope = registerScope(paths, label2);
10200
+ if (reviveScope(scope.hash)) {
10201
+ const cleared = commentStore(scope.hash).clearAll();
10202
+ if (cleared > 0) {
10203
+ emitCommentsChanged({ scopeHash: scope.hash });
10204
+ }
10205
+ }
9989
10206
  opts.broadcast("scopes-changed", { hash: scope.hash });
9990
10207
  const announceCheckpoint = (entry) => {
9991
10208
  const payload = { scopeHash: scope.hash, id: entry.id };
@@ -9998,6 +10215,10 @@ function mountScopeRoutes(app, opts) {
9998
10215
  }).catch((err) => {
9999
10216
  console.error("[checkpoint] initial snapshot failed:", err);
10000
10217
  });
10218
+ } else {
10219
+ rebaselineIfHeadAdvanced(scope.hash, scope.paths).catch((err) => {
10220
+ console.error("[checkpoint] re-baseline failed:", err);
10221
+ });
10001
10222
  }
10002
10223
  if (!checkpointWatched.has(scope.hash)) {
10003
10224
  checkpointWatched.add(scope.hash);
@@ -10017,8 +10238,11 @@ function mountScopeRoutes(app, opts) {
10017
10238
  lastStatus.set(hash, fp);
10018
10239
  } catch {
10019
10240
  }
10020
- takeCheckpoint(hash, scopeRepos(scope.paths)).then((entry) => {
10021
- if (entry) announceCheckpoint(entry);
10241
+ rebaselineIfHeadAdvanced(hash, scope.paths).then(() => takeCheckpoint(hash, scopeRepos(scope.paths))).then((entry) => {
10242
+ if (entry) {
10243
+ announceCheckpoint(entry);
10244
+ ensureSummary(scope, entry.id);
10245
+ }
10022
10246
  }).catch((err) => {
10023
10247
  console.error("[checkpoint] auto-snapshot failed:", err);
10024
10248
  });
@@ -10051,19 +10275,55 @@ function mountScopeRoutes(app, opts) {
10051
10275
  const matched = scopesForCwd(cwd);
10052
10276
  let snapshotted = 0;
10053
10277
  for (const s of matched) {
10054
- const entry = await takeCheckpoint(s.hash, scopeRepos(s.paths)).catch(
10055
- () => null
10056
- );
10278
+ await rebaselineIfHeadAdvanced(s.hash, s.paths);
10279
+ const liveId = liveCheckpoint.get(s.hash);
10280
+ let entry = null;
10281
+ if (liveId !== void 0) {
10282
+ const res = await updateCheckpoint(
10283
+ s.hash,
10284
+ scopeRepos(s.paths),
10285
+ liveId
10286
+ ).catch(() => ({ status: "missing" }));
10287
+ if (res.status === "updated") {
10288
+ entry = res.entry;
10289
+ } else if (res.status === "missing") {
10290
+ liveCheckpoint.delete(s.hash);
10291
+ }
10292
+ }
10293
+ if (entry === null && !liveCheckpoint.has(s.hash)) {
10294
+ const appended = await takeCheckpoint(
10295
+ s.hash,
10296
+ scopeRepos(s.paths)
10297
+ ).catch(() => null);
10298
+ if (appended) {
10299
+ entry = appended;
10300
+ liveCheckpoint.set(s.hash, appended.id);
10301
+ }
10302
+ }
10057
10303
  if (entry) {
10058
10304
  const payload = { scopeHash: s.hash, id: entry.id };
10059
10305
  opts.broadcast("checkpoints-changed", payload);
10060
10306
  scopeBus.emit("checkpoints-changed", payload);
10307
+ ensureSummary(s, entry.id);
10061
10308
  snapshotted++;
10062
10309
  }
10063
10310
  }
10064
10311
  return c.json({ ok: true, scopes: matched.length, snapshotted });
10065
10312
  }
10066
10313
  );
10314
+ app.post(
10315
+ "/api/checkpoint/seal",
10316
+ zValidator5("json", z4.object({ cwd: z4.string().min(1) })),
10317
+ (c) => {
10318
+ const { cwd } = c.req.valid("json");
10319
+ const matched = scopesForCwd(cwd);
10320
+ let sealed = 0;
10321
+ for (const s of matched) {
10322
+ if (liveCheckpoint.delete(s.hash)) sealed++;
10323
+ }
10324
+ return c.json({ ok: true, scopes: matched.length, sealed });
10325
+ }
10326
+ );
10067
10327
  app.delete("/api/scopes/:hash", (c) => {
10068
10328
  const hash = c.req.param("hash");
10069
10329
  const scope = getScope(hash);
@@ -10071,6 +10331,10 @@ function mountScopeRoutes(app, opts) {
10071
10331
  const ok = removeScope(hash);
10072
10332
  checkpointWatched.delete(hash);
10073
10333
  lastStatus.delete(hash);
10334
+ liveCheckpoint.delete(hash);
10335
+ for (const key of summarizing) {
10336
+ if (key.startsWith(`${hash}:`)) summarizing.delete(key);
10337
+ }
10074
10338
  const pendingTimer = snapshotTimers.get(hash);
10075
10339
  if (pendingTimer) {
10076
10340
  clearTimeout(pendingTimer);
@@ -10224,7 +10488,7 @@ function mountScopeRoutes(app, opts) {
10224
10488
  const store = commentStore(scope.hash);
10225
10489
  try {
10226
10490
  const comment = store.post(c.req.valid("json"));
10227
- opts.broadcast("comments-changed", {
10491
+ emitCommentsChanged({
10228
10492
  scopeHash: scope.hash,
10229
10493
  id: comment.id
10230
10494
  });
@@ -10240,7 +10504,7 @@ function mountScopeRoutes(app, opts) {
10240
10504
  const store = commentStore(scope.hash);
10241
10505
  const removed = store.remove(c.req.param("cid"));
10242
10506
  if (removed) {
10243
- opts.broadcast("comments-changed", {
10507
+ emitCommentsChanged({
10244
10508
  scopeHash: scope.hash,
10245
10509
  deleted: c.req.param("cid")
10246
10510
  });
@@ -10259,7 +10523,7 @@ function mountScopeRoutes(app, opts) {
10259
10523
  c.req.valid("json").resolved
10260
10524
  );
10261
10525
  if (updated) {
10262
- opts.broadcast("comments-changed", {
10526
+ emitCommentsChanged({
10263
10527
  scopeHash: scope.hash,
10264
10528
  id: updated.id
10265
10529
  });
@@ -10275,7 +10539,7 @@ function mountScopeRoutes(app, opts) {
10275
10539
  if (!scope) return c.json({ error: "unknown scope" }, 404);
10276
10540
  const store = commentStore(scope.hash);
10277
10541
  const result = store.submit(c.req.valid("json").summary);
10278
- opts.broadcast("comments-changed", {
10542
+ emitCommentsChanged({
10279
10543
  scopeHash: scope.hash,
10280
10544
  submittedCount: result.drafts.length
10281
10545
  });
@@ -10291,7 +10555,7 @@ function mountScopeRoutes(app, opts) {
10291
10555
  const store = commentStore(scope.hash);
10292
10556
  const discarded = store.discardDrafts();
10293
10557
  if (discarded > 0) {
10294
- opts.broadcast("comments-changed", { scopeHash: scope.hash });
10558
+ emitCommentsChanged({ scopeHash: scope.hash });
10295
10559
  }
10296
10560
  return c.json({ discarded, comments: store.snapshot() });
10297
10561
  });
@@ -10301,7 +10565,9 @@ function mountScopeRoutes(app, opts) {
10301
10565
  const store = commentStore(scope.hash);
10302
10566
  const count = store.list().length;
10303
10567
  markScopeEnded(scope.hash);
10304
- opts.broadcast("review-done", { scopeHash: scope.hash, count });
10568
+ const payload = { scopeHash: scope.hash, count };
10569
+ opts.broadcast("review-done", payload);
10570
+ scopeBus.emit("review-done", payload);
10305
10571
  return c.json({ ok: true, count });
10306
10572
  });
10307
10573
  app.get("/api/scopes/:hash/events", (c) => {
@@ -10324,11 +10590,31 @@ function mountScopeRoutes(app, opts) {
10324
10590
  });
10325
10591
  };
10326
10592
  scopeBus.on("checkpoints-changed", onCheckpoint);
10593
+ const onComments = (payload) => {
10594
+ if (payload.scopeHash !== scope.hash) return;
10595
+ stream.writeSSE({
10596
+ event: "comments-changed",
10597
+ data: JSON.stringify(payload)
10598
+ }).catch(() => {
10599
+ });
10600
+ };
10601
+ scopeBus.on("comments-changed", onComments);
10602
+ const onDone = (payload) => {
10603
+ if (payload.scopeHash !== scope.hash) return;
10604
+ stream.writeSSE({
10605
+ event: "review-done",
10606
+ data: JSON.stringify(payload)
10607
+ }).catch(() => {
10608
+ });
10609
+ };
10610
+ scopeBus.on("review-done", onDone);
10327
10611
  await stream.writeSSE({ event: "connected", data: "" });
10328
10612
  await new Promise((resolve) => {
10329
10613
  stream.onAbort(() => {
10330
10614
  unsubscribe?.();
10331
10615
  scopeBus.off("checkpoints-changed", onCheckpoint);
10616
+ scopeBus.off("comments-changed", onComments);
10617
+ scopeBus.off("review-done", onDone);
10332
10618
  resolve();
10333
10619
  });
10334
10620
  });
@@ -10779,6 +11065,13 @@ var webCommand = {
10779
11065
  timeoutSec: 5
10780
11066
  }).catch(() => {
10781
11067
  });
11068
+ await installCommandHook({
11069
+ owner: "web-checkpoint",
11070
+ event: "UserPromptSubmit",
11071
+ command: "work hook checkpoint-seal",
11072
+ timeoutSec: 5
11073
+ }).catch(() => {
11074
+ });
10782
11075
  const shutdown = () => {
10783
11076
  info2(chalk23.gray("\nStopping work web."));
10784
11077
  try {
@@ -10803,6 +11096,10 @@ var webCommand = {
10803
11096
  removeCommandHookSync("web-checkpoint", "Stop");
10804
11097
  } catch {
10805
11098
  }
11099
+ try {
11100
+ removeCommandHookSync("web-checkpoint", "UserPromptSubmit");
11101
+ } catch {
11102
+ }
10806
11103
  handle.stop();
10807
11104
  process.exit(0);
10808
11105
  };
@@ -10827,7 +11124,7 @@ var webCommand = {
10827
11124
  import fs42 from "fs";
10828
11125
  import os14 from "os";
10829
11126
  import path42 from "path";
10830
- async function triggerCheckpoint(cwd) {
11127
+ async function postToWeb(route, cwd) {
10831
11128
  let base;
10832
11129
  try {
10833
11130
  base = fs42.readFileSync(path42.join(os14.homedir(), ".work", "web.url"), "utf-8").trim();
@@ -10838,7 +11135,7 @@ async function triggerCheckpoint(cwd) {
10838
11135
  const controller = new AbortController();
10839
11136
  const timer = setTimeout(() => controller.abort(), 3e3);
10840
11137
  try {
10841
- await fetch(`${base}api/checkpoint`, {
11138
+ await fetch(`${base}${route}`, {
10842
11139
  method: "POST",
10843
11140
  headers: { "Content-Type": "application/json" },
10844
11141
  body: JSON.stringify({ cwd }),
@@ -10898,15 +11195,20 @@ var hookCommand = {
10898
11195
  // hidden — humans don't call this directly
10899
11196
  builder: (y) => y.positional("event", {
10900
11197
  type: "string",
10901
- choices: ["prompt-submit", "stop", "checkpoint"],
11198
+ choices: ["prompt-submit", "stop", "checkpoint", "checkpoint-seal"],
10902
11199
  describe: "Hook event name"
10903
11200
  }),
10904
11201
  handler: async (argv) => {
11202
+ if (isInternalClaude()) return;
10905
11203
  const event = argv.event;
10906
11204
  const payload = await readStdinJson();
10907
11205
  const cwd = payload.cwd ?? process.cwd();
10908
11206
  if (event === "checkpoint") {
10909
- await triggerCheckpoint(cwd);
11207
+ await postToWeb("api/checkpoint", cwd);
11208
+ return;
11209
+ }
11210
+ if (event === "checkpoint-seal") {
11211
+ await postToWeb("api/checkpoint/seal", cwd);
10910
11212
  return;
10911
11213
  }
10912
11214
  const result = computeHookOutput({ event, cwd });
@@ -11460,7 +11762,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
11460
11762
  }
11461
11763
 
11462
11764
  // src/version.ts
11463
- var VERSION = true ? "1.9.0" : "dev";
11765
+ var VERSION = true ? "1.11.0" : "dev";
11464
11766
 
11465
11767
  // src/cli.ts
11466
11768
  function showHelp() {