@moberg_hr/work-tree 2.0.2 → 2.0.4

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.
Files changed (198) hide show
  1. package/dist/{answer-BD5A6XMM.js → answer-GX4XSHO4.js} +8 -8
  2. package/dist/{attach-ID6KEOQ5.js → attach-E5HGK3QS.js} +11 -11
  3. package/dist/bin.js +2 -2
  4. package/dist/{block-AQDYKNWG.js → block-LBR2SM5T.js} +8 -8
  5. package/dist/{broadcast-BSI5NDDB.js → broadcast-ZDPVFRXD.js} +5 -5
  6. package/dist/{catchup-3454JUMS.js → catchup-DGFAJS5A.js} +10 -10
  7. package/dist/{chunk-M4FVCAT6.js → chunk-2NZQ6NIY.js} +36 -3
  8. package/dist/{chunk-M4FVCAT6.js.map → chunk-2NZQ6NIY.js.map} +1 -1
  9. package/dist/{chunk-2PRI27ND.js → chunk-3NXGK6TU.js} +12 -12
  10. package/dist/{chunk-ZXPYWZL5.js → chunk-46UD4QBL.js} +10 -6
  11. package/dist/chunk-46UD4QBL.js.map +1 -0
  12. package/dist/{chunk-IXKVCR4Y.js → chunk-563DLDDS.js} +3 -3
  13. package/dist/{chunk-FPKERDK7.js → chunk-6GCF2XWP.js} +2 -2
  14. package/dist/{chunk-CA7LI4N2.js → chunk-A2SMSRS3.js} +7 -6
  15. package/dist/{chunk-CA7LI4N2.js.map → chunk-A2SMSRS3.js.map} +1 -1
  16. package/dist/{chunk-P3BL4EOP.js → chunk-BQP2BWZ7.js} +2 -2
  17. package/dist/{chunk-R2LN3JJJ.js → chunk-BSCAA322.js} +2 -2
  18. package/dist/{chunk-C2THFSXA.js → chunk-D42K7F3P.js} +4 -4
  19. package/dist/{chunk-XJDEROHY.js → chunk-F7O3DYAL.js} +2 -2
  20. package/dist/{chunk-Q6WZCO45.js → chunk-FFLT7OJS.js} +2 -2
  21. package/dist/{chunk-NDWSLQPB.js → chunk-FOG4WG3Y.js} +2 -2
  22. package/dist/{chunk-CLGVSX36.js → chunk-FPGVLM2H.js} +4 -4
  23. package/dist/{chunk-YZDD5YGE.js → chunk-G2O7EIKX.js} +2 -2
  24. package/dist/{chunk-QECEHQ4U.js → chunk-GGTPVCXZ.js} +45 -45
  25. package/dist/{chunk-FR3EWVXI.js → chunk-GSEZZNSW.js} +4 -4
  26. package/dist/{chunk-PN44M5EE.js → chunk-HRD6F4NW.js} +13 -3
  27. package/dist/chunk-HRD6F4NW.js.map +1 -0
  28. package/dist/{chunk-ZJN5RWZD.js → chunk-ILQ3ID7S.js} +3 -3
  29. package/dist/{chunk-YKODIG22.js → chunk-J6AS2Q3L.js} +4 -4
  30. package/dist/{chunk-5QK7GB5K.js → chunk-JJRPLNLN.js} +2 -2
  31. package/dist/{chunk-O3VNU7EZ.js → chunk-KIOLKLGC.js} +6 -6
  32. package/dist/{chunk-YNKWLC45.js → chunk-M3HMYWDB.js} +3 -3
  33. package/dist/{chunk-77XFJQGC.js → chunk-MFKARSOP.js} +5 -5
  34. package/dist/{chunk-JNBYNRFS.js → chunk-NEZNZM7K.js} +2 -2
  35. package/dist/{chunk-O3QTWVSK.js → chunk-NOP2ATBT.js} +14 -8
  36. package/dist/chunk-NOP2ATBT.js.map +1 -0
  37. package/dist/{chunk-UFY7C5PP.js → chunk-NS3HSXF7.js} +2 -2
  38. package/dist/{chunk-ITNPMWPY.js → chunk-OLC5NBEY.js} +8 -8
  39. package/dist/{chunk-4BOK2GXL.js → chunk-QHWHQR24.js} +3 -3
  40. package/dist/{chunk-YZWADOEW.js → chunk-RJEKLIR4.js} +3 -3
  41. package/dist/{chunk-TUC4QY4O.js → chunk-RM6XOZMU.js} +2 -2
  42. package/dist/{chunk-SOCPIHCS.js → chunk-RMRRLKLR.js} +2 -2
  43. package/dist/{chunk-JYTMT5DF.js → chunk-RXXRPNWF.js} +5 -5
  44. package/dist/{chunk-G2WWMJJB.js → chunk-SHPZQNVG.js} +8 -8
  45. package/dist/chunk-UDJ623JI.js +9 -0
  46. package/dist/{chunk-3JWTO5VZ.js → chunk-VLVOOPPN.js} +46 -26
  47. package/dist/chunk-VLVOOPPN.js.map +1 -0
  48. package/dist/{chunk-7OLPI334.js → chunk-VWQ7GB2I.js} +2 -2
  49. package/dist/{chunk-7NCW3LUT.js → chunk-WF57CF7A.js} +14 -1
  50. package/dist/chunk-WF57CF7A.js.map +1 -0
  51. package/dist/{chunk-KGZ6OZ2T.js → chunk-WTX477XA.js} +5 -5
  52. package/dist/{chunk-6H3MLDGG.js → chunk-XZ5NJ2ET.js} +4 -4
  53. package/dist/{chunk-QBAZG4CY.js → chunk-Y6F4JSYV.js} +2 -2
  54. package/dist/{chunk-OYQFLBLO.js → chunk-YBGZWOYZ.js} +7 -7
  55. package/dist/{chunk-6FTIY5M6.js → chunk-YNTSWQA4.js} +4 -4
  56. package/dist/{chunk-VHWQE2WE.js → chunk-ZEHFA3EO.js} +3 -3
  57. package/dist/{chunk-C2BK6EBN.js → chunk-ZOXO5M34.js} +4 -4
  58. package/dist/{cleanup-E6OD3TUM.js → cleanup-WSPCOX34.js} +20 -20
  59. package/dist/{cli-O6IF63TS.js → cli-HCXJLNIA.js} +3 -3
  60. package/dist/{config-IEIU7A66.js → config-PHYE6XG5.js} +9 -9
  61. package/dist/{diff-K47HB6SA.js → diff-63W4LBMD.js} +8 -8
  62. package/dist/{digest-FBZTBXQO.js → digest-KK4VUUZP.js} +7 -7
  63. package/dist/{fork-XJPZFNMX.js → fork-HEYAX5PM.js} +18 -18
  64. package/dist/{hook-MTWRSD4S.js → hook-4TAFJYJJ.js} +8 -8
  65. package/dist/{hydrate-Y2AAMZTA.js → hydrate-TCXT3XDH.js} +4 -4
  66. package/dist/{init-7ESFTYZC.js → init-RY5K3YFW.js} +8 -8
  67. package/dist/{install-skills-O34BHFHD.js → install-skills-XJKQ2UBP.js} +3 -3
  68. package/dist/install-skills-bin.js +2 -2
  69. package/dist/{move-FKT2P5LY.js → move-OM552GP7.js} +11 -11
  70. package/dist/{note-M53Q6EWY.js → note-4OBZ32FO.js} +8 -8
  71. package/dist/{overlaps-FRLMMIGC.js → overlaps-EVDLCYBQ.js} +7 -7
  72. package/dist/{pin-VMM5TINM.js → pin-QOZJ6PTK.js} +8 -8
  73. package/dist/{pr-EHF642TN.js → pr-IRCJZCKF.js} +9 -9
  74. package/dist/{prune-3DRPO3VJ.js → prune-V4GA4XWG.js} +19 -19
  75. package/dist/{pty-host-RWIS55N4.js → pty-host-ZEAVQOKT.js} +65 -16
  76. package/dist/pty-host-ZEAVQOKT.js.map +1 -0
  77. package/dist/{read-DDQDRHRB.js → read-WQKAE5RC.js} +7 -7
  78. package/dist/{recent-IE3LYQ65.js → recent-YVSZPJVO.js} +5 -5
  79. package/dist/{remove-XJYZVAPX.js → remove-YFFZ52PE.js} +18 -18
  80. package/dist/{resume-UUP6R2IE.js → resume-O4UYWQTU.js} +5 -5
  81. package/dist/{run-V4755W7C.js → run-K66K7TMM.js} +4 -4
  82. package/dist/{screen-XMGBRC25.js → screen-OO566RNR.js} +8 -8
  83. package/dist/{search-3JZXLCR2.js → search-N4KN2GEG.js} +4 -4
  84. package/dist/{section-OO7IOLI7.js → section-AZZO4ZSO.js} +8 -8
  85. package/dist/{send-GMG27KFT.js → send-ZNDJON57.js} +9 -9
  86. package/dist/{sessions-GOP5Y6LS.js → sessions-OYQIYTDE.js} +15 -15
  87. package/dist/{snooze-HOS6J3SY.js → snooze-BNERTMXJ.js} +7 -7
  88. package/dist/{start-2XGTR7NW.js → start-MVEIYUSE.js} +8 -8
  89. package/dist/{state-4DFV6SHG.js → state-FGYNNSDP.js} +2 -2
  90. package/dist/{status-H5OW4LYE.js → status-F5IHLWVS.js} +4 -4
  91. package/dist/{stop-2B2HFRHR.js → stop-EIYNXNNN.js} +8 -8
  92. package/dist/{sync-YP6NMA5H.js → sync-ANIWWB4H.js} +19 -19
  93. package/dist/{time-5SAXO4M7.js → time-UKNNRLOD.js} +8 -8
  94. package/dist/{todo-LWMQY6XW.js → todo-Y2BZ65MS.js} +3 -3
  95. package/dist/{tree-7BMORJ6J.js → tree-REBGNULD.js} +11 -11
  96. package/dist/{update-A7G46IYO.js → update-CQTSLOEX.js} +10 -10
  97. package/dist/{wait-NP6HODWB.js → wait-JE4GEXFC.js} +8 -8
  98. package/dist/wd-bin.js +2 -2
  99. package/dist/web/assets/{PtyView-BdoF3ROW.js → PtyView-DqardtO3.js} +2 -2
  100. package/dist/web/assets/{PtyView-BdoF3ROW.js.map → PtyView-DqardtO3.js.map} +1 -1
  101. package/dist/web/assets/index-3TfcsOhs.css +1 -0
  102. package/dist/web/assets/index-Cp_xBIDU.js +117 -0
  103. package/dist/web/assets/index-Cp_xBIDU.js.map +1 -0
  104. package/dist/web/index.html +2 -2
  105. package/dist/{web-FSOY6574.js → web-QPX373JI.js} +420 -119
  106. package/dist/web-QPX373JI.js.map +1 -0
  107. package/npm-shrinkwrap.json +2 -2
  108. package/package.json +3 -1
  109. package/dist/chunk-3JWTO5VZ.js.map +0 -1
  110. package/dist/chunk-7NCW3LUT.js.map +0 -1
  111. package/dist/chunk-O3QTWVSK.js.map +0 -1
  112. package/dist/chunk-PN44M5EE.js.map +0 -1
  113. package/dist/chunk-UJD6QUGG.js +0 -9
  114. package/dist/chunk-ZXPYWZL5.js.map +0 -1
  115. package/dist/pty-host-RWIS55N4.js.map +0 -1
  116. package/dist/web/assets/index-BrkfzFos.js +0 -116
  117. package/dist/web/assets/index-BrkfzFos.js.map +0 -1
  118. package/dist/web/assets/index-L8mjakHP.css +0 -1
  119. package/dist/web-FSOY6574.js.map +0 -1
  120. /package/dist/{answer-BD5A6XMM.js.map → answer-GX4XSHO4.js.map} +0 -0
  121. /package/dist/{attach-ID6KEOQ5.js.map → attach-E5HGK3QS.js.map} +0 -0
  122. /package/dist/{block-AQDYKNWG.js.map → block-LBR2SM5T.js.map} +0 -0
  123. /package/dist/{broadcast-BSI5NDDB.js.map → broadcast-ZDPVFRXD.js.map} +0 -0
  124. /package/dist/{catchup-3454JUMS.js.map → catchup-DGFAJS5A.js.map} +0 -0
  125. /package/dist/{chunk-2PRI27ND.js.map → chunk-3NXGK6TU.js.map} +0 -0
  126. /package/dist/{chunk-IXKVCR4Y.js.map → chunk-563DLDDS.js.map} +0 -0
  127. /package/dist/{chunk-FPKERDK7.js.map → chunk-6GCF2XWP.js.map} +0 -0
  128. /package/dist/{chunk-P3BL4EOP.js.map → chunk-BQP2BWZ7.js.map} +0 -0
  129. /package/dist/{chunk-R2LN3JJJ.js.map → chunk-BSCAA322.js.map} +0 -0
  130. /package/dist/{chunk-C2THFSXA.js.map → chunk-D42K7F3P.js.map} +0 -0
  131. /package/dist/{chunk-XJDEROHY.js.map → chunk-F7O3DYAL.js.map} +0 -0
  132. /package/dist/{chunk-Q6WZCO45.js.map → chunk-FFLT7OJS.js.map} +0 -0
  133. /package/dist/{chunk-NDWSLQPB.js.map → chunk-FOG4WG3Y.js.map} +0 -0
  134. /package/dist/{chunk-CLGVSX36.js.map → chunk-FPGVLM2H.js.map} +0 -0
  135. /package/dist/{chunk-YZDD5YGE.js.map → chunk-G2O7EIKX.js.map} +0 -0
  136. /package/dist/{chunk-QECEHQ4U.js.map → chunk-GGTPVCXZ.js.map} +0 -0
  137. /package/dist/{chunk-FR3EWVXI.js.map → chunk-GSEZZNSW.js.map} +0 -0
  138. /package/dist/{chunk-ZJN5RWZD.js.map → chunk-ILQ3ID7S.js.map} +0 -0
  139. /package/dist/{chunk-YKODIG22.js.map → chunk-J6AS2Q3L.js.map} +0 -0
  140. /package/dist/{chunk-5QK7GB5K.js.map → chunk-JJRPLNLN.js.map} +0 -0
  141. /package/dist/{chunk-O3VNU7EZ.js.map → chunk-KIOLKLGC.js.map} +0 -0
  142. /package/dist/{chunk-YNKWLC45.js.map → chunk-M3HMYWDB.js.map} +0 -0
  143. /package/dist/{chunk-77XFJQGC.js.map → chunk-MFKARSOP.js.map} +0 -0
  144. /package/dist/{chunk-JNBYNRFS.js.map → chunk-NEZNZM7K.js.map} +0 -0
  145. /package/dist/{chunk-UFY7C5PP.js.map → chunk-NS3HSXF7.js.map} +0 -0
  146. /package/dist/{chunk-ITNPMWPY.js.map → chunk-OLC5NBEY.js.map} +0 -0
  147. /package/dist/{chunk-4BOK2GXL.js.map → chunk-QHWHQR24.js.map} +0 -0
  148. /package/dist/{chunk-YZWADOEW.js.map → chunk-RJEKLIR4.js.map} +0 -0
  149. /package/dist/{chunk-TUC4QY4O.js.map → chunk-RM6XOZMU.js.map} +0 -0
  150. /package/dist/{chunk-SOCPIHCS.js.map → chunk-RMRRLKLR.js.map} +0 -0
  151. /package/dist/{chunk-JYTMT5DF.js.map → chunk-RXXRPNWF.js.map} +0 -0
  152. /package/dist/{chunk-G2WWMJJB.js.map → chunk-SHPZQNVG.js.map} +0 -0
  153. /package/dist/{chunk-UJD6QUGG.js.map → chunk-UDJ623JI.js.map} +0 -0
  154. /package/dist/{chunk-7OLPI334.js.map → chunk-VWQ7GB2I.js.map} +0 -0
  155. /package/dist/{chunk-KGZ6OZ2T.js.map → chunk-WTX477XA.js.map} +0 -0
  156. /package/dist/{chunk-6H3MLDGG.js.map → chunk-XZ5NJ2ET.js.map} +0 -0
  157. /package/dist/{chunk-QBAZG4CY.js.map → chunk-Y6F4JSYV.js.map} +0 -0
  158. /package/dist/{chunk-OYQFLBLO.js.map → chunk-YBGZWOYZ.js.map} +0 -0
  159. /package/dist/{chunk-6FTIY5M6.js.map → chunk-YNTSWQA4.js.map} +0 -0
  160. /package/dist/{chunk-VHWQE2WE.js.map → chunk-ZEHFA3EO.js.map} +0 -0
  161. /package/dist/{chunk-C2BK6EBN.js.map → chunk-ZOXO5M34.js.map} +0 -0
  162. /package/dist/{cleanup-E6OD3TUM.js.map → cleanup-WSPCOX34.js.map} +0 -0
  163. /package/dist/{cli-O6IF63TS.js.map → cli-HCXJLNIA.js.map} +0 -0
  164. /package/dist/{config-IEIU7A66.js.map → config-PHYE6XG5.js.map} +0 -0
  165. /package/dist/{diff-K47HB6SA.js.map → diff-63W4LBMD.js.map} +0 -0
  166. /package/dist/{digest-FBZTBXQO.js.map → digest-KK4VUUZP.js.map} +0 -0
  167. /package/dist/{fork-XJPZFNMX.js.map → fork-HEYAX5PM.js.map} +0 -0
  168. /package/dist/{hook-MTWRSD4S.js.map → hook-4TAFJYJJ.js.map} +0 -0
  169. /package/dist/{hydrate-Y2AAMZTA.js.map → hydrate-TCXT3XDH.js.map} +0 -0
  170. /package/dist/{init-7ESFTYZC.js.map → init-RY5K3YFW.js.map} +0 -0
  171. /package/dist/{install-skills-O34BHFHD.js.map → install-skills-XJKQ2UBP.js.map} +0 -0
  172. /package/dist/{move-FKT2P5LY.js.map → move-OM552GP7.js.map} +0 -0
  173. /package/dist/{note-M53Q6EWY.js.map → note-4OBZ32FO.js.map} +0 -0
  174. /package/dist/{overlaps-FRLMMIGC.js.map → overlaps-EVDLCYBQ.js.map} +0 -0
  175. /package/dist/{pin-VMM5TINM.js.map → pin-QOZJ6PTK.js.map} +0 -0
  176. /package/dist/{pr-EHF642TN.js.map → pr-IRCJZCKF.js.map} +0 -0
  177. /package/dist/{prune-3DRPO3VJ.js.map → prune-V4GA4XWG.js.map} +0 -0
  178. /package/dist/{read-DDQDRHRB.js.map → read-WQKAE5RC.js.map} +0 -0
  179. /package/dist/{recent-IE3LYQ65.js.map → recent-YVSZPJVO.js.map} +0 -0
  180. /package/dist/{remove-XJYZVAPX.js.map → remove-YFFZ52PE.js.map} +0 -0
  181. /package/dist/{resume-UUP6R2IE.js.map → resume-O4UYWQTU.js.map} +0 -0
  182. /package/dist/{run-V4755W7C.js.map → run-K66K7TMM.js.map} +0 -0
  183. /package/dist/{screen-XMGBRC25.js.map → screen-OO566RNR.js.map} +0 -0
  184. /package/dist/{search-3JZXLCR2.js.map → search-N4KN2GEG.js.map} +0 -0
  185. /package/dist/{section-OO7IOLI7.js.map → section-AZZO4ZSO.js.map} +0 -0
  186. /package/dist/{send-GMG27KFT.js.map → send-ZNDJON57.js.map} +0 -0
  187. /package/dist/{sessions-GOP5Y6LS.js.map → sessions-OYQIYTDE.js.map} +0 -0
  188. /package/dist/{snooze-HOS6J3SY.js.map → snooze-BNERTMXJ.js.map} +0 -0
  189. /package/dist/{start-2XGTR7NW.js.map → start-MVEIYUSE.js.map} +0 -0
  190. /package/dist/{state-4DFV6SHG.js.map → state-FGYNNSDP.js.map} +0 -0
  191. /package/dist/{status-H5OW4LYE.js.map → status-F5IHLWVS.js.map} +0 -0
  192. /package/dist/{stop-2B2HFRHR.js.map → stop-EIYNXNNN.js.map} +0 -0
  193. /package/dist/{sync-YP6NMA5H.js.map → sync-ANIWWB4H.js.map} +0 -0
  194. /package/dist/{time-5SAXO4M7.js.map → time-UKNNRLOD.js.map} +0 -0
  195. /package/dist/{todo-LWMQY6XW.js.map → todo-Y2BZ65MS.js.map} +0 -0
  196. /package/dist/{tree-7BMORJ6J.js.map → tree-REBGNULD.js.map} +0 -0
  197. /package/dist/{update-A7G46IYO.js.map → update-CQTSLOEX.js.map} +0 -0
  198. /package/dist/{wait-NP6HODWB.js.map → wait-JE4GEXFC.js.map} +0 -0
