@moberg_hr/work-tree 1.9.1 → 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/README.md +15 -3
- package/dist/bin.js +269 -13
- package/dist/bin.js.map +1 -1
- package/dist/wd-bin.js +269 -13
- package/dist/wd-bin.js.map +1 -1
- package/dist/web/assets/{index-BaT8rhHI.js → index-BZPJ-jWm.js} +72 -70
- package/dist/web/assets/index-BZPJ-jWm.js.map +1 -0
- package/dist/web/assets/index-CAPdwxaB.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +2 -1
- package/scripts/postinstall.mjs +4 -4
- package/dist/web/assets/index-BYfxyhDx.css +0 -1
- package/dist/web/assets/index-BaT8rhHI.js.map +0 -1
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
|
-
[](https://www.npmjs.com/package/@moberg_hr/work-tree)
|
|
10
10
|
[](https://moberghr.github.io/cli-work-tree-manager/)
|
|
11
11
|
[](https://nodejs.org/)
|
|
12
12
|
[](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 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
|
|
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**
|
|
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
|
-
{
|
|
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);
|
|
@@ -9667,6 +9707,106 @@ async function takeCheckpoint(scopeHash, repos, opts = {}) {
|
|
|
9667
9707
|
return entry;
|
|
9668
9708
|
});
|
|
9669
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
|
+
}
|
|
9670
9810
|
async function setCheckpointLabel(scopeHash, id, label2) {
|
|
9671
9811
|
const file = manifestPath(scopeHash);
|
|
9672
9812
|
ensureFile(file, JSON.stringify(emptyManifest(scopeHash), null, 2));
|
|
@@ -9678,6 +9818,29 @@ async function setCheckpointLabel(scopeHash, id, label2) {
|
|
|
9678
9818
|
atomicWriteFile(file, JSON.stringify(manifest, null, 2));
|
|
9679
9819
|
});
|
|
9680
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
|
+
}
|
|
9681
9844
|
function clearCheckpoints(scopeHash, repoRoots) {
|
|
9682
9845
|
const manifest = loadManifest(scopeHash);
|
|
9683
9846
|
for (const root of repoRoots) {
|
|
@@ -9771,7 +9934,10 @@ function runClaude(prompt, timeoutMs = 25e3) {
|
|
|
9771
9934
|
try {
|
|
9772
9935
|
child = spawn13("claude", ["-p"], {
|
|
9773
9936
|
stdio: ["pipe", "pipe", "ignore"],
|
|
9774
|
-
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() }
|
|
9775
9941
|
});
|
|
9776
9942
|
} catch {
|
|
9777
9943
|
finish(null);
|
|
@@ -9967,6 +10133,8 @@ import { streamSSE as streamSSE2 } from "hono/streaming";
|
|
|
9967
10133
|
function mountScopeRoutes(app, opts) {
|
|
9968
10134
|
const checkpointWatched = /* @__PURE__ */ new Set();
|
|
9969
10135
|
const lastStatus = /* @__PURE__ */ new Map();
|
|
10136
|
+
const liveCheckpoint = /* @__PURE__ */ new Map();
|
|
10137
|
+
const summarizing = /* @__PURE__ */ new Set();
|
|
9970
10138
|
const snapshotTimers = /* @__PURE__ */ new Map();
|
|
9971
10139
|
const CHECKPOINT_SETTLE_MS = 4e3;
|
|
9972
10140
|
const CLAUDE_SESSION_MS = 5 * 6e4;
|
|
@@ -9991,6 +10159,31 @@ function mountScopeRoutes(app, opts) {
|
|
|
9991
10159
|
function scopeRepos(scopePaths) {
|
|
9992
10160
|
return scopePaths.map((p) => ({ name: p, root: p }));
|
|
9993
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
|
+
}
|
|
9994
10187
|
app.post(
|
|
9995
10188
|
"/api/scopes",
|
|
9996
10189
|
zValidator5(
|
|
@@ -10022,6 +10215,10 @@ function mountScopeRoutes(app, opts) {
|
|
|
10022
10215
|
}).catch((err) => {
|
|
10023
10216
|
console.error("[checkpoint] initial snapshot failed:", err);
|
|
10024
10217
|
});
|
|
10218
|
+
} else {
|
|
10219
|
+
rebaselineIfHeadAdvanced(scope.hash, scope.paths).catch((err) => {
|
|
10220
|
+
console.error("[checkpoint] re-baseline failed:", err);
|
|
10221
|
+
});
|
|
10025
10222
|
}
|
|
10026
10223
|
if (!checkpointWatched.has(scope.hash)) {
|
|
10027
10224
|
checkpointWatched.add(scope.hash);
|
|
@@ -10041,8 +10238,11 @@ function mountScopeRoutes(app, opts) {
|
|
|
10041
10238
|
lastStatus.set(hash, fp);
|
|
10042
10239
|
} catch {
|
|
10043
10240
|
}
|
|
10044
|
-
takeCheckpoint(hash, scopeRepos(scope.paths)).then((entry) => {
|
|
10045
|
-
if (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
|
+
}
|
|
10046
10246
|
}).catch((err) => {
|
|
10047
10247
|
console.error("[checkpoint] auto-snapshot failed:", err);
|
|
10048
10248
|
});
|
|
@@ -10075,19 +10275,55 @@ function mountScopeRoutes(app, opts) {
|
|
|
10075
10275
|
const matched = scopesForCwd(cwd);
|
|
10076
10276
|
let snapshotted = 0;
|
|
10077
10277
|
for (const s of matched) {
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
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
|
+
}
|
|
10081
10303
|
if (entry) {
|
|
10082
10304
|
const payload = { scopeHash: s.hash, id: entry.id };
|
|
10083
10305
|
opts.broadcast("checkpoints-changed", payload);
|
|
10084
10306
|
scopeBus.emit("checkpoints-changed", payload);
|
|
10307
|
+
ensureSummary(s, entry.id);
|
|
10085
10308
|
snapshotted++;
|
|
10086
10309
|
}
|
|
10087
10310
|
}
|
|
10088
10311
|
return c.json({ ok: true, scopes: matched.length, snapshotted });
|
|
10089
10312
|
}
|
|
10090
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
|
+
);
|
|
10091
10327
|
app.delete("/api/scopes/:hash", (c) => {
|
|
10092
10328
|
const hash = c.req.param("hash");
|
|
10093
10329
|
const scope = getScope(hash);
|
|
@@ -10095,6 +10331,10 @@ function mountScopeRoutes(app, opts) {
|
|
|
10095
10331
|
const ok = removeScope(hash);
|
|
10096
10332
|
checkpointWatched.delete(hash);
|
|
10097
10333
|
lastStatus.delete(hash);
|
|
10334
|
+
liveCheckpoint.delete(hash);
|
|
10335
|
+
for (const key of summarizing) {
|
|
10336
|
+
if (key.startsWith(`${hash}:`)) summarizing.delete(key);
|
|
10337
|
+
}
|
|
10098
10338
|
const pendingTimer = snapshotTimers.get(hash);
|
|
10099
10339
|
if (pendingTimer) {
|
|
10100
10340
|
clearTimeout(pendingTimer);
|
|
@@ -10825,6 +11065,13 @@ var webCommand = {
|
|
|
10825
11065
|
timeoutSec: 5
|
|
10826
11066
|
}).catch(() => {
|
|
10827
11067
|
});
|
|
11068
|
+
await installCommandHook({
|
|
11069
|
+
owner: "web-checkpoint",
|
|
11070
|
+
event: "UserPromptSubmit",
|
|
11071
|
+
command: "work hook checkpoint-seal",
|
|
11072
|
+
timeoutSec: 5
|
|
11073
|
+
}).catch(() => {
|
|
11074
|
+
});
|
|
10828
11075
|
const shutdown = () => {
|
|
10829
11076
|
info2(chalk23.gray("\nStopping work web."));
|
|
10830
11077
|
try {
|
|
@@ -10849,6 +11096,10 @@ var webCommand = {
|
|
|
10849
11096
|
removeCommandHookSync("web-checkpoint", "Stop");
|
|
10850
11097
|
} catch {
|
|
10851
11098
|
}
|
|
11099
|
+
try {
|
|
11100
|
+
removeCommandHookSync("web-checkpoint", "UserPromptSubmit");
|
|
11101
|
+
} catch {
|
|
11102
|
+
}
|
|
10852
11103
|
handle.stop();
|
|
10853
11104
|
process.exit(0);
|
|
10854
11105
|
};
|
|
@@ -10873,7 +11124,7 @@ var webCommand = {
|
|
|
10873
11124
|
import fs42 from "fs";
|
|
10874
11125
|
import os14 from "os";
|
|
10875
11126
|
import path42 from "path";
|
|
10876
|
-
async function
|
|
11127
|
+
async function postToWeb(route, cwd) {
|
|
10877
11128
|
let base;
|
|
10878
11129
|
try {
|
|
10879
11130
|
base = fs42.readFileSync(path42.join(os14.homedir(), ".work", "web.url"), "utf-8").trim();
|
|
@@ -10884,7 +11135,7 @@ async function triggerCheckpoint(cwd) {
|
|
|
10884
11135
|
const controller = new AbortController();
|
|
10885
11136
|
const timer = setTimeout(() => controller.abort(), 3e3);
|
|
10886
11137
|
try {
|
|
10887
|
-
await fetch(`${base}
|
|
11138
|
+
await fetch(`${base}${route}`, {
|
|
10888
11139
|
method: "POST",
|
|
10889
11140
|
headers: { "Content-Type": "application/json" },
|
|
10890
11141
|
body: JSON.stringify({ cwd }),
|
|
@@ -10944,15 +11195,20 @@ var hookCommand = {
|
|
|
10944
11195
|
// hidden — humans don't call this directly
|
|
10945
11196
|
builder: (y) => y.positional("event", {
|
|
10946
11197
|
type: "string",
|
|
10947
|
-
choices: ["prompt-submit", "stop", "checkpoint"],
|
|
11198
|
+
choices: ["prompt-submit", "stop", "checkpoint", "checkpoint-seal"],
|
|
10948
11199
|
describe: "Hook event name"
|
|
10949
11200
|
}),
|
|
10950
11201
|
handler: async (argv) => {
|
|
11202
|
+
if (isInternalClaude()) return;
|
|
10951
11203
|
const event = argv.event;
|
|
10952
11204
|
const payload = await readStdinJson();
|
|
10953
11205
|
const cwd = payload.cwd ?? process.cwd();
|
|
10954
11206
|
if (event === "checkpoint") {
|
|
10955
|
-
await
|
|
11207
|
+
await postToWeb("api/checkpoint", cwd);
|
|
11208
|
+
return;
|
|
11209
|
+
}
|
|
11210
|
+
if (event === "checkpoint-seal") {
|
|
11211
|
+
await postToWeb("api/checkpoint/seal", cwd);
|
|
10956
11212
|
return;
|
|
10957
11213
|
}
|
|
10958
11214
|
const result = computeHookOutput({ event, cwd });
|
|
@@ -11506,7 +11762,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
|
|
|
11506
11762
|
}
|
|
11507
11763
|
|
|
11508
11764
|
// src/version.ts
|
|
11509
|
-
var VERSION = true ? "1.
|
|
11765
|
+
var VERSION = true ? "1.11.0" : "dev";
|
|
11510
11766
|
|
|
11511
11767
|
// src/cli.ts
|
|
11512
11768
|
function showHelp() {
|