@moberg_hr/work-tree 2.3.1 → 2.4.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.
Files changed (250) hide show
  1. package/README.md +6 -1
  2. package/dist/add-repo-5SYBDVG2.js +384 -0
  3. package/dist/add-repo-5SYBDVG2.js.map +1 -0
  4. package/dist/{answer-UWI22VOE.js → answer-OA2WTJCZ.js} +11 -11
  5. package/dist/{attach-HYHEXW5J.js → attach-5GXPA7BV.js} +14 -14
  6. package/dist/bin.js +5 -5
  7. package/dist/{block-A25XE7HC.js → block-VINEC2MW.js} +11 -11
  8. package/dist/{broadcast-AG7P5BKQ.js → broadcast-ENAJDNVU.js} +8 -8
  9. package/dist/{catchup-VTGG7BAR.js → catchup-NC4WHSBF.js} +14 -14
  10. package/dist/{chunk-XDBMLTFY.js → chunk-3HBHM2VX.js} +4 -4
  11. package/dist/chunk-3IOIY4W6.js +39 -0
  12. package/dist/chunk-3IOIY4W6.js.map +1 -0
  13. package/dist/{chunk-7OBX4MJY.js → chunk-3KOYICWB.js} +4 -4
  14. package/dist/{chunk-HWIRY3WO.js → chunk-3NISM3OI.js} +7 -6
  15. package/dist/chunk-3NISM3OI.js.map +1 -0
  16. package/dist/{chunk-ZSXMIPU4.js → chunk-3Q6S6TRY.js} +3 -3
  17. package/dist/{chunk-MEK7BIVS.js → chunk-45X4QO4V.js} +37 -17
  18. package/dist/chunk-45X4QO4V.js.map +1 -0
  19. package/dist/{chunk-3D63HGOG.js → chunk-4ETSGWB2.js} +3 -3
  20. package/dist/{chunk-IVPV6VPW.js → chunk-4VNUU6S6.js} +3 -3
  21. package/dist/{chunk-7W6I4VXA.js → chunk-65YMLGQB.js} +7 -7
  22. package/dist/{chunk-C3E7XETB.js → chunk-6KM2C2UO.js} +7 -7
  23. package/dist/{chunk-R5QLAXNJ.js → chunk-6SJOM62D.js} +2 -2
  24. package/dist/{chunk-ROLNJOSE.js → chunk-A53IRCOO.js} +2 -1
  25. package/dist/chunk-A53IRCOO.js.map +1 -0
  26. package/dist/{chunk-QQNPAZNP.js → chunk-AC6N2EIN.js} +12 -11
  27. package/dist/{chunk-QQNPAZNP.js.map → chunk-AC6N2EIN.js.map} +1 -1
  28. package/dist/{chunk-YIODX4PM.js → chunk-AKGDIBSE.js} +2 -2
  29. package/dist/{chunk-HWP4NEYL.js → chunk-BCPH3SZM.js} +2 -2
  30. package/dist/{chunk-4P533364.js → chunk-BO3BNBBE.js} +7 -7
  31. package/dist/{chunk-KNYEQLIF.js → chunk-BURVDS7U.js} +2 -2
  32. package/dist/{chunk-MF6LDFDW.js → chunk-C224P3D3.js} +2 -2
  33. package/dist/{chunk-B3HIALTV.js → chunk-CGJGWALF.js} +2 -2
  34. package/dist/{chunk-CALBDLDJ.js → chunk-DHBKD2TG.js} +3 -3
  35. package/dist/{chunk-PIEYQBWL.js → chunk-EASMYJG3.js} +13 -12
  36. package/dist/chunk-EASMYJG3.js.map +1 -0
  37. package/dist/{chunk-EOETYHTD.js → chunk-FRCV6NWT.js} +2 -2
  38. package/dist/{chunk-GOHSGTR5.js → chunk-FXHTSSV2.js} +3 -3
  39. package/dist/{chunk-NER44YB7.js → chunk-FXIEYT6L.js} +8 -8
  40. package/dist/{chunk-WRUQPVTS.js → chunk-GDCTRDUY.js} +4 -4
  41. package/dist/{chunk-DRYY4BPY.js → chunk-I2TUJLI4.js} +5 -5
  42. package/dist/{chunk-IJ6YYFXY.js → chunk-IOSB2HMV.js} +3 -3
  43. package/dist/{chunk-S5RS4YZT.js → chunk-IZSMQ6X2.js} +67 -56
  44. package/dist/chunk-IZSMQ6X2.js.map +1 -0
  45. package/dist/{chunk-5EGGS6Y6.js → chunk-JCCGLFMU.js} +94 -56
  46. package/dist/chunk-JCCGLFMU.js.map +1 -0
  47. package/dist/{chunk-Y2HNFNCS.js → chunk-JCMGIW7G.js} +5 -3
  48. package/dist/chunk-JCMGIW7G.js.map +1 -0
  49. package/dist/{chunk-YV2MPIFG.js → chunk-JDW4GXEA.js} +4 -4
  50. package/dist/chunk-JUGSJ37Z.js +9 -0
  51. package/dist/{chunk-LMLVJEY7.js → chunk-L3JK6V5I.js} +2 -2
  52. package/dist/{chunk-T6YP6GPK.js → chunk-L7OQ7O4K.js} +3 -3
  53. package/dist/{chunk-WMOXIFBF.js → chunk-LYKWTHOD.js} +38 -10
  54. package/dist/chunk-LYKWTHOD.js.map +1 -0
  55. package/dist/{chunk-KPGO5VFR.js → chunk-M2TQNGMD.js} +5 -5
  56. package/dist/{chunk-Y33WKESH.js → chunk-MAFJE26N.js} +2 -2
  57. package/dist/{chunk-CIAXJC5H.js → chunk-MM32YZT6.js} +4 -4
  58. package/dist/{chunk-OB63GDEC.js → chunk-OESAI3XS.js} +2 -2
  59. package/dist/{chunk-722K7XWW.js → chunk-PLOO7NQU.js} +4 -4
  60. package/dist/{chunk-DMUZIBPM.js → chunk-R2SR3PER.js} +10 -4
  61. package/dist/chunk-R2SR3PER.js.map +1 -0
  62. package/dist/{chunk-B2Q5BYOD.js → chunk-R7334LAS.js} +5 -5
  63. package/dist/{chunk-NM4SABMQ.js → chunk-RFQRVXFQ.js} +529 -424
  64. package/dist/chunk-RFQRVXFQ.js.map +1 -0
  65. package/dist/{chunk-U3NYRIFH.js → chunk-S4ILKUFN.js} +13 -3
  66. package/dist/{chunk-U3NYRIFH.js.map → chunk-S4ILKUFN.js.map} +1 -1
  67. package/dist/{chunk-H7KH5CDM.js → chunk-SBRHGEFP.js} +3 -3
  68. package/dist/{chunk-CGMFZOS5.js → chunk-VES42DOD.js} +236 -81
  69. package/dist/chunk-VES42DOD.js.map +1 -0
  70. package/dist/chunk-VGQV4LX7.js +33 -0
  71. package/dist/chunk-VGQV4LX7.js.map +1 -0
  72. package/dist/{chunk-OBFHGN7Q.js → chunk-WOAFMVKW.js} +2 -2
  73. package/dist/{chunk-TKL4B2OI.js → chunk-WUJJ2FTK.js} +8 -4
  74. package/dist/chunk-WUJJ2FTK.js.map +1 -0
  75. package/dist/{chunk-CFO2JMKW.js → chunk-XEIREYW6.js} +29 -25
  76. package/dist/chunk-XEIREYW6.js.map +1 -0
  77. package/dist/{chunk-QDKLIYGR.js → chunk-XZ5DA5X4.js} +14 -3
  78. package/dist/{chunk-QDKLIYGR.js.map → chunk-XZ5DA5X4.js.map} +1 -1
  79. package/dist/{chunk-TBOE7DG5.js → chunk-YDYHURVA.js} +2 -2
  80. package/dist/{chunk-75I3DHVU.js → chunk-ZFSV65M5.js} +3 -3
  81. package/dist/{chunk-RFE4EBUP.js → chunk-ZHKE637Q.js} +3 -3
  82. package/dist/{cleanup-Q6AQXSRS.js → cleanup-7VJ4KUMR.js} +28 -27
  83. package/dist/{cleanup-Q6AQXSRS.js.map → cleanup-7VJ4KUMR.js.map} +1 -1
  84. package/dist/cli-RFG23HUW.js +18 -0
  85. package/dist/{command-hook-installer-2ZFJJGKY.js → command-hook-installer-PTTVCWH7.js} +4 -4
  86. package/dist/{config-DOPH6NOU.js → config-CREG6OI3.js} +9 -9
  87. package/dist/{diff-DZJLSTRO.js → diff-UYXZID2B.js} +12 -12
  88. package/dist/{digest-QTNPN2E6.js → digest-I5Z6W2EP.js} +10 -10
  89. package/dist/{fork-HDJ54HH2.js → fork-5AOB45N2.js} +26 -25
  90. package/dist/{fork-HDJ54HH2.js.map → fork-5AOB45N2.js.map} +1 -1
  91. package/dist/history-3LFLB4FO.js +55 -0
  92. package/dist/{hook-V7JNOY2E.js → hook-SJOCXGLD.js} +14 -14
  93. package/dist/{hydrate-NGZ26R2Y.js → hydrate-YEJCVZZ7.js} +29 -12
  94. package/dist/hydrate-YEJCVZZ7.js.map +1 -0
  95. package/dist/{init-BQIBLPP5.js → init-6F67TVM7.js} +9 -9
  96. package/dist/{install-skills-LCXJIHK4.js → install-skills-ESCNSPBY.js} +4 -4
  97. package/dist/install-skills-bin.js +3 -3
  98. package/dist/{list-4KATUVO3.js → list-NHZUEVTA.js} +32 -12
  99. package/dist/list-NHZUEVTA.js.map +1 -0
  100. package/dist/{move-LYO5J2ZH.js → move-JICK4XA5.js} +25 -23
  101. package/dist/{move-LYO5J2ZH.js.map → move-JICK4XA5.js.map} +1 -1
  102. package/dist/{note-7XR4YA6R.js → note-KZMWEGZP.js} +11 -11
  103. package/dist/{overlaps-5WKQT3LX.js → overlaps-O353DOQI.js} +9 -9
  104. package/dist/{pin-GJM3KSG7.js → pin-7CON36HF.js} +11 -11
  105. package/dist/{pr-YO7XSYUA.js → pr-4KUGJDZ2.js} +14 -14
  106. package/dist/{prune-BUGPJLLO.js → prune-KQ77276H.js} +27 -26
  107. package/dist/{prune-BUGPJLLO.js.map → prune-KQ77276H.js.map} +1 -1
  108. package/dist/{pty-host-O5H4FKWF.js → pty-host-MSCJGN5G.js} +10 -10
  109. package/dist/{read-XMU63E3F.js → read-J42H6OVE.js} +10 -10
  110. package/dist/{recent-73SHXIFU.js → recent-BZQP3RKA.js} +10 -10
  111. package/dist/recent-BZQP3RKA.js.map +1 -0
  112. package/dist/{remove-ZXDVVOHF.js → remove-GRRKSGS7.js} +28 -27
  113. package/dist/{remove-ZXDVVOHF.js.map → remove-GRRKSGS7.js.map} +1 -1
  114. package/dist/report-BSETCIYQ.js +18 -0
  115. package/dist/{restart-S4D7LD3A.js → restart-REFEZGH2.js} +11 -11
  116. package/dist/{resume-YIIQIJCS.js → resume-RGP2BCKL.js} +10 -10
  117. package/dist/resume-RGP2BCKL.js.map +1 -0
  118. package/dist/{run-WN2O7EX7.js → run-WYDFP6EL.js} +7 -7
  119. package/dist/{screen-LX6XHNYN.js → screen-YWJLDINC.js} +11 -11
  120. package/dist/{search-DCDJVBKW.js → search-M4DU4GUB.js} +7 -7
  121. package/dist/{section-XD46IHMW.js → section-AYN6EHPO.js} +11 -11
  122. package/dist/{send-P4NILVGL.js → send-O3SI53O7.js} +16 -16
  123. package/dist/{sessions-POSS5NRV.js → sessions-4BASM7AC.js} +20 -20
  124. package/dist/{snooze-ONAR2WNP.js → snooze-F3NT7PZO.js} +10 -10
  125. package/dist/{start-6YKHYYX5.js → start-7OQNLGDU.js} +11 -11
  126. package/dist/{state-NV4FQNMT.js → state-NRK5CBXZ.js} +5 -5
  127. package/dist/{status-KYRZRITO.js → status-HLOEWXJ3.js} +8 -8
  128. package/dist/{stop-QU372WAY.js → stop-YRGANOU7.js} +11 -11
  129. package/dist/{sync-JR24WVJ7.js → sync-YDK5R7XQ.js} +27 -26
  130. package/dist/{sync-JR24WVJ7.js.map → sync-YDK5R7XQ.js.map} +1 -1
  131. package/dist/{time-FYXXC5XC.js → time-T5RBWMDN.js} +12 -12
  132. package/dist/time-actions-FLLFYEVY.js +15 -0
  133. package/dist/time-actions-FLLFYEVY.js.map +1 -0
  134. package/dist/{timesheet-57EG6ABE.js → timesheet-UB6OASXF.js} +14 -14
  135. package/dist/{todo-UDYY4QTY.js → todo-OE62TNES.js} +6 -6
  136. package/dist/{tree-RDPJOIDT.js → tree-DRDDTXQ2.js} +42 -24
  137. package/dist/tree-DRDDTXQ2.js.map +1 -0
  138. package/dist/{update-OZXFQMYI.js → update-S57YQGPG.js} +13 -13
  139. package/dist/{wait-3MQST3FP.js → wait-2CRY7XQ5.js} +11 -11
  140. package/dist/wd-bin.js +9 -9
  141. package/dist/web/assets/{PtyView-CVskPWtH.js → PtyView-BZ57sEm1.js} +2 -2
  142. package/dist/web/assets/{PtyView-CVskPWtH.js.map → PtyView-BZ57sEm1.js.map} +1 -1
  143. package/dist/web/assets/index-CDYWfNo_.css +1 -0
  144. package/dist/web/assets/index-CqTf1VAm.js +119 -0
  145. package/dist/web/assets/index-CqTf1VAm.js.map +1 -0
  146. package/dist/web/index.html +2 -2
  147. package/dist/{web-GYU324DV.js → web-A3VW2IYG.js} +471 -298
  148. package/dist/web-A3VW2IYG.js.map +1 -0
  149. package/npm-shrinkwrap.json +2 -2
  150. package/package.json +1 -1
  151. package/dist/chunk-5EGGS6Y6.js.map +0 -1
  152. package/dist/chunk-72IRO7WA.js +0 -9
  153. package/dist/chunk-CFO2JMKW.js.map +0 -1
  154. package/dist/chunk-CGMFZOS5.js.map +0 -1
  155. package/dist/chunk-DMUZIBPM.js.map +0 -1
  156. package/dist/chunk-HWIRY3WO.js.map +0 -1
  157. package/dist/chunk-MEK7BIVS.js.map +0 -1
  158. package/dist/chunk-NM4SABMQ.js.map +0 -1
  159. package/dist/chunk-PIEYQBWL.js.map +0 -1
  160. package/dist/chunk-ROLNJOSE.js.map +0 -1
  161. package/dist/chunk-S5RS4YZT.js.map +0 -1
  162. package/dist/chunk-TKL4B2OI.js.map +0 -1
  163. package/dist/chunk-WMOXIFBF.js.map +0 -1
  164. package/dist/chunk-Y2HNFNCS.js.map +0 -1
  165. package/dist/cli-5PNLG3YH.js +0 -18
  166. package/dist/hydrate-NGZ26R2Y.js.map +0 -1
  167. package/dist/list-4KATUVO3.js.map +0 -1
  168. package/dist/recent-73SHXIFU.js.map +0 -1
  169. package/dist/report-TEIRRYH4.js +0 -16
  170. package/dist/resume-YIIQIJCS.js.map +0 -1
  171. package/dist/time-actions-L3OWQHEX.js +0 -15
  172. package/dist/tree-RDPJOIDT.js.map +0 -1
  173. package/dist/web/assets/index-CqY-C3y-.js +0 -119
  174. package/dist/web/assets/index-CqY-C3y-.js.map +0 -1
  175. package/dist/web/assets/index-YbJdcXjZ.css +0 -1
  176. package/dist/web-GYU324DV.js.map +0 -1
  177. /package/dist/{answer-UWI22VOE.js.map → answer-OA2WTJCZ.js.map} +0 -0
  178. /package/dist/{attach-HYHEXW5J.js.map → attach-5GXPA7BV.js.map} +0 -0
  179. /package/dist/{block-A25XE7HC.js.map → block-VINEC2MW.js.map} +0 -0
  180. /package/dist/{broadcast-AG7P5BKQ.js.map → broadcast-ENAJDNVU.js.map} +0 -0
  181. /package/dist/{catchup-VTGG7BAR.js.map → catchup-NC4WHSBF.js.map} +0 -0
  182. /package/dist/{chunk-XDBMLTFY.js.map → chunk-3HBHM2VX.js.map} +0 -0
  183. /package/dist/{chunk-7OBX4MJY.js.map → chunk-3KOYICWB.js.map} +0 -0
  184. /package/dist/{chunk-ZSXMIPU4.js.map → chunk-3Q6S6TRY.js.map} +0 -0
  185. /package/dist/{chunk-3D63HGOG.js.map → chunk-4ETSGWB2.js.map} +0 -0
  186. /package/dist/{chunk-IVPV6VPW.js.map → chunk-4VNUU6S6.js.map} +0 -0
  187. /package/dist/{chunk-7W6I4VXA.js.map → chunk-65YMLGQB.js.map} +0 -0
  188. /package/dist/{chunk-C3E7XETB.js.map → chunk-6KM2C2UO.js.map} +0 -0
  189. /package/dist/{chunk-R5QLAXNJ.js.map → chunk-6SJOM62D.js.map} +0 -0
  190. /package/dist/{chunk-YIODX4PM.js.map → chunk-AKGDIBSE.js.map} +0 -0
  191. /package/dist/{chunk-HWP4NEYL.js.map → chunk-BCPH3SZM.js.map} +0 -0
  192. /package/dist/{chunk-4P533364.js.map → chunk-BO3BNBBE.js.map} +0 -0
  193. /package/dist/{chunk-KNYEQLIF.js.map → chunk-BURVDS7U.js.map} +0 -0
  194. /package/dist/{chunk-MF6LDFDW.js.map → chunk-C224P3D3.js.map} +0 -0
  195. /package/dist/{chunk-B3HIALTV.js.map → chunk-CGJGWALF.js.map} +0 -0
  196. /package/dist/{chunk-CALBDLDJ.js.map → chunk-DHBKD2TG.js.map} +0 -0
  197. /package/dist/{chunk-EOETYHTD.js.map → chunk-FRCV6NWT.js.map} +0 -0
  198. /package/dist/{chunk-GOHSGTR5.js.map → chunk-FXHTSSV2.js.map} +0 -0
  199. /package/dist/{chunk-NER44YB7.js.map → chunk-FXIEYT6L.js.map} +0 -0
  200. /package/dist/{chunk-WRUQPVTS.js.map → chunk-GDCTRDUY.js.map} +0 -0
  201. /package/dist/{chunk-DRYY4BPY.js.map → chunk-I2TUJLI4.js.map} +0 -0
  202. /package/dist/{chunk-IJ6YYFXY.js.map → chunk-IOSB2HMV.js.map} +0 -0
  203. /package/dist/{chunk-YV2MPIFG.js.map → chunk-JDW4GXEA.js.map} +0 -0
  204. /package/dist/{chunk-72IRO7WA.js.map → chunk-JUGSJ37Z.js.map} +0 -0
  205. /package/dist/{chunk-LMLVJEY7.js.map → chunk-L3JK6V5I.js.map} +0 -0
  206. /package/dist/{chunk-T6YP6GPK.js.map → chunk-L7OQ7O4K.js.map} +0 -0
  207. /package/dist/{chunk-KPGO5VFR.js.map → chunk-M2TQNGMD.js.map} +0 -0
  208. /package/dist/{chunk-Y33WKESH.js.map → chunk-MAFJE26N.js.map} +0 -0
  209. /package/dist/{chunk-CIAXJC5H.js.map → chunk-MM32YZT6.js.map} +0 -0
  210. /package/dist/{chunk-OB63GDEC.js.map → chunk-OESAI3XS.js.map} +0 -0
  211. /package/dist/{chunk-722K7XWW.js.map → chunk-PLOO7NQU.js.map} +0 -0
  212. /package/dist/{chunk-B2Q5BYOD.js.map → chunk-R7334LAS.js.map} +0 -0
  213. /package/dist/{chunk-H7KH5CDM.js.map → chunk-SBRHGEFP.js.map} +0 -0
  214. /package/dist/{chunk-OBFHGN7Q.js.map → chunk-WOAFMVKW.js.map} +0 -0
  215. /package/dist/{chunk-TBOE7DG5.js.map → chunk-YDYHURVA.js.map} +0 -0
  216. /package/dist/{chunk-75I3DHVU.js.map → chunk-ZFSV65M5.js.map} +0 -0
  217. /package/dist/{chunk-RFE4EBUP.js.map → chunk-ZHKE637Q.js.map} +0 -0
  218. /package/dist/{cli-5PNLG3YH.js.map → cli-RFG23HUW.js.map} +0 -0
  219. /package/dist/{command-hook-installer-2ZFJJGKY.js.map → command-hook-installer-PTTVCWH7.js.map} +0 -0
  220. /package/dist/{config-DOPH6NOU.js.map → config-CREG6OI3.js.map} +0 -0
  221. /package/dist/{diff-DZJLSTRO.js.map → diff-UYXZID2B.js.map} +0 -0
  222. /package/dist/{digest-QTNPN2E6.js.map → digest-I5Z6W2EP.js.map} +0 -0
  223. /package/dist/{install-skills-LCXJIHK4.js.map → history-3LFLB4FO.js.map} +0 -0
  224. /package/dist/{hook-V7JNOY2E.js.map → hook-SJOCXGLD.js.map} +0 -0
  225. /package/dist/{init-BQIBLPP5.js.map → init-6F67TVM7.js.map} +0 -0
  226. /package/dist/{report-TEIRRYH4.js.map → install-skills-ESCNSPBY.js.map} +0 -0
  227. /package/dist/{note-7XR4YA6R.js.map → note-KZMWEGZP.js.map} +0 -0
  228. /package/dist/{overlaps-5WKQT3LX.js.map → overlaps-O353DOQI.js.map} +0 -0
  229. /package/dist/{pin-GJM3KSG7.js.map → pin-7CON36HF.js.map} +0 -0
  230. /package/dist/{pr-YO7XSYUA.js.map → pr-4KUGJDZ2.js.map} +0 -0
  231. /package/dist/{pty-host-O5H4FKWF.js.map → pty-host-MSCJGN5G.js.map} +0 -0
  232. /package/dist/{read-XMU63E3F.js.map → read-J42H6OVE.js.map} +0 -0
  233. /package/dist/{time-actions-L3OWQHEX.js.map → report-BSETCIYQ.js.map} +0 -0
  234. /package/dist/{restart-S4D7LD3A.js.map → restart-REFEZGH2.js.map} +0 -0
  235. /package/dist/{run-WN2O7EX7.js.map → run-WYDFP6EL.js.map} +0 -0
  236. /package/dist/{screen-LX6XHNYN.js.map → screen-YWJLDINC.js.map} +0 -0
  237. /package/dist/{search-DCDJVBKW.js.map → search-M4DU4GUB.js.map} +0 -0
  238. /package/dist/{section-XD46IHMW.js.map → section-AYN6EHPO.js.map} +0 -0
  239. /package/dist/{send-P4NILVGL.js.map → send-O3SI53O7.js.map} +0 -0
  240. /package/dist/{sessions-POSS5NRV.js.map → sessions-4BASM7AC.js.map} +0 -0
  241. /package/dist/{snooze-ONAR2WNP.js.map → snooze-F3NT7PZO.js.map} +0 -0
  242. /package/dist/{start-6YKHYYX5.js.map → start-7OQNLGDU.js.map} +0 -0
  243. /package/dist/{state-NV4FQNMT.js.map → state-NRK5CBXZ.js.map} +0 -0
  244. /package/dist/{status-KYRZRITO.js.map → status-HLOEWXJ3.js.map} +0 -0
  245. /package/dist/{stop-QU372WAY.js.map → stop-YRGANOU7.js.map} +0 -0
  246. /package/dist/{time-FYXXC5XC.js.map → time-T5RBWMDN.js.map} +0 -0
  247. /package/dist/{timesheet-57EG6ABE.js.map → timesheet-UB6OASXF.js.map} +0 -0
  248. /package/dist/{todo-UDYY4QTY.js.map → todo-OE62TNES.js.map} +0 -0
  249. /package/dist/{update-OZXFQMYI.js.map → update-S57YQGPG.js.map} +0 -0
  250. /package/dist/{wait-3MQST3FP.js.map → wait-2CRY7XQ5.js.map} +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  killTree,