@@ -1,34 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  listReplies
4
- } from "./chunk-FPKERDK7.js";
4
+ } from "./chunk-6GCF2XWP.js";
5
5
  import {
6
6
  examineWorktree,
7
7
  normPath
8
8
  } from "./chunk-AKMPF72Y.js";
9
9
  import {
10
10
  teardownWorktree
11
- } from "./chunk-CLGVSX36.js";
11
+ } from "./chunk-FPGVLM2H.js";
12
12
  import {
13
13
  disposePty
14
- } from "./chunk-O3QTWVSK.js";
14
+ } from "./chunk-NOP2ATBT.js";
15
15
  import {
16
16
  shownState
17
- } from "./chunk-6H3MLDGG.js";
17
+ } from "./chunk-XZ5NJ2ET.js";
18
18
  import {
19
19
  runInternal
20
- } from "./chunk-FR3EWVXI.js";
20
+ } from "./chunk-GSEZZNSW.js";
21
21
  import {
22
22
  checkedOutBranch,
23
23
  readPendingForSession
24
- } from "./chunk-CA7LI4N2.js";
24
+ } from "./chunk-A2SMSRS3.js";
25
25
  import {
26
26
  buildFoldersOf,
27
27
  clearBuildFolders
28
- } from "./chunk-NDWSLQPB.js";
28
+ } from "./chunk-FOG4WG3Y.js";
29
29
  import {
30
30
  defaultRunner
31
- } from "./chunk-ZXPYWZL5.js";
31
+ } from "./chunk-46UD4QBL.js";
32
32
  import {
33
33
  archiveRefFor,
34
34
  archiveSession,
@@ -41,13 +41,13 @@ import {
41
41
  setSessionArchived,
42
42
  stopDev,
43
43
  turnInProgress
44
- } from "./chunk-M4FVCAT6.js";
44
+ } from "./chunk-2NZQ6NIY.js";
45
45
  import {
46
46
  sessionIdFor
47
- } from "./chunk-7NCW3LUT.js";
47
+ } from "./chunk-WF57CF7A.js";
48
48
  import {
49
49
  agentOf
50
- } from "./chunk-PN44M5EE.js";
50
+ } from "./chunk-HRD6F4NW.js";
51
51
  import {
52
52
  loadConfig
53
53
  } from "./chunk-7HEB6SQS.js";
