@moberg_hr/work-tree 2.0.13 → 2.2.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/{answer-IL5AQHRO.js → answer-OF2QNF4A.js} +6 -6
- package/dist/{attach-MFU4KN47.js → attach-PAFAZ2EH.js} +9 -9
- package/dist/bin.js +2 -2
- package/dist/{block-OXGEQ2PZ.js → block-3LEG4LKJ.js} +6 -6
- package/dist/{broadcast-UJURJNEK.js → broadcast-ZDIL7UBP.js} +3 -3
- package/dist/{catchup-HN4VL5XK.js → catchup-ZZ5HZJIT.js} +8 -8
- package/dist/{chunk-E35NZVPX.js → chunk-2GX3IOSV.js} +15 -2
- package/dist/chunk-2GX3IOSV.js.map +1 -0
- package/dist/{chunk-R7B46WXN.js → chunk-3GAYLP7W.js} +4 -4
- package/dist/{chunk-OZIR2255.js → chunk-453EGT2R.js} +11 -7
- package/dist/chunk-453EGT2R.js.map +1 -0
- package/dist/{chunk-RLR66XLG.js → chunk-46VAWZZX.js} +2 -2
- package/dist/{chunk-SH7NSDRW.js → chunk-4CVUV2SE.js} +2 -2
- package/dist/{chunk-3XY76XBD.js → chunk-62C3CJ5M.js} +2 -2
- package/dist/{chunk-MIIJ2HQS.js → chunk-77SVSNME.js} +4 -4
- package/dist/{chunk-OQAQMCHF.js → chunk-C7OK4XEZ.js} +58 -9
- package/dist/chunk-C7OK4XEZ.js.map +1 -0
- package/dist/{chunk-YZLNJQAV.js → chunk-DLSAAP3S.js} +2 -2
- package/dist/{chunk-B2RCWZUW.js → chunk-EDAOG56H.js} +35 -7
- package/dist/chunk-EDAOG56H.js.map +1 -0
- package/dist/{chunk-EU3BS5A6.js → chunk-EXJYPF64.js} +3 -3
- package/dist/{chunk-PUYXTZ32.js → chunk-INVFNKU7.js} +4 -4
- package/dist/{chunk-KUWFGPGW.js → chunk-ISZM5C22.js} +15 -9
- package/dist/chunk-ISZM5C22.js.map +1 -0
- package/dist/{chunk-F375JY4M.js → chunk-KSVZVHTI.js} +6 -6
- package/dist/{chunk-F375JY4M.js.map → chunk-KSVZVHTI.js.map} +1 -1
- package/dist/{chunk-RQE5UOIW.js → chunk-KTFDSJUD.js} +16 -1
- package/dist/chunk-KTFDSJUD.js.map +1 -0
- package/dist/{chunk-HDO3PXCU.js → chunk-KWU35O5S.js} +3 -3
- package/dist/{chunk-U4UB4LG6.js → chunk-LBQR7KTC.js} +2 -2
- package/dist/{chunk-YXQIGBL6.js → chunk-LGDECE7V.js} +3 -3
- package/dist/{chunk-FX4IA5U4.js → chunk-M4YXBQZN.js} +5 -5
- package/dist/{chunk-OOCMPS5L.js → chunk-MRXD2NSO.js} +2 -2
- package/dist/{chunk-ZFPV46FA.js → chunk-NBI2INQS.js} +22 -13
- package/dist/chunk-NBI2INQS.js.map +1 -0
- package/dist/{chunk-BSFL3WDR.js → chunk-OCDHKDUN.js} +45 -45
- package/dist/{chunk-MVU7JAKG.js → chunk-OE34YZFO.js} +2 -2
- package/dist/{chunk-6O6765M7.js → chunk-OIQY4OKO.js} +2 -2
- package/dist/{chunk-M7AUWYOP.js → chunk-R4M5DDSN.js} +4 -4
- package/dist/{chunk-YJVZ5H3I.js → chunk-RK6NHIL6.js} +2 -2
- package/dist/chunk-THJGDJVO.js +9 -0
- package/dist/{chunk-4KNBN2OF.js.map → chunk-THJGDJVO.js.map} +1 -1
- package/dist/chunk-TN2TXRHS.js +249 -0
- package/dist/chunk-TN2TXRHS.js.map +1 -0
- package/dist/{chunk-427RB7E4.js → chunk-TROTIHD5.js} +3 -3
- package/dist/{chunk-KSIXTTO6.js → chunk-U4YUMSJY.js} +3 -3
- package/dist/{chunk-7JPCVEOY.js → chunk-U5V5J237.js} +6 -6
- package/dist/{chunk-PVN5IGDZ.js → chunk-UDOXLAE7.js} +2 -2
- package/dist/{chunk-MI3PS2SH.js → chunk-UOSZFFNY.js} +2 -2
- package/dist/{chunk-7GQCPGKQ.js → chunk-X6VBITXV.js} +4 -4
- package/dist/{chunk-OW46TR4G.js → chunk-XIL4QZFW.js} +3 -3
- package/dist/{chunk-QX4LFFNS.js → chunk-ZR2KWY6V.js} +2 -2
- package/dist/{chunk-4MXWNDH7.js → chunk-ZVJEWMJN.js} +39 -1
- package/dist/chunk-ZVJEWMJN.js.map +1 -0
- package/dist/{cleanup-LRT6J36R.js → cleanup-W5RGZ3Q6.js} +17 -15
- package/dist/{cleanup-LRT6J36R.js.map → cleanup-W5RGZ3Q6.js.map} +1 -1
- package/dist/{cli-VGUJI5WG.js → cli-64TLWGRH.js} +3 -3
- package/dist/{config-SSWYCX4C.js → config-MR7UZCST.js} +4 -4
- package/dist/{diff-JBCBQM4I.js → diff-URDY6YMT.js} +7 -7
- package/dist/{digest-WCZD6N7M.js → digest-D4FEZNLU.js} +6 -6
- package/dist/{fork-RJ3ZPPWT.js → fork-7EUVNEB7.js} +15 -15
- package/dist/{hook-CA5X3VKU.js → hook-6AD3FRKZ.js} +6 -6
- package/dist/{hydrate-Q4FWUQRC.js → hydrate-ZJZPM6YW.js} +3 -3
- package/dist/{init-AT3BQLXM.js → init-LWL4WVSJ.js} +4 -4
- package/dist/{install-skills-Z76FLXOU.js → install-skills-TQVWZDUD.js} +3 -3
- package/dist/install-skills-bin.js +2 -2
- package/dist/{move-OLXCDNA3.js → move-URV7XIDT.js} +7 -7
- package/dist/{note-JOR53JP4.js → note-S6EGTEIL.js} +5 -5
- package/dist/{overlaps-GXSEH2LG.js → overlaps-4T7NLTJH.js} +5 -5
- package/dist/{pin-DAWKCVB2.js → pin-KKQZ3AR6.js} +5 -5
- package/dist/{pr-RKOVRSHC.js → pr-5ZILTVDM.js} +5 -5
- package/dist/{prune-UYCQOEUF.js → prune-OK23KLHG.js} +16 -14
- package/dist/{prune-UYCQOEUF.js.map → prune-OK23KLHG.js.map} +1 -1
- package/dist/{pty-host-X3QK2LSK.js → pty-host-I5OJGWYA.js} +5 -5
- package/dist/{read-IKDSIDJD.js → read-NHK26F22.js} +5 -5
- package/dist/{recent-2LM44HN2.js → recent-DNSOJQVQ.js} +4 -4
- package/dist/{remove-6XACPXUU.js → remove-TZQVN2EG.js} +15 -13
- package/dist/{remove-6XACPXUU.js.map → remove-TZQVN2EG.js.map} +1 -1
- package/dist/{restart-6ZAFDRBO.js → restart-WHJDPDQA.js} +6 -6
- package/dist/{resume-VA34T7ZR.js → resume-BXIYEZM3.js} +4 -4
- package/dist/{run-E2WZPHHK.js → run-4MQLY3XF.js} +3 -3
- package/dist/{screen-KUXSDDLB.js → screen-URKN7PU6.js} +6 -6
- package/dist/{search-FJUZPI3P.js → search-MNBYJEL7.js} +3 -3
- package/dist/{section-QLUIAYAV.js → section-B3OQFADP.js} +5 -5
- package/dist/{send-V6LL6YR6.js → send-2QTMQQ6E.js} +7 -7
- package/dist/{sessions-MKXREA2M.js → sessions-4B22O45G.js} +12 -12
- package/dist/{snooze-JXI7VZJ4.js → snooze-LSCCM3QT.js} +5 -5
- package/dist/{start-5XFUYT6I.js → start-KVNLZRF5.js} +6 -6
- package/dist/{status-U5HKQ7MY.js → status-UEMXFLZZ.js} +3 -3
- package/dist/{stop-PFI7J2CS.js → stop-NEQBEYEY.js} +6 -6
- package/dist/{sync-MSU7QJWN.js → sync-BHEY6RXE.js} +16 -14
- package/dist/{sync-MSU7QJWN.js.map → sync-BHEY6RXE.js.map} +1 -1
- package/dist/{time-VDRCEIYQ.js → time-ON27QFG4.js} +6 -6
- package/dist/{timesheet-LSRRWV7Z.js → timesheet-HK5CHAA7.js} +8 -8
- package/dist/{tree-MOIO4GQL.js → tree-C5BEEKLO.js} +18 -11
- package/dist/tree-C5BEEKLO.js.map +1 -0
- package/dist/{update-DXIY6BEX.js → update-M4KS23HB.js} +7 -7
- package/dist/{wait-KPH5BQUD.js → wait-5QVWSCOL.js} +6 -6
- package/dist/wd-bin.js +2 -2
- package/dist/web/assets/{PtyView-D1TEpjVE.js → PtyView-TjC4VYWv.js} +2 -2
- package/dist/web/assets/{PtyView-D1TEpjVE.js.map → PtyView-TjC4VYWv.js.map} +1 -1
- package/dist/web/assets/index-BPadZeCm.js +119 -0
- package/dist/web/assets/index-BPadZeCm.js.map +1 -0
- package/dist/web/assets/index-YbJdcXjZ.css +1 -0
- package/dist/web/index.html +2 -2
- package/dist/{web-6AOR3MIE.js → web-5YGNY6MI.js} +746 -147
- package/dist/web-5YGNY6MI.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/chunk-4KNBN2OF.js +0 -9
- package/dist/chunk-4MXWNDH7.js.map +0 -1
- package/dist/chunk-B2RCWZUW.js.map +0 -1
- package/dist/chunk-E35NZVPX.js.map +0 -1
- package/dist/chunk-KUWFGPGW.js.map +0 -1
- package/dist/chunk-OQAQMCHF.js.map +0 -1
- package/dist/chunk-OZIR2255.js.map +0 -1
- package/dist/chunk-RQE5UOIW.js.map +0 -1
- package/dist/chunk-ZFPV46FA.js.map +0 -1
- package/dist/tree-MOIO4GQL.js.map +0 -1
- package/dist/web/assets/index-BVeughC2.css +0 -1
- package/dist/web/assets/index-DoMf82kx.js +0 -118
- package/dist/web/assets/index-DoMf82kx.js.map +0 -1
- package/dist/web-6AOR3MIE.js.map +0 -1
- /package/dist/{answer-IL5AQHRO.js.map → answer-OF2QNF4A.js.map} +0 -0
- /package/dist/{attach-MFU4KN47.js.map → attach-PAFAZ2EH.js.map} +0 -0
- /package/dist/{block-OXGEQ2PZ.js.map → block-3LEG4LKJ.js.map} +0 -0
- /package/dist/{broadcast-UJURJNEK.js.map → broadcast-ZDIL7UBP.js.map} +0 -0
- /package/dist/{catchup-HN4VL5XK.js.map → catchup-ZZ5HZJIT.js.map} +0 -0
- /package/dist/{chunk-R7B46WXN.js.map → chunk-3GAYLP7W.js.map} +0 -0
- /package/dist/{chunk-RLR66XLG.js.map → chunk-46VAWZZX.js.map} +0 -0
- /package/dist/{chunk-SH7NSDRW.js.map → chunk-4CVUV2SE.js.map} +0 -0
- /package/dist/{chunk-3XY76XBD.js.map → chunk-62C3CJ5M.js.map} +0 -0
- /package/dist/{chunk-MIIJ2HQS.js.map → chunk-77SVSNME.js.map} +0 -0
- /package/dist/{chunk-YZLNJQAV.js.map → chunk-DLSAAP3S.js.map} +0 -0
- /package/dist/{chunk-EU3BS5A6.js.map → chunk-EXJYPF64.js.map} +0 -0
- /package/dist/{chunk-PUYXTZ32.js.map → chunk-INVFNKU7.js.map} +0 -0
- /package/dist/{chunk-HDO3PXCU.js.map → chunk-KWU35O5S.js.map} +0 -0
- /package/dist/{chunk-U4UB4LG6.js.map → chunk-LBQR7KTC.js.map} +0 -0
- /package/dist/{chunk-YXQIGBL6.js.map → chunk-LGDECE7V.js.map} +0 -0
- /package/dist/{chunk-FX4IA5U4.js.map → chunk-M4YXBQZN.js.map} +0 -0
- /package/dist/{chunk-OOCMPS5L.js.map → chunk-MRXD2NSO.js.map} +0 -0
- /package/dist/{chunk-BSFL3WDR.js.map → chunk-OCDHKDUN.js.map} +0 -0
- /package/dist/{chunk-MVU7JAKG.js.map → chunk-OE34YZFO.js.map} +0 -0
- /package/dist/{chunk-6O6765M7.js.map → chunk-OIQY4OKO.js.map} +0 -0
- /package/dist/{chunk-M7AUWYOP.js.map → chunk-R4M5DDSN.js.map} +0 -0
- /package/dist/{chunk-YJVZ5H3I.js.map → chunk-RK6NHIL6.js.map} +0 -0
- /package/dist/{chunk-427RB7E4.js.map → chunk-TROTIHD5.js.map} +0 -0
- /package/dist/{chunk-KSIXTTO6.js.map → chunk-U4YUMSJY.js.map} +0 -0
- /package/dist/{chunk-7JPCVEOY.js.map → chunk-U5V5J237.js.map} +0 -0
- /package/dist/{chunk-PVN5IGDZ.js.map → chunk-UDOXLAE7.js.map} +0 -0
- /package/dist/{chunk-MI3PS2SH.js.map → chunk-UOSZFFNY.js.map} +0 -0
- /package/dist/{chunk-7GQCPGKQ.js.map → chunk-X6VBITXV.js.map} +0 -0
- /package/dist/{chunk-OW46TR4G.js.map → chunk-XIL4QZFW.js.map} +0 -0
- /package/dist/{chunk-QX4LFFNS.js.map → chunk-ZR2KWY6V.js.map} +0 -0
- /package/dist/{cli-VGUJI5WG.js.map → cli-64TLWGRH.js.map} +0 -0
- /package/dist/{config-SSWYCX4C.js.map → config-MR7UZCST.js.map} +0 -0
- /package/dist/{diff-JBCBQM4I.js.map → diff-URDY6YMT.js.map} +0 -0
- /package/dist/{digest-WCZD6N7M.js.map → digest-D4FEZNLU.js.map} +0 -0
- /package/dist/{fork-RJ3ZPPWT.js.map → fork-7EUVNEB7.js.map} +0 -0
- /package/dist/{hook-CA5X3VKU.js.map → hook-6AD3FRKZ.js.map} +0 -0
- /package/dist/{hydrate-Q4FWUQRC.js.map → hydrate-ZJZPM6YW.js.map} +0 -0
- /package/dist/{init-AT3BQLXM.js.map → init-LWL4WVSJ.js.map} +0 -0
- /package/dist/{install-skills-Z76FLXOU.js.map → install-skills-TQVWZDUD.js.map} +0 -0
- /package/dist/{move-OLXCDNA3.js.map → move-URV7XIDT.js.map} +0 -0
- /package/dist/{note-JOR53JP4.js.map → note-S6EGTEIL.js.map} +0 -0
- /package/dist/{overlaps-GXSEH2LG.js.map → overlaps-4T7NLTJH.js.map} +0 -0
- /package/dist/{pin-DAWKCVB2.js.map → pin-KKQZ3AR6.js.map} +0 -0
- /package/dist/{pr-RKOVRSHC.js.map → pr-5ZILTVDM.js.map} +0 -0
- /package/dist/{pty-host-X3QK2LSK.js.map → pty-host-I5OJGWYA.js.map} +0 -0
- /package/dist/{read-IKDSIDJD.js.map → read-NHK26F22.js.map} +0 -0
- /package/dist/{recent-2LM44HN2.js.map → recent-DNSOJQVQ.js.map} +0 -0
- /package/dist/{restart-6ZAFDRBO.js.map → restart-WHJDPDQA.js.map} +0 -0
- /package/dist/{resume-VA34T7ZR.js.map → resume-BXIYEZM3.js.map} +0 -0
- /package/dist/{run-E2WZPHHK.js.map → run-4MQLY3XF.js.map} +0 -0
- /package/dist/{screen-KUXSDDLB.js.map → screen-URKN7PU6.js.map} +0 -0
- /package/dist/{search-FJUZPI3P.js.map → search-MNBYJEL7.js.map} +0 -0
- /package/dist/{section-QLUIAYAV.js.map → section-B3OQFADP.js.map} +0 -0
- /package/dist/{send-V6LL6YR6.js.map → send-2QTMQQ6E.js.map} +0 -0
- /package/dist/{sessions-MKXREA2M.js.map → sessions-4B22O45G.js.map} +0 -0
- /package/dist/{snooze-JXI7VZJ4.js.map → snooze-LSCCM3QT.js.map} +0 -0
- /package/dist/{start-5XFUYT6I.js.map → start-KVNLZRF5.js.map} +0 -0
- /package/dist/{status-U5HKQ7MY.js.map → status-UEMXFLZZ.js.map} +0 -0
- /package/dist/{stop-PFI7J2CS.js.map → stop-NEQBEYEY.js.map} +0 -0
- /package/dist/{time-VDRCEIYQ.js.map → time-ON27QFG4.js.map} +0 -0
- /package/dist/{timesheet-LSRRWV7Z.js.map → timesheet-HK5CHAA7.js.map} +0 -0
- /package/dist/{update-DXIY6BEX.js.map → update-M4KS23HB.js.map} +0 -0
- /package/dist/{wait-KPH5BQUD.js.map → wait-5QVWSCOL.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
loadHistory
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-C7OK4XEZ.js";
|
|
5
5
|
import {
|
|
6
6
|
json,
|
|
7
7
|
sessionIdFor,
|
|
@@ -148,4 +148,4 @@ export {
|
|
|
148
148
|
sweepBlocks,
|
|
149
149
|
blockRefFrom
|
|
150
150
|
};
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
151
|
+
//# sourceMappingURL=chunk-DLSAAP3S.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
computeDiff,
|
|
4
4
|
isInsideRoot
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OIQY4OKO.js";
|
|
6
6
|
import {
|
|
7
7
|
packageRoot
|
|
8
8
|
} from "./chunk-LNHSBM4L.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
createFsWatcher,
|
|
14
14
|
loadHistory
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-C7OK4XEZ.js";
|
|
16
16
|
import {
|
|
17
17
|
spawn_default
|
|
18
18
|
} from "./chunk-RCYI7SRA.js";
|
|
@@ -89,11 +89,13 @@ function findAnyParentBranch(cwd) {
|
|
|
89
89
|
function detectParentBranch(cwd) {
|
|
90
90
|
return findParent(cwd, true);
|
|
91
91
|
}
|
|
92
|
+
var PARENT_CANDIDATES = ["main", "master", "dev", "develop"].flatMap((name) => [name, `origin/${name}`]);
|
|
92
93
|
function findParent(cwd, requireAheadOfParent) {
|
|
93
94
|
const currentResult = git(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
|
|
94
95
|
const currentBranch = currentResult.exitCode === 0 ? currentResult.stdout : "";
|
|
95
|
-
const candidates =
|
|
96
|
+
const candidates = PARENT_CANDIDATES;
|
|
96
97
|
let best = null;
|
|
98
|
+
let fresh;
|
|
97
99
|
for (const ref of candidates) {
|
|
98
100
|
if (ref === currentBranch) continue;
|
|
99
101
|
const exists = git(["rev-parse", "--verify", "--quiet", ref], cwd);
|
|
@@ -102,18 +104,42 @@ function findParent(cwd, requireAheadOfParent) {
|
|
|
102
104
|
if (mb.exitCode !== 0 || !mb.stdout) continue;
|
|
103
105
|
if (requireAheadOfParent) {
|
|
104
106
|
const headSha = git(["rev-parse", "HEAD"], cwd).stdout;
|
|
105
|
-
if (mb.stdout === headSha) continue;
|
|
107
|
+
if (mb.stdout === headSha && !(fresh ??= stillAtCreation(cwd, currentBranch, headSha))) continue;
|
|
106
108
|
}
|
|
107
109
|
const timeResult = git(["show", "-s", "--format=%ct", mb.stdout], cwd);
|
|
108
110
|
if (timeResult.exitCode !== 0) continue;
|
|
109
111
|
const time = Number(timeResult.stdout);
|
|
110
112
|
if (!Number.isFinite(time)) continue;
|
|
111
|
-
|
|
113
|
+
const later = !!best && time === best.time && mb.stdout !== best.sha && git(["merge-base", "--is-ancestor", best.sha, mb.stdout], cwd).exitCode === 0;
|
|
114
|
+
if (!best || time > best.time || later) {
|
|
112
115
|
best = { ref, sha: mb.stdout, time };
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
return best?.ref ?? null;
|
|
116
119
|
}
|
|
120
|
+
function stillAtCreation(cwd, branch, headSha) {
|
|
121
|
+
if (!branch || branch === "HEAD") return false;
|
|
122
|
+
const log = git(["reflog", "show", "--format=%H %gs", `refs/heads/${branch}`, "--"], cwd);
|
|
123
|
+
if (log.exitCode !== 0 || !log.stdout) return false;
|
|
124
|
+
const lines = log.stdout.split("\n").filter(Boolean);
|
|
125
|
+
const m = /^(\S+) branch: Created from (\S+)$/.exec(lines[lines.length - 1] ?? "");
|
|
126
|
+
if (!m || m[1] !== headSha) return false;
|
|
127
|
+
const from = m[2].replace(/^refs\/(heads|remotes)\//, "");
|
|
128
|
+
return from === "HEAD" || PARENT_CANDIDATES.includes(from);
|
|
129
|
+
}
|
|
130
|
+
function recordedBase(cwd, name) {
|
|
131
|
+
const refs = name.startsWith("origin/") ? [name] : [name, `origin/${name}`];
|
|
132
|
+
let best = null;
|
|
133
|
+
for (const ref of refs) {
|
|
134
|
+
if (git(["rev-parse", "--verify", "--quiet", ref], cwd).exitCode !== 0) continue;
|
|
135
|
+
const mb = git(["merge-base", ref, "HEAD"], cwd);
|
|
136
|
+
if (mb.exitCode !== 0 || !mb.stdout) continue;
|
|
137
|
+
if (!best || mb.stdout !== best.mb && git(["merge-base", "--is-ancestor", best.mb, mb.stdout], cwd).exitCode === 0) {
|
|
138
|
+
best = { ref, mb: mb.stdout };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return best;
|
|
142
|
+
}
|
|
117
143
|
function resolveBase(scope, argv) {
|
|
118
144
|
if (argv.base) return { base: argv.base, source: "arg" };
|
|
119
145
|
if (argv.branch) {
|
|
@@ -144,7 +170,9 @@ function resolveRepoDiff(root, base, sessionBaseBranch) {
|
|
|
144
170
|
if (base === "uncommitted") {
|
|
145
171
|
return { resolvedBase: "HEAD", diffArg: "HEAD" };
|
|
146
172
|
}
|
|
147
|
-
const
|
|
173
|
+
const recorded = sessionBaseBranch ? recordedBase(root, sessionBaseBranch) : null;
|
|
174
|
+
if (recorded) return { resolvedBase: recorded.ref, diffArg: recorded.mb };
|
|
175
|
+
const parent = detectParentBranch(root) ?? findAnyParentBranch(root);
|
|
148
176
|
if (!parent) return { resolvedBase: "HEAD", diffArg: "HEAD" };
|
|
149
177
|
let diffArg = "HEAD";
|
|
150
178
|
const mb = git(["merge-base", parent, "HEAD"], root);
|
|
@@ -484,4 +512,4 @@ export {
|
|
|
484
512
|
submitReviewSchema,
|
|
485
513
|
resolveSchema
|
|
486
514
|
};
|
|
487
|
-
//# sourceMappingURL=chunk-
|
|
515
|
+
//# sourceMappingURL=chunk-EDAOG56H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/diff/diff-scope.ts","../src/core/platform/web-static.ts","../src/server/local-origin.ts","../src/server/local-server.ts","../src/server/spa-handler.ts","../src/server/diff-server.ts","../src/core/diff/file-context.ts","../src/core/comments/comment-schemas.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { git } from '../git/git.js';\nimport { loadHistory, type WorktreeSession } from '../sessions/history.js';\nimport type { RepoSpec } from './repo-spec.js';\nimport { report } from '../platform/report.js';\n\nexport interface DiffScope {\n isGroup: boolean;\n session: WorktreeSession | null;\n /** Repos to diff (1 for single, N for group). */\n repos: { name: string; root: string }[];\n /** Name of the repo whose subtree the user is in (initial active tab). */\n activeRepoName: string | null;\n}\n\nexport interface ResolvedBase {\n base: string;\n source: 'arg' | 'session' | 'auto-detected' | 'default';\n}\n\nfunction normPath(p: string): string {\n return path.resolve(p).replace(/\\\\/g, '/').toLowerCase();\n}\n\n/**\n * Like {@link normPath} but resolves to the OS-canonical real path.\n * `git rev-parse --show-toplevel` returns the realpath (e.g. macOS `/var` →\n * `/private/var`, and on Windows the long-form name), so comparing it to a\n * stored session path must canonicalize both sides the same way.\n *\n * Uses `realpathSync.native`: the plain `realpathSync` does NOT expand Windows\n * 8.3 short names (`SAMDEV~1` → `SamDev`), so a session path under a\n * short-name parent would never match git's long-form toplevel. `.native`\n * resolves both 8.3 and symlinks. Falls back to {@link normPath} for paths\n * that don't exist (e.g. unit-test fixtures).\n */\nfunction realNorm(p: string): string {\n try {\n return normPath(fs.realpathSync.native(p));\n } catch {\n return normPath(p);\n }\n}\n\n/**\n * Resolve what scope to diff based on cwd. Handles single-repo worktrees,\n * group worktrees (cwd at group root or anywhere inside a sub-repo), and\n * \"random\" git repos not managed by `work`.\n */\nexport function resolveScope(cwd: string): DiffScope | null {\n const normCwd = normPath(cwd);\n const sessions = loadHistory();\n\n // cwd's own git worktree root. Used to reject session-path matches that are\n // really a *parent* repo: linked worktrees often live physically inside\n // another repo (e.g. `<repo>/.claude/worktrees/<branch>`), so a naive prefix\n // match collapses every nested worktree onto the parent's scope — they'd\n // share one daemon and show each other's diff.\n const top = git(['rev-parse', '--show-toplevel'], cwd);\n const toplevel = top.exitCode === 0 && top.stdout ? top.stdout : null;\n const realTop = toplevel ? realNorm(toplevel) : null;\n\n // 1. cwd is at or inside one of a session's repo paths.\n for (const s of sessions) {\n for (const p of s.paths) {\n const np = normPath(p);\n if (normCwd === np || normCwd.startsWith(np + '/')) {\n // Only honour the match if this session path is cwd's actual worktree\n // root. When cwd is in a nested worktree, its toplevel is deeper than\n // `np` — skip so we resolve the real (nested) worktree below.\n if (realTop && realNorm(p) !== realTop) continue;\n if (s.isGroup) {\n return {\n isGroup: true,\n session: s,\n repos: s.paths.map((rp) => ({ name: path.basename(rp), root: rp })),\n activeRepoName: path.basename(p),\n };\n }\n return {\n isGroup: false,\n session: s,\n repos: [{ name: path.basename(p), root: p }],\n activeRepoName: path.basename(p),\n };\n }\n }\n }\n\n // 2. cwd is at the group root (parent of all of a group's repo paths).\n for (const s of sessions) {\n if (!s.isGroup || s.paths.length === 0) continue;\n const parents = s.paths.map((p) => normPath(path.dirname(p)));\n const groupRoot = parents[0];\n if (!parents.every((par) => par === groupRoot)) continue;\n if (normCwd === groupRoot || normCwd.startsWith(groupRoot + '/')) {\n return {\n isGroup: true,\n session: s,\n repos: s.paths.map((rp) => ({ name: path.basename(rp), root: rp })),\n activeRepoName: null,\n };\n }\n }\n\n // 3. Fall back to git rev-parse for repos not managed by `work`.\n if (!toplevel) return null;\n return {\n isGroup: false,\n session: null,\n repos: [{ name: path.basename(toplevel), root: toplevel }],\n activeRepoName: path.basename(toplevel),\n };\n}\n\n/**\n * Find any plausible parent branch — same candidate list as\n * `detectParentBranch`, but DOESN'T require the parent to have commits\n * past HEAD. Returns the candidate with the most-recent merge-base (or\n * null only if no candidates exist at all).\n *\n * Used by the static renderer and the diff server's `?base=branch`\n * route to decide whether to offer the \"Since branch\" tab. `detectParentBranch`\n * skips parents where merge-base == HEAD (correct for the CLI's \"show\n * me what I added past parent\" semantic — empty diff), but the toggle\n * should still appear in that case so the user can confirm \"no, there's\n * nothing committed yet\".\n */\nexport function findAnyParentBranch(cwd: string): string | null {\n return findParent(cwd, false);\n}\n\n/** Walk candidate base branches and pick the one with the most recent merge-base. */\nexport function detectParentBranch(cwd: string): string | null {\n return findParent(cwd, true);\n}\n\nconst PARENT_CANDIDATES = ['main', 'master', 'dev', 'develop'].flatMap((name) => [name, `origin/${name}`]);\n\nfunction findParent(cwd: string, requireAheadOfParent: boolean): string | null {\n const currentResult = git(['rev-parse', '--abbrev-ref', 'HEAD'], cwd);\n const currentBranch = currentResult.exitCode === 0 ? currentResult.stdout : '';\n\n const candidates = PARENT_CANDIDATES;\n\n let best: { ref: string; sha: string; time: number } | null = null;\n let fresh: boolean | undefined;\n\n for (const ref of candidates) {\n if (ref === currentBranch) continue;\n const exists = git(['rev-parse', '--verify', '--quiet', ref], cwd);\n if (exists.exitCode !== 0 || !exists.stdout) continue;\n\n const mb = git(['merge-base', ref, 'HEAD'], cwd);\n if (mb.exitCode !== 0 || !mb.stdout) continue;\n\n // Skip parents where the merge-base IS HEAD only when the caller\n // asked us to (CLI \"show me what I added\" semantics): a `dev` that\n // already contains this branch's commits isn't where it came from. When\n // called for the toggle UI, we want to surface the parent even though\n // the diff will be empty. A branch with no commits of its own yet is\n // the exception: there every parent it was made from contains HEAD, and\n // skipping them picked an older mainline — a branch just made from dev\n // showed all of dev's commits since main.\n if (requireAheadOfParent) {\n const headSha = git(['rev-parse', 'HEAD'], cwd).stdout;\n if (mb.stdout === headSha && !(fresh ??= stillAtCreation(cwd, currentBranch, headSha))) continue;\n }\n\n const timeResult = git(['show', '-s', '--format=%ct', mb.stdout], cwd);\n if (timeResult.exitCode !== 0) continue;\n const time = Number(timeResult.stdout);\n if (!Number.isFinite(time)) continue;\n\n // A tie in time (commits made in the same second): the later of the two, the one the other is an ancestor of.\n const later =\n !!best &&\n time === best.time &&\n mb.stdout !== best.sha &&\n git(['merge-base', '--is-ancestor', best.sha, mb.stdout], cwd).exitCode === 0;\n if (!best || time > best.time || later) {\n best = { ref, sha: mb.stdout, time };\n }\n }\n\n return best?.ref ?? null;\n}\n\n/**\n * The branch has no commits of its own: it was made here from HEAD or a\n * mainline (its reflog's oldest entry, \"branch: Created from dev\") and HEAD is\n * still that commit. One made from its own `origin/<branch>` (a PR, someone's\n * branch) or at a commit (Restore) carries commits that are its own, though\n * they weren't made here. No reflog (expired, a detached HEAD) says no.\n */\nfunction stillAtCreation(cwd: string, branch: string, headSha: string): boolean {\n if (!branch || branch === 'HEAD') return false;\n const log = git(['reflog', 'show', '--format=%H %gs', `refs/heads/${branch}`, '--'], cwd);\n if (log.exitCode !== 0 || !log.stdout) return false;\n const lines = log.stdout.split('\\n').filter(Boolean);\n const m = /^(\\S+) branch: Created from (\\S+)$/.exec(lines[lines.length - 1] ?? '');\n if (!m || m[1] !== headSha) return false;\n const from = m[2].replace(/^refs\\/(heads|remotes)\\//, '');\n return from === 'HEAD' || PARENT_CANDIDATES.includes(from);\n}\n\n/**\n * A recorded base, as fresh as this clone has it: the branch or its\n * `origin/` copy, whichever shares the later commit with HEAD (the local one\n * is pulled only when a worktree is made from it, so it falls behind a branch\n * that merged origin's since). Null when neither exists (deleted since).\n */\nfunction recordedBase(cwd: string, name: string): { ref: string; mb: string } | null {\n const refs = name.startsWith('origin/') ? [name] : [name, `origin/${name}`];\n let best: { ref: string; mb: string } | null = null;\n for (const ref of refs) {\n if (git(['rev-parse', '--verify', '--quiet', ref], cwd).exitCode !== 0) continue;\n const mb = git(['merge-base', ref, 'HEAD'], cwd);\n if (mb.exitCode !== 0 || !mb.stdout) continue;\n if (!best || (mb.stdout !== best.mb && git(['merge-base', '--is-ancestor', best.mb, mb.stdout], cwd).exitCode === 0)) {\n best = { ref, mb: mb.stdout };\n }\n }\n return best;\n}\n\nexport function resolveBase(scope: DiffScope, argv: { base?: string; branch?: boolean }): ResolvedBase {\n if (argv.base) return { base: argv.base, source: 'arg' };\n\n if (argv.branch) {\n if (scope.session?.baseBranch) {\n return { base: scope.session.baseBranch, source: 'session' };\n }\n const primaryRoot = scope.repos.find((r) => r.name === scope.activeRepoName)?.root ?? scope.repos[0].root;\n const detected = detectParentBranch(primaryRoot);\n if (detected) return { base: detected, source: 'auto-detected' };\n\n report('error', 'Could not determine a parent branch for this worktree.');\n report('detail', 'Pass one explicitly: diff <ref>');\n process.exit(1);\n }\n\n return { base: 'HEAD', source: 'default' };\n}\n\n/**\n * Compute per-repo merge-base when comparing against a non-HEAD ref.\n *\n * `perRepoBase` (keyed by repo root) overrides `base` for individual repos —\n * used by group worktrees forked with different bases per repo\n * (`work tree --base backend=dev --base frontend=feat/x`). A repo without an\n * override falls back to the shared `base`.\n */\nexport function buildRepoSpecs(scope: DiffScope, base: string, perRepoBase?: Record<string, string>): RepoSpec[] {\n return scope.repos.map((r) => {\n const repoBase = perRepoBase?.[r.root] ?? base;\n let diffArg = repoBase;\n if (repoBase !== 'HEAD') {\n const mb = git(['merge-base', repoBase, 'HEAD'], r.root);\n if (mb.exitCode === 0 && mb.stdout) diffArg = mb.stdout;\n }\n return { name: r.name, root: r.root, diffArg };\n });\n}\n\nexport interface ResolvedRepoDiff {\n /** The git ref the diff was computed against. `HEAD` for uncommitted,\n * the resolved parent (e.g. `origin/main`) for branch mode. */\n resolvedBase: string;\n /** The actual argument passed to `git diff` — typically the merge-base\n * sha for branch mode, or `HEAD` for uncommitted. */\n diffArg: string;\n}\n\n/**\n * Resolve the diff target for a single repo. Centralises the\n * \"find-parent → merge-base → fall back to HEAD\" dance that previously\n * lived in three places (scope-routes, web-server, the static renderer).\n *\n * For `base === 'uncommitted'` this is trivially `HEAD`. For\n * `base === 'branch'` it prefers an explicit `sessionBaseBranch` (the\n * value the user recorded with `work tree --base`), falling back to\n * `findAnyParentBranch` (so the toggle stays available even when the\n * branch has no commits past parent yet — diff just renders empty).\n */\nexport function resolveRepoDiff(root: string, base: 'uncommitted' | 'branch', sessionBaseBranch?: string | null): ResolvedRepoDiff {\n if (base === 'uncommitted') {\n return { resolvedBase: 'HEAD', diffArg: 'HEAD' };\n }\n // Prefer a parent we're actually *ahead of* (`detectParentBranch` skips\n // candidates whose merge-base is HEAD, e.g. a `dev` that already contains\n // this branch — unless the branch has no commits yet, when the one it was\n // made from is right). `findAnyParentBranch` would pick the most-recent merge-base\n // even when it's HEAD — yielding a useless 0-commit \"since branch\" diff.\n // Fall back to it only so the toggle still resolves to *something*.\n // A recorded base wins, at its freshest; one that's gone (merged and deleted) leaves it to detection.\n const recorded = sessionBaseBranch ? recordedBase(root, sessionBaseBranch) : null;\n if (recorded) return { resolvedBase: recorded.ref, diffArg: recorded.mb };\n const parent = detectParentBranch(root) ?? findAnyParentBranch(root);\n if (!parent) return { resolvedBase: 'HEAD', diffArg: 'HEAD' };\n let diffArg = 'HEAD';\n const mb = git(['merge-base', parent, 'HEAD'], root);\n if (mb.exitCode === 0 && mb.stdout) diffArg = mb.stdout;\n return { resolvedBase: parent, diffArg };\n}\n\n/**\n * Look up the recorded fork point for a worktree path from session history.\n * Prefers the per-repo base (`baseBranches`) for that exact path, falling\n * back to the session's representative `baseBranch`. Returns undefined when\n * the path isn't a known worktree — callers then auto-detect.\n *\n * Used by the scope diff route, which only carries repo paths (no session),\n * so a `wd` forked with `--base feat/x` still diffs against `feat/x` even\n * though auto-detection wouldn't find a non-mainline parent.\n */\nexport function sessionBaseForPath(root: string): string | undefined {\n const norm = normPath(root);\n for (const s of loadHistory()) {\n for (const p of s.paths) {\n if (normPath(p) === norm) {\n return s.baseBranches?.[p] ?? s.baseBranch;\n }\n }\n }\n return undefined;\n}\n","import fs from 'node:fs';\nimport { packageRoot } from './package-root.js';\nimport http from 'node:http';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst MIME: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'application/javascript; charset=utf-8',\n '.mjs': 'application/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n '.map': 'application/json; charset=utf-8',\n};\n\n/** Resolve the directory shipped by the Vite build. */\nexport function resolveWebRoot(): string | null {\n const entryDir = path.dirname(process.argv[1] ?? '');\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n const candidates = [\n path.join(entryDir, 'web'),\n // bundled: this module is inlined into dist/<bin>.js, so dist/web is a\n // sibling of the bundle. Works even when argv[1] is an npm bin symlink\n // (which is not realpath'd, so the entryDir candidate above misses).\n path.join(moduleDir, 'web'),\n // dev/tsx: the package's dist/web (wherever under src/ this module sits).\n ...(packageRoot() ? [path.join(packageRoot()!, 'dist', 'web')] : []),\n ];\n for (const c of candidates) {\n if (fs.existsSync(path.join(c, 'index.html'))) return c;\n }\n return null;\n}\n\n/**\n * Serve a static file under `root`. Returns true if it served a file. Does\n * NOT do SPA fallback — caller decides whether to re-try with /index.html\n * on miss.\n */\nexport function serveStatic(root: string, urlPath: string, res: http.ServerResponse): boolean {\n const clean = urlPath.split('?')[0];\n const requested = clean === '/' ? '/index.html' : clean;\n const filePath = path.join(root, requested);\n const norm = path.normalize(filePath);\n const base = path.normalize(root);\n if (norm !== base && !norm.startsWith(base + path.sep)) return false;\n let stat: fs.Stats;\n try {\n stat = fs.statSync(norm);\n } catch {\n return false;\n }\n if (!stat.isFile()) return false;\n const ext = path.extname(norm).toLowerCase();\n res.writeHead(200, {\n 'Content-Type': MIME[ext] ?? 'application/octet-stream',\n 'Cache-Control': 'no-cache',\n });\n fs.createReadStream(norm).pipe(res);\n return true;\n}\n\n/** Convenience: serve the file if it exists, else fall back to index.html. */\nexport function serveStaticOrShell(root: string, urlPath: string, res: http.ServerResponse): boolean {\n if (serveStatic(root, urlPath, res)) return true;\n if (serveStatic(root, '/index.html', res)) return true;\n return false;\n}\n","/**\n * Who may talk to our localhost servers (work web / wd / comment server).\n *\n * Binding to 127.0.0.1 keeps the network out, and the Host check stops DNS\n * rebinding — but neither stops a web page you have open from making YOUR\n * browser send requests to 127.0.0.1:<port> (cross-site request forgery).\n * The port is predictable and session ids are guessable, and the terminal\n * WebSocket types straight into Claude — so every request that changes\n * something, and every WebSocket upgrade, must come from our own origin.\n *\n * Rules:\n * - Host must be 127.0.0.1:<port> or localhost:<port> (DNS rebinding).\n * - A browser marking the request `Sec-Fetch-Site: cross-site` (or\n * `same-site`: another localhost port) is refused,\n * except a top-level page load (GET/HEAD, `Sec-Fetch-Mode: navigate`,\n * `Sec-Fetch-Dest: document`): clicking a dashboard or diff link in\n * GitHub, Jira or Slack must open it. The opening site can't read the\n * response and a GET changes nothing; frames stay refused, so no other\n * page can embed the dashboard.\n * - Mutating requests (anything but GET/HEAD/OPTIONS) and WebSocket\n * upgrades: `Origin` must be absent (non-browser callers — the Claude\n * hooks, `wd`, the CLI — send none) or exactly our own origin. Browsers\n * always send Origin on cross-origin POSTs and on every WebSocket, and a\n * page can't forge it. `Origin: null` (sandboxed frames, file://) is\n * refused.\n */\n\nexport function allowedHost(host: string | undefined, port: number): boolean {\n return host === `127.0.0.1:${port}` || host === `localhost:${port}`;\n}\n\nexport function allowedOrigin(origin: string | undefined, port: number): boolean {\n if (origin === undefined || origin === '') return true;\n return origin === `http://127.0.0.1:${port}` || origin === `http://localhost:${port}`;\n}\n\nconst SAFE_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);\n\nexport interface RequestFacts {\n method: string;\n host?: string;\n origin?: string;\n secFetchSite?: string;\n secFetchMode?: string;\n secFetchDest?: string;\n /** A WebSocket upgrade — always checked like a mutating request. */\n upgrade?: boolean;\n}\n\n/** Null when allowed, else a short reason (for the 403 body / logs). */\nexport function refuseReason(req: RequestFacts, port: number): string | null {\n if (!allowedHost(req.host, port)) return 'bad host';\n const mutating = req.upgrade || !SAFE_METHODS.has(req.method.toUpperCase());\n const pageLoad =\n !req.upgrade &&\n ['GET', 'HEAD'].includes(req.method.toUpperCase()) &&\n req.secFetchMode === 'navigate' &&\n req.secFetchDest === 'document';\n // same-site = another localhost port (your dev servers, say): the\n // dashboard itself is always same-origin, so treat it like cross-site.\n if ((req.secFetchSite === 'cross-site' || req.secFetchSite === 'same-site') && !pageLoad) return 'cross-site request';\n if (mutating && !allowedOrigin(req.origin, port)) return 'foreign origin';\n return null;\n}\n","import { report } from '../core/platform/report.js';\nimport { Hono } from 'hono';\nimport { serve, type ServerType } from '@hono/node-server';\nimport { refuseReason } from './local-origin.js';\n\n// The one way to start a local HTTP server (work web, wd, the comment\n// server, the demo): 127.0.0.1 only, random port, behind the Host/Origin\n// guard. Its own module so a server that needs no git/fs — the demo — can\n// use it without importing the diff server.\n\nexport interface DiffServerHandle {\n url: string;\n port: number;\n stop(): Promise<void>;\n}\n\n/** Start a Hono app on a random port; resolve when it's listening. The\n * raw Node server is exposed via `httpServer` so callers can attach\n * WebSocket upgrade handlers (the terminal bridge).\n *\n * Installs a guard (core/local-origin.ts): Host must be ours (DNS\n * rebinding), and mutating requests must not come from another origin\n * (cross-site request forgery from any page open in the browser). The SPA\n * is served same-origin, and Node callers send no Origin, so both pass.\n */\nexport function launch(app: Hono): Promise<DiffServerHandle & { httpServer: ServerType }> {\n return new Promise((resolve) => {\n // Captured before serve() resolves; first guarded request runs after\n // this is set because serve() doesn't accept connections until it's\n // bound, and bind precedes the info-callback.\n let listenPort = 0;\n const guard = new Hono();\n guard.use('*', async (c, next) => {\n // Host (DNS rebinding) + Origin / Sec-Fetch-Site (cross-site request\n // forgery from any page open in the browser) — see local-origin.ts.\n const reason = refuseReason(\n {\n method: c.req.method,\n host: c.req.header('host'),\n origin: c.req.header('origin'),\n secFetchSite: c.req.header('sec-fetch-site'),\n secFetchMode: c.req.header('sec-fetch-mode'),\n secFetchDest: c.req.header('sec-fetch-dest'),\n },\n listenPort,\n );\n if (reason) return c.text(`Forbidden (${reason})`, 403);\n await next();\n });\n guard.route('/', app);\n\n const server: ServerType = serve({ fetch: guard.fetch, port: 0, hostname: '127.0.0.1' }, (info) => {\n listenPort = info.port;\n const url = `http://127.0.0.1:${info.port}/`;\n report('detail', `[server] listening at ${url}`);\n resolve({\n url,\n port: info.port,\n httpServer: server,\n stop: () =>\n new Promise<void>((res) => {\n server.close(() => res());\n }),\n });\n });\n });\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport type { Context } from 'hono';\n\nconst MIME: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'application/javascript; charset=utf-8',\n '.mjs': 'application/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n '.map': 'application/json; charset=utf-8',\n};\n\nfunction readFile(root: string, relPath: string): { body: Buffer; ext: string } | null {\n const clean = relPath.split('?')[0];\n const requested = clean === '/' ? '/index.html' : clean;\n const filePath = path.join(root, requested);\n const norm = path.normalize(filePath);\n if (!norm.startsWith(path.normalize(root))) return null;\n let stat: fs.Stats;\n try {\n stat = fs.statSync(norm);\n } catch {\n return null;\n }\n if (!stat.isFile()) return null;\n const ext = path.extname(norm).toLowerCase();\n return { body: fs.readFileSync(norm), ext };\n}\n\n/**\n * Hono handler for the bundled SPA. Tries to serve the requested file; if it\n * doesn't exist, falls back to index.html so client-side routing works on\n * deep links. Skips /api/* paths entirely (those should be handled by\n * earlier routes; if we reach here it's a 404).\n */\nexport function serveSpa(c: Context, webRoot: string): Response {\n const url = new URL(c.req.url);\n if (url.pathname.startsWith('/api/')) {\n return c.json({ error: 'not found' }, 404);\n }\n const hit = readFile(webRoot, url.pathname) ?? readFile(webRoot, '/index.html');\n if (!hit) return c.json({ error: 'not found' }, 404);\n return new Response(new Uint8Array(hit.body), {\n status: 200,\n headers: {\n 'Content-Type': MIME[hit.ext] ?? 'application/octet-stream',\n 'Cache-Control': 'no-cache',\n },\n });\n}\n","import { launch, type DiffServerHandle } from './local-server.js';\n\nexport { launch, type DiffServerHandle } from './local-server.js';\nimport { Hono, type Context } from 'hono';\nimport { streamSSE } from 'hono/streaming';\nimport { computeDiff } from '../core/diff/diff-pipeline.js';\nimport { readContextLines } from '../core/diff/file-context.js';\nimport { createFsWatcher } from '../core/platform/fs-watcher.js';\nimport { resolveRepoDiff } from '../core/diff/diff-scope.js';\nimport { git } from '../core/git/git.js';\nimport { resolveWebRoot } from '../core/platform/web-static.js';\nimport { serveSpa } from './spa-handler.js';\nimport type { RepoSpec } from '../core/diff/repo-spec.js';\n\nexport interface DiffServerOptions {\n /** Repos this server scopes to. */\n repos: RepoSpec[];\n /** Short human-readable label for /api/context. */\n scopeLabel: string;\n /** Optional session baseBranch (the value captured at `work tree --base`).\n * When set, the `?base=branch` route uses it instead of auto-detection,\n * so the diff matches what the user actually declared. */\n sessionBaseBranch?: string;\n /** Per-repo fork points keyed by repo root. Overrides `sessionBaseBranch`\n * for individual repos in a group forked with different bases per repo. */\n sessionBaseBranches?: Record<string, string>;\n /** Debounce for fs.watch events before broadcasting diff-changed. */\n watchDebounceMs?: number;\n /** When true, /api/context advertises readOnly=true and the SPA hides\n * the comment UI. Default false. */\n readOnly?: boolean;\n /** Called once the base app is built so feature apps (e.g. comments) can\n * mount themselves and emit events via the SSE hub. */\n attachRoutes?: (api: DiffServerApi) => void;\n}\n\n/** A typed SSE event broadcast to every connected client. */\nexport interface SseEvent {\n event: string;\n data: unknown;\n}\n\nexport interface DiffServerApi {\n /** Mount a Hono sub-app at the given path prefix. */\n route(prefix: string, app: Hono): void;\n /** Broadcast on the shared SSE hub. Fan-out is one-shot per client. */\n broadcast(event: string, data: unknown): void;\n}\n\n/**\n * The shared local HTTP server used by both `wd` (read-only) and `wd -c`\n * (comments). Owns the fs watcher, the SSE hub, and the three routes every\n * mode needs: GET /api/context, GET /api/diff, GET /events. Comment routes\n * register themselves via `attachRoutes`.\n */\nexport async function startDiffServer(opts: DiffServerOptions): Promise<DiffServerHandle> {\n const webRoot = resolveWebRoot();\n if (!webRoot) {\n throw new Error('Could not find dist/web/. Run `npm run build` first.');\n }\n\n const sseListeners = new Set<(e: SseEvent) => void>();\n const watcher = createFsWatcher({\n roots: opts.repos.map((r) => r.root),\n debounceMs: opts.watchDebounceMs,\n onChange: () => broadcast('diff-changed', { ts: Date.now() }),\n });\n\n function broadcast(event: string, data: unknown): void {\n const payload: SseEvent = { event, data };\n for (const cb of sseListeners) cb(payload);\n }\n\n const app = new Hono();\n // No CORS headers and no OPTIONS preflight handler — the SPA is served\n // same-origin so its requests don't trigger preflight. The Host guard in\n // `launch` rejects cross-origin requests before they reach any handler.\n\n app.get('/api/context', (c) => {\n // Current branch of the primary repo, for the \"<branch> vs <base>\" title.\n const primaryRoot = opts.repos[0]?.root;\n let headBranch: string | undefined;\n if (primaryRoot) {\n const head = git(['rev-parse', '--abbrev-ref', 'HEAD'], primaryRoot);\n if (head.exitCode === 0 && head.stdout && head.stdout !== 'HEAD') {\n headBranch = head.stdout;\n }\n }\n return c.json({\n mode: 'review',\n scopeLabel: opts.scopeLabel,\n repos: opts.repos.map((r) => ({ name: r.name })),\n readOnly: !!opts.readOnly,\n headBranch,\n });\n });\n\n app.get('/api/diff', (c) => {\n const base = c.req.query('base') === 'branch' ? 'branch' : 'uncommitted';\n try {\n // For 'uncommitted' we honour the configured `diffArg` (typically\n // HEAD) so single-repo callers preserve whatever ref they\n // configured. For 'branch' we delegate to `resolveRepoDiff` per\n // repo — each one resolves its own parent and merge-base. The\n // top-level `resolvedBase` is the primary repo's value (matches\n // scope-routes and web-server behavior for the badge label).\n const resolved = opts.repos.map((r) =>\n base === 'uncommitted'\n ? { resolvedBase: 'HEAD', diffArg: r.diffArg }\n : resolveRepoDiff(r.root, 'branch', opts.sessionBaseBranches?.[r.root] ?? opts.sessionBaseBranch),\n );\n const repos = opts.repos.map((r, i) => ({\n name: r.name,\n root: r.root,\n resolvedBase: resolved[i].resolvedBase,\n files: computeDiff({ root: r.root, diffArg: resolved[i].diffArg }),\n }));\n const resolvedBase = resolved[0]?.resolvedBase ?? 'HEAD';\n return c.json({ repos, base, resolvedBase });\n } catch (err) {\n return c.json({ error: (err as Error).message }, 500);\n }\n });\n\n // Reveal unchanged context lines around a hunk (\"expand lines\"). Maps the\n // SPA's repo name back to its RepoSpec root; single-repo scopes (the\n // common standalone case) skip the lookup.\n app.get('/api/file-lines', (c) => {\n const repoName = c.req.query('repo') ?? '';\n const relPath = c.req.query('path') ?? '';\n const start = Number(c.req.query('start'));\n const end = Number(c.req.query('end'));\n const ref = c.req.query('ref') || undefined;\n if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {\n return c.json({ error: 'bad path/start/end' }, 400);\n }\n const root = opts.repos.length === 1 ? opts.repos[0].root : opts.repos.find((r) => r.name === repoName)?.root;\n if (!root) return c.json({ error: 'unknown repo' }, 404);\n const result = readContextLines({ root, relPath, start, end, ref });\n if (!result) return c.json({ error: 'cannot read file' }, 400);\n return c.json(result);\n });\n\n app.get('/events', (c) =>\n streamSSE(c, async (stream) => {\n const listener = (e: SseEvent) => {\n stream.writeSSE({ event: e.event, data: JSON.stringify(e.data) }).catch(() => {\n /* client gone */\n });\n };\n sseListeners.add(listener);\n await stream.writeSSE({ event: 'connected', data: '' });\n // Keep the stream open until the client disconnects.\n await new Promise<void>((resolve) => {\n stream.onAbort(() => {\n sseListeners.delete(listener);\n resolve();\n });\n });\n }),\n );\n\n // attachRoutes can mount Hono sub-apps with their own routes.\n if (opts.attachRoutes) {\n opts.attachRoutes({\n route: (prefix, sub) => app.route(prefix, sub),\n broadcast,\n });\n }\n\n // SPA fallback for the bundled web assets.\n app.get('*', (c: Context) => serveSpa(c, webRoot));\n\n // Wrap the handle so server shutdown also tears down our chokidar watcher.\n // Without this the watcher keeps Node's event loop open after `stop()` —\n // a real test/teardown leak (vitest hangs after a suite that exercises\n // the server) and a wasteful long-running ghost in dev.\n const handle = await launch(app);\n const baseStop = handle.stop;\n return {\n ...handle,\n stop: async () => {\n try {\n watcher.stop();\n } catch {\n /* */\n }\n await baseStop();\n },\n };\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport spawn from '../platform/spawn.js';\nimport { isInsideRoot } from './diff-pipeline.js';\n\nexport interface ContextLinesOptions {\n /** Git toplevel (repo root) the file lives under. */\n root: string;\n /** Repo-relative path of the file. */\n relPath: string;\n /** 1-based inclusive first line to return. */\n start: number;\n /** 1-based inclusive last line to return. */\n end: number;\n /** When omitted or `'working'`, read the working-tree file. Otherwise the\n * content comes from `git show <ref>:<relPath>` — used when the diff's\n * \"new\" side is a committed snapshot (checkpoint range) rather than the\n * live tree. */\n ref?: string;\n}\n\nexport interface ContextLinesResult {\n /** The requested slice. Shorter than `end - start + 1` when the file ends\n * before `end`. */\n lines: string[];\n /** Echoed 1-based first line of `lines` (clamped to >= 1). */\n start: number;\n /** Total line count of the file at this ref. */\n totalLines: number;\n /** True when `end` reached (or passed) the last line — there is nothing\n * further below to expand. */\n eof: boolean;\n}\n\n/**\n * Read a contiguous range of lines from a file so the diff viewer can\n * reveal the unchanged context around hunks (\"expand lines\" in GitHub's\n * UI). The expandable region is, by definition, identical on both diff\n * sides, so a single read of the appropriate side is enough — the caller\n * maps the old line numbers via the constant gap offset.\n *\n * Path safety mirrors `readMarkdownContent` in diff-pipeline: the textual\n * `relPath` is rejected if it escapes `root`, and the working-tree read is\n * symlink-canonicalised so a `notes.md -> /etc/passwd` symlink can't\n * exfiltrate an out-of-tree file into the payload.\n *\n * Returns `null` when the path is rejected or the content can't be read\n * (missing file, unknown ref, binary). Callers surface that as a 404/400.\n */\nexport function readContextLines(opts: ContextLinesOptions): ContextLinesResult | null {\n const { root, relPath, ref } = opts;\n if (!relPath || !isInsideRoot(root, relPath)) return null;\n\n const start = Math.max(1, Math.floor(opts.start));\n const end = Math.max(start, Math.floor(opts.end));\n\n const content = !ref || ref === 'working' ? readWorkingTree(root, relPath) : readAtRef(root, ref, relPath);\n if (content === null) return null;\n\n // Split on either line ending; drop the trailing empty element a final\n // newline produces so `totalLines` matches the line count git/editors\n // report. Matches how `parseGitDiff` strips line endings from hunk text,\n // so revealed context lines render identically to diff context lines.\n const all = content.split(/\\r?\\n/);\n if (all.length > 0 && all[all.length - 1] === '') all.pop();\n\n const totalLines = all.length;\n // start past EOF → empty slice, eof true.\n const slice = all.slice(start - 1, end);\n return {\n lines: slice,\n start,\n totalLines,\n eof: end >= totalLines,\n };\n}\n\n/** Symlink-safe working-tree read. Returns null on any failure. */\nfunction readWorkingTree(root: string, relPath: string): string | null {\n try {\n const absPath = path.join(root, relPath);\n const realRoot = fs.realpathSync(path.resolve(root));\n const realPath = fs.realpathSync(absPath);\n const sep = path.sep;\n if (realPath !== realRoot && !realPath.startsWith(realRoot + sep)) {\n return null;\n }\n return fs.readFileSync(absPath, 'utf-8');\n } catch {\n return null;\n }\n}\n\n/**\n * A ref we may hand to `git show`: a commit id, or a plain ref name. It\n * comes from a query string, and `git show` takes options — a ref of\n * `--output=/some/file` would make it WRITE a file. So nothing that starts\n * with `-`, and only characters refs actually use.\n */\nexport function isSafeRef(ref: string): boolean {\n return /^[A-Za-z0-9_][A-Za-z0-9._/~^@{}+-]{0,199}$/.test(ref) && !ref.includes('..');\n}\n\n/** `git show <ref>:<relPath>`. Uses cross-spawn directly (not the trimming\n * `git()` helper) so trailing newlines survive. Returns null on failure\n * (including a ref that isn't safe to pass — see isSafeRef). */\nfunction readAtRef(root: string, ref: string, relPath: string): string | null {\n if (!isSafeRef(ref)) return null;\n const r = spawn.sync('git', ['show', '--end-of-options', `${ref}:${relPath}`], {\n cwd: root,\n encoding: 'utf-8',\n maxBuffer: 64 * 1024 * 1024,\n windowsHide: true,\n });\n if (r.status === 0 && typeof r.stdout === 'string') return r.stdout;\n return null;\n}\n","/**\n * Shared zod schemas for the comment HTTP surface. Kept separate from\n * `comment-types.ts` because the SPA imports `comment-types.ts` for the\n * type-only exports and pulling zod into the SPA bundle is wasteful —\n * the schemas are server-side validation only.\n */\n\nimport { z } from 'zod';\n\nexport const commentInputSchema = z.object({\n repo: z.string().optional(),\n file: z.string().optional(),\n line: z.number().int().optional(),\n side: z.enum(['left', 'right', 'general', 'file']).optional(),\n body: z.string().min(1),\n status: z.enum(['published', 'draft']).optional(),\n lineContent: z.string().optional(),\n parentId: z.string().optional(),\n author: z.enum(['user', 'claude']).optional(),\n});\n\nexport const submitReviewSchema = z.object({\n summary: z.string().optional(),\n});\n\nexport const resolveSchema = z.object({\n resolved: z.boolean(),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAoBjB,SAAS,SAAS,GAAmB;AACnC,SAAO,KAAK,QAAQ,CAAC,EAAE,QAAQ,OAAO,GAAG,EAAE,YAAY;AACzD;AAcA,SAAS,SAAS,GAAmB;AACnC,MAAI;AACF,WAAO,SAAS,GAAG,aAAa,OAAO,CAAC,CAAC;AAAA,EAC3C,QAAQ;AACN,WAAO,SAAS,CAAC;AAAA,EACnB;AACF;AAOO,SAAS,aAAa,KAA+B;AAC1D,QAAM,UAAU,SAAS,GAAG;AAC5B,QAAM,WAAW,YAAY;AAO7B,QAAM,MAAM,IAAI,CA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K,CAAC,aAAa,OAAO,CAAC,EAAE,SAAS;AAAA,EAChD,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC,EAAE,SAAS;AAC9C,CAAC;AAEM,IAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,SAAS,EAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAEM,IAAM,gBAAgB,EAAE,OAAO;AAAA,EACpC,UAAU,EAAE,QAAQ;AACtB,CAAC;","names":["fs","path","path","fs","fs","path","Hono","fs","path","path","fs","Hono"]}
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-6AQRYLOB.js";
|
|
5
5
|
import {
|
|
6
6
|
findSessionForCwd
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UDOXLAE7.js";
|
|
8
8
|
import {
|
|
9
9
|
findSession,
|
|
10
10
|
loadHistory
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-C7OK4XEZ.js";
|
|
12
12
|
import {
|
|
13
13
|
loadConfig
|
|
14
14
|
} from "./chunk-QXUHOISF.js";
|
|
@@ -38,4 +38,4 @@ export {
|
|
|
38
38
|
sessionPositionals,
|
|
39
39
|
sessionFromArgs
|
|
40
40
|
};
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
41
|
+
//# sourceMappingURL=chunk-EXJYPF64.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
sessionStatusView
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TROTIHD5.js";
|
|
5
5
|
import {
|
|
6
6
|
buildDigest,
|
|
7
7
|
loadHistory,
|
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
readStatus,
|
|
12
12
|
scopeHashForPaths,
|
|
13
13
|
workSteps
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-C7OK4XEZ.js";
|
|
15
15
|
import {
|
|
16
16
|
agentOf,
|
|
17
17
|
lineTimeOf,
|
|
18
18
|
readJsonlSince
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-KTFDSJUD.js";
|
|
20
20
|
import {
|
|
21
21
|
sessionIdFor
|
|
22
22
|
} from "./chunk-RT4QZRTC.js";
|
|
@@ -99,4 +99,4 @@ function createDigestSource(deps = {}) {
|
|
|
99
99
|
export {
|
|
100
100
|
createDigestSource
|
|
101
101
|
};
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
102
|
+
//# sourceMappingURL=chunk-INVFNKU7.js.map
|
|
@@ -6,27 +6,31 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
listReplies
|
|
8
8
|
} from "./chunk-26IZBYVL.js";
|
|
9
|
+
import {
|
|
10
|
+
runningFromNames,
|
|
11
|
+
stopRunningFrom
|
|
12
|
+
} from "./chunk-TN2TXRHS.js";
|
|
9
13
|
import {
|
|
10
14
|
saveIgnored,
|
|
11
15
|
teardownWorktree,
|
|
12
16
|
worktreeFor
|
|
13
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NBI2INQS.js";
|
|
14
18
|
import {
|
|
15
19
|
isLeftover
|
|
16
20
|
} from "./chunk-L6RUHCKB.js";
|
|
17
21
|
import {
|
|
18
22
|
disposePty
|
|
19
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-U5V5J237.js";
|
|
20
24
|
import {
|
|
21
25
|
shownState
|
|
22
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-TROTIHD5.js";
|
|
23
27
|
import {
|
|
24
28
|
runInternal
|
|
25
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-3GAYLP7W.js";
|
|
26
30
|
import {
|
|
27
31
|
checkedOutBranch,
|
|
28
32
|
readPendingForSession
|
|
29
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-UDOXLAE7.js";
|
|
30
34
|
import {
|
|
31
35
|
buildFoldersOf,
|
|
32
36
|
clearBuildFolders
|
|
@@ -44,10 +48,10 @@ import {
|
|
|
44
48
|
setSessionArchived,
|
|
45
49
|
stopDev,
|
|
46
50
|
turnInProgress
|
|
47
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-C7OK4XEZ.js";
|
|
48
52
|
import {
|
|
49
53
|
agentOf
|
|
50
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-KTFDSJUD.js";
|
|
51
55
|
import {
|
|
52
56
|
sessionIdFor
|
|
53
57
|
} from "./chunk-RT4QZRTC.js";
|
|
@@ -114,7 +118,7 @@ async function archiveMergedSession(id, deps, onChanged = () => {
|
|
|
114
118
|
}) {
|
|
115
119
|
const s = loadHistory().find((x) => sessionIdFor(x) === id);
|
|
116
120
|
if (!s || s.archivedAt) return void 0;
|
|
117
|
-
const out = await archiveSession(s, deps, { merged: true });
|
|
121
|
+
const out = await archiveSession(s, deps, { merged: true, unattended: true, by: "pr-merged" });
|
|
118
122
|
onChanged();
|
|
119
123
|
if (!out.ok) throw new Error(out.message);
|
|
120
124
|
return out.kept;
|
|
@@ -205,6 +209,8 @@ function defaultArchiveDeps(opts = {}) {
|
|
|
205
209
|
};
|
|
206
210
|
},
|
|
207
211
|
stopDev: (id) => void stopDev(id),
|
|
212
|
+
stopRunningFrom: (s) => stopRunningFrom(s.paths),
|
|
213
|
+
runningFrom: (s) => runningFromNames(s.paths),
|
|
208
214
|
heads: (s) => {
|
|
209
215
|
const out = {};
|
|
210
216
|
for (const [alias, repo] of repoPaths(s, loadConfig())) {
|
|
@@ -272,4 +278,4 @@ export {
|
|
|
272
278
|
archiveMergedSession,
|
|
273
279
|
defaultArchiveDeps
|
|
274
280
|
};
|
|
275
|
-
//# sourceMappingURL=chunk-
|
|
281
|
+
//# sourceMappingURL=chunk-ISZM5C22.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/archive/session-archive-deps.ts","../src/core/archive/archive-summary.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { checkedOutBranch } from '../git/git-head.js';\nimport { loadConfig } from '../platform/config.js';\nimport { agentOf } from '../agents/index.js';\nimport { examineWorktree, normPath, type CleanupSession } from '../cleanup/cleanup.js';\nimport { loadHistory, setSessionArchived, type WorktreeSession } from '../sessions/history.js';\nimport { disposePty } from '../pty/pty-pool.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { readStatus, turnInProgress } from '../status/session-status.js';\nimport { shownState } from '../status/turn-activity.js';\nimport { defaultRunner, type CommandRunner } from '../pr/ship.js';\nimport { teardownWorktree } from '../worktree/worktree.js';\nimport { archiveSession, type ArchiveDeps, type ArchivedPr } from './session-archive.js';\nimport { archiveRefFor, dropSaved, saveUncommitted, type SavedUncommitted } from './archive-uncommitted.js';\nimport { readPendingForSession } from '../comments/pending-delivery.js';\nimport { listReplies } from '../pr/pr-replies.js';\nimport { stopDev } from '../worktree/dev-server.js';\nimport { runningFromNames, stopRunningFrom } from '../platform/running-from.js';\nimport { buildFoldersOf, clearBuildFolders } from '../cleanup/build-folders.js';\nimport { runInternal } from '../diff/checkpoint-summary.js';\nimport { summarizeArchive } from './archive-summary.js';\nimport { isLeftover } from '../worktree/leftover.js';\nimport { saveIgnored, type SavedIgnored } from './archive-ignored.js';\nimport { worktreeFor } from './archive-restore.js';\n\nconst plural = (n: number, one: string, many: string) => `${n} ${n === 1 ? one : many}`;\n\n/**\n * What archiving now would leave unfinished, in words (empty: nothing):\n * replies Claude drafted for you to post, notes its Claude hasn't been\n * given yet, a Claude mid-turn or waiting for your answer.\n */\nexport function archiveWaiting(id: string): string[] {\n const out: string[] = [];\n const drafts = listReplies(id).filter((r) => r.status === 'draft').length;\n if (drafts) out.push(`${plural(drafts, 'reply', 'replies')} to post on review threads`);\n const pending = readPendingForSession(id).length;\n if (pending) out.push(`${plural(pending, 'note', 'notes')} not yet delivered to its Claude`);\n // As the dashboard shows it (a Claude that died mid-turn isn't \"working\" forever).\n const session = loadHistory().find((s) => sessionIdFor(s) === id);\n const st = session ? shownState(session) : readStatus(id)?.state;\n if (st === 'working') out.push('its Claude is working');\n if (st === 'needs_input') out.push('its Claude is waiting for your answer');\n return out;\n}\n\n/**\n * The PR watch's archive of merged work (its `archive` dep): `merged`, so\n * nothing waiting in it holds it up. Resolves to what it kept that was\n * waiting (\"2 reply drafts\"), for the Activity note; throws when it didn't\n * archive (a turn in progress), so the watch notes it and tries again.\n */\nexport async function archiveMergedSession(id: string, deps: ArchiveDeps, onChanged: () => void = () => {}): Promise<string | undefined> {\n const s = loadHistory().find((x) => sessionIdFor(x) === id);\n if (!s || s.archivedAt) return undefined;\n // The PR watch, unasked: what you run from it is yours, so it keeps the worktree rather than stop it.\n const out = await archiveSession(s, deps, { merged: true, unattended: true, by: 'pr-merged' });\n onChanged();\n if (!out.ok) throw new Error(out.message);\n return out.kept;\n}\n\nexport interface ArchiveDepsOptions {\n /** Release other handles on its folders first (the web server's watchers,\n * a Claude): Windows won't delete a folder something holds open. */\n release?: (sessionId: string) => Promise<void>;\n /** Its PRs, for the summary (the PR watch's cache). */\n prs?: (sessionId: string) => ArchivedPr[];\n run?: CommandRunner;\n}\n\n/** The real inputs of archiveSession, the same for the dashboard, the PR watch and the CLI. */\nexport function defaultArchiveDeps(opts: ArchiveDepsOptions = {}): ArchiveDeps {\n const run = opts.run ?? defaultRunner;\n const config = () => {\n const c = loadConfig();\n if (!c) throw new Error('No config: run `work init` first.');\n return c;\n };\n return {\n stopClaude: async (id) => {\n await disposePty(id);\n await opts.release?.(id);\n },\n removable: async (s, { uncommittedSaved = false } = {}) => {\n const cfg = loadConfig();\n if (!cfg) return { ok: false, reason: 'no work config to check it against' };\n const repos = Object.values(cfg.repos).map(normPath);\n // A session on a repo's own checkout (`work tree <repo>` without a\n // branch) points at the repo itself: that folder is never removed.\n if (s.paths.some((p) => repos.includes(normPath(p)))) return { ok: false, reason: \"it is the repo's own checkout\" };\n if (s.paths.every((p) => !fs.existsSync(p))) return { ok: true, reason: 'already gone' };\n const cs: CleanupSession = {\n id: sessionIdFor(s),\n target: s.target,\n branch: s.branch,\n isGroup: s.isGroup,\n paths: s.paths,\n archivedAt: null,\n lastActiveMs: 0,\n aliases: s.isGroup ? (cfg.groups[s.target] ?? []) : [s.target],\n };\n const c = await examineWorktree(cs, { baseCheckouts: () => Object.values(cfg.repos), run });\n // Uncommitted files that were saved don't keep it; commits not in the\n // main branch still do (nothing else has them).\n const savedAway = uncommittedSaved && c.verdict === 'dirty' && c.repos.every((r) => !r.exists || r.merged !== null);\n return { ok: c.verdict === 'merged' || c.verdict === 'gone' || savedAway, reason: c.reason };\n },\n saveUncommitted: async (s, dir, stamp) => {\n const id = sessionIdFor(s);\n const saved: Record<string, SavedUncommitted> = {};\n for (const [alias, repo] of repoPaths(s, loadConfig())) {\n const wt = worktreeOf(s, repo);\n // A repo's own checkout is never removed, so nothing of it needs saving.\n if (!wt || !fs.existsSync(wt) || normPath(wt) === normPath(repo)) continue;\n const r = await saveUncommitted(wt, alias, archiveRefFor(id, alias, stamp), dir, `${alias}-${stamp}`);\n if ('error' in r) return { saved, error: r.error };\n if ('saved' in r) saved[alias] = r.saved;\n }\n return { saved, error: null };\n },\n dropSaved: async (s, saved, dir) => {\n const cfg = loadConfig();\n for (const [alias, u] of Object.entries(saved)) {\n const repo = cfg?.repos[alias];\n if (repo) await dropSaved(repo, u, dir);\n }\n },\n halfRemoved: (s) => s.paths.filter(isLeftover),\n saveIgnored: async (s, dir) => {\n const cfg = loadConfig();\n const out: Record<string, SavedIgnored> = {};\n for (const [alias] of repoPaths(s, cfg)) {\n const wt = cfg ? worktreeFor(s, alias, cfg) : null;\n if (!wt || !fs.existsSync(wt)) continue;\n const r = await saveIgnored(wt, path.join(dir, 'ignored', alias));\n if (r.files || r.skipped) out[alias] = r;\n }\n return out;\n },\n removeWorktree: async (s) => {\n if (s.paths.every((p) => !fs.existsSync(p))) return true;\n return teardownWorktree(s.target, s.isGroup, s.branch, config(), true, s.paths);\n },\n setArchived: (s) => setSessionArchived(s.target, s.branch, true),\n transcripts: (s: WorktreeSession) => (agentOf(s).conversation?.files(s) ?? []).map((t) => t.file),\n prs: opts.prs,\n lastSummary: (id) => readStatus(id)?.summary ?? null,\n waiting: archiveWaiting,\n // Mid-turn: working as the dashboard shows it, or at a dialog mid-turn (turnInProgress).\n working: (id) => {\n const session = loadHistory().find((x) => sessionIdFor(x) === id);\n return (session ? shownState(session) : readStatus(id)?.state) === 'working' || turnInProgress(readStatus(id));\n },\n kept: (id) => {\n const st = readStatus(id);\n return {\n replyDrafts: listReplies(id)\n .filter((r) => r.status === 'draft')\n .map((r) => ({ threadId: r.threadId, url: r.url, reviewer: r.reviewer, draft: r.draft ?? '' })),\n notes: readPendingForSession(id).map((c) => ({ id: c.id, text: c.body })),\n ...(st?.state === 'needs_input' && st.summary ? { askingYou: st.summary } : {}),\n };\n },\n stopDev: (id) => void stopDev(id),\n stopRunningFrom: (s) => stopRunningFrom(s.paths),\n runningFrom: (s) => runningFromNames(s.paths),\n heads: (s) => {\n const out: Record<string, string> = {};\n for (const [alias, repo] of repoPaths(s, loadConfig())) {\n const wt = worktreeOf(s, repo);\n const branch = wt ? checkedOutBranch(wt) : null;\n if (branch && branch !== s.branch) out[alias] = branch;\n }\n return out;\n },\n tips: async (s, heads) => {\n const cfg = loadConfig();\n const out: Record<string, string> = {};\n for (const [alias, repo] of repoPaths(s, cfg)) {\n const r = await run('git', ['-C', repo, 'rev-parse', '--verify', '--quiet', `refs/heads/${heads[alias] ?? s.branch}`], repo);\n if (r.code === 0 && r.stdout.trim()) out[alias] = r.stdout.trim();\n }\n return out;\n },\n clearBuildFolders: async (s) => {\n let folders = 0;\n let bytes = 0;\n for (const p of s.paths) {\n if (!fs.existsSync(p)) continue;\n const sized = await buildFoldersOf(p, run);\n const r = await clearBuildFolders(p, run);\n folders += r.removed.length;\n bytes += sized.filter((f) => r.removed.includes(f.path)).reduce((n, f) => n + f.bytes, 0);\n }\n return { folders, bytes };\n },\n tidy: async (s, heads) => {\n const cfg = loadConfig();\n const repos = repoPaths(s, cfg);\n // Its per-turn checkpoints stay (refs in the repos, and their manifest): Restore puts the\n // worktree back at the same path, so the Diff tab's turns come back with it. They go when\n // the session is deleted (clearSessionCheckpoints).\n // A local branch already in the main branch goes (its tip is recorded,\n // and reachable from the main branch, so Restore can recreate it). A\n // squash-merged one stays: its commits are reachable from nothing else.\n // Both the session's branch and the one checked out, when Claude switched.\n const deleted: string[] = [];\n for (const [alias, repo] of repos) {\n const base = (await run('git', ['-C', repo, 'rev-parse', '--abbrev-ref', 'origin/HEAD'], repo)).stdout.trim();\n if (!base || base === 'origin/HEAD') continue;\n const merged = (await run('git', ['-C', repo, 'branch', '--merged', base, '--format=%(refname:short)'], repo)).stdout\n .split('\\n')\n .map((l) => l.trim());\n const inUse = (await run('git', ['-C', repo, 'worktree', 'list', '--porcelain'], repo)).stdout;\n const head = heads[alias] ?? s.branch;\n for (const branch of new Set([s.branch, head])) {\n if (!merged.includes(branch) || inUse.includes(`branch refs/heads/${branch}\\n`)) continue;\n // Reported only for the checked-out one: that is what Restore recreates.\n if ((await run('git', ['-C', repo, 'branch', '-D', branch], repo)).code === 0 && branch === head) deleted.push(alias);\n }\n }\n return deleted;\n },\n summarize: (rec) => summarizeArchive(rec, (prompt) => runInternal(prompt, 60_000)),\n };\n}\n\n/** The session's worktree of a repo: its only path, or (a group) the one named after the repo's folder. */\nfunction worktreeOf(s: WorktreeSession, repo: string): string | null {\n if (!s.isGroup) return s.paths[0] ?? null;\n const name = path.basename(repo).toLowerCase();\n return s.paths.find((p) => path.basename(p).toLowerCase() === name) ?? null;\n}\n\n/** The session's repos as [alias, base checkout path] (a group: each member). */\nfunction repoPaths(s: WorktreeSession, cfg: ReturnType<typeof loadConfig>): Array<[string, string]> {\n if (!cfg) return [];\n const aliases = s.isGroup ? (cfg.groups[s.target] ?? []) : [s.target];\n return aliases.filter((a) => cfg.repos[a] && fs.existsSync(cfg.repos[a])).map((a) => [a, cfg.repos[a]]);\n}\n","import type { ArchiveRecord } from './session-archive.js';\n\n/**\n * The few sentences an archived session keeps on what was done and why —\n * what the Sessions list shows for it, and what archive search finds.\n * Written after archiving by an internal `claude -p` (no tools, neutral\n * cwd: the prompts are your text, but they are only material here).\n */\n\nconst MAX_PROMPT_CHARS = 600;\nconst MAX_INPUT_CHARS = 12_000;\n\n/** The prompt for the summary, from what the archive kept (pure, for tests). */\nexport function summaryPrompt(rec: ArchiveRecord): string {\n const prompts = rec.summary.prompts\n .map((p) => `- ${p.text.replace(/\\s+/g, ' ').slice(0, MAX_PROMPT_CHARS)}`)\n .join('\\n')\n .slice(0, MAX_INPUT_CHARS);\n const prs = rec.summary.prs.map((p) => `#${p.number} (${p.repo}, ${p.state.toLowerCase()})`).join(', ');\n return [\n 'Below is what a developer asked a coding assistant during one piece of work on a git branch, and how it ended.',\n 'Write 2–4 plain sentences on what was done and why, for finding this work again months later:',\n 'name the feature or bug, the main changes, and anything left open. No preamble, no lists, no markdown.',\n '',\n `Branch: ${rec.branch} (${rec.target})`,\n rec.summary.jiraKey ? `Jira: ${rec.summary.jiraKey}` : '',\n prs ? `Pull requests: ${prs}` : '',\n '',\n `The developer's requests (${rec.summary.promptCount} in all; first and latest shown):`,\n prompts || '(none kept)',\n '',\n rec.summary.lastSummary ? `How the last turn ended: ${rec.summary.lastSummary}` : '',\n ]\n .filter((l, i, all) => l !== '' || all[i - 1] !== '')\n .join('\\n');\n}\n\n/** Ask `claude -p` (injectable) for the summary; null when it can't say. */\nexport async function summarizeArchive(rec: ArchiveRecord, ask: (prompt: string) => Promise<string | null>): Promise<string | null> {\n if (rec.summary.prompts.length === 0 && !rec.summary.lastSummary) return null;\n const out = (await ask(summaryPrompt(rec)))?.trim();\n if (!out) return null;\n // One paragraph, bounded: it is shown in a list row.\n return clipToSentence(out.replace(/\\s+/g, ' '), MAX_SUMMARY_CHARS);\n}\n\nconst MAX_SUMMARY_CHARS = 800;\n\n/** At most `max` characters, ending at a sentence when one ends past half of it (else at a word, with \"…\"). */\nexport function clipToSentence(text: string, max = MAX_SUMMARY_CHARS): string {\n if (text.length <= max) return text;\n const head = text.slice(0, max);\n const end = Math.max(head.lastIndexOf('. '), head.lastIndexOf('! '), head.lastIndexOf('? '));\n if (end >= max / 2) return head.slice(0, end + 1);\n const space = head.lastIndexOf(' ');\n return `${head.slice(0, space > 0 ? space : max).trimEnd()}…`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;;;ACQjB,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAGjB,SAAS,cAAc,KAA4B;AACxD,QAAM,UAAU,IAAI,QAAQ,QACzB,IAAI,CAAC,MAAM,KAAK,EAAE,KAAK,QAAQ,QAAQ,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC,EAAE,EACxE,KAAK,IAAI,EACT,MAAM,GAAG,eAAe;AAC3B,QAAM,MAAM,IAAI,QAAQ,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE,MAAM,KAAK,EAAE,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC,GAAG,EAAE,KAAK,IAAI;AACtG,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,IAAI,MAAM,KAAK,IAAI,MAAM;AAAA,IACpC,IAAI,QAAQ,UAAU,SAAS,IAAI,QAAQ,OAAO,KAAK;AAAA,IACvD,MAAM,kBAAkB,GAAG,KAAK;AAAA,IAChC;AAAA,IACA,6BAA6B,IAAI,QAAQ,WAAW;AAAA,IACpD,WAAW;AAAA,IACX;AAAA,IACA,IAAI,QAAQ,cAAc,4BAA4B,IAAI,QAAQ,WAAW,KAAK;AAAA,EACpF,EACG,OAAO,CAAC,GAAG,GAAG,QAAQ,MAAM,MAAM,IAAI,IAAI,CAAC,MA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";
|
|
5
5
|
import {
|
|
6
6
|
normPath
|
|
7
7
|
} from "./chunk-AKMPF72Y.js";
|
|
8
8
|
import {
|
|
9
9
|
teardownWorktree
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NBI2INQS.js";
|
|
11
11
|
import {
|
|
12
12
|
disposePty
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-U5V5J237.js";
|
|
14
14
|
import {
|
|
15
15
|
defaultRunner
|
|
16
16
|
} from "./chunk-4KZBZA5D.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
readSessionActivity,
|
|
24
24
|
readStatus,
|
|
25
25
|
removeSession
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-C7OK4XEZ.js";
|
|
27
27
|
import {
|
|
28
28
|
sessionIdFor
|
|
29
29
|
} from "./chunk-RT4QZRTC.js";
|
|
@@ -139,7 +139,7 @@ function defaultCleanupDeps(opts = {}) {
|
|
|
139
139
|
if (action === "archive") {
|
|
140
140
|
const session = loadHistory().find((h) => sessionIdFor(h) === s.id);
|
|
141
141
|
if (!session) throw new Error("Not archived: work does not track it.");
|
|
142
|
-
const out = await archiveSession(session, defaultArchiveDeps({ release: opts.release, run }));
|
|
142
|
+
const out = await archiveSession(session, defaultArchiveDeps({ release: opts.release, run }), { by: "cleanup" });
|
|
143
143
|
if (!out.ok) throw new Error(out.message);
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
@@ -159,4 +159,4 @@ function defaultCleanupDeps(opts = {}) {
|
|
|
159
159
|
export {
|
|
160
160
|
defaultCleanupDeps
|
|
161
161
|
};
|
|
162
|
-
//# sourceMappingURL=chunk-
|
|
162
|
+
//# sourceMappingURL=chunk-KSVZVHTI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/cleanup/cleanup-deps.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { loadConfig, type WorkConfig } from '../platform/config.js';\nimport { loadHistory, removeSession } from '../sessions/history.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { readSessionActivity } from '../sessions/session-activity.js';\nimport { readStatus } from '../status/session-status.js';\nimport { disposePty } from '../pty/pty-pool.js';\nimport { teardownWorktree } from '../worktree/worktree.js';\nimport { archiveSession } from '../archive/session-archive.js';\nimport { defaultArchiveDeps } from '../archive/session-archive-deps.js';\nimport { fetchRemoteAsync } from '../git/git.js';\nimport { defaultRunner, type CommandRunner } from '../pr/ship.js';\nimport { normPath, type CleanupDeps, type CleanupSession } from './cleanup.js';\nimport type { CleanupAction } from '../api-types.js';\n\n/**\n * The real inputs for cleanup (cleanup.ts): work's history, the worktrees\n * git has that history doesn't, the configured repos, and the removal that\n * Delete in the dashboard uses. The same for the web view and the CLI.\n */\n\n/** Newest sign of life: the hook status, Claude's last write, the entry. */\nfunction lastActiveMs(lastAccessedAt: string, id: string, activity: number | null): number {\n const status = readStatus(id);\n return Math.max(Date.parse(lastAccessedAt) || 0, activity ?? 0, status ? Date.parse(status.updatedAt) || 0 : 0);\n}\n\nfunction parsePorcelain(out: string): Array<{ path: string; branch: string }> {\n const list: Array<{ path: string; branch: string }> = [];\n let cur: { path?: string; branch?: string } = {};\n for (const line of out.split('\\n')) {\n const w = line.match(/^worktree (.+)$/);\n if (w) {\n if (cur.path) list.push({ path: cur.path, branch: cur.branch ?? '' });\n cur = { path: w[1].trim() };\n }\n const b = line.match(/^branch refs\\/heads\\/(.+)$/);\n if (b) cur.branch = b[1].trim();\n }\n if (cur.path) list.push({ path: cur.path, branch: cur.branch ?? '' });\n return list;\n}\n\n/**\n * Worktrees git knows that work's history doesn't: a group laid out under\n * `<worktreesRoot>/<group>/<branch>/<repo>`, and any other linked worktree of\n * a configured repo. They have no activity data (lastActiveMs 0): the\n * uncommitted-changes check is what protects them.\n */\nexport async function untrackedWorktrees(\n config: WorkConfig,\n trackedPaths: Set<string>,\n run: CommandRunner = defaultRunner,\n): Promise<CleanupSession[]> {\n const out: CleanupSession[] = [];\n const covered = new Set(trackedPaths);\n\n for (const [group, aliases] of Object.entries(config.groups)) {\n const groupDir = path.join(config.worktreesRoot, group);\n let branchDirs: string[];\n try {\n branchDirs = fs\n .readdirSync(groupDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name);\n } catch {\n continue;\n }\n for (const dir of branchDirs) {\n const members = aliases\n .map((alias) => ({ alias, repo: config.repos[alias] }))\n .filter((m) => !!m.repo)\n .map((m) => ({ ...m, wt: path.join(groupDir, dir, path.basename(m.repo)) }))\n .filter((m) => fs.existsSync(m.wt));\n if (members.length === 0 || members.some((m) => covered.has(normPath(m.wt)))) continue;\n const branch = (await run('git', ['branch', '--show-current'], members[0].wt)).stdout.trim();\n if (!branch) continue;\n for (const m of members) covered.add(normPath(m.wt));\n out.push({\n id: `untracked:${normPath(path.join(groupDir, dir))}`,\n target: group,\n branch,\n isGroup: true,\n paths: members.map((m) => m.wt),\n archivedAt: null,\n lastActiveMs: 0,\n aliases: members.map((m) => m.alias),\n untracked: true,\n });\n }\n }\n\n for (const [alias, repo] of Object.entries(config.repos)) {\n if (!fs.existsSync(repo)) continue;\n const list = await run('git', ['worktree', 'list', '--porcelain'], repo);\n if (list.code !== 0) continue;\n // The first entry is always the main worktree (the repo itself).\n for (const wt of parsePorcelain(list.stdout).slice(1)) {\n if (!wt.branch || covered.has(normPath(wt.path))) continue;\n covered.add(normPath(wt.path));\n out.push({\n id: `untracked:${normPath(wt.path)}`,\n target: alias,\n branch: wt.branch,\n isGroup: false,\n paths: [path.resolve(wt.path)],\n archivedAt: null,\n lastActiveMs: 0,\n aliases: [alias],\n untracked: true,\n });\n }\n }\n return out;\n}\n\nexport interface CleanupDepsOptions {\n /** Release other handles on a worktree before it is removed (the web\n * server closes its file watcher; a watched folder can't be deleted on\n * Windows). The session's PTY is always stopped. */\n release?: (sessionId: string) => Promise<void>;\n run?: CommandRunner;\n}\n\nexport function defaultCleanupDeps(opts: CleanupDepsOptions = {}): CleanupDeps {\n const run = opts.run ?? defaultRunner;\n const config = () => {\n const c = loadConfig();\n if (!c) throw new Error('No config: run `work init` first.');\n return c;\n };\n return {\n sessions: async () => {\n const cfg = config();\n const tracked: CleanupSession[] = loadHistory().map((s) => {\n const id = sessionIdFor(s);\n return {\n id,\n target: s.target,\n branch: s.branch,\n isGroup: s.isGroup,\n paths: s.paths,\n archivedAt: s.archivedAt ?? null,\n lastActiveMs: lastActiveMs(s.lastAccessedAt, id, readSessionActivity(s).lastActivity),\n aliases: s.isGroup ? (cfg.groups[s.target] ?? []) : [s.target],\n };\n });\n const trackedPaths = new Set(tracked.flatMap((s) => s.paths.map(normPath)));\n return [...tracked, ...(await untrackedWorktrees(cfg, trackedPaths, run))];\n },\n baseCheckouts: () => Object.values(loadConfig()?.repos ?? {}),\n fetchRepos: () =>\n Object.entries(loadConfig()?.repos ?? {})\n .filter(([, p]) => fs.existsSync(p))\n .map(([alias, p]) => ({ alias, path: p })),\n fetch: (repoPath) => fetchRemoteAsync(repoPath),\n run,\n act: async (s: CleanupSession, action: CleanupAction) => {\n if (action === 'archive') {\n // Keeps the conversation; the worktree stays when it has work in it.\n const session = loadHistory().find((h) => sessionIdFor(h) === s.id);\n if (!session) throw new Error('Not archived: work does not track it.');\n const out = await archiveSession(session, defaultArchiveDeps({ release: opts.release, run }));\n if (!out.ok) throw new Error(out.message);\n return;\n }\n if (action === 'delete') {\n // Stop its Claude and release our handles first: a live PTY's cwd\n // (or a watched folder) blocks the delete on Windows. Force skips\n // only the \"ahead of upstream\" refusal: the caller just re-checked\n // there is nothing uncommitted (or was told to discard it) and\n // nothing the main branch lacks; the branch itself is kept.\n if (!s.untracked) {\n await disposePty(s.id);\n await opts.release?.(s.id);\n }\n // By its folder (what the scan examined), not by branch name: the\n // branch checked out there may since have changed.\n if (!teardownWorktree(s.target, s.isGroup, s.branch, config(), true, s.paths))\n throw new Error('git refused to remove the worktree.');\n }\n if (!s.untracked) await removeSession(s.target, s.branch); // delete and forget\n },\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:path';\nimport { loadConfig, type WorkConfig } from '../platform/config.js';\nimport { loadHistory, removeSession } from '../sessions/history.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { readSessionActivity } from '../sessions/session-activity.js';\nimport { readStatus } from '../status/session-status.js';\nimport { disposePty } from '../pty/pty-pool.js';\nimport { teardownWorktree } from '../worktree/worktree.js';\nimport { archiveSession } from '../archive/session-archive.js';\nimport { defaultArchiveDeps } from '../archive/session-archive-deps.js';\nimport { fetchRemoteAsync } from '../git/git.js';\nimport { defaultRunner, type CommandRunner } from '../pr/ship.js';\nimport { normPath, type CleanupDeps, type CleanupSession } from './cleanup.js';\nimport type { CleanupAction } from '../api-types.js';\n\n/**\n * The real inputs for cleanup (cleanup.ts): work's history, the worktrees\n * git has that history doesn't, the configured repos, and the removal that\n * Delete in the dashboard uses. The same for the web view and the CLI.\n */\n\n/** Newest sign of life: the hook status, Claude's last write, the entry. */\nfunction lastActiveMs(lastAccessedAt: string, id: string, activity: number | null): number {\n const status = readStatus(id);\n return Math.max(Date.parse(lastAccessedAt) || 0, activity ?? 0, status ? Date.parse(status.updatedAt) || 0 : 0);\n}\n\nfunction parsePorcelain(out: string): Array<{ path: string; branch: string }> {\n const list: Array<{ path: string; branch: string }> = [];\n let cur: { path?: string; branch?: string } = {};\n for (const line of out.split('\\n')) {\n const w = line.match(/^worktree (.+)$/);\n if (w) {\n if (cur.path) list.push({ path: cur.path, branch: cur.branch ?? '' });\n cur = { path: w[1].trim() };\n }\n const b = line.match(/^branch refs\\/heads\\/(.+)$/);\n if (b) cur.branch = b[1].trim();\n }\n if (cur.path) list.push({ path: cur.path, branch: cur.branch ?? '' });\n return list;\n}\n\n/**\n * Worktrees git knows that work's history doesn't: a group laid out under\n * `<worktreesRoot>/<group>/<branch>/<repo>`, and any other linked worktree of\n * a configured repo. They have no activity data (lastActiveMs 0): the\n * uncommitted-changes check is what protects them.\n */\nexport async function untrackedWorktrees(\n config: WorkConfig,\n trackedPaths: Set<string>,\n run: CommandRunner = defaultRunner,\n): Promise<CleanupSession[]> {\n const out: CleanupSession[] = [];\n const covered = new Set(trackedPaths);\n\n for (const [group, aliases] of Object.entries(config.groups)) {\n const groupDir = path.join(config.worktreesRoot, group);\n let branchDirs: string[];\n try {\n branchDirs = fs\n .readdirSync(groupDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name);\n } catch {\n continue;\n }\n for (const dir of branchDirs) {\n const members = aliases\n .map((alias) => ({ alias, repo: config.repos[alias] }))\n .filter((m) => !!m.repo)\n .map((m) => ({ ...m, wt: path.join(groupDir, dir, path.basename(m.repo)) }))\n .filter((m) => fs.existsSync(m.wt));\n if (members.length === 0 || members.some((m) => covered.has(normPath(m.wt)))) continue;\n const branch = (await run('git', ['branch', '--show-current'], members[0].wt)).stdout.trim();\n if (!branch) continue;\n for (const m of members) covered.add(normPath(m.wt));\n out.push({\n id: `untracked:${normPath(path.join(groupDir, dir))}`,\n target: group,\n branch,\n isGroup: true,\n paths: members.map((m) => m.wt),\n archivedAt: null,\n lastActiveMs: 0,\n aliases: members.map((m) => m.alias),\n untracked: true,\n });\n }\n }\n\n for (const [alias, repo] of Object.entries(config.repos)) {\n if (!fs.existsSync(repo)) continue;\n const list = await run('git', ['worktree', 'list', '--porcelain'], repo);\n if (list.code !== 0) continue;\n // The first entry is always the main worktree (the repo itself).\n for (const wt of parsePorcelain(list.stdout).slice(1)) {\n if (!wt.branch || covered.has(normPath(wt.path))) continue;\n covered.add(normPath(wt.path));\n out.push({\n id: `untracked:${normPath(wt.path)}`,\n target: alias,\n branch: wt.branch,\n isGroup: false,\n paths: [path.resolve(wt.path)],\n archivedAt: null,\n lastActiveMs: 0,\n aliases: [alias],\n untracked: true,\n });\n }\n }\n return out;\n}\n\nexport interface CleanupDepsOptions {\n /** Release other handles on a worktree before it is removed (the web\n * server closes its file watcher; a watched folder can't be deleted on\n * Windows). The session's PTY is always stopped. */\n release?: (sessionId: string) => Promise<void>;\n run?: CommandRunner;\n}\n\nexport function defaultCleanupDeps(opts: CleanupDepsOptions = {}): CleanupDeps {\n const run = opts.run ?? defaultRunner;\n const config = () => {\n const c = loadConfig();\n if (!c) throw new Error('No config: run `work init` first.');\n return c;\n };\n return {\n sessions: async () => {\n const cfg = config();\n const tracked: CleanupSession[] = loadHistory().map((s) => {\n const id = sessionIdFor(s);\n return {\n id,\n target: s.target,\n branch: s.branch,\n isGroup: s.isGroup,\n paths: s.paths,\n archivedAt: s.archivedAt ?? null,\n lastActiveMs: lastActiveMs(s.lastAccessedAt, id, readSessionActivity(s).lastActivity),\n aliases: s.isGroup ? (cfg.groups[s.target] ?? []) : [s.target],\n };\n });\n const trackedPaths = new Set(tracked.flatMap((s) => s.paths.map(normPath)));\n return [...tracked, ...(await untrackedWorktrees(cfg, trackedPaths, run))];\n },\n baseCheckouts: () => Object.values(loadConfig()?.repos ?? {}),\n fetchRepos: () =>\n Object.entries(loadConfig()?.repos ?? {})\n .filter(([, p]) => fs.existsSync(p))\n .map(([alias, p]) => ({ alias, path: p })),\n fetch: (repoPath) => fetchRemoteAsync(repoPath),\n run,\n act: async (s: CleanupSession, action: CleanupAction) => {\n if (action === 'archive') {\n // Keeps the conversation; the worktree stays when it has work in it.\n const session = loadHistory().find((h) => sessionIdFor(h) === s.id);\n if (!session) throw new Error('Not archived: work does not track it.');\n const out = await archiveSession(session, defaultArchiveDeps({ release: opts.release, run }), { by: 'cleanup' });\n if (!out.ok) throw new Error(out.message);\n return;\n }\n if (action === 'delete') {\n // Stop its Claude and release our handles first: a live PTY's cwd\n // (or a watched folder) blocks the delete on Windows. Force skips\n // only the \"ahead of upstream\" refusal: the caller just re-checked\n // there is nothing uncommitted (or was told to discard it) and\n // nothing the main branch lacks; the branch itself is kept.\n if (!s.untracked) {\n await disposePty(s.id);\n await opts.release?.(s.id);\n }\n // By its folder (what the scan examined), not by branch name: the\n // branch checked out there may since have changed.\n if (!teardownWorktree(s.target, s.isGroup, s.branch, config(), true, s.paths))\n throw new Error('git refused to remove the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206,6 +206,20 @@ function killTree(pid) {
|
|
|
206
206
|
return false;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
+
function killTreeAsync(pid) {
|
|
210
|
+
if (process.platform !== "win32") return Promise.resolve(killTree(pid) || !isPidAlive(pid));
|
|
211
|
+
return new Promise(
|
|
212
|
+
(resolve) => (
|
|
213
|
+
// taskkill fails the whole call when one child had already exited or won't go; the top gone is what counts.
|
|
214
|
+
execFile(
|
|
215
|
+
"taskkill",
|
|
216
|
+
["/PID", String(pid), "/T", "/F"],
|
|
217
|
+
{ windowsHide: true, timeout: 1e4 },
|
|
218
|
+
(err) => resolve(!err || !isPidAlive(pid))
|
|
219
|
+
)
|
|
220
|
+
)
|
|
221
|
+
);
|
|
222
|
+
}
|
|
209
223
|
function spawnDetachedWork(workBin, args, logFile) {
|
|
210
224
|
const log = fs2.openSync(logFile, "a");
|
|
211
225
|
try {
|
|
@@ -878,6 +892,7 @@ export {
|
|
|
878
892
|
recentProcessTable,
|
|
879
893
|
bootTime,
|
|
880
894
|
killTree,
|
|
895
|
+
killTreeAsync,
|
|
881
896
|
spawnDetachedWork,
|
|
882
897
|
internalRunEnv,
|
|
883
898
|
isInternalRun,
|
|
@@ -895,4 +910,4 @@ export {
|
|
|
895
910
|
agentToRecord,
|
|
896
911
|
agentFor
|
|
897
912
|
};
|
|
898
|
-
//# sourceMappingURL=chunk-
|
|
913
|
+
//# sourceMappingURL=chunk-KTFDSJUD.js.map
|