8
8
  processName,
9
9
  readJsonlTail
10
- } from "./chunk-Y2HNFNCS.js";
10
+ } from "./chunk-JCMGIW7G.js";
11
11
  import {
12
12
  spawn_default
13
13
  } from "./chunk-RCYI7SRA.js";
@@ -20,20 +20,24 @@ import {
20
20
  sessionIdFor,
21
21
  tx,
22
22
  withDb
23
- } from "./chunk-GOHSGTR5.js";
23
+ } from "./chunk-FXHTSSV2.js";
24
24
  import {
25
25
  report
26
- } from "./chunk-U3NYRIFH.js";
26
+ } from "./chunk-S4ILKUFN.js";
27
27
  import {
28
28
  debugLog
29
- } from "./chunk-EOETYHTD.js";
29
+ } from "./chunk-FRCV6NWT.js";
30
30
  import {
31
31
  atomicWriteFile,
32
32
  ensureFile,
33
33
  getConfigDir,
34
34
  loadConfig,
35
35
  withFileLock
36
- } from "./chunk-ROLNJOSE.js";
36
+ } from "./chunk-A53IRCOO.js";
37
+
38
+ // src/core/sessions/history.ts
39
+ import fs10 from "fs";
40
+ import path10 from "path";
37
41
 
38
42
  // src/core/sessions/session-activity.ts