@@ -264,4 +264,4 @@ export {
264
264
  archiveMergedSession,
265
265
  defaultArchiveDeps
266
266
  };
267
- //# sourceMappingURL=chunk-2PRI27ND.js.map
267
+ //# sourceMappingURL=chunk-3NXGK6TU.js.map
@@ -58,16 +58,18 @@ function checksFromRollup(rollup) {
58
58
  return pending ? "pending" : "pass";
59
59
  }
60
60
  function repoDone(r) {
61
+ if (r.gitError) return { done: false };
61
62
  if (r.pr?.state === "MERGED") {
62
63
  const nothingSince = r.dirtyFiles === 0 && !r.ahead && (!r.localSha || r.localSha === r.pr.headSha);
63
64
  return nothingSince ? { done: true, reason: "merged" } : { done: false };
64
65
  }
65
- if (!r.pr && r.dirtyFiles === 0 && r.commitsVsBase === 0) return { done: true, reason: "untouched" };
66
+ if (!r.pr && !r.ghError && r.dirtyFiles === 0 && r.commitsVsBase === 0) return { done: true, reason: "untouched" };
66
67
  return { done: false };
67
68
  }
68
69
  function mergeBlockers(r) {
69
70
  if (repoDone(r).done) return [];
70
71
  const out = [];
72
+ if (r.gitError) out.push(r.gitError);
71
73
  if (r.ghError) out.push(r.ghError);
72
74
  if (r.dirtyFiles > 0) out.push(`${r.dirtyFiles} uncommitted file${r.dirtyFiles === 1 ? "" : "s"} \u2014 commit or stash first`);
73
75
  if (!r.hasUpstream) out.push("branch not pushed yet");
@@ -112,6 +114,7 @@ async function inspectRepo(repo, run, askGh) {
112
114
  const localSha = (await git("rev-parse", "HEAD")).stdout.trim();
113
115
  const status = await git("status", "--porcelain");
114
116
  const dirtyFiles = status.stdout.split("\n").filter((l) => l.trim()).length;
117
+ const gitError = status.code === 0 ? void 0 : `git couldn't read the working tree (${oneLineErr(status.stderr) || `exit ${status.code}`})`;
115
118
  const remoteRef = `refs/remotes/origin/${branch}`;
116
119
  const hasUpstream = (await git("rev-parse", "--verify", "--quiet", remoteRef)).code === 0;
117
120
  const upstream = await git("rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}");
@@ -128,9 +131,9 @@ async function inspectRepo(repo, run, askGh) {
128
131
  }
129
132
  let commitsVsBase = null;
130
133
  const baseRef = (await git("rev-parse", "--abbrev-ref", "origin/HEAD")).stdout.trim();
131
- if (baseRef && baseRef !== "origin/HEAD") {
132
- const n = Number((await git("rev-list", "--count", `${baseRef}..HEAD`)).stdout.trim());
133
- if (Number.isFinite(n)) commitsVsBase = n;
134
+ if (status.code === 0 && baseRef && baseRef !== "origin/HEAD") {
135
+ const count = await git("rev-list", "--count", `${baseRef}..HEAD`);
136
+ if (count.code === 0 && /^\d+$/.test(count.stdout.trim())) commitsVsBase = Number(count.stdout.trim());
134
137
  }
135
138
  let pr = null;
136
139
  let ghError;
@@ -182,7 +185,8 @@ async function inspectRepo(repo, run, askGh) {
182
185
  behind,
183
186
  pr,
184
187
  ghError,
185
- commitsVsBase
188
+ commitsVsBase,
189
+ ...gitError ? { gitError } : {}
186
190
  };
187
191
  const { done, reason } = repoDone(facts);
188
192
  return { ...facts, done, doneReason: reason, mergeBlockers: mergeBlockers(facts) };
@@ -304,4 +308,4 @@ export {
304
308
  runShipAction,
305
309
  mergeSelected
306
310
  };
307
- //# sourceMappingURL=chunk-ZXPYWZL5.js.map
311
+ //# sourceMappingURL=chunk-46UD4QBL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/pr/ship.ts"],"sourcesContent":["import path from 'node:path';\nimport crossSpawn from '../platform/spawn.js';\nimport type { WorktreeSession } from '../sessions/history.js';\nimport type {\n ChecksState,\n FailingCheck,\n MergeMethod,\n MergeSelection,\n RepoShipState,\n ShipPr,\n ShipPreflight,\n ShipResult,\n} from '../api-types.js';\n\nexport type {\n ChecksState,\n MergeMethod,\n MergeSelection,\n RepoShipState,\n ShipAction,\n ShipPr,\n ShipPreflight,\n ShipResult,\n} from '../api-types.js';\n\n/**\n * Ship a session's work: push, open a PR, merge it — per repo, because a\n * group's repos ship independently: backend can be merged and done while\n * frontend still waits for review.\n *\n * Group rules (the careful part):\n * - A repo whose PR is MERGED, or that was never touched (no commits vs\n * the base, clean, no PR), is `done` — never a blocker for the others.\n * - Merge takes an explicit list of repos, each with the PR head SHA the\n * user was shown. The server re-checks every one of them and merges\n * NONE if any is blocked or its PR moved; repos not listed are left\n * alone. So a group can be shipped in parts, deliberately.\n * - The session is archived only when a merge actually merged something\n * AND every repo is done afterwards.\n *\n * Every git/gh call goes through a `CommandRunner` with an argv array — no\n * shell (§1.1) — injectable so the decision logic is unit-testable.\n */\n\nexport interface RunResult {\n code: number;\n stdout: string;\n stderr: string;\n}\nexport type CommandRunner = (cmd: string, args: string[], cwd: string) => Promise<RunResult>;\n\n/**\n * Real runner: cross-spawn, not execFile — on Windows execFile only finds\n * .exe files, so a `gh` installed as a .cmd shim (scoop, wrappers) would\n * look \"not installed\"; cross-spawn resolves shims like `work tree` does,\n * with cmd-escaped args. Exit code 127 = the binary itself is missing.\n */\nexport const defaultRunner: CommandRunner = (cmd, args, cwd) =>\n new Promise((resolve) => {\n let stdout = '';\n let stderr = '';\n let settled = false;\n const done = (r: RunResult) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(r);\n };\n const child = crossSpawn(cmd, args, { cwd, windowsHide: true });\n const timer = setTimeout(() => {\n child.kill();\n done({ code: 124, stdout, stderr: stderr || `${cmd} timed out` });\n }, 60_000);\n child.stdout?.on('data', (d: Buffer) => {\n stdout += d.toString();\n });\n child.stderr?.on('data', (d: Buffer) => {\n stderr += d.toString();\n });\n child.on('error', (err: NodeJS.ErrnoException) => {\n done({ code: err.code === 'ENOENT' ? 127 : 1, stdout, stderr: err.message });\n });\n child.on('close', (code) => done({ code: code ?? 1, stdout, stderr }));\n });\n\n/** The repos a session ships: each worktree path, named by its folder. */\nexport function shipRepos(session: WorktreeSession): Array<{ name: string; path: string }> {\n return session.paths.map((p) => ({\n name: session.isGroup ? path.basename(p) : session.target,\n path: p,\n }));\n}\n\ninterface CheckRollupItem {\n status?: string | null;\n conclusion?: string | null;\n state?: string | null;\n /** Check runs carry name + detailsUrl; commit statuses context + targetUrl. */\n name?: string | null;\n context?: string | null;\n detailsUrl?: string | null;\n targetUrl?: string | null;\n}\n\nconst FAILED = ['FAILURE', 'ERROR', 'CANCELLED', 'TIMED_OUT', 'ACTION_REQUIRED', 'STARTUP_FAILURE'];\n\n/** The failed checks in a rollup, named, with their links. */\nexport function failingFromRollup(rollup: CheckRollupItem[] | null | undefined): FailingCheck[] {\n return (rollup ?? [])\n .filter((c) => FAILED.includes((c.conclusion ?? c.state ?? '').toUpperCase()))\n .map((c) => {\n const url = c.detailsUrl ?? c.targetUrl ?? undefined;\n return { name: c.name ?? c.context ?? 'check', ...(url ? { url } : {}) };\n });\n}\n\n/** Collapse gh's statusCheckRollup (check runs + commit statuses). */\nexport function checksFromRollup(rollup: CheckRollupItem[] | null | undefined): ChecksState {\n if (!rollup || rollup.length === 0) return 'none';\n let pending = false;\n for (const c of rollup) {\n const v = (c.conclusion ?? c.state ?? '').toUpperCase();\n if (FAILED.includes(v)) {\n return 'fail';\n }\n const status = (c.status ?? '').toUpperCase();\n if (!v || v === 'PENDING' || v === 'EXPECTED' || (status && status !== 'COMPLETED')) pending = true;\n }\n return pending ? 'pending' : 'pass';\n}\n\ntype RepoFacts = Omit<RepoShipState, 'mergeBlockers' | 'done' | 'doneReason'>;\n\n/** Done = nothing left to ship from this repo. */\nexport function repoDone(r: RepoFacts): { done: boolean; reason?: 'merged' | 'untouched' } {\n // Merged AND nothing since: a follow-up commit (pushed or not) or an\n // edit after the merge is new work — it must stay visible, get pushed,\n // and block archiving until it's shipped too.\n // A tree git couldn't read may hold anything: never done on a guess.\n if (r.gitError) return { done: false };\n if (r.pr?.state === 'MERGED') {\n const nothingSince = r.dirtyFiles === 0 && !r.ahead && (!r.localSha || r.localSha === r.pr.headSha);\n return nothingSince ? { done: true, reason: 'merged' } : { done: false };\n }\n // Untouched only when every fact was read: a gh that failed (no network right after a\n // wake) is not \"no PR\", and a git that failed is not \"0 commits\" — reading them so once\n // archived a group whose other PR was still open.\n if (!r.pr && !r.ghError && r.dirtyFiles === 0 && r.commitsVsBase === 0) return { done: true, reason: 'untouched' };\n return { done: false };\n}\n\n/** Why \"merge\" isn't available for this repo right now ([] = go). */\nexport function mergeBlockers(r: RepoFacts): string[] {\n if (repoDone(r).done) return [];\n const out: string[] = [];\n if (r.gitError) out.push(r.gitError);\n if (r.ghError) out.push(r.ghError);\n if (r.dirtyFiles > 0) out.push(`${r.dirtyFiles} uncommitted file${r.dirtyFiles === 1 ? '' : 's'} — commit or stash first`);\n if (!r.hasUpstream) out.push('branch not pushed yet');\n if (r.ahead && r.ahead > 0) out.push(`${r.ahead} unpushed commit${r.ahead === 1 ? '' : 's'}`);\n if (r.behind && r.behind > 0) out.push(`origin has ${r.behind} commit${r.behind === 1 ? '' : 's'} you don't have locally — pull first`);\n if (!r.pr) {\n if (!r.ghError) out.push('no pull request');\n return out;\n }\n if (r.pr.state === 'CLOSED') out.push('pull request is closed');\n if (r.pr.state === 'MERGED') {\n // Not done (repoDone), so there's work after the merge.\n out.push(`PR #${r.pr.number} is already merged — the new work needs a new PR`);\n return out;\n }\n if (r.pr.isDraft) out.push('pull request is a draft');\n // The PR must be exactly what you have locally: otherwise merging lands\n // commits you haven't seen (or leaves out ones you have).\n if (r.localSha && r.pr.headSha && r.pr.headSha !== r.localSha && !(r.ahead || r.behind)) {\n out.push(\"the PR's head isn't your local HEAD — push or pull first\");\n }\n switch (r.pr.mergeStateStatus) {\n case 'DIRTY':\n out.push('merge conflicts with the base branch');\n break;\n case 'BEHIND':\n out.push('branch is behind the base branch');\n break;\n case 'BLOCKED':\n out.push('blocked by branch protection (reviews or required checks)');\n break;\n default:\n break;\n }\n if (r.pr.checks === 'fail') out.push('checks failing');\n else if (r.pr.checks === 'pending') out.push('checks still running');\n return out;\n}\n\nfunction oneLineErr(s: string): string {\n return (\n s\n .split(/\\r?\\n/)\n .map((l) => l.trim())\n .find(Boolean) ?? ''\n );\n}\n\n/** Whether to ask GitHub about a repo's PR at all (the PR watch skips\n * branches that were never pushed and have no PR it knows of). */\nexport type AskGh = (repo: { name: string; hasUpstream: boolean; commitsVsBase: number | null }) => boolean;\n\nasync function inspectRepo(repo: { name: string; path: string }, run: CommandRunner, askGh?: AskGh): Promise<RepoShipState> {\n const git = (...args: string[]) => run('git', args, repo.path);\n const branch = (await git('rev-parse', '--abbrev-ref', 'HEAD')).stdout.trim();\n const localSha = (await git('rev-parse', 'HEAD')).stdout.trim();\n const status = await git('status', '--porcelain');\n const dirtyFiles = status.stdout.split('\\n').filter((l) => l.trim()).length;\n const gitError =\n status.code === 0 ? undefined : `git couldn't read the working tree (${oneLineErr(status.stderr) || `exit ${status.code}`})`;\n\n // \"Published\" = origin/<branch> exists — NOT whatever @{u} points at.\n // `work tree` forks branches tracking origin/main, so @{u} is often the\n // base: measuring against it hides unpushed commits, and a plain push\n // fails (\"upstream branch ... does not match the name of your current\n // branch\").\n const remoteRef = `refs/remotes/origin/${branch}`;\n const hasUpstream = (await git('rev-parse', '--verify', '--quiet', remoteRef)).code === 0;\n const upstream = await git('rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}');\n const tracksRemote = upstream.code === 0 && upstream.stdout.trim() === `origin/${branch}`;\n let ahead: number | null = null;\n let behind: number | null = null;\n if (hasUpstream) {\n const counts = await git('rev-list', '--left-right', '--count', `${remoteRef}...HEAD`);\n const [b, a] = counts.stdout.trim().split(/\\s+/).map(Number);\n if (Number.isFinite(a) && Number.isFinite(b)) {\n ahead = a;\n behind = b;\n }\n }\n\n let commitsVsBase: number | null = null;\n const baseRef = (await git('rev-parse', '--abbrev-ref', 'origin/HEAD')).stdout.trim();\n // A git that failed (a timeout under load) tells nothing: no count, so never \"untouched\".\n if (status.code === 0 && baseRef && baseRef !== 'origin/HEAD') {\n // Only a count git gave: `Number('')` is 0, which read a failed git as \"no commits\".\n const count = await git('rev-list', '--count', `${baseRef}..HEAD`);\n if (count.code === 0 && /^\\d+$/.test(count.stdout.trim())) commitsVsBase = Number(count.stdout.trim());\n }\n\n let pr: ShipPr | null = null;\n let ghError: string | undefined;\n const skipGh = askGh ? !askGh({ name: repo.name, hasUpstream, commitsVsBase }) : false;\n const view = skipGh\n ? { code: 1, stdout: '', stderr: 'no pull requests found (not asked: never pushed)' }\n : await run(\n 'gh',\n [\n 'pr',\n 'view',\n branch,\n '--json',\n 'number,url,state,isDraft,mergeStateStatus,headRefOid,mergedAt,updatedAt,statusCheckRollup,reviewDecision',\n ],\n repo.path,\n );\n if (view.code === 0) {\n try {\n const j = JSON.parse(view.stdout) as {\n number: number;\n url: string;\n state: ShipPr['state'];\n isDraft: boolean;\n mergeStateStatus?: string;\n headRefOid: string;\n mergedAt?: string | null;\n updatedAt?: string;\n statusCheckRollup?: CheckRollupItem[];\n reviewDecision?: string | null;\n };\n pr = {\n number: j.number,\n url: j.url,\n state: j.state,\n isDraft: j.isDraft,\n mergeStateStatus: j.mergeStateStatus ?? 'UNKNOWN',\n checks: checksFromRollup(j.statusCheckRollup),\n headSha: j.headRefOid,\n ...(j.mergedAt ? { mergedAt: j.mergedAt } : {}),\n ...(j.updatedAt ? { updatedAt: j.updatedAt } : {}),\n ...(typeof j.reviewDecision === 'string' ? { reviewDecision: j.reviewDecision } : {}),\n ...(checksFromRollup(j.statusCheckRollup) === 'fail' ? { failing: failingFromRollup(j.statusCheckRollup) } : {}),\n };\n } catch {\n ghError = 'could not read `gh pr view` output';\n }\n } else if (view.code === 127) {\n ghError = 'GitHub CLI (gh) not found — install it to open and merge PRs';\n } else if (!/no pull requests found/i.test(view.stderr)) {\n ghError = oneLineErr(view.stderr) || 'gh pr view failed';\n }\n\n const facts: RepoFacts = {\n name: repo.name,\n path: repo.path,\n branch,\n localSha,\n dirtyFiles,\n hasUpstream,\n tracksRemote,\n ahead,\n behind,\n pr,\n ghError,\n commitsVsBase,\n ...(gitError ? { gitError } : {}),\n };\n const { done, reason } = repoDone(facts);\n return { ...facts, done, doneReason: reason, mergeBlockers: mergeBlockers(facts) };\n}\n\nexport async function shipPreflight(\n session: WorktreeSession,\n run: CommandRunner = defaultRunner,\n opts: { askGh?: AskGh } = {},\n): Promise<ShipPreflight> {\n const repos = await Promise.all(shipRepos(session).map((r) => inspectRepo(r, run, opts.askGh)));\n return { repos };\n}\n\nasync function push(r: RepoShipState, run: CommandRunner): Promise<ShipResult> {\n // Set tracking to origin/<branch> unless it already is; a plain push\n // with tracking on the base branch is refused by git.\n const args = r.tracksRemote ? ['push'] : ['push', '-u', 'origin', r.branch];\n const res = await run('git', args, r.path);\n return res.code === 0\n ? { repo: r.name, ok: true, message: r.hasUpstream ? 'pushed' : `published ${r.branch}` }\n : { repo: r.name, ok: false, message: oneLineErr(res.stderr) || 'git push failed' };\n}\n\n/**\n * push / create-pr across the session's repos. Done repos and repos with\n * no commits vs the base are skipped (reported ok), never failed.\n */\nexport async function runShipAction(\n session: WorktreeSession,\n action: 'push' | 'create-pr',\n opts: { draft?: boolean } = {},\n run: CommandRunner = defaultRunner,\n): Promise<ShipResult[]> {\n const { repos } = await shipPreflight(session, run);\n const results: ShipResult[] = [];\n for (const r of repos) {\n if (r.done) {\n results.push({ repo: r.name, ok: true, message: r.doneReason === 'merged' ? 'already merged' : 'untouched — skipped' });\n continue;\n }\n if (r.commitsVsBase === 0 && !r.pr) {\n results.push({ repo: r.name, ok: true, message: 'no commits vs the base branch — skipped' });\n continue;\n }\n if (action === 'push') {\n if (r.hasUpstream && !r.ahead && r.tracksRemote) {\n results.push({ repo: r.name, ok: true, message: 'nothing to push' });\n continue;\n }\n results.push(await push(r, run));\n continue;\n }\n // create-pr (a MERGED PR that isn't done means new work → new PR)\n if (r.pr && r.pr.state === 'OPEN') {\n results.push({ repo: r.name, ok: true, message: `PR #${r.pr.number} already open`, url: r.pr.url });\n continue;\n }\n if (r.ghError) {\n results.push({ repo: r.name, ok: false, message: r.ghError });\n continue;\n }\n if (!r.hasUpstream || (r.ahead ?? 0) > 0 || !r.tracksRemote) {\n const pushed = await push(r, run);\n if (!pushed.ok) {\n results.push(pushed);\n continue;\n }\n }\n const args = ['pr', 'create', '--fill', '--head', r.branch];\n if (opts.draft) args.push('--draft');\n const res = await run('gh', args, r.path);\n if (res.code === 0) {\n const url = res.stdout\n .trim()\n .split(/\\s+/)\n .find((t) => t.startsWith('http'));\n results.push({ repo: r.name, ok: true, message: opts.draft ? 'draft PR opened' : 'PR opened', url });\n } else {\n results.push({ repo: r.name, ok: false, message: oneLineErr(res.stderr) || 'gh pr create failed' });\n }\n }\n return results;\n}\n\nexport interface MergeOutcome {\n results: ShipResult[];\n /** Something was merged by this call. */\n mergedAny: boolean;\n /** After this call, every repo in the session is done. */\n allDone: boolean;\n}\n\n/**\n * Merge exactly the selected repos, at exactly the PR heads the user saw.\n *\n * Validation happens for ALL selected repos before ANY merge: an unknown\n * repo, a PR that moved (someone pushed after the user looked), or any\n * blocker refuses the whole call — no half-applied selection. Repos not\n * selected are never touched, so shipping a group in parts is a deliberate\n * choice, not an accident.\n */\nexport async function mergeSelected(\n session: WorktreeSession,\n selection: MergeSelection[],\n method: MergeMethod,\n run: CommandRunner = defaultRunner,\n): Promise<MergeOutcome> {\n const { repos } = await shipPreflight(session, run);\n const byName = new Map(repos.map((r) => [r.name, r]));\n if (selection.length === 0) {\n return {\n results: [{ repo: '-', ok: false, message: 'no repositories selected' }],\n mergedAny: false,\n allDone: repos.every((r) => r.done),\n };\n }\n\n const problems: ShipResult[] = [];\n for (const sel of selection) {\n const r = byName.get(sel.name);\n if (!r) {\n problems.push({ repo: sel.name, ok: false, message: 'not a repository of this session' });\n } else if (r.done) {\n problems.push({ repo: r.name, ok: false, message: r.doneReason === 'merged' ? 'already merged' : 'nothing to merge' });\n } else if (!r.pr || r.pr.headSha !== sel.headSha) {\n problems.push({\n repo: r.name,\n ok: false,\n message: 'the pull request changed since you looked — review it again before merging',\n });\n } else if (r.mergeBlockers.length > 0) {\n problems.push({ repo: r.name, ok: false, message: `not merged: ${r.mergeBlockers.join('; ')}` });\n }\n }\n if (problems.length > 0) {\n const failed = new Set(problems.map((p) => p.repo));\n const held = selection\n .filter((s) => !failed.has(s.name))\n .map((s) => ({ repo: s.name, ok: false, message: 'not merged: another selected repo is blocked' }));\n return { results: [...problems, ...held], mergedAny: false, allDone: repos.every((r) => r.done) };\n }\n\n const results: ShipResult[] = [];\n const mergedNow = new Set<string>();\n for (const sel of selection) {\n const r = byName.get(sel.name)!;\n const res = await run('gh', ['pr', 'merge', String(r.pr!.number), `--${method}`, '--match-head-commit', sel.headSha], r.path);\n if (res.code === 0) {\n mergedNow.add(r.name);\n results.push({ repo: r.name, ok: true, merged: true, message: `PR #${r.pr!.number} merged (${method})`, url: r.pr!.url });\n } else {\n // Stop at the first failure rather than keep merging a partially\n // failing selection; what's merged is reported as merged.\n results.push({ repo: r.name, ok: false, message: oneLineErr(res.stderr) || 'gh pr merge failed' });\n break;\n }\n }\n const attempted = new Set(results.map((x) => x.repo));\n for (const sel of selection) {\n if (!attempted.has(sel.name)) {\n results.push({ repo: sel.name, ok: false, message: 'not merged: stopped after an earlier failure' });\n }\n }\n const allDone = repos.every((r) => r.done || mergedNow.has(r.name));\n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AA,EACF;AACA,QAAM,YAAY,IAAI,IAAI,QAAQ,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;AACpD,aAAW,OAAO,WAAW;AAC3B,QAAI,CAAC,UAAU,IAAI,IAAI,IAAI,GAAG;AAC5B,cAAQ,KAAK,EAAE,MAAM,IAAI,MAAM,IAAI,OAAO,SAAS,+CAA+C,CAAC;AAAA,IACrG;AAAA,EACF;AACA,QAAM,UAAU,MAAM,MAAM,CAAC,MAAM,EAAE,QAAQ,UAAU,IAAI,EAAE,IAAI,CAAC;AAClE,SAAO,EAAE,SAAS,WAAW,UAAU,OAAO,GAAG,QAAQ;AAC3D;","names":[]}
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  computeDiff,
4
4
  isInsideRoot
5
- } from "./chunk-7OLPI334.js";
5
+ } from "./chunk-VWQ7GB2I.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-M4FVCAT6.js";
15
+ } from "./chunk-2NZQ6NIY.js";
16
16
  import {
17
17
  spawn_default
18
18
  } from "./chunk-RCYI7SRA.js";
@@ -484,4 +484,4 @@ export {
484
484
  submitReviewSchema,
485
485
  resolveSchema
486
486
  };
487
- //# sourceMappingURL=chunk-IXKVCR4Y.js.map
487
+ //# sourceMappingURL=chunk-563DLDDS.js.map
@@ -4,7 +4,7 @@ import {
4
4
  sessionIdFor,
5
5
  tx,
6
6
  withDb
7
- } from "./chunk-7NCW3LUT.js";
7
+ } from "./chunk-WF57CF7A.js";
8
8
 
9
9
  // src/core/pr/pr-replies.ts
10
10
  var THREAD_ID = /^PRRT_[A-Za-z0-9_-]{4,120}$/;
@@ -139,4 +139,4 @@ export {
139
139
  postDrafts,
140
140
  markPostedAnswered
141
141
  };
142
- //# sourceMappingURL=chunk-FPKERDK7.js.map
142
+ //# sourceMappingURL=chunk-6GCF2XWP.js.map
@@ -5,15 +5,15 @@ import {
5
5
  import {
6
6
  getCommentFileStore,
7
7
  readStoreComments
8
- } from "./chunk-5QK7GB5K.js";
8
+ } from "./chunk-JJRPLNLN.js";
9
9
  import {
10
10
  loadHistory
11
- } from "./chunk-M4FVCAT6.js";
11
+ } from "./chunk-2NZQ6NIY.js";
12
12
  import {
13
13
  sessionIdFor,
14
14
  tx,
15
15
  withDb
16
- } from "./chunk-7NCW3LUT.js";
16
+ } from "./chunk-WF57CF7A.js";
17
17
 
18
18
  // src/core/git/git-head.ts
19
19
  import fs from "fs";
@@ -135,7 +135,8 @@ function claimForDelivery(sessionId, ids) {
135
135
  });
136
136
  }
137
137
  var MAX_BODY_BYTES = 4 * 1024;
138
- var MAX_TOTAL_BYTES = 32 * 1024;
138
+ var MAX_NOTE_BYTES = 16 * 1024;
139
+ var MAX_TOTAL_BYTES = 4 * MAX_NOTE_BYTES;
139
140
  function formatPendingForPrompt(pending) {
140
141
  if (pending.length === 0) return "";
141
142
  const sorted = [...pending].sort((a, b) => a.createdAt.localeCompare(b.createdAt));
@@ -187,7 +188,7 @@ function formatBody(prefix, c) {
187
188
  }
188
189
  function formatFullBody(prefix, c) {
189
190
  const body = c.body.trim();
190
- const capped = body.length > MAX_BODY_BYTES ? `${body.slice(0, MAX_BODY_BYTES)}\u2026` : body;
191
+ const capped = body.length > MAX_NOTE_BYTES ? `${body.slice(0, MAX_NOTE_BYTES)}\u2026` : body;
191
192
  const bodyLines = capped.split("\n");
192
193
  if (bodyLines.length === 1) return `${prefix}: ${bodyLines[0]}`;
193
194
  const [first, ...rest] = bodyLines;
@@ -204,4 +205,4 @@ export {
204
205
  claimForDelivery,
205
206
  formatPendingForPrompt
206
207
  };
207
- //# sourceMappingURL=chunk-CA7LI4N2.js.map
208
+ //# sourceMappingURL=chunk-A2SMSRS3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/git/git-head.ts","../src/core/comments/pending-delivery.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * The branch checked out in a checkout, read from its HEAD file — no `git`\n * process, so the session list can ask for every session on every request.\n * A worktree's `.git` is a file (`gitdir: <repo>/.git/worktrees/<name>`)\n * whose HEAD names the branch; a base checkout's `.git` is the folder.\n *\n * null: detached HEAD, not a checkout, or unreadable.\n */\nexport function checkedOutBranch(checkout: string): string | null {\n try {\n const dotGit = path.join(checkout, '.git');\n let gitDir = dotGit;\n if (fs.statSync(dotGit).isFile()) {\n const m = /^gitdir:\\s*(.+?)\\s*$/m.exec(fs.readFileSync(dotGit, 'utf8'));\n if (!m) return null;\n gitDir = path.resolve(checkout, m[1]);\n }\n return branchFromHead(fs.readFileSync(path.join(gitDir, 'HEAD'), 'utf8'));\n } catch {\n return null;\n }\n}\n\n/** `ref: refs/heads/fix/x` → `fix/x`; a commit sha (detached) → null. */\nexport function branchFromHead(head: string): string | null {\n const m = /^ref:\\s*refs\\/heads\\/(.+?)\\s*$/m.exec(head);\n return m ? m[1] : null;\n}\n","/**\n * Bridge between `work web` review comments and any live Claude session\n * running in the same worktree. Storage (state.db, see db.ts):\n *\n * comments the comment stores (comment-file-store.ts)\n * comment_deliveries (session, comment id) pairs surfaced to Claude\n *\n * \"Pending\" = published, user-authored, not in the delivered list. Replies\n * authored by Claude (author === 'claude') are excluded — Claude wrote\n * them; we don't need to echo them back.\n *\n * Delivery is lazy: when a Claude in the matching worktree submits a\n * prompt, the hook reads pending comments via this module, prints them as\n * a system-reminder block to stdout (which Claude Code injects into the\n * conversation), and marks them delivered.\n */\n\nimport { checkedOutBranch } from '../git/git-head.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { loadHistory, type WorktreeSession } from '../sessions/history.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { getCommentFileStore, readStoreComments } from './comment-file-store.js';\nimport { scopeHashFor } from '../diff/repo-spec.js';\nimport { tx, withDb, type Db } from '../platform/db.js';\nimport type { Comment } from './comment-types.js';\n\nfunction deliveredIds(d: Db, sessionId: string): Set<string> {\n return new Set(\n (d.prepare('SELECT comment_id FROM comment_deliveries WHERE session_id = ?').all(sessionId) as Array<{ comment_id: string }>).map(\n (r) => r.comment_id,\n ),\n );\n}\n\n/** Norm-path comparison that mirrors what we do server-side. */\nfunction normalize(p: string): string {\n return path.resolve(p).replace(/\\\\/g, '/').toLowerCase();\n}\n\n/** Map a Claude cwd back to a session. Tries direct-match against any\n * session's path first, then ancestor match (so cwd inside a subdir of a\n * worktree still resolves to the worktree's session). */\n/**\n * Two sessions on one folder (an old entry and a newer one, a typo'd target\n * re-added): which of them a Claude there is. Not an archived one when the\n * other isn't; then the one whose branch is checked out there; then the one\n * entered last. The oldest used to win, so status and comments went to an\n * entry nobody looks at.\n */\nfunction owns(candidate: WorktreeSession, current: WorktreeSession, root: string): boolean {\n if (!!candidate.archivedAt !== !!current.archivedAt) return !candidate.archivedAt;\n const onBranch = checkedOutBranch(root);\n const a = candidate.branch === onBranch;\n const b = current.branch === onBranch;\n if (a !== b) return a;\n return (Date.parse(candidate.lastAccessedAt) || 0) > (Date.parse(current.lastAccessedAt) || 0);\n}\n\nexport function findSessionForCwd(cwd: string, sessions: WorktreeSession[] = loadHistory()): WorktreeSession | null {\n const here = normalize(cwd);\n // Deepest root containing cwd wins, so nested worktrees disambiguate. A\n // group's roots include the group root (the sub-repos' parent) — that's\n // where `work tree` launches Claude for a group, so hooks fire from there.\n let best: { session: WorktreeSession; root: string; len: number } | null = null;\n for (const s of sessions) {\n const roots = s.isGroup && s.paths[0] ? [...s.paths, path.dirname(s.paths[0])] : s.paths;\n for (const root of roots) {\n const r = normalize(root);\n if (!(here === r || here.startsWith(r + '/'))) continue;\n if (!best || r.length > best.len || (r.length === best.len && owns(s, best.session, root))) {\n best = { session: s, root, len: r.length };\n }\n }\n }\n if (!best) return null;\n // A separate checkout nested INSIDE the session's tree (a git worktree at\n // <repo>/.claude/worktrees/x, a vendored repo) is not this session: its\n // Claude must not report status, take checkpoints or receive comments as\n // if it were the parent. Any `.git` between cwd and the matched root —\n // other than the session's own repos — marks a different checkout.\n // (Plain fs checks: this runs on every hook.)\n const own = new Set(best.session.paths.map(normalize));\n const top = normalize(best.root);\n for (let dir = path.resolve(cwd); normalize(dir) !== top && normalize(dir).startsWith(top + '/'); dir = path.dirname(dir)) {\n if (!own.has(normalize(dir)) && fs.existsSync(path.join(dir, '.git'))) return null;\n if (path.dirname(dir) === dir) break;\n }\n return best.session;\n}\n\nfunction isPendingFor(delivered: Set<string>) {\n return (c: Comment) => c.status === 'published' && c.author === 'user' && !delivered.has(c.id);\n}\n\n/** Returns published user comments that haven't been delivered yet.\n * Reads through the file-store cache so we see in-flight writes\n * (`session-meta.ts` and other readers couldn't, when they re-read the\n * disk directly). */\n/**\n * The line typed into an idle Claude (or given as the first prompt of one\n * work starts) so its UserPromptSubmit hook attaches the pending comments.\n * Short on purpose: a long typed note got mangled by Claude Code's paste\n * handling. It says where the content is, so it reads right in the\n * transcript.\n */\nexport const NOTE_NUDGE =\n 'work has new notes for you (review feedback, CI results or comments); they are attached to this message. Work through them now.';\n\nexport function readPendingForSession(sessionId: string): Comment[] {\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n return readStoreComments(sessionId).filter(isPendingFor(delivered));\n}\n\n/** Comment-store ids for every `wd` scope that could cover this worktree.\n * A scope is keyed by `sha1` of its sorted repo roots (see\n * `repo-spec.scopeHashFor`), so from a session's paths we can rebuild the\n * exact ids without consulting `work web`'s in-memory scope registry:\n * - the whole-set hash → a group `wd` opened at the group root, or the\n * single-repo `wd` (one path);\n * - each individual path's hash → a `wd` opened inside one sub-repo of a\n * group worktree.\n * `registerScope` hashes `path.resolve()`d roots, so we resolve here too or\n * the hashes won't line up. Mirrors `scope-manager.commentStoreIdForScope`\n * (`scope-<hash>`). */\nfunction scopeStoreIdsForPaths(paths: string[]): string[] {\n const resolved = paths.map((p) => path.resolve(p));\n const ids = new Set<string>();\n ids.add(`scope-${scopeHashFor(resolved)}`);\n for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);\n return [...ids];\n}\n\n/**\n * Pending comments for a whole worktree: the session's own comment store\n * PLUS any `wd` / `wd -c` scope review store covering the same paths.\n *\n * `wd` registers its review under a scope-hash comment store, not the\n * session store the hook reads — without this merge, comments left in the\n * `wd` review UI would never reach the Claude running in that worktree.\n * Delivered-tracking stays per-session (one `<sessionId>.delivered.json`),\n * so a comment surfaced here won't be re-delivered regardless of which\n * store it came from.\n */\nexport function readPendingForWorktree(session: WorktreeSession): Comment[] {\n const sessionId = sessionIdFor(session);\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n const pending = isPendingFor(delivered);\n const seen = new Set<string>();\n const out: Comment[] = [];\n const collect = (storeId: string) => {\n for (const c of readStoreComments(storeId)) {\n if (seen.has(c.id) || !pending(c)) continue;\n seen.add(c.id);\n out.push(c);\n }\n };\n collect(sessionId);\n for (const storeId of scopeStoreIdsForPaths(session.paths)) collect(storeId);\n return out;\n}\n\n/**\n * What was handed to Claude is done once its turn really ends: your review\n * comments and work's notes to it (PR feedback, CI, a prompt you sent) —\n * every top-level comment of yours it was given, in the session's store and\n * any `wd` scope store over its paths — are marked resolved. Left open, they\n * piled up on the Diff tab's badge (three PR-watch notes read as \"3\"), to\n * resolve or delete by hand. Resolved threads stay listed (dimmed) and can\n * be reopened. Claude's own replies are left as they are. Returns the ids\n * resolved.\n */\nexport function resolveAddressed(session: WorktreeSession): string[] {\n const sessionId = sessionIdFor(session);\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n if (delivered.size === 0) return [];\n const done: string[] = [];\n for (const storeId of [sessionId, ...scopeStoreIdsForPaths(session.paths)]) {\n const open = readStoreComments(storeId).filter(\n (c) => delivered.has(c.id) && c.author === 'user' && c.status === 'published' && !c.parentId && !c.resolved,\n );\n if (open.length === 0) continue;\n const store = getCommentFileStore(storeId);\n for (const c of open) if (store.setResolved(c.id, true)) done.push(c.id);\n }\n return done;\n}\n\n/** Persist a delivery batch, so these ids are never surfaced again. */\nexport function markDelivered(sessionId: string, ids: string[]): void {\n if (ids.length === 0) return;\n tx((d) => {\n const ins = d.prepare('INSERT OR IGNORE INTO comment_deliveries (session_id, comment_id) VALUES (?, ?)');\n for (const id of ids) ins.run(sessionId, id);\n });\n}\n\n/**\n * Claim comments for delivery: of `ids`, return the ones nobody has\n * delivered yet, and mark them delivered — atomically. Two deliverers\n * racing (a Stop hook and the PTY push for the same comment) then can't\n * both send it: only the one that claimed it does. A deliverer whose send\n * fails gives the ids back with `releaseClaim`.\n */\nexport function claimForDelivery(sessionId: string, ids: string[]): string[] {\n if (ids.length === 0) return [];\n // INSERT OR IGNORE in one write transaction: a row inserted here is our\n // claim; one that already existed was someone else's.\n return tx((d) => {\n const ins = d.prepare('INSERT OR IGNORE INTO comment_deliveries (session_id, comment_id) VALUES (?, ?)');\n return ids.filter((id) => ins.run(sessionId, id).changes > 0);\n });\n}\n\n/** Undo a claim whose delivery failed, so the next hook picks them up. */\nexport function releaseClaim(sessionId: string, ids: string[]): void {\n if (ids.length === 0) return;\n tx((d) => {\n const del = d.prepare('DELETE FROM comment_deliveries WHERE session_id = ? AND comment_id = ?');\n for (const id of ids) del.run(sessionId, id);\n });\n}\n\n/** Cap the size of one comment body we surface to Claude. A pathologically\n * long comment shouldn't blow out Claude's context — we truncate, then\n * hint at the rest via \"(truncated)\". 4 KB is generous for a code-review\n * note while leaving headroom for batches. */\nconst MAX_BODY_BYTES = 4 * 1024;\n/** Overall cap on the whole system-reminder payload. Multiple long\n * comments at once still get bounded. */\nconst MAX_TOTAL_BYTES = 32 * 1024;\n\n/**\n * Format pending comments as a system-reminder block suitable for stdout.\n * Returns empty string when there's nothing pending — the caller (the\n * `work hook` CLI) just exits silently in that case.\n *\n * Truncates pathologically long bodies and caps the overall payload so\n * one runaway comment can't displace the rest of Claude's context.\n */\nexport function formatPendingForPrompt(pending: Comment[]): string {\n if (pending.length === 0) return '';\n\n const sorted = [...pending].sort((a, b) => a.createdAt.localeCompare(b.createdAt));\n\n const general = sorted.filter((c) => c.side === 'general' && !c.parentId);\n const inline = sorted.filter((c) => c.side !== 'general' && !c.parentId);\n const replies = sorted.filter((c) => c.parentId);\n\n const lines: string[] = [];\n lines.push('<system-reminder>');\n lines.push(`New review comments from \\`work web\\` (${pending.length} item${pending.length === 1 ? '' : 's'}):`);\n lines.push('');\n\n if (general.length > 0) {\n lines.push('## General notes');\n for (const c of general) {\n // General notes (this is where `work broadcast` lands) may be multi-line\n // prompts — deliver the whole body, not just line 1. Only the byte cap\n // applies. Inline/reply comments still use the one-line `formatBody`.\n lines.push(formatFullBody('-', c));\n }\n lines.push('');\n }\n\n if (inline.length > 0) {\n lines.push('## Inline comments');\n for (const c of inline) {\n const where = `${c.repo}/${c.file}:${c.line} (${c.side})`;\n lines.push(formatBody(`- ${where}`, c));\n }\n lines.push('');\n }\n\n if (replies.length > 0) {\n lines.push('## Replies');\n for (const c of replies) {\n lines.push(formatBody(`- (reply to ${c.parentId})`, c));\n }\n lines.push('');\n }\n\n lines.push(\n 'Address them as part of your next response. You can reply via the same review UI by posting back to the latest review URL at `~/.work/web.url` + `/api/sessions/<id>/comments` with `author: \"claude\"`.',\n );\n lines.push('</system-reminder>');\n const out = lines.join('\\n');\n if (out.length <= MAX_TOTAL_BYTES) return out;\n const trimmed = out.slice(0, MAX_TOTAL_BYTES - 200);\n return (\n trimmed +\n '\\n\\n(…review payload truncated for context-window safety; ' +\n `${pending.length} comment(s) total — open work web for the full list.)\\n` +\n '</system-reminder>'\n );\n}\n\nfunction formatBody(prefix: string, c: Comment): string {\n const lead = c.body.split('\\n')[0].trim();\n const capped = lead.length > MAX_BODY_BYTES ? `${lead.slice(0, MAX_BODY_BYTES)}…` : lead;\n return `${prefix}: ${capped}${c.body.includes('\\n') ? ' …' : ''}`;\n}\n\n/** Like `formatBody` but preserves the full multi-line body (only the byte\n * cap applies). Multi-line bodies are emitted under the bullet, indented, so\n * a broadcast prompt arrives intact rather than truncated to its first line. */\nfunction formatFullBody(prefix: string, c: Comment): string {\n const body = c.body.trim();\n const capped = body.length > MAX_BODY_BYTES ? `${body.slice(0, MAX_BODY_BYTES)}…` : body;\n const bodyLines = capped.split('\\n');\n if (bodyLines.length === 1) return `${prefix}: ${bodyLines[0]}`;\n const [first, ...rest] = bodyLines;\n return [`${prefix}: ${first}`, ...rest.map((l) => ` ${l}`)].join('\\n');\n}\n\n/** Re-export so consumers don't have to know which module owns it. */\nexport { sessionIdFor };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAUV,SAAS,iBAAiB,UAAiC;AAChE,MAAI;AACF,UAAM,SAAS,KAAK,KAAK,UAAU,MAAM;AACzC,QAAI,SAAS;AACb,QAAI,GAAG,SAAS,MAAM,EAAE,OAAO,GAAG;AAChC,YAAM,IAAI,wBAAwB,KAAK,GAAG,aAAa,QAAQ,MAAM,CAAC;AACtE,UAAI,CAAC,EAAG,QAAO;AACf,eAAS,KAAK,QAAQ,UAAU,EAAE,CAAC,CAAC;AAAA,IACtC;AACA,WAAO,eAAe,GAAG,aAAa,KAAK,KAAK,QAAQ,MAAM,GAAG,MAAM,CAAC;AAAA,EAC1E,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,eAAe,MAA6B;AAC1D,QAAM,IAAI,kCAAkC,KAAK,IAAI;AACrD,SAAO,IAAI,EAAE,CAAC,IAAI;AACpB;;;ACZA,OAAOA,SAAQ;AACf,OAAOC,WAAU;AAQjB,SAAS,aAAa,GAAO,WAAgC;AAC3D,SAAO,IAAI;AAAA,IACR,EAAE,QAAQ,gEAAgE,EAAE,IAAI,SAAS,EAAoC;AAAA,MAC5H,CAAC,MAAM,EAAE;AAAA,IACX;AAAA,EACF;AACF;AAGA,SAAS,UAAU,GAAmB;AACpC,SAAOC,MAAK,QAAQ,CAAC,EAAE,QAAQ,OAAO,GAAG,EAAE,YAAY;AACzD;AAYA,SAAS,KAAK,WAA4B,SAA0B,MAAuB;AACzF,MAAI,CAAC,CAAC,UAAU,eAAe,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;AACpF,SAAO,GAAG,MAAM,KAAK,MAAM,GAAG,EAAE,KAAK,SAAS,IAAI,IAAI,YAAO,EAAE;AACjE;AAKA,SAAS,eAAe,QAAgB,GAAoB;AAC1D,QAAM,OAAO,EAAE,KAAK,KAAK;AACzB,QAAM,SAAS,KAAK,SAAS,iBAAiB,GAAG,KAAK,MAAM,GAAG,cAAc,CAAC,WAAM;AACpF,QAAM,YAAY,OAAO,MAAM,IAAI;AACnC,MAAI,UAAU,WAAW,EAAG,QAAO,GAAG,MAAM,KAAK,UAAU,CAAC,CAAC;AAC7D,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AACzB,SAAO,CAAC,GAAG,MAAM,KAAK,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,IAAI;AACxE;","names":["fs","path","path","fs"]}
1
+ {"version":3,"sources":["../src/core/git/git-head.ts","../src/core/comments/pending-delivery.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * The branch checked out in a checkout, read from its HEAD file — no `git`\n * process, so the session list can ask for every session on every request.\n * A worktree's `.git` is a file (`gitdir: <repo>/.git/worktrees/<name>`)\n * whose HEAD names the branch; a base checkout's `.git` is the folder.\n *\n * null: detached HEAD, not a checkout, or unreadable.\n */\nexport function checkedOutBranch(checkout: string): string | null {\n try {\n const dotGit = path.join(checkout, '.git');\n let gitDir = dotGit;\n if (fs.statSync(dotGit).isFile()) {\n const m = /^gitdir:\\s*(.+?)\\s*$/m.exec(fs.readFileSync(dotGit, 'utf8'));\n if (!m) return null;\n gitDir = path.resolve(checkout, m[1]);\n }\n return branchFromHead(fs.readFileSync(path.join(gitDir, 'HEAD'), 'utf8'));\n } catch {\n return null;\n }\n}\n\n/** `ref: refs/heads/fix/x` → `fix/x`; a commit sha (detached) → null. */\nexport function branchFromHead(head: string): string | null {\n const m = /^ref:\\s*refs\\/heads\\/(.+?)\\s*$/m.exec(head);\n return m ? m[1] : null;\n}\n","/**\n * Bridge between `work web` review comments and any live Claude session\n * running in the same worktree. Storage (state.db, see db.ts):\n *\n * comments the comment stores (comment-file-store.ts)\n * comment_deliveries (session, comment id) pairs surfaced to Claude\n *\n * \"Pending\" = published, user-authored, not in the delivered list. Replies\n * authored by Claude (author === 'claude') are excluded — Claude wrote\n * them; we don't need to echo them back.\n *\n * Delivery is lazy: when a Claude in the matching worktree submits a\n * prompt, the hook reads pending comments via this module, prints them as\n * a system-reminder block to stdout (which Claude Code injects into the\n * conversation), and marks them delivered.\n */\n\nimport { checkedOutBranch } from '../git/git-head.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { loadHistory, type WorktreeSession } from '../sessions/history.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { getCommentFileStore, readStoreComments } from './comment-file-store.js';\nimport { scopeHashFor } from '../diff/repo-spec.js';\nimport { tx, withDb, type Db } from '../platform/db.js';\nimport type { Comment } from './comment-types.js';\n\nfunction deliveredIds(d: Db, sessionId: string): Set<string> {\n return new Set(\n (d.prepare('SELECT comment_id FROM comment_deliveries WHERE session_id = ?').all(sessionId) as Array<{ comment_id: string }>).map(\n (r) => r.comment_id,\n ),\n );\n}\n\n/** Norm-path comparison that mirrors what we do server-side. */\nfunction normalize(p: string): string {\n return path.resolve(p).replace(/\\\\/g, '/').toLowerCase();\n}\n\n/** Map a Claude cwd back to a session. Tries direct-match against any\n * session's path first, then ancestor match (so cwd inside a subdir of a\n * worktree still resolves to the worktree's session). */\n/**\n * Two sessions on one folder (an old entry and a newer one, a typo'd target\n * re-added): which of them a Claude there is. Not an archived one when the\n * other isn't; then the one whose branch is checked out there; then the one\n * entered last. The oldest used to win, so status and comments went to an\n * entry nobody looks at.\n */\nfunction owns(candidate: WorktreeSession, current: WorktreeSession, root: string): boolean {\n if (!!candidate.archivedAt !== !!current.archivedAt) return !candidate.archivedAt;\n const onBranch = checkedOutBranch(root);\n const a = candidate.branch === onBranch;\n const b = current.branch === onBranch;\n if (a !== b) return a;\n return (Date.parse(candidate.lastAccessedAt) || 0) > (Date.parse(current.lastAccessedAt) || 0);\n}\n\nexport function findSessionForCwd(cwd: string, sessions: WorktreeSession[] = loadHistory()): WorktreeSession | null {\n const here = normalize(cwd);\n // Deepest root containing cwd wins, so nested worktrees disambiguate. A\n // group's roots include the group root (the sub-repos' parent) — that's\n // where `work tree` launches Claude for a group, so hooks fire from there.\n let best: { session: WorktreeSession; root: string; len: number } | null = null;\n for (const s of sessions) {\n const roots = s.isGroup && s.paths[0] ? [...s.paths, path.dirname(s.paths[0])] : s.paths;\n for (const root of roots) {\n const r = normalize(root);\n if (!(here === r || here.startsWith(r + '/'))) continue;\n if (!best || r.length > best.len || (r.length === best.len && owns(s, best.session, root))) {\n best = { session: s, root, len: r.length };\n }\n }\n }\n if (!best) return null;\n // A separate checkout nested INSIDE the session's tree (a git worktree at\n // <repo>/.claude/worktrees/x, a vendored repo) is not this session: its\n // Claude must not report status, take checkpoints or receive comments as\n // if it were the parent. Any `.git` between cwd and the matched root —\n // other than the session's own repos — marks a different checkout.\n // (Plain fs checks: this runs on every hook.)\n const own = new Set(best.session.paths.map(normalize));\n const top = normalize(best.root);\n for (let dir = path.resolve(cwd); normalize(dir) !== top && normalize(dir).startsWith(top + '/'); dir = path.dirname(dir)) {\n if (!own.has(normalize(dir)) && fs.existsSync(path.join(dir, '.git'))) return null;\n if (path.dirname(dir) === dir) break;\n }\n return best.session;\n}\n\nfunction isPendingFor(delivered: Set<string>) {\n return (c: Comment) => c.status === 'published' && c.author === 'user' && !delivered.has(c.id);\n}\n\n/** Returns published user comments that haven't been delivered yet.\n * Reads through the file-store cache so we see in-flight writes\n * (`session-meta.ts` and other readers couldn't, when they re-read the\n * disk directly). */\n/**\n * The line typed into an idle Claude (or given as the first prompt of one\n * work starts) so its UserPromptSubmit hook attaches the pending comments.\n * Short on purpose: a long typed note got mangled by Claude Code's paste\n * handling. It says where the content is, so it reads right in the\n * transcript.\n */\nexport const NOTE_NUDGE =\n 'work has new notes for you (review feedback, CI results or comments); they are attached to this message. Work through them now.';\n\nexport function readPendingForSession(sessionId: string): Comment[] {\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n return readStoreComments(sessionId).filter(isPendingFor(delivered));\n}\n\n/** Comment-store ids for every `wd` scope that could cover this worktree.\n * A scope is keyed by `sha1` of its sorted repo roots (see\n * `repo-spec.scopeHashFor`), so from a session's paths we can rebuild the\n * exact ids without consulting `work web`'s in-memory scope registry:\n * - the whole-set hash → a group `wd` opened at the group root, or the\n * single-repo `wd` (one path);\n * - each individual path's hash → a `wd` opened inside one sub-repo of a\n * group worktree.\n * `registerScope` hashes `path.resolve()`d roots, so we resolve here too or\n * the hashes won't line up. Mirrors `scope-manager.commentStoreIdForScope`\n * (`scope-<hash>`). */\nfunction scopeStoreIdsForPaths(paths: string[]): string[] {\n const resolved = paths.map((p) => path.resolve(p));\n const ids = new Set<string>();\n ids.add(`scope-${scopeHashFor(resolved)}`);\n for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);\n return [...ids];\n}\n\n/**\n * Pending comments for a whole worktree: the session's own comment store\n * PLUS any `wd` / `wd -c` scope review store covering the same paths.\n *\n * `wd` registers its review under a scope-hash comment store, not the\n * session store the hook reads — without this merge, comments left in the\n * `wd` review UI would never reach the Claude running in that worktree.\n * Delivered-tracking stays per-session (one `<sessionId>.delivered.json`),\n * so a comment surfaced here won't be re-delivered regardless of which\n * store it came from.\n */\nexport function readPendingForWorktree(session: WorktreeSession): Comment[] {\n const sessionId = sessionIdFor(session);\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n const pending = isPendingFor(delivered);\n const seen = new Set<string>();\n const out: Comment[] = [];\n const collect = (storeId: string) => {\n for (const c of readStoreComments(storeId)) {\n if (seen.has(c.id) || !pending(c)) continue;\n seen.add(c.id);\n out.push(c);\n }\n };\n collect(sessionId);\n for (const storeId of scopeStoreIdsForPaths(session.paths)) collect(storeId);\n return out;\n}\n\n/**\n * What was handed to Claude is done once its turn really ends: your review\n * comments and work's notes to it (PR feedback, CI, a prompt you sent) —\n * every top-level comment of yours it was given, in the session's store and\n * any `wd` scope store over its paths — are marked resolved. Left open, they\n * piled up on the Diff tab's badge (three PR-watch notes read as \"3\"), to\n * resolve or delete by hand. Resolved threads stay listed (dimmed) and can\n * be reopened. Claude's own replies are left as they are. Returns the ids\n * resolved.\n */\nexport function resolveAddressed(session: WorktreeSession): string[] {\n const sessionId = sessionIdFor(session);\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n if (delivered.size === 0) return [];\n const done: string[] = [];\n for (const storeId of [sessionId, ...scopeStoreIdsForPaths(session.paths)]) {\n const open = readStoreComments(storeId).filter(\n (c) => delivered.has(c.id) && c.author === 'user' && c.status === 'published' && !c.parentId && !c.resolved,\n );\n if (open.length === 0) continue;\n const store = getCommentFileStore(storeId);\n for (const c of open) if (store.setResolved(c.id, true)) done.push(c.id);\n }\n return done;\n}\n\n/** Persist a delivery batch, so these ids are never surfaced again. */\nexport function markDelivered(sessionId: string, ids: string[]): void {\n if (ids.length === 0) return;\n tx((d) => {\n const ins = d.prepare('INSERT OR IGNORE INTO comment_deliveries (session_id, comment_id) VALUES (?, ?)');\n for (const id of ids) ins.run(sessionId, id);\n });\n}\n\n/**\n * Claim comments for delivery: of `ids`, return the ones nobody has\n * delivered yet, and mark them delivered — atomically. Two deliverers\n * racing (a Stop hook and the PTY push for the same comment) then can't\n * both send it: only the one that claimed it does. A deliverer whose send\n * fails gives the ids back with `releaseClaim`.\n */\nexport function claimForDelivery(sessionId: string, ids: string[]): string[] {\n if (ids.length === 0) return [];\n // INSERT OR IGNORE in one write transaction: a row inserted here is our\n // claim; one that already existed was someone else's.\n return tx((d) => {\n const ins = d.prepare('INSERT OR IGNORE INTO comment_deliveries (session_id, comment_id) VALUES (?, ?)');\n return ids.filter((id) => ins.run(sessionId, id).changes > 0);\n });\n}\n\n/** Undo a claim whose delivery failed, so the next hook picks them up. */\nexport function releaseClaim(sessionId: string, ids: string[]): void {\n if (ids.length === 0) return;\n tx((d) => {\n const del = d.prepare('DELETE FROM comment_deliveries WHERE session_id = ? AND comment_id = ?');\n for (const id of ids) del.run(sessionId, id);\n });\n}\n\n/** Cap the size of one comment body we surface to Claude. A pathologically\n * long comment shouldn't blow out Claude's context — we truncate, then\n * hint at the rest via \"(truncated)\". 4 KB is generous for a code-review\n * note while leaving headroom for batches. */\nconst MAX_BODY_BYTES = 4 * 1024;\n/** A general note: a prompt, or work's own note (a PR review round quotes\n * every thread, then a bot's overview). 4 KB once cut such a note before\n * the line telling Claude how to draft its replies. */\nconst MAX_NOTE_BYTES = 16 * 1024;\n/** Overall cap on the whole system-reminder payload. Multiple long\n * comments at once still get bounded — but room for four whole notes, since\n * the cut falls on the newest one's end: its instructions. */\nconst MAX_TOTAL_BYTES = 4 * MAX_NOTE_BYTES;\n\n/**\n * Format pending comments as a system-reminder block suitable for stdout.\n * Returns empty string when there's nothing pending — the caller (the\n * `work hook` CLI) just exits silently in that case.\n *\n * Truncates pathologically long bodies and caps the overall payload so\n * one runaway comment can't displace the rest of Claude's context.\n */\nexport function formatPendingForPrompt(pending: Comment[]): string {\n if (pending.length === 0) return '';\n\n const sorted = [...pending].sort((a, b) => a.createdAt.localeCompare(b.createdAt));\n\n const general = sorted.filter((c) => c.side === 'general' && !c.parentId);\n const inline = sorted.filter((c) => c.side !== 'general' && !c.parentId);\n const replies = sorted.filter((c) => c.parentId);\n\n const lines: string[] = [];\n lines.push('<system-reminder>');\n lines.push(`New review comments from \\`work web\\` (${pending.length} item${pending.length === 1 ? '' : 's'}):`);\n lines.push('');\n\n if (general.length > 0) {\n lines.push('## General notes');\n for (const c of general) {\n // General notes (this is where `work broadcast` lands) may be multi-line\n // prompts — deliver the whole body, not just line 1. Only the byte cap\n // applies. Inline/reply comments still use the one-line `formatBody`.\n lines.push(formatFullBody('-', c));\n }\n lines.push('');\n }\n\n if (inline.length > 0) {\n lines.push('## Inline comments');\n for (const c of inline) {\n const where = `${c.repo}/${c.file}:${c.line} (${c.side})`;\n lines.push(formatBody(`- ${where}`, c));\n }\n lines.push('');\n }\n\n if (replies.length > 0) {\n lines.push('## Replies');\n for (const c of replies) {\n lines.push(formatBody(`- (reply to ${c.parentId})`, c));\n }\n lines.push('');\n }\n\n lines.push(\n 'Address them as part of your next response. You can reply via the same review UI by posting back to the latest review URL at `~/.work/web.url` + `/api/sessions/<id>/comments` with `author: \"claude\"`.',\n );\n lines.push('</system-reminder>');\n const out = lines.join('\\n');\n if (out.length <= MAX_TOTAL_BYTES) return out;\n const trimmed = out.slice(0, MAX_TOTAL_BYTES - 200);\n return (\n trimmed +\n '\\n\\n(…review payload truncated for context-window safety; ' +\n `${pending.length} comment(s) total — open work web for the full list.)\\n` +\n '</system-reminder>'\n );\n}\n\nfunction formatBody(prefix: string, c: Comment): string {\n const lead = c.body.split('\\n')[0].trim();\n const capped = lead.length > MAX_BODY_BYTES ? `${lead.slice(0, MAX_BODY_BYTES)}…` : lead;\n return `${prefix}: ${capped}${c.body.includes('\\n') ? ' …' : ''}`;\n}\n\n/** Like `formatBody` but preserves the full multi-line body (only the note\n * cap applies). Multi-line bodies are emitted under the bullet, indented, so\n * a broadcast prompt arrives intact rather than truncated to its first line. */\nfunction formatFullBody(prefix: string, c: Comment): string {\n const body = c.body.trim();\n const capped = body.length > MAX_NOTE_BYTES ? `${body.slice(0, MAX_NOTE_BYTES)}…` : body;\n const bodyLines = capped.split('\\n');\n if (bodyLines.length === 1) return `${prefix}: ${bodyLines[0]}`;\n const [first, ...rest] = bodyLines;\n return [`${prefix}: ${first}`, ...rest.map((l) => ` ${l}`)].join('\\n');\n}\n\n/** Re-export so consumers don't have to know which module owns it. */\nexport { sessionIdFor };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAUV,SAAS,iBAAiB,UAAiC;AAChE,MAAI;AACF,UAAM,SAAS,KAAK,KAAK,UAAU,MAAM;AACzC,QAAI,SAAS;AACb,QAAI,GA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CAAC,GAAG,MAAM,KAAK,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,IAAI;AACxE;","names":["fs","path","path","fs"]}
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  buildAiLaunchArgs
4
- } from "./chunk-PN44M5EE.js";
4
+ } from "./chunk-HRD6F4NW.js";
5
5
  import {
6
6
  spawn_default
7
7
  } from "./chunk-RCYI7SRA.js";
@@ -34,4 +34,4 @@ export {
34
34
  openVSCode,
35
35
  launchAi
36
36
  };
37
- //# sourceMappingURL=chunk-P3BL4EOP.js.map
37
+ //# sourceMappingURL=chunk-BQP2BWZ7.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  BUILD_DIR_NAMES
4
- } from "./chunk-NDWSLQPB.js";
4
+ } from "./chunk-FOG4WG3Y.js";
5
5
 
6
6
  // src/core/worktree/repo-rules.ts
7
7
  var baseName = (p) => p.replace(/[\\/]+$/, "").split(/[\\/]/).pop() ?? p;
@@ -129,4 +129,4 @@ export {
129
129
  originUrl,
130
130
  scanForRepos
131
131
  };
132
- //# sourceMappingURL=chunk-R2LN3JJJ.js.map
132
+ //# sourceMappingURL=chunk-BSCAA322.js.map
@@ -3,16 +3,16 @@ import {
3
3
  computeChanges,
4
4
  findOverlaps,
5
5
  wantsDiffStat
6
- } from "./chunk-4BOK2GXL.js";
6
+ } from "./chunk-QHWHQR24.js";
7
7
  import {
8
8
  pool
9
9
  } from "./chunk-AKMPF72Y.js";
10
10
  import {
11
11
  defaultRunner
12
- } from "./chunk-ZXPYWZL5.js";
12
+ } from "./chunk-46UD4QBL.js";
13
13
  import {
14
14
  sessionIdFor
15
- } from "./chunk-7NCW3LUT.js";
15
+ } from "./chunk-WF57CF7A.js";
16
16
 
17
17
  // src/core/diff/overlap-scan.ts
18
18
  import path from "path";
@@ -34,4 +34,4 @@ async function scanChanges(sessions, opts = {}) {
34
34
  export {
35
35
  scanChanges
36
36
  };
37
- //# sourceMappingURL=chunk-C2THFSXA.js.map
37
+ //# sourceMappingURL=chunk-D42K7F3P.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readStatus
4
- } from "./chunk-M4FVCAT6.js";
4
+ } from "./chunk-2NZQ6NIY.js";
5
5
 
6
6
  // src/commands/shared/turn-wait.ts
7
7
  var cliWaitDeps = {
@@ -16,4 +16,4 @@ var cliWaitDeps = {
16
16
  export {
17
17
  cliWaitDeps
18
18
  };
19
- //# sourceMappingURL=chunk-XJDEROHY.js.map
19
+ //# sourceMappingURL=chunk-F7O3DYAL.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-LNHSBM4L.js";
5
5
  import {
6
6
  knownAgents
7
- } from "./chunk-PN44M5EE.js";
7
+ } from "./chunk-HRD6F4NW.js";
8
8
 
9
9
  // src/commands/install-skills.ts
10
10
  import chalk from "chalk";
@@ -44,4 +44,4 @@ export {
44
44
  runInstallSkills,
45
45
  installSkillsCommand
46
46
  };
47
- //# sourceMappingURL=chunk-Q6WZCO45.js.map
47
+ //# sourceMappingURL=chunk-FFLT7OJS.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  defaultRunner
4
- } from "./chunk-ZXPYWZL5.js";
4
+ } from "./chunk-46UD4QBL.js";
5
5
 
6
6
  // src/core/cleanup/build-folders.ts
7
7
  import fs from "fs";
@@ -109,4 +109,4 @@ export {
109
109
  buildFoldersOf,
110
110
  clearBuildFolders
111
111
  };