39
43
  var ACTIVE_MS = 3e4;
@@ -57,6 +61,278 @@ function effectiveLastAccessedAt(session) {
57
61
  return new Date(Math.max(Number.isFinite(recorded) ? recorded : 0, lastConversationWriteMs(session))).toISOString();
58
62
  }
59
63
 
64
+ // src/core/worktree/port-allocator.ts
65
+ import fs from "fs";
66
+ import net from "net";
67
+ var DEFAULT_PORT_RANGE = { start: 3e3, end: 3099 };
68
+ var PortRangeExhaustedError = class extends Error {
69
+ start;
70
+ end;
71
+ constructor(start, end) {
72
+ super(
73
+ `No free dev-server port available in range ${start}-${end} (all ${end - start + 1} in use). Widen "portRange" in ~/.work/config.json.`
74
+ );
75
+ this.name = "PortRangeExhaustedError";
76
+ this.start = start;
77
+ this.end = end;
78
+ }
79
+ };
80
+ function hashString(input) {
81
+ let hash = 2166136261;
82
+ for (let i = 0; i < input.length; i++) {
83
+ hash ^= input.charCodeAt(i);
84
+ hash = Math.imul(hash, 16777619);
85
+ }
86
+ return hash >>> 0;
87
+ }
88
+ function normalizeRange(config) {
89
+ const range = config.portRange ?? DEFAULT_PORT_RANGE;
90
+ const start = Math.min(range.start, range.end);
91
+ const end = Math.max(range.start, range.end);
92
+ const rangeSize = end - start + 1;
93
+ if (rangeSize <= 0) {
94
+ throw new Error(`Invalid port range: ${range.start}-${range.end}`);
95
+ }
96
+ return { start, end, rangeSize };
97
+ }
98
+ function portsHeldByActiveSessions(sessions) {
99
+ const inUse = /* @__PURE__ */ new Set();
100
+ for (const session of sessions) {
101
+ if (session.port === void 0) continue;
102
+ const active = session.paths.some((p) => fs.existsSync(p));
103
+ if (active) inUse.add(session.port);
104
+ }
105
+ return inUse;
106
+ }
107
+ function isPortFree(port) {
108
+ return new Promise((resolve) => {
109
+ const server = net.createServer();
110
+ server.once("error", (err) => {
111
+ resolve(err.code !== "EADDRINUSE");
112
+ });
113
+ server.once("listening", () => {
114
+ server.close(() => resolve(true));
115
+ });
116
+ server.listen(port, "127.0.0.1");
117
+ });
118
+ }
119
+ async function allocateFreePort(seedKey, config, sessions, probe = isPortFree) {
120
+ const { start, end, rangeSize } = normalizeRange(config);
121
+ const inUse = portsHeldByActiveSessions(sessions);
122
+ const baseOffset = hashString(seedKey) % rangeSize;
123
+ for (let i = 0; i < rangeSize; i++) {
124
+ const candidate = start + (baseOffset + i) % rangeSize;
125
+ if (inUse.has(candidate)) continue;
126
+ if (await probe(candidate)) {
127
+ return candidate;
128
+ }
129
+ }
130
+ throw new PortRangeExhaustedError(start, end);
131
+ }
132
+
133
+ // src/core/sessions/session-store.ts
134
+ import fs9 from "fs";
135
+
136
+ // src/core/api-types.ts
137
+ var ARCHIVED_BY = ["you", "shipped", "pr-merged", "cleanup"];
138
+
139
+ // src/core/archive/session-archive.ts
140
+ import fs4 from "fs";
141
+
142
+ // src/core/archive/archive-uncommitted.ts
143
+ import fs3 from "fs";
144
+ import path2 from "path";
145
+
146
+ // src/core/diff/git-tree-snapshot.ts
147
+ import fs2 from "fs";
148
+ import os from "os";
149
+ import path from "path";
150
+ import crypto from "crypto";
151
+ function writeTempTree(repoRoot, opts = {}) {
152
+ const steps = tempTreeSteps(repoRoot, opts.includeWorkingTree ?? true);
153
+ let next = steps.next();
154
+ while (!next.done) next = steps.next(runGitSync(repoRoot, next.value));
155
+ return next.value;
156
+ }
157
+ function writeTempTreeAsync(repoRoot, opts = {}) {
158
+ return inRepoQueue(repoRoot, async () => {
159
+ const steps = tempTreeSteps(repoRoot, opts.includeWorkingTree ?? true);
160
+ let next = steps.next();
161
+ while (!next.done) next = steps.next(await runGitAsync(repoRoot, next.value));
162
+ return next.value;
163
+ });
164
+ }
165
+ function* tempTreeSteps(repoRoot, includeWorkingTree) {
166
+ const tmpIndex = path.join(os.tmpdir(), `wd-tree-${process.pid}-${crypto.randomBytes(6).toString("hex")}.idx`);
167
+ const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
168
+ try {
169
+ const headSha = ((yield { args: ["rev-parse", "--verify", "HEAD"] }).stdout ?? "").trim() || null;
170
+ let seeded = false;
171
+ if (includeWorkingTree) {
172
+ const out = (yield { args: ["rev-parse", "--git-path", "index"] }).stdout;
173
+ if (seedIndexCopy(repoRoot, out, tmpIndex)) {
174
+ const listed = yield { args: ["ls-files", "-v"], env };
175
+ const flagged = listed.status !== 0 || (listed.stdout ?? "").split("\n").some((line) => {
176
+ const tag = line.charAt(0);
177
+ return tag === "S" || tag >= "a" && tag <= "z";
178
+ });
179
+ if (flagged) removeQuietly(tmpIndex);
180
+ else seeded = true;
181
+ }
182
+ }
183
+ if (!seeded && headSha) {
184
+ if ((yield { args: ["read-tree", "HEAD"], env }).status !== 0) return null;
185
+ }
186
+ if (includeWorkingTree) {
187
+ if ((yield { args: ["add", "-A"], env }).status !== 0) return null;
188
+ }
189
+ const wt = yield { args: ["write-tree"], env };
190
+ if (wt.status !== 0 || !wt.stdout) return null;
191
+ return { treeSha: wt.stdout.trim(), headSha };
192
+ } finally {
193
+ removeQuietly(tmpIndex);
194
+ }
195
+ }
196
+ function seedIndexCopy(repoRoot, gitPathOut, tmpIndex) {
197
+ try {
198
+ if (!gitPathOut) return false;
199
+ const realIndex = path.resolve(repoRoot, gitPathOut.trim());
200
+ if (!fs2.existsSync(realIndex)) return false;
201
+ fs2.copyFileSync(realIndex, tmpIndex);
202
+ const st = fs2.statSync(realIndex);
203
+ fs2.utimesSync(tmpIndex, st.atime, st.mtime);
204
+ return true;
205
+ } catch {
206
+ return false;
207
+ }
208
+ }
209
+ function removeQuietly(file) {
210
+ try {
211
+ if (fs2.existsSync(file)) fs2.unlinkSync(file);
212
+ } catch {
213
+ }
214
+ }
215
+ var GIT_MAX_BUFFER = 64 * 1024 * 1024;
216
+ function runGitSync(cwd, step) {
217
+ const r = spawn_default.sync("git", step.args, {
218
+ cwd,
219
+ encoding: "utf-8",
220
+ env: step.env ?? process.env,
221
+ windowsHide: true,
222
+ maxBuffer: GIT_MAX_BUFFER
223
+ });
224
+ return { status: r.status, stdout: r.stdout ?? "" };
225
+ }
226
+ function runGitAsync(cwd, step) {
227
+ return new Promise((resolve) => {
228
+ let stdout = "";
229
+ let size = 0;
230
+ let child;
231
+ try {
232
+ child = spawn_default("git", step.args, { cwd, env: step.env ?? process.env, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] });
233
+ } catch {
234
+ resolve({ status: null, stdout: "" });
235
+ return;
236
+ }
237
+ child.stdout?.setEncoding("utf-8");
238
+ child.stdout?.on("data", (d) => {
239
+ size += d.length;
240
+ if (size <= GIT_MAX_BUFFER) stdout += d;
241
+ });
242
+ child.on("error", () => resolve({ status: null, stdout: "" }));
243
+ child.on("close", (code) => resolve({ status: code, stdout }));
244
+ });
245
+ }
246
+ var repoQueues = /* @__PURE__ */ new Map();
247
+ function inRepoQueue(repoRoot, fn) {
248
+ const key = path.resolve(repoRoot).toLowerCase();
249
+ const prev = repoQueues.get(key) ?? Promise.resolve();
250
+ const run = prev.then(fn, fn);
251
+ const tail = run.catch(() => {
252
+ });
253
+ repoQueues.set(key, tail);
254
+ void tail.then(() => {
255
+ if (repoQueues.get(key) === tail) repoQueues.delete(key);
256
+ });
257
+ return run;
258
+ }
259
+
260
+ // src/core/archive/archive-uncommitted.ts
261
+ var MAX_SAVED_PATCH_BYTES = 50 * 1024 * 1024;
262
+ var safeName = (s) => s.replace(/[^A-Za-z0-9._-]/g, "_");
263
+ var archiveRefFor = (sessionId, repo, stamp) => `refs/work/archive/${safeName(sessionId)}/${safeName(repo)}/${stamp}`;
264
+ var archiveRefsPrefix = (sessionId) => `refs/work/archive/${safeName(sessionId)}/`;
265
+ var uncommittedDir = (archiveDir) => path2.join(archiveDir, "uncommitted");
266
+ var COMMIT_ENV = {
267
+ GIT_AUTHOR_NAME: "work",
268
+ GIT_AUTHOR_EMAIL: "work@local",
269
+ GIT_COMMITTER_NAME: "work",
270
+ GIT_COMMITTER_EMAIL: "work@local"
271
+ };
272
+ async function saveUncommitted(worktree, repo, ref, archiveDir, patchName = repo, maxBytes = MAX_SAVED_PATCH_BYTES) {
273
+ const status = await runGitAsync(worktree, { args: ["status", "--porcelain", "--untracked-files=all"] });
274
+ if (status.status !== 0) return { error: `git can't read ${repo}` };
275
+ const files = status.stdout.split("\n").filter((l) => l.trim()).length;
276
+ if (files === 0) return { clean: true };
277
+ const tree = await writeTempTreeAsync(worktree, { includeWorkingTree: true });
278
+ if (!tree?.headSha) return { error: `git couldn't snapshot ${repo}` };
279
+ const commit = await runGitAsync(worktree, {
280
+ args: ["commit-tree", tree.treeSha, "-p", tree.headSha, "-m", "work archive: uncommitted changes"],
281
+ env: { ...process.env, ...COMMIT_ENV }
282
+ });
283
+ const sha = commit.stdout.trim();
284
+ if (commit.status !== 0 || !sha) return { error: `git couldn't snapshot ${repo}` };
285
+ const dir = uncommittedDir(archiveDir);
286
+ fs3.mkdirSync(dir, { recursive: true });
287
+ const patch = `${safeName(patchName)}.patch`;
288
+ const patchPath = path2.join(dir, patch);
289
+ const diff = await runGitAsync(worktree, {
290
+ args: ["diff", "--binary", "--no-color", "--no-ext-diff", `--output=${patchPath}`, tree.headSha, sha]
291
+ });
292
+ const size = fs3.existsSync(patchPath) ? fs3.statSync(patchPath).size : 0;
293
+ if (diff.status !== 0 || size === 0) {
294
+ fs3.rmSync(patchPath, { force: true });
295
+ return { error: `git couldn't write ${repo}'s changes as a patch` };
296
+ }
297
+ if (size > maxBytes) {
298
+ fs3.rmSync(patchPath, { force: true });
299
+ return { error: `${repo}'s uncommitted changes are too large to keep (${Math.round(size / 1024 / 1024)} MB)` };
300
+ }
301
+ const pinned = await runGitAsync(worktree, { args: ["update-ref", ref, sha] });
302
+ if (pinned.status !== 0) {
303
+ fs3.rmSync(patchPath, { force: true });
304
+ return { error: `git couldn't keep ${repo}'s changes (update-ref)` };
305
+ }
306
+ return { saved: { commit: sha, base: tree.headSha, ref, files, patch } };
307
+ }
308
+ async function dropSaved(repoRoot, saved, archiveDir) {
309
+ await runGitAsync(repoRoot, { args: ["update-ref", "-d", saved.ref] });
310
+ fs3.rmSync(path2.join(uncommittedDir(archiveDir), saved.patch), { force: true });
311
+ }
312
+ async function restoreUncommitted(worktree, saved, archiveDir) {
313
+ const patchPath = path2.join(uncommittedDir(archiveDir), saved.patch);
314
+ const byHand = `the changes are kept in ${saved.ref} and ${patchPath}`;
315
+ if (!fs3.existsSync(patchPath)) return { ok: false, error: `its saved patch is missing (${patchPath})` };
316
+ const status = await runGitAsync(worktree, { args: ["status", "--porcelain", "--untracked-files=all"] });
317
+ if (status.status !== 0) return { ok: false, error: `git can't read the worktree; ${byHand}` };
318
+ if (status.stdout.trim()) return { ok: false, error: `the worktree already has changes, so they weren't mixed in; ${byHand}` };
319
+ const check = await runGitAsync(worktree, { args: ["apply", "--binary", "--check", patchPath] });
320
+ if (check.status !== 0) return { ok: false, error: `they no longer apply (the branch moved on); ${byHand}` };
321
+ const apply = await runGitAsync(worktree, { args: ["apply", "--binary", patchPath] });
322
+ if (apply.status !== 0) return { ok: false, error: `git apply failed; ${byHand}` };
323
+ await runGitAsync(worktree, { args: ["update-ref", "-d", saved.ref] });
324
+ return { ok: true };
325
+ }
326
+ function dropSessionSaves(repoRoot, sessionId) {
327
+ const refs = runGitSync(repoRoot, { args: ["for-each-ref", "--format=%(refname)", archiveRefsPrefix(sessionId)] });
328
+ for (const ref of refs.stdout.split("\n").map((l) => l.trim()).filter(Boolean))
329
+ runGitSync(repoRoot, { args: ["update-ref", "-d", ref] });
330
+ }
331
+ function isSavedUncommitted(x) {
332
+ const v = x;
333
+ return !!v && typeof v === "object" && typeof v.commit === "string" && typeof v.base === "string" && typeof v.ref === "string" && typeof v.patch === "string" && typeof v.files === "number";
334
+ }
335
+
60
336
  // src/core/platform/best-effort.ts