112
- //# sourceMappingURL=chunk-NDWSLQPB.js.map
112
+ //# sourceMappingURL=chunk-FOG4WG3Y.js.map
@@ -27,13 +27,13 @@ import {
27
27
  upsertSession,
28
28
  upsertSessionWithPort,
29
29
  writeArchiveRecord
30
- } from "./chunk-M4FVCAT6.js";
30
+ } from "./chunk-2NZQ6NIY.js";
31
31
  import {
32
32
  sessionIdFor
33
- } from "./chunk-7NCW3LUT.js";
33
+ } from "./chunk-WF57CF7A.js";
34
34
  import {
35
35
  agentFor
36
- } from "./chunk-PN44M5EE.js";
36
+ } from "./chunk-HRD6F4NW.js";
37
37
  import {
38
38
  report
39
39
  } from "./chunk-DW4JPVXB.js";
@@ -665,4 +665,4 @@ export {
665
665
  teardownWorktree,
666
666
  openBaseCheckout
667
667
  };
668
- //# sourceMappingURL=chunk-CLGVSX36.js.map
668
+ //# sourceMappingURL=chunk-FPGVLM2H.js.map
@@ -5,7 +5,7 @@ import {
5
5
  samePathKey,
6
6
  scanForRepos,
7
7
  suggestAlias
8
- } from "./chunk-R2LN3JJJ.js";
8
+ } from "./chunk-BSCAA322.js";
9
9
  import {
10
10
  atomicWriteFile,
11
11
  getConfigDir,
@@ -162,4 +162,4 @@ export {
162
162
  saveGroup,
163
163
  deleteGroup
164
164
  };
165
- //# sourceMappingURL=chunk-YZDD5YGE.js.map
165
+ //# sourceMappingURL=chunk-G2O7EIKX.js.map