61
337
  function logSwallowed(label, err) {
62
338
  const e = err;
@@ -376,290 +652,85 @@ async function updateStatus(sessionId, fn) {
376
652
  return tx((d) => {
377
653
  const prev = readRow(d, sessionId);
378
654
  const next = fn(prev);
379
- if (next) {
380
- d.prepare("INSERT OR REPLACE INTO session_status (session_id, data) VALUES (?, ?)").run(sessionId, JSON.stringify(next));
381
- }
382
- return { prev, next };
383
- });
384
- }
385
- function recordStatusEvent(sessionId, event, now = /* @__PURE__ */ new Date()) {
386
- return updateStatus(sessionId, (prev) => ({
387
- ...applyStatusEvent(prev, event, now),
388
- // A Stop ends a turn even when no prompt hook said one began (a `!`
389
- // command, a background task's result): as far as notifying goes, it
390
- // was working — so you hear that it finished.
391
- prevState: event.kind === "stop" && prev?.state === "idle" ? "working" : prev?.state ?? null
392
- }));
393
- }
394
- function turnInProgress(s) {
395
- if (!s) return false;
396
- if (s.state === "working") return true;
397
- if (s.state !== "needs_input") return false;
398
- const ended = s.turnEndedAt ? Date.parse(s.turnEndedAt) : NaN;
399
- return !(ended >= Date.parse(s.since));
400
- }
401
- async function markSeen(sessionId) {
402
- const { next } = await updateStatus(
403
- sessionId,
404
- (prev) => prev && !prev.seen ? { ...prev, seen: true, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } : prev
405
- );
406
- return next;
407
- }
408
- function notifyKindForTransition(prev, next) {
409
- if (!next) return null;
410
- if (next.state === "needs_input" && prev?.state !== "needs_input") return "needs_input";
411
- if (next.state === "idle" && (prev?.state === "working" || prev?.state === "needs_input")) return "idle";
412
- return null;
413
- }
414
-
415
- // src/core/rail/snooze-store.ts
416
- function isSnooze(v) {
417
- const o = v;
418
- return !!o && typeof o === "object" && (o.until === null || typeof o.until === "string") && typeof o.at === "string";
419
- }
420
- function readSnooze(sessionId) {
421
- const row = withDb(
422
- (d) => d.prepare("SELECT data FROM session_snooze WHERE session_id = ?").get(sessionId)
423
- );
424
- const v = row ? json.parse(row.data) : null;
425
- return isSnooze(v) ? v : null;
426
- }
427
- function allSnoozes() {
428
- const rows2 = withDb((d) => d.prepare("SELECT session_id, data FROM session_snooze").all());
429
- const out = /* @__PURE__ */ new Map();
430
- for (const r of rows2) {
431
- const v = json.parse(r.data);
432
- if (isSnooze(v)) out.set(r.session_id, v);
433
- }
434
- return out;
435
- }
436
- function saveSnooze(sessionId, snooze) {
437
- withDb((d) => d.prepare("INSERT OR REPLACE INTO session_snooze (session_id, data) VALUES (?, ?)").run(sessionId, JSON.stringify(snooze)));
438
- }
439
- function clearSnooze(sessionId) {
440
- return withDb((d) => d.prepare("DELETE FROM session_snooze WHERE session_id = ?").run(sessionId).changes > 0);
441
- }
442
- function cleanSnoozeRequest(raw) {
443
- const o = raw;
444
- if (!o || typeof o !== "object") return null;
445
- if (o.for === "2h" || o.for === "tomorrow" || o.for === "change") return { for: o.for };
446
- if (typeof o.until === "string" && o.until) return { until: o.until };
447
- return null;
448
- }
449
- function requestSnooze(sessionId, req, shown = {}, now = /* @__PURE__ */ new Date()) {
450
- const snooze = "until" in req ? snoozeUntil(req.until, now) : snoozeFor(
451
- req.for,
452
- { attention: readStatus(sessionId), openReviewThreads: shown.openReviewThreads ?? 0, prStage: shown.prStage },
453
- now
454
- );
455
- if (!snooze) return { ok: false, error: "not a time to snooze until: give one in the next 30 days" };
456
- saveSnooze(sessionId, snooze);
457
- return { ok: true, snooze };
458
- }
459
-
460
- // src/core/conversations/conversation-store.ts
461
- import fs4 from "fs";
462
- import path4 from "path";
463
- import zlib2 from "zlib";
464
-
465
- // src/core/api-types.ts
466
- var ARCHIVED_BY = ["you", "shipped", "pr-merged", "cleanup"];
467
-
468
- // src/core/archive/session-archive.ts
469
- import fs3 from "fs";
470
-
471
- // src/core/archive/archive-uncommitted.ts
472
- import fs2 from "fs";
473
- import path2 from "path";
474
-
475
- // src/core/diff/git-tree-snapshot.ts
476
- import fs from "fs";
477
- import os from "os";
478
- import path from "path";
479
- import crypto from "crypto";
480
- function writeTempTree(repoRoot, opts = {}) {
481
- const steps = tempTreeSteps(repoRoot, opts.includeWorkingTree ?? true);
482
- let next = steps.next();
483
- while (!next.done) next = steps.next(runGitSync(repoRoot, next.value));
484
- return next.value;
485
- }
486
- function writeTempTreeAsync(repoRoot, opts = {}) {
487
- return inRepoQueue(repoRoot, async () => {
488
- const steps = tempTreeSteps(repoRoot, opts.includeWorkingTree ?? true);
489
- let next = steps.next();
490
- while (!next.done) next = steps.next(await runGitAsync(repoRoot, next.value));
491
- return next.value;
492
- });
493
- }
494
- function* tempTreeSteps(repoRoot, includeWorkingTree) {
495
- const tmpIndex = path.join(os.tmpdir(), `wd-tree-${process.pid}-${crypto.randomBytes(6).toString("hex")}.idx`);
496
- const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
497
- try {
498
- const headSha = ((yield { args: ["rev-parse", "--verify", "HEAD"] }).stdout ?? "").trim() || null;
499
- let seeded = false;
500
- if (includeWorkingTree) {
501
- const out = (yield { args: ["rev-parse", "--git-path", "index"] }).stdout;
502
- if (seedIndexCopy(repoRoot, out, tmpIndex)) {
503
- const listed = yield { args: ["ls-files", "-v"], env };
504
- const flagged = listed.status !== 0 || (listed.stdout ?? "").split("\n").some((line) => {
505
- const tag = line.charAt(0);
506
- return tag === "S" || tag >= "a" && tag <= "z";
507
- });
508
- if (flagged) removeQuietly(tmpIndex);
509
- else seeded = true;
510
- }
511
- }
512
- if (!seeded && headSha) {
513
- if ((yield { args: ["read-tree", "HEAD"], env }).status !== 0) return null;
514
- }
515
- if (includeWorkingTree) {
516
- if ((yield { args: ["add", "-A"], env }).status !== 0) return null;
517
- }
518
- const wt = yield { args: ["write-tree"], env };
519
- if (wt.status !== 0 || !wt.stdout) return null;
520
- return { treeSha: wt.stdout.trim(), headSha };
521
- } finally {
522
- removeQuietly(tmpIndex);
523
- }
524
- }
525
- function seedIndexCopy(repoRoot, gitPathOut, tmpIndex) {
526
- try {
527
- if (!gitPathOut) return false;
528
- const realIndex = path.resolve(repoRoot, gitPathOut.trim());
529
- if (!fs.existsSync(realIndex)) return false;
530
- fs.copyFileSync(realIndex, tmpIndex);
531
- const st = fs.statSync(realIndex);
532
- fs.utimesSync(tmpIndex, st.atime, st.mtime);
533
- return true;
534
- } catch {
535
- return false;
536
- }
537
- }
538
- function removeQuietly(file) {
539
- try {
540
- if (fs.existsSync(file)) fs.unlinkSync(file);
541
- } catch {
542
- }
543
- }
544
- var GIT_MAX_BUFFER = 64 * 1024 * 1024;
545
- function runGitSync(cwd, step) {
546
- const r = spawn_default.sync("git", step.args, {
547
- cwd,
548
- encoding: "utf-8",
549
- env: step.env ?? process.env,
550
- windowsHide: true,
551
- maxBuffer: GIT_MAX_BUFFER
552
- });
553
- return { status: r.status, stdout: r.stdout ?? "" };
554
- }
555
- function runGitAsync(cwd, step) {
556
- return new Promise((resolve) => {
557
- let stdout = "";
558
- let size = 0;
559
- let child;
560
- try {
561
- child = spawn_default("git", step.args, { cwd, env: step.env ?? process.env, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] });
562
- } catch {
563
- resolve({ status: null, stdout: "" });
564
- return;
565
- }
566
- child.stdout?.setEncoding("utf-8");
567
- child.stdout?.on("data", (d) => {
568
- size += d.length;
569
- if (size <= GIT_MAX_BUFFER) stdout += d;
570
- });
571
- child.on("error", () => resolve({ status: null, stdout: "" }));
572
- child.on("close", (code) => resolve({ status: code, stdout }));
655
+ if (next) {
656
+ d.prepare("INSERT OR REPLACE INTO session_status (session_id, data) VALUES (?, ?)").run(sessionId, JSON.stringify(next));
657
+ }
658
+ return { prev, next };
573
659
  });
574
660
  }
575
- var repoQueues = /* @__PURE__ */ new Map();
576
- function inRepoQueue(repoRoot, fn) {
577
- const key = path.resolve(repoRoot).toLowerCase();
578
- const prev = repoQueues.get(key) ?? Promise.resolve();
579
- const run = prev.then(fn, fn);
580
- const tail = run.catch(() => {
581
- });
582
- repoQueues.set(key, tail);
583
- void tail.then(() => {
584
- if (repoQueues.get(key) === tail) repoQueues.delete(key);
585
- });
586
- return run;
661
+ function recordStatusEvent(sessionId, event, now = /* @__PURE__ */ new Date()) {
662
+ return updateStatus(sessionId, (prev) => ({
663
+ ...applyStatusEvent(prev, event, now),
664
+ // A Stop ends a turn even when no prompt hook said one began (a `!`
665
+ // command, a background task's result): as far as notifying goes, it
666
+ // was working — so you hear that it finished.
667
+ prevState: event.kind === "stop" && prev?.state === "idle" ? "working" : prev?.state ?? null
668
+ }));
669
+ }
670
+ function turnInProgress(s) {
671
+ if (!s) return false;
672
+ if (s.state === "working") return true;
673
+ if (s.state !== "needs_input") return false;
674
+ const ended = s.turnEndedAt ? Date.parse(s.turnEndedAt) : NaN;
675
+ return !(ended >= Date.parse(s.since));
676
+ }
677
+ async function markSeen(sessionId) {
678
+ const { next } = await updateStatus(
679
+ sessionId,
680
+ (prev) => prev && !prev.seen ? { ...prev, seen: true, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } : prev
681
+ );
682
+ return next;
683
+ }
684
+ function notifyKindForTransition(prev, next) {
685
+ if (!next) return null;
686
+ if (next.state === "needs_input" && prev?.state !== "needs_input") return "needs_input";
687
+ if (next.state === "idle" && (prev?.state === "working" || prev?.state === "needs_input")) return "idle";
688
+ return null;
587
689
  }
588
690
 
589
- // src/core/archive/archive-uncommitted.ts
590
- var MAX_SAVED_PATCH_BYTES = 50 * 1024 * 1024;
591
- var safeName = (s) => s.replace(/[^A-Za-z0-9._-]/g, "_");
592
- var archiveRefFor = (sessionId, repo, stamp) => `refs/work/archive/${safeName(sessionId)}/${safeName(repo)}/${stamp}`;
593
- var archiveRefsPrefix = (sessionId) => `refs/work/archive/${safeName(sessionId)}/`;
594
- var uncommittedDir = (archiveDir) => path2.join(archiveDir, "uncommitted");
595
- var COMMIT_ENV = {
596
- GIT_AUTHOR_NAME: "work",
597
- GIT_AUTHOR_EMAIL: "work@local",
598
- GIT_COMMITTER_NAME: "work",
599
- GIT_COMMITTER_EMAIL: "work@local"
600
- };
601
- async function saveUncommitted(worktree, repo, ref, archiveDir, patchName = repo, maxBytes = MAX_SAVED_PATCH_BYTES) {
602
- const status = await runGitAsync(worktree, { args: ["status", "--porcelain", "--untracked-files=all"] });
603
- if (status.status !== 0) return { error: `git can't read ${repo}` };
604
- const files = status.stdout.split("\n").filter((l) => l.trim()).length;
605
- if (files === 0) return { clean: true };
606
- const tree = await writeTempTreeAsync(worktree, { includeWorkingTree: true });
607
- if (!tree?.headSha) return { error: `git couldn't snapshot ${repo}` };
608
- const commit = await runGitAsync(worktree, {
609
- args: ["commit-tree", tree.treeSha, "-p", tree.headSha, "-m", "work archive: uncommitted changes"],
610
- env: { ...process.env, ...COMMIT_ENV }
611
- });
612
- const sha = commit.stdout.trim();
613
- if (commit.status !== 0 || !sha) return { error: `git couldn't snapshot ${repo}` };
614
- const dir = uncommittedDir(archiveDir);
615
- fs2.mkdirSync(dir, { recursive: true });
616
- const patch = `${safeName(patchName)}.patch`;
617
- const patchPath = path2.join(dir, patch);
618
- const diff = await runGitAsync(worktree, {
619
- args: ["diff", "--binary", "--no-color", "--no-ext-diff", `--output=${patchPath}`, tree.headSha, sha]
620
- });
621
- const size = fs2.existsSync(patchPath) ? fs2.statSync(patchPath).size : 0;
622
- if (diff.status !== 0 || size === 0) {
623
- fs2.rmSync(patchPath, { force: true });
624
- return { error: `git couldn't write ${repo}'s changes as a patch` };
625
- }
626
- if (size > maxBytes) {
627
- fs2.rmSync(patchPath, { force: true });
628
- return { error: `${repo}'s uncommitted changes are too large to keep (${Math.round(size / 1024 / 1024)} MB)` };
629
- }
630
- const pinned = await runGitAsync(worktree, { args: ["update-ref", ref, sha] });
631
- if (pinned.status !== 0) {
632
- fs2.rmSync(patchPath, { force: true });
633
- return { error: `git couldn't keep ${repo}'s changes (update-ref)` };
691
+ // src/core/rail/snooze-store.ts
692
+ function isSnooze(v) {
693
+ const o = v;
694
+ return !!o && typeof o === "object" && (o.until === null || typeof o.until === "string") && typeof o.at === "string";
695
+ }
696
+ function readSnooze(sessionId) {
697
+ const row = withDb(
698
+ (d) => d.prepare("SELECT data FROM session_snooze WHERE session_id = ?").get(sessionId)
699
+ );
700
+ const v = row ? json.parse(row.data) : null;
701
+ return isSnooze(v) ? v : null;
702
+ }
703
+ function allSnoozes() {
704
+ const rows2 = withDb((d) => d.prepare("SELECT session_id, data FROM session_snooze").all());
705
+ const out = /* @__PURE__ */ new Map();
706
+ for (const r of rows2) {
707
+ const v = json.parse(r.data);
708
+ if (isSnooze(v)) out.set(r.session_id, v);
634
709
  }
635
- return { saved: { commit: sha, base: tree.headSha, ref, files, patch } };
710
+ return out;
636
711
  }
637
- async function dropSaved(repoRoot, saved, archiveDir) {
638
- await runGitAsync(repoRoot, { args: ["update-ref", "-d", saved.ref] });
639
- fs2.rmSync(path2.join(uncommittedDir(archiveDir), saved.patch), { force: true });
712
+ function saveSnooze(sessionId, snooze) {
713
+ withDb((d) => d.prepare("INSERT OR REPLACE INTO session_snooze (session_id, data) VALUES (?, ?)").run(sessionId, JSON.stringify(snooze)));
640
714
  }
641
- async function restoreUncommitted(worktree, saved, archiveDir) {
642
- const patchPath = path2.join(uncommittedDir(archiveDir), saved.patch);
643
- const byHand = `the changes are kept in ${saved.ref} and ${patchPath}`;
644
- if (!fs2.existsSync(patchPath)) return { ok: false, error: `its saved patch is missing (${patchPath})` };
645
- const status = await runGitAsync(worktree, { args: ["status", "--porcelain", "--untracked-files=all"] });
646
- if (status.status !== 0) return { ok: false, error: `git can't read the worktree; ${byHand}` };
647
- if (status.stdout.trim()) return { ok: false, error: `the worktree already has changes, so they weren't mixed in; ${byHand}` };
648
- const check = await runGitAsync(worktree, { args: ["apply", "--binary", "--check", patchPath] });
649
- if (check.status !== 0) return { ok: false, error: `they no longer apply (the branch moved on); ${byHand}` };
650
- const apply = await runGitAsync(worktree, { args: ["apply", "--binary", patchPath] });
651
- if (apply.status !== 0) return { ok: false, error: `git apply failed; ${byHand}` };
652
- await runGitAsync(worktree, { args: ["update-ref", "-d", saved.ref] });
653
- return { ok: true };
715
+ function clearSnooze(sessionId) {
716
+ return withDb((d) => d.prepare("DELETE FROM session_snooze WHERE session_id = ?").run(sessionId).changes > 0);
654
717
  }
655
- function dropSessionSaves(repoRoot, sessionId) {
656
- const refs = runGitSync(repoRoot, { args: ["for-each-ref", "--format=%(refname)", archiveRefsPrefix(sessionId)] });
657
- for (const ref of refs.stdout.split("\n").map((l) => l.trim()).filter(Boolean))
658
- runGitSync(repoRoot, { args: ["update-ref", "-d", ref] });
718
+ function cleanSnoozeRequest(raw) {
719
+ const o = raw;
720
+ if (!o || typeof o !== "object") return null;
721
+ if (o.for === "2h" || o.for === "tomorrow" || o.for === "change") return { for: o.for };
722
+ if (typeof o.until === "string" && o.until) return { until: o.until };
723
+ return null;
659
724
  }
660
- function isSavedUncommitted(x) {
661
- const v = x;
662
- return !!v && typeof v === "object" && typeof v.commit === "string" && typeof v.base === "string" && typeof v.ref === "string" && typeof v.patch === "string" && typeof v.files === "number";
725
+ function requestSnooze(sessionId, req, shown = {}, now = /* @__PURE__ */ new Date()) {
726
+ const snooze = "until" in req ? snoozeUntil(req.until, now) : snoozeFor(
727
+ req.for,
728
+ { attention: readStatus(sessionId), openReviewThreads: shown.openReviewThreads ?? 0, prStage: shown.prStage },
729
+ now
730
+ );
731
+ if (!snooze) return { ok: false, error: "not a time to snooze until: give one in the next 30 days" };
732
+ saveSnooze(sessionId, snooze);
733
+ return { ok: true, snooze };
663
734
  }
664
735
 
665
736
  // src/core/archive/archiving.ts
@@ -858,10 +929,10 @@ async function archiveSteps(s, deps, opts) {
858
929
  const toEntries = agentOf(s).conversation?.entries ?? (() => []);
859
930
  const entries = [];
860
931
  try {
861
- fs3.mkdirSync(path3.join(dir, "transcripts"), { recursive: true });
932
+ fs4.mkdirSync(path3.join(dir, "transcripts"), { recursive: true });
862
933
  for (const file of deps.transcripts(s)) {
863
934
  const name = path3.basename(file);
864
- fs3.copyFileSync(file, path3.join(dir, "transcripts", name));
935
+ fs4.copyFileSync(file, path3.join(dir, "transcripts", name));
865
936
  copied.push({ file: name, projectDir: path3.basename(path3.dirname(file)) });
866
937
  entries.push(toEntries(readJsonlTail(file, 64 * 1024 * 1024)));
867
938
  }
@@ -888,11 +959,11 @@ async function archiveSteps(s, deps, opts) {
888
959
  const runningThere = verdict.ok && opts.unattended ? await deps.runningFrom?.(s).catch(() => ["(couldn't tell: the process list didn't answer)"]) ?? [] : [];
889
960
  if (verdict.ok && runningThere.length === 0) {
890
961
  if (!opts.unattended) stopped = await deps.stopRunningFrom?.(s).catch(() => []) ?? [];
891
- fs3.rmSync(ignoredDir, { recursive: true, force: true });
962
+ fs4.rmSync(ignoredDir, { recursive: true, force: true });
892
963
  ignored = deps.saveIgnored ? await deps.saveIgnored(s, dir).catch(() => ({})) : {};
893
964
  worktreeRemoved = await deps.removeWorktree(s);
894
965
  leftovers = worktreeRemoved ? [] : deps.halfRemoved?.(s) ?? [];
895
- if (leftovers.length && s.paths.every((p) => leftovers.includes(p) || !fs3.existsSync(p))) worktreeRemoved = true;
966
+ if (leftovers.length && s.paths.every((p) => leftovers.includes(p) || !fs4.existsSync(p))) worktreeRemoved = true;
896
967
  else if (!worktreeRemoved)
897
968
  keptBecause = leftovers.length ? `git removed ${leftovers.join(", ")} only in part (a file in use) and kept the rest` : "git refused to remove the worktree";
898
969
  } else {
@@ -904,7 +975,7 @@ async function archiveSteps(s, deps, opts) {
904
975
  saved = {};
905
976
  }
906
977
  if (!worktreeRemoved && !leftovers.length && Object.keys(ignored).length) {
907
- fs3.rmSync(ignoredDir, { recursive: true, force: true });
978
+ fs4.rmSync(ignoredDir, { recursive: true, force: true });
908
979
  ignored = {};
909
980
  }
910
981
  const kept = deps.kept?.(id);
@@ -946,7 +1017,7 @@ async function archiveSteps(s, deps, opts) {
946
1017
  ...unrestored.length ? { unrestored } : {},
947
1018
  ...keptAny(kept) ? { kept } : {}
948
1019
  };
949
- fs3.writeFileSync(path3.join(dir, "archive.json"), JSON.stringify(record, null, 2));
1020
+ fs4.writeFileSync(path3.join(dir, "archive.json"), JSON.stringify(record, null, 2));
950
1021
  await deps.setArchived(s);
951
1022
  try {
952
1023
  clearSnooze(id);
@@ -988,24 +1059,24 @@ async function writeArchiveSummary(id, summarize, root = archiveRoot()) {
988
1059
  function writeArchiveRecord(rec, root = archiveRoot()) {
989
1060
  const file = path3.join(archiveDirFor(rec.sessionId, root), "archive.json");
990
1061
  const tmp = `${file}.tmp-${process.pid}`;
991
- fs3.writeFileSync(tmp, JSON.stringify(rec, null, 2));
992
- fs3.renameSync(tmp, file);
1062
+ fs4.writeFileSync(tmp, JSON.stringify(rec, null, 2));
1063
+ fs4.renameSync(tmp, file);
993
1064
  }
994
1065
  function readArchivedTranscript(id, file, root = archiveRoot()) {
995
1066
  const plain = path3.join(archiveDirFor(id, root), "transcripts", file);
996
1067
  try {
997
- return fs3.readFileSync(plain, "utf8");
1068
+ return fs4.readFileSync(plain, "utf8");
998
1069
  } catch {
999
1070
  }
1000
1071
  try {
1001
- return zlib.gunzipSync(fs3.readFileSync(`${plain}.gz`)).toString("utf8");
1072
+ return zlib.gunzipSync(fs4.readFileSync(`${plain}.gz`)).toString("utf8");
1002
1073
  } catch {
1003
1074
  return null;
1004
1075
  }
1005
1076
  }
1006
1077
  function readArchive(id, root = archiveRoot()) {
1007
1078
  try {
1008
- const raw = JSON.parse(fs3.readFileSync(path3.join(archiveDirFor(id, root), "archive.json"), "utf8"));
1079
+ const raw = JSON.parse(fs4.readFileSync(path3.join(archiveDirFor(id, root), "archive.json"), "utf8"));
1009
1080
  return isArchiveRecord(raw) ? withValidSaves(raw) : null;
1010
1081
  } catch {
1011
1082
  return null;
@@ -1053,7 +1124,7 @@ function lastEntryTime(file, entries) {
1053
1124
  }
1054
1125
  function fileSize(file) {
1055
1126
  try {
1056
- return fs3.statSync(file).size;
1127
+ return fs4.statSync(file).size;
1057
1128
  } catch {
1058
1129
  return 0;
1059
1130
  }
@@ -1067,11 +1138,11 @@ function restoreArchivedTranscripts(s, root = archiveRoot(), restoreDir = (x) =>
1067
1138
  const written = /* @__PURE__ */ new Set();
1068
1139
  for (const t of rec.transcripts) {
1069
1140
  const to = path3.join(dest, t.file);
1070
- if (fs3.existsSync(to)) continue;
1141
+ if (fs4.existsSync(to)) continue;
1071
1142
  const text = readArchivedTranscript(id, t.file, root);
1072
1143
  if (text === null) continue;
1073
- fs3.mkdirSync(dest, { recursive: true });
1074
- fs3.writeFileSync(to, text);
1144
+ fs4.mkdirSync(dest, { recursive: true });
1145
+ fs4.writeFileSync(to, text);
1075
1146
  written.add(to);
1076
1147
  }
1077
1148
  if (written.size === 0) return 0;
@@ -1080,7 +1151,7 @@ function restoreArchivedTranscripts(s, root = archiveRoot(), restoreDir = (x) =>
1080
1151
  for (const t of rec.transcripts) {
1081
1152
  const file = path3.join(dest, t.file);
1082
1153
  try {
1083
- files.push({ file, last: lastEntryTime(file, entries) || (written.has(file) ? 0 : fs3.statSync(file).mtimeMs) });
1154
+ files.push({ file, last: lastEntryTime(file, entries) || (written.has(file) ? 0 : fs4.statSync(file).mtimeMs) });
1084
1155
  } catch {
1085
1156
  }
1086
1157
  }
@@ -1089,13 +1160,18 @@ function restoreArchivedTranscripts(s, root = archiveRoot(), restoreDir = (x) =>
1089
1160
  for (const [i, { file }] of files.entries()) {
1090
1161
  const at = new Date(newest - (files.length - 1 - i) * 1e3);
1091
1162
  try {
1092
- fs3.utimesSync(file, at, at);
1163
+ fs4.utimesSync(file, at, at);
1093
1164
  } catch {
1094
1165
  }
1095
1166
  }
1096
1167
  return written.size;
1097
1168
  }
1098
1169
 
1170
+ // src/core/conversations/conversation-store.ts
1171
+ import fs5 from "fs";
1172
+ import path4 from "path";
1173
+ import zlib2 from "zlib";
1174
+
1099
1175
  // src/core/archive/archive-search.ts
1100
1176
  var SNIPPET_CHARS = 220;
1101
1177
  function messageOf(e) {
@@ -1154,30 +1230,30 @@ async function syncConversation(s, root = conversationRoot(), sources = agentOf(
1154
1230
  let have = 0;
1155
1231
  let haveMtime = 0;
1156
1232
  try {
1157
- const st = await fs4.promises.stat(dest);
1233
+ const st = await fs5.promises.stat(dest);
1158
1234
  [have, haveMtime] = [st.size, st.mtimeMs];
1159
1235
  } catch {
1160
1236
  }
1161
1237
  if (have === src.size) {
1162
1238
  if (Math.abs(haveMtime - src.mtimeMs) > 1e3)
1163
- await fs4.promises.utimes(dest, /* @__PURE__ */ new Date(), new Date(src.mtimeMs)).catch(() => void 0);
1239
+ await fs5.promises.utimes(dest, /* @__PURE__ */ new Date(), new Date(src.mtimeMs)).catch(() => void 0);
1164
1240
  continue;
1165
1241
  }
1166
- await fs4.promises.mkdir(dir, { recursive: true });
1242
+ await fs5.promises.mkdir(dir, { recursive: true });
1167
1243
  if (have > src.size) {
1168
- await fs4.promises.copyFile(src.file, dest);
1244
+ await fs5.promises.copyFile(src.file, dest);
1169
1245
  out.bytes += src.size;
1170
1246
  } else {
1171
1247
  out.bytes += await appendRange(src.file, dest, have, src.size);
1172
1248
  }
1173
- await fs4.promises.utimes(dest, /* @__PURE__ */ new Date(), new Date(src.mtimeMs)).catch(() => void 0);
1249
+ await fs5.promises.utimes(dest, /* @__PURE__ */ new Date(), new Date(src.mtimeMs)).catch(() => void 0);
1174
1250
  out.files++;
1175
1251
  }
1176
1252
  return out;
1177
1253
  }
1178
1254
  async function packedState(dest, srcMtimeMs) {
1179
1255
  try {
1180
- const st = await fs4.promises.stat(`${dest}.gz`);
1256
+ const st = await fs5.promises.stat(`${dest}.gz`);
1181
1257
  return srcMtimeMs <= st.mtimeMs + 1e3 ? "current" : "stale";
1182
1258
  } catch {
1183
1259
  return "none";
@@ -1186,16 +1262,16 @@ async function packedState(dest, srcMtimeMs) {
1186
1262
  async function unpack(dest) {
1187
1263
  const gz = `${dest}.gz`;
1188
1264
  const tmp = `${dest}.unpack-${process.pid}`;
1189
- await fs4.promises.writeFile(tmp, zlib2.gunzipSync(await fs4.promises.readFile(gz)));
1190
- await fs4.promises.rename(tmp, dest);
1191
- await fs4.promises.rm(gz, { force: true });
1265
+ await fs5.promises.writeFile(tmp, zlib2.gunzipSync(await fs5.promises.readFile(gz)));
1266
+ await fs5.promises.rename(tmp, dest);
1267
+ await fs5.promises.rm(gz, { force: true });
1192
1268
  }
1193
1269
  var PACK_QUIET_MS = 2 * 24 * 36e5;
1194
1270
  async function compressQuietCopies(root = conversationRoot(), now = Date.now(), quietMs = PACK_QUIET_MS) {
1195
1271
  const out = { files: 0, bytesSaved: 0 };
1196
1272
  let dirs;
1197
1273
  try {
1198
- dirs = await fs4.promises.readdir(root);
1274
+ dirs = await fs5.promises.readdir(root);
1199
1275
  } catch {
1200
1276
  return out;
1201
1277
  }
@@ -1203,21 +1279,21 @@ async function compressQuietCopies(root = conversationRoot(), now = Date.now(),
1203
1279
  const dir = path4.join(root, d);
1204
1280
  let names;
1205
1281
  try {
1206
- names = (await fs4.promises.readdir(dir)).filter((n) => n.endsWith(".jsonl"));
1282
+ names = (await fs5.promises.readdir(dir)).filter((n) => n.endsWith(".jsonl"));
1207
1283
  } catch {
1208
1284
  continue;
1209
1285
  }
1210
1286
  for (const n of names) {
1211
1287
  const file = path4.join(dir, n);
1212
1288
  try {
1213
- const st = await fs4.promises.stat(file);
1289
+ const st = await fs5.promises.stat(file);
1214
1290
  if (now - st.mtimeMs < quietMs) continue;
1215
- const packed = zlib2.gzipSync(await fs4.promises.readFile(file));
1291
+ const packed = zlib2.gzipSync(await fs5.promises.readFile(file));
1216
1292
  const tmp = `${file}.gz.tmp-${process.pid}`;
1217
- await fs4.promises.writeFile(tmp, packed);
1218
- await fs4.promises.utimes(tmp, /* @__PURE__ */ new Date(), new Date(st.mtimeMs));
1219
- await fs4.promises.rename(tmp, `${file}.gz`);
1220
- await fs4.promises.rm(file, { force: true });
1293
+ await fs5.promises.writeFile(tmp, packed);
1294
+ await fs5.promises.utimes(tmp, /* @__PURE__ */ new Date(), new Date(st.mtimeMs));
1295
+ await fs5.promises.rename(tmp, `${file}.gz`);
1296
+ await fs5.promises.rm(file, { force: true });
1221
1297
  out.files++;
1222
1298
  out.bytesSaved += st.size - packed.length;
1223
1299
  } catch {
@@ -1227,8 +1303,8 @@ async function compressQuietCopies(root = conversationRoot(), now = Date.now(),
1227
1303
  return out;
1228
1304
  }
1229
1305
  async function appendRange(src, dest, from, to) {
1230
- await (await fs4.promises.open(dest, "a")).close();
1231
- const [inp, out] = [await fs4.promises.open(src, "r"), await fs4.promises.open(dest, "r+")];
1306
+ await (await fs5.promises.open(dest, "a")).close();
1307
+ const [inp, out] = [await fs5.promises.open(src, "r"), await fs5.promises.open(dest, "r+")];
1232
1308
  try {
1233
1309
  const chunk = 4 * 1024 * 1024;
1234
1310
  let done = 0;
@@ -1265,7 +1341,7 @@ var SNIPPETS_PER_SESSION = 3;
1265
1341
  function storedTranscripts(dir) {
1266
1342
  let names;
1267
1343
  try {
1268
- names = fs4.readdirSync(dir).filter((n) => n.endsWith(".jsonl") || n.endsWith(".jsonl.gz"));
1344
+ names = fs5.readdirSync(dir).filter((n) => n.endsWith(".jsonl") || n.endsWith(".jsonl.gz"));
1269
1345
  } catch {
1270
1346
  return [];
1271
1347
  }
@@ -1273,12 +1349,12 @@ function storedTranscripts(dir) {
1273
1349
  const file = path4.join(dir, n);
1274
1350
  let mtimeMs = 0;
1275
1351
  try {
1276
- mtimeMs = fs4.statSync(file).mtimeMs;
1352
+ mtimeMs = fs5.statSync(file).mtimeMs;
1277
1353
  } catch {
1278
1354
  }
1279
1355
  const read = () => {
1280
1356
  try {
1281
- const buf = fs4.readFileSync(file);
1357
+ const buf = fs5.readFileSync(file);
1282
1358
  return (n.endsWith(".gz") ? zlib2.gunzipSync(buf) : buf).toString("utf8");
1283
1359
  } catch {
1284
1360
  return null;
@@ -1339,93 +1415,52 @@ async function searchConversations(query, opts) {
1339
1415
  return hits;
1340
1416
  }
1341
1417
 
1342
- // src/core/sessions/history.ts
1343
- import fs10 from "fs";
1344
- import path9 from "path";
1418
+ // src/core/worktree/dev-server.ts
1419
+ import fs6 from "fs";
1420
+ import net2 from "net";
1421
+ import path6 from "path";
1422
+ import { spawn } from "child_process";
1345
1423
 
1346
- // src/core/worktree/port-allocator.ts
1347
- import fs5 from "fs";
1348
- import net from "net";
1349
- var DEFAULT_PORT_RANGE = { start: 3e3, end: 3099 };
1350
- var PortRangeExhaustedError = class extends Error {
1351
- start;
1352
- end;
1353
- constructor(start, end) {
1354
- super(
1355
- `No free dev-server port available in range ${start}-${end} (all ${end - start + 1} in use). Widen "portRange" in ~/.work/config.json.`
1356
- );
1357
- this.name = "PortRangeExhaustedError";
1358
- this.start = start;
1359
- this.end = end;
1360
- }
1361
- };
1362
- function hashString(input) {
1363
- let hash = 2166136261;
1364
- for (let i = 0; i < input.length; i++) {
1365
- hash ^= input.charCodeAt(i);
1366
- hash = Math.imul(hash, 16777619);
1367
- }
1368
- return hash >>> 0;
1369
- }
1370
- function normalizeRange(config) {
1371
- const range = config.portRange ?? DEFAULT_PORT_RANGE;
1372
- const start = Math.min(range.start, range.end);
1373
- const end = Math.max(range.start, range.end);
1374
- const rangeSize = end - start + 1;
1375
- if (rangeSize <= 0) {
1376
- throw new Error(`Invalid port range: ${range.start}-${range.end}`);
1377
- }
1378
- return { start, end, rangeSize };
1379
- }
1380
- function portsHeldByActiveSessions(sessions) {
1381
- const inUse = /* @__PURE__ */ new Set();
1382
- for (const session of sessions) {
1383
- if (session.port === void 0) continue;
1384
- const active = session.paths.some((p) => fs5.existsSync(p));
1385
- if (active) inUse.add(session.port);
1386
- }
1387
- return inUse;
1388
- }
1389
- function isPortFree(port) {
1390
- return new Promise((resolve) => {
1391
- const server = net.createServer();
1392
- server.once("error", (err) => {
1393
- resolve(err.code !== "EADDRINUSE");
1394
- });
1395
- server.once("listening", () => {
1396
- server.close(() => resolve(true));
1424
+ // src/core/sessions/session-repos.ts
1425
+ import path5 from "path";
1426
+ function recordedRepos(s) {
1427
+ if (!Array.isArray(s.repos) || s.repos.length !== s.paths.length || s.repos.length === 0) return null;
1428
+ if (!s.repos.every((a) => typeof a === "string" && a)) return null;
1429
+ return s.repos.map((alias, i) => ({ alias, path: s.paths[i] }));
1430
+ }
1431
+ var sameName = (a, b) => path5.basename(a).toLowerCase() === path5.basename(b).toLowerCase();
1432
+ function sessionRepos(s, config) {
1433
+ const recorded = recordedRepos(s);
1434
+ if (recorded) return recorded;
1435
+ if (!s.isGroup) return s.paths.length ? [{ alias: s.target, path: s.paths[0] }] : [];
1436
+ const listed = Array.isArray(s.repos) ? s.repos.filter((a) => typeof a === "string" && !!a) : [];
1437
+ const members = [.../* @__PURE__ */ new Set([...listed, ...config?.groups?.[s.target] ?? []])];
1438
+ return s.paths.map((p) => {
1439
+ const alias = members.find((a) => {
1440
+ const repo = config?.repos?.[a];
1441
+ return repo !== void 0 && sameName(repo, p);
1397
1442
  });
1398
- server.listen(port, "127.0.0.1");
1443
+ return alias ? { alias, path: p } : { alias: path5.basename(p), path: p, guessed: true };
1399
1444
  });
1400
1445
  }
1401
- async function allocateFreePort(seedKey, config, sessions, probe = isPortFree) {
1402
- const { start, end, rangeSize } = normalizeRange(config);
1403
- const inUse = portsHeldByActiveSessions(sessions);
1404
- const baseOffset = hashString(seedKey) % rangeSize;
1405
- for (let i = 0; i < rangeSize; i++) {
1406
- const candidate = start + (baseOffset + i) % rangeSize;
1407
- if (inUse.has(candidate)) continue;
1408
- if (await probe(candidate)) {
1409
- return candidate;
1410
- }
1411
- }
1412
- throw new PortRangeExhaustedError(start, end);
1446
+ function sessionAliases(s, config) {
1447
+ const recorded = recordedRepos(s);
1448
+ if (recorded) return recorded.map((r) => r.alias);
1449
+ if (Array.isArray(s.repos) && s.isGroup)
1450
+ return config?.repos ? sessionRepos(s, config).filter((r) => !r.guessed).map((r) => r.alias) : s.repos.filter((a) => typeof a === "string" && !!a);
1451
+ return s.isGroup ? config?.groups?.[s.target] ?? [] : [s.target];
1452
+ }
1453
+ function isFolderSession(s) {
1454
+ return s.isGroup;
1413
1455
  }
1414
-
1415
- // src/core/sessions/session-store.ts
1416
- import fs9 from "fs";
1417
1456
 
1418
1457
  // src/core/worktree/dev-server.ts
1419
- import fs6 from "fs";
1420
- import net2 from "net";
1421
- import path5 from "path";
1422
- import { spawn } from "child_process";
1423
1458
  function devDir() {
1424
- const dir = path5.join(getConfigDir(), "dev");
1459
+ const dir = path6.join(getConfigDir(), "dev");
1425
1460
  fs6.mkdirSync(dir, { recursive: true });
1426
1461
  return dir;
1427
1462
  }
1428
- var devLogFile = (id) => path5.join(devDir(), `${id}.log`);
1463
+ var devLogFile = (id) => path6.join(devDir(), `${id}.log`);
1429
1464
  var REBOOT_SLACK_MS = 5 * 6e4;
1430
1465
  function isRunRecord(x) {
1431
1466
  const r = x;
@@ -1449,14 +1484,10 @@ function forgetRun(id) {
1449
1484
  }
1450
1485
  function devCommandFor(session, config) {
1451
1486
  const commands = config?.devCommands ?? {};
1452
- const aliases = session.isGroup ? config?.groups?.[session.target] ?? [] : [session.target];
1453
- for (const p of session.paths) {
1454
- const alias = aliases.find((a) => {
1455
- const repo = config?.repos?.[a];
1456
- return repo !== void 0 && path5.basename(repo).toLowerCase() === path5.basename(p).toLowerCase();
1457
- }) ?? (session.isGroup ? void 0 : session.target);
1458
- const command = alias ? commands[alias] : void 0;
1459
- if (alias && typeof command === "string" && command.trim()) return { command, cwd: p, repo: alias };
1487
+ for (const { alias, path: p, guessed } of sessionRepos(session, config)) {
1488
+ if (guessed) continue;
1489
+ const command = commands[alias];
1490
+ if (typeof command === "string" && command.trim()) return { command, cwd: p, repo: alias };
1460
1491
  }
1461
1492
  return null;
1462
1493
  }
@@ -1566,11 +1597,11 @@ function devLogTail(id, maxBytes = 64 * 1024) {
1566
1597
  // src/core/diff/checkpoint.ts
1567
1598
  import fs7 from "fs";
1568
1599
  import os2 from "os";
1569
- import path6 from "path";
1600
+ import path7 from "path";
1570
1601
  function manifestPath(scopeHash) {
1571
- const dir = path6.join(os2.homedir(), ".work", "diffs");
1602
+ const dir = path7.join(os2.homedir(), ".work", "diffs");
1572
1603
  fs7.mkdirSync(dir, { recursive: true });
1573
- return path6.join(dir, `${scopeHash}.checkpoints.json`);
1604
+ return path7.join(dir, `${scopeHash}.checkpoints.json`);
1574
1605
  }
1575
1606
  function emptyManifest(scopeHash) {
1576
1607
  return { version: 1, scopeHash, entries: [] };
@@ -1868,12 +1899,12 @@ function clearCheckpoints(scopeHash, repoRoots) {
1868
1899
  }
1869
1900
 
1870
1901
  // src/core/diff/scope-manager.ts
1871
- import path8 from "path";
1902
+ import path9 from "path";
1872
1903
  import crypto2 from "crypto";
1873
1904
 
1874
1905
  // src/core/platform/fs-watcher.ts
1875
1906
  import fs8 from "fs";
1876
- import path7 from "path";
1907
+ import path8 from "path";
1877
1908
  import { createRequire } from "module";
1878
1909
  var loadChokidar = () => createRequire(import.meta.url)("chokidar");
1879
1910
  var IGNORED_DIRS = /* @__PURE__ */ new Set([
@@ -1899,7 +1930,7 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
1899
1930
  ]);
1900
1931
  function isIgnoredWatchPath(roots, filePath) {
1901
1932
  for (const root of roots) {
1902
- const rel = path7.relative(root, filePath).replace(/\\/g, "/");
1933
+ const rel = path8.relative(root, filePath).replace(/\\/g, "/");
1903
1934
  if (rel === "" || rel.startsWith("../")) continue;
1904
1935
  if (rel.split("/").some((seg) => IGNORED_DIRS.has(seg))) return true;
1905
1936
  }
@@ -1922,7 +1953,7 @@ function createFsWatcher(opts) {
1922
1953
  if (SUPPORTS_RECURSIVE_WATCH) {
1923
1954
  const watchers = opts.roots.map((root) => {
1924
1955
  const w = fs8.watch(root, { recursive: true }, (_event, filename) => {
1925
- if (filename && isIgnoredWatchPath([root], path7.join(root, filename.toString()))) {
1956
+ if (filename && isIgnoredWatchPath([root], path8.join(root, filename.toString()))) {
1926
1957
  return;
1927
1958
  }
1928
1959
  fire();
@@ -1973,7 +2004,7 @@ var ScopePathRejectedError = class extends Error {
1973
2004
  }
1974
2005
  };
1975
2006
  function normaliseForCompare(p) {
1976
- return path8.resolve(p).replace(/\\/g, "/").toLowerCase();
2007
+ return path9.resolve(p).replace(/\\/g, "/").toLowerCase();
1977
2008
  }
1978
2009
  function rejectedPaths(normalised) {
1979
2010
  const config = loadConfig();
@@ -1988,7 +2019,7 @@ function rejectedPaths(normalised) {
1988
2019
  });
1989
2020
  }
1990
2021
  function registerScope(paths, label) {
1991
- const normalised = paths.map((p) => path8.resolve(p));
2022
+ const normalised = paths.map((p) => path9.resolve(p));
1992
2023
  const rejected = rejectedPaths(normalised);
1993
2024
  if (rejected.length > 0) throw new ScopePathRejectedError(rejected);
1994
2025
  const hash = hashFor(normalised);
@@ -2002,7 +2033,7 @@ function registerScope(paths, label) {
2002
2033
  const scope = {
2003
2034
  hash,
2004
2035
  paths: normalised,
2005
- label: label ?? path8.basename(normalised[0]),
2036
+ label: label ?? path9.basename(normalised[0]),
2006
2037
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2007
2038
  ended: false
2008
2039
  };
@@ -2028,17 +2059,17 @@ function reviveScope(hash) {
2028
2059
  return true;
2029
2060
  }
2030
2061
  function scopesToSweep(scopes2, sessionPaths) {
2031
- const owned = new Set(sessionPaths.map((paths) => hashFor(paths.map((p) => path8.resolve(p)))));
2062
+ const owned = new Set(sessionPaths.map((paths) => hashFor(paths.map((p) => path9.resolve(p)))));
2032
2063
  return scopes2.filter((s) => !owned.has(s.hash));
2033
2064
  }
2034
2065
  function sessionOwnsScope(hash, sessionPaths) {
2035
- return sessionPaths.some((paths) => hashFor(paths.map((p) => path8.resolve(p))) === hash);
2066
+ return sessionPaths.some((paths) => hashFor(paths.map((p) => path9.resolve(p))) === hash);
2036
2067
  }
2037
2068
  function findScope(paths) {
2038
2069
  return getScope(scopeHashForPaths(paths));
2039
2070
  }
2040
2071
  function scopeHashForPaths(paths) {
2041
- return hashFor(paths.map((p) => path8.resolve(p)));
2072
+ return hashFor(paths.map((p) => path9.resolve(p)));
2042
2073
  }
2043
2074
  function getScope(hash) {
2044
2075
  return scopes.get(hash)?.scope ?? null;
@@ -2120,7 +2151,7 @@ function stopSessionDevServer(id) {
2120
2151
  function clearSessionCheckpoints(s) {
2121
2152
  try {
2122
2153
  const cfg = loadConfig();
2123
- const aliases = s.isGroup ? cfg?.groups[s.target] ?? [] : [s.target];
2154
+ const aliases = sessionAliases(s, cfg);
2124
2155
  const roots = aliases.map((a) => cfg?.repos[a]).filter((r) => !!r && fs9.existsSync(r));
2125
2156
  clearCheckpoints(scopeHashForPaths(s.paths), roots);
2126
2157
  if (s.branch !== void 0) for (const r of roots) dropSessionSaves(r, sessionIdFor({ target: s.target, branch: s.branch }));
@@ -2143,6 +2174,9 @@ var recordAgent = () => {
2143
2174
  const agent = agentToRecord(loadConfig());
2144
2175
  return agent ? { agent } : {};
2145
2176
  };
2177
+ function getHistoryPath() {
2178
+ return path10.join(getConfigDir(), "history.json");
2179
+ }
2146
2180
  function valid(s) {
2147
2181
  const x = s;
2148
2182
  return !!x && typeof x.target === "string" && typeof x.branch === "string" && Array.isArray(x.paths);
@@ -2160,6 +2194,31 @@ function putRow(d, s) {
2160
2194
  "INSERT INTO sessions (id, target, branch, data) VALUES (?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET data = excluded.data"
2161
2195
  ).run(sessionIdFor(s), s.target, s.branch, JSON.stringify(s));
2162
2196
  }
2197
+ function appendSessionRepo(id, alias, worktree, from, config, imports = false) {
2198
+ return tx((d) => {
2199
+ const r = d.prepare("SELECT data FROM sessions WHERE id = ?").get(id);
2200
+ const s = r ? json.parse(r.data) : null;
2201
+ if (!valid(s)) return null;
2202
+ const own = sessionRepos(s, config);
2203
+ const unknown = own.filter((x) => x.guessed).map((x) => path10.basename(x.path));
2204
+ if (unknown.length) throw new Error(`no repo of its group is in ${unknown.join(", ")}, so its repos can't be recorded`);
2205
+ const repos = own.map((x) => x.alias);
2206
+ const before = [...s.paths];
2207
+ if (repos.includes(alias)) return { before, session: s };
2208
+ if (s.baseBranch && from !== s.baseBranch) {
2209
+ const perRepo = { ...s.baseBranches ?? {} };
2210
+ for (const p of s.paths) perRepo[p] ??= s.baseBranch;
2211
+ s.baseBranches = perRepo;
2212
+ delete s.baseBranch;
2213
+ }
2214
+ s.paths = [...s.paths, worktree];
2215
+ s.repos = [...repos, alias];
2216
+ if (imports && !s.instructions) s.instructions = config.groups?.[s.target] ? "summary+imports" : "imports";
2217
+ if (from) s.baseBranches = { ...s.baseBranches ?? {}, [worktree]: from };
2218
+ putRow(d, s);
2219
+ return { before, session: s };
2220
+ });
2221
+ }
2163
2222
  function findSessionById(id) {
2164
2223
  return withDb((d) => {
2165
2224
  const r = d.prepare("SELECT data FROM sessions WHERE id = ?").get(id);
@@ -2189,12 +2248,34 @@ function sessionKey(target, branch) {
2189
2248
  function findSession(sessions, target, branch) {
2190
2249
  return sessions.find((s) => s.target === target && s.branch === branch);
2191
2250
  }
2192
- async function upsertSession(target, isGroup, branch, paths, jiraKey, baseBranch, port) {
2251
+ function setOwnRepos(existing, paths, repos) {
2252
+ const recorded = recordedRepos(existing);
2253
+ if (!recorded) {
2254
+ existing.paths = paths;
2255
+ if (repos) existing.repos = [...repos];
2256
+ return;
2257
+ }
2258
+ const given = repos && repos.length === paths.length ? repos.map((alias, i) => ({ alias, path: paths[i] })) : paths.length === recorded.length ? recorded.map((r, i) => ({ alias: r.alias, path: paths[i] })) : recorded;
2259
+ const kept = recorded.filter((r) => !given.some((g) => g.alias === r.alias));
2260
+ const all = [...given, ...kept];
2261
+ existing.paths = all.map((r) => r.path);
2262
+ existing.repos = all.map((r) => r.alias);
2263
+ }
2264
+ function touchSession(target, branch) {
2265
+ tx((d) => {
2266
+ const s = getRow(d, target, branch);
2267
+ if (!s) return;
2268
+ s.lastAccessedAt = (/* @__PURE__ */ new Date()).toISOString();
2269
+ delete s.archivedAt;
2270
+ putRow(d, s);
2271
+ });
2272
+ }
2273
+ async function upsertSession(target, isGroup, branch, paths, jiraKey, baseBranch, port, repos) {
2193
2274
  tx((d) => {
2194
2275
  const existing = getRow(d, target, branch);
2195
2276
  const now = (/* @__PURE__ */ new Date()).toISOString();
2196
2277
  if (existing) {
2197
- existing.paths = paths;
2278
+ setOwnRepos(existing, paths, repos);
2198
2279
  existing.lastAccessedAt = now;
2199
2280
  delete existing.archivedAt;
2200
2281
  if (jiraKey) existing.jiraKey = jiraKey;
@@ -2214,24 +2295,27 @@ async function upsertSession(target, isGroup, branch, paths, jiraKey, baseBranch
2214
2295
  if (jiraKey) session.jiraKey = jiraKey;
2215
2296
  if (baseBranch) session.baseBranch = baseBranch;
2216
2297
  if (port !== void 0) session.port = port;
2298
+ if (repos) session.repos = [...repos];
2217
2299
  putRow(d, session);
2218
2300
  }
2219
2301
  });
2220
2302
  }
2221
- async function upsertSessionWithPort(target, isGroup, branch, paths, config, jiraKey, baseBranch, baseBranches) {
2303
+ async function upsertSessionWithPort(target, isGroup, branch, paths, config, jiraKey, baseBranch, baseBranches, own = {}) {
2304
+ const { repos, instructions } = own;
2222
2305
  const hasPerRepo = baseBranches && Object.keys(baseBranches).length > 0;
2223
2306
  const id = sessionIdFor({ target, branch });
2224
2307
  const write = (d, port) => {
2225
2308
  const existing = getRow(d, target, branch);
2226
2309
  const now = (/* @__PURE__ */ new Date()).toISOString();
2227
2310
  if (existing) {
2228
- existing.paths = paths;
2311
+ setOwnRepos(existing, paths, repos);
2229
2312
  existing.lastAccessedAt = now;
2230
2313
  delete existing.archivedAt;
2231
2314
  if (jiraKey) existing.jiraKey = jiraKey;
2232
2315
  if (baseBranch && !existing.baseBranch) existing.baseBranch = baseBranch;
2233
2316
  if (hasPerRepo && !existing.baseBranches) existing.baseBranches = baseBranches;
2234
2317
  if (existing.port === void 0 && port !== void 0) existing.port = port;
2318
+ if (instructions) existing.instructions = instructions;
2235
2319
  putRow(d, existing);
2236
2320
  return existing.port;
2237
2321
  }
@@ -2240,6 +2324,8 @@ async function upsertSessionWithPort(target, isGroup, branch, paths, config, jir
2240
2324
  if (baseBranch) session.baseBranch = baseBranch;
2241
2325
  if (hasPerRepo) session.baseBranches = baseBranches;
2242
2326
  if (port !== void 0) session.port = port;
2327
+ if (repos) session.repos = [...repos];
2328
+ if (instructions) session.instructions = instructions;
2243
2329
  putRow(d, session);
2244
2330
  return port;
2245
2331
  };
@@ -2364,7 +2450,16 @@ async function mergeHydratedSessions(incoming) {
2364
2450
  let updated = 0;
2365
2451
  for (const inc of incoming) {
2366
2452
  const existing = getRow(d, inc.target, inc.branch);
2367
- if (existing) {
2453
+ const own = existing ? recordedRepos(existing) : null;
2454
+ if (existing && own) {
2455
+ const extra = inc.paths.map((p, i) => ({ path: p, alias: inc.repos?.[i] })).filter((x) => !own.some((r) => samePath(r.path, x.path)));
2456
+ if (extra.length && extra.every((x) => typeof x.alias === "string")) {
2457
+ existing.paths = [...existing.paths, ...extra.map((x) => x.path)];
2458
+ existing.repos = [...own.map((r) => r.alias), ...extra.map((x) => x.alias)];
2459
+ putRow(d, existing);
2460
+ updated++;
2461
+ }
2462
+ } else if (existing) {
2368
2463
  const sortedA = [...existing.paths].sort();
2369
2464
  const sortedB = [...inc.paths].sort();
2370
2465
  const same = sortedA.length === sortedB.length && sortedA.every((p, i) => p === sortedB[i]);
@@ -2382,7 +2477,7 @@ async function mergeHydratedSessions(incoming) {
2382
2477
  });
2383
2478
  }
2384
2479
  var samePath = (a, b) => {
2385
- const n = (p) => path9.resolve(p).split(path9.sep).join("/").toLowerCase();
2480
+ const n = (p) => path10.resolve(p).split(path10.sep).join("/").toLowerCase();
2386
2481
  return n(a) === n(b);
2387
2482
  };
2388
2483
  async function forgetOtherBaseCheckoutEntries(target, keepBranch, repoPath) {
@@ -2456,10 +2551,15 @@ export {
2456
2551
  compressQuietCopies,
2457
2552
  syncConversations,
2458
2553
  searchConversations,
2554
+ recordedRepos,
2555
+ sessionRepos,
2556
+ sessionAliases,
2557
+ isFolderSession,
2459
2558
  devState,
2460
2559
  startDev,
2461
2560
  stopDev,
2462
2561
  devLogTail,
2562
+ manifestPath,
2463
2563
  loadManifest,
2464
2564
  takeCheckpoint,
2465
2565
  updateCheckpoint,
@@ -2485,10 +2585,14 @@ export {
2485
2585
  subscribeScope,
2486
2586
  disposeAllScopes,
2487
2587
  commentStoreIdForScope,
2588
+ getHistoryPath,
2589
+ appendSessionRepo,
2488
2590
  findSessionById,
2489
2591
  loadHistory,
2490
2592
  saveHistory,
2491
2593
  findSession,
2594
+ setOwnRepos,
2595
+ touchSession,
2492
2596
  upsertSession,
2493
2597
  upsertSessionWithPort,
2494
2598
  recordLaunch,
@@ -2498,8 +2602,9 @@ export {
2498
2602
  removeSession,
2499
2603
  getSessionsForTarget,
2500
2604
  getRecentSessions,
2605
+ pruneStaleEntries,
2501
2606
  prunePersistedStaleEntries,
2502
2607
  mergeHydratedSessions,
2503
2608
  forgetOtherBaseCheckoutEntries
2504
2609
  };
2505
- //# sourceMappingURL=chunk-NM4SABMQ.js.map
2610
+ //# sourceMappingURL=chunk-RFQRVXFQ.js.map