@moberg_hr/work-tree 2.6.3 → 2.7.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 (257) hide show
  1. package/dist/{add-repo-VAGLNLIJ.js → add-repo-E7KWNJJV.js} +30 -29
  2. package/dist/{add-repo-VAGLNLIJ.js.map → add-repo-E7KWNJJV.js.map} +1 -1
  3. package/dist/{answer-4CUJSRIP.js → answer-2CBOWCL5.js} +13 -12
  4. package/dist/{answer-4CUJSRIP.js.map → answer-2CBOWCL5.js.map} +1 -1
  5. package/dist/{attach-GLCZILIH.js → attach-AWRY4LSI.js} +16 -15
  6. package/dist/{attach-GLCZILIH.js.map → attach-AWRY4LSI.js.map} +1 -1
  7. package/dist/bin.js +10 -8
  8. package/dist/bin.js.map +1 -1
  9. package/dist/{block-SC5IZJMA.js → block-JTJX5QIO.js} +13 -12
  10. package/dist/{block-SC5IZJMA.js.map → block-JTJX5QIO.js.map} +1 -1
  11. package/dist/{broadcast-VFY5UFYA.js → broadcast-3SF55HA6.js} +10 -9
  12. package/dist/{broadcast-VFY5UFYA.js.map → broadcast-3SF55HA6.js.map} +1 -1
  13. package/dist/{catchup-4EBF6RZ6.js → catchup-2WNHEMLD.js} +16 -15
  14. package/dist/{catchup-4EBF6RZ6.js.map → catchup-2WNHEMLD.js.map} +1 -1
  15. package/dist/{chunk-UNEHT6FI.js → chunk-2IKWNRMV.js} +3 -3
  16. package/dist/{chunk-P2THO7D7.js → chunk-3JY3QT4J.js} +5 -5
  17. package/dist/{chunk-35VLAPL2.js → chunk-3PLWNCRM.js} +2 -2
  18. package/dist/chunk-3Q5RZCQW.js +9 -0
  19. package/dist/{chunk-C6STZ6HD.js → chunk-3UHKPHTB.js} +7 -7
  20. package/dist/chunk-3ZGZNZTY.js +134 -0
  21. package/dist/chunk-3ZGZNZTY.js.map +1 -0
  22. package/dist/{chunk-CRPV5YCC.js → chunk-46UTKL5L.js} +2 -2
  23. package/dist/{chunk-VMLRIO4T.js → chunk-4PRPDACI.js} +5 -5
  24. package/dist/{chunk-4IEQ7LY4.js → chunk-5BNNPXID.js} +6 -6
  25. package/dist/{chunk-CXCMATZG.js → chunk-5GA3PFK5.js} +16 -16
  26. package/dist/{chunk-VIWPTRRR.js → chunk-5WEDCEZG.js} +5 -5
  27. package/dist/{command-hook-installer-W7IEVT6V.js → chunk-5XSY3C6E.js} +16 -86
  28. package/dist/chunk-5XSY3C6E.js.map +1 -0
  29. package/dist/{chunk-YLIPAOBT.js → chunk-AFW7HREX.js} +11 -11
  30. package/dist/{chunk-G7TS5DCS.js → chunk-B2HUKRWX.js} +4 -4
  31. package/dist/{chunk-Z3NQJALE.js → chunk-B7C3RYSJ.js} +3 -3
  32. package/dist/{chunk-YSGXXNBL.js → chunk-BHU26CNH.js} +4 -4
  33. package/dist/chunk-BHU26CNH.js.map +1 -0
  34. package/dist/{chunk-72U52KTJ.js → chunk-BVJ2ZE7B.js} +12 -14
  35. package/dist/{chunk-72U52KTJ.js.map → chunk-BVJ2ZE7B.js.map} +1 -1
  36. package/dist/{chunk-ANWA4Z56.js → chunk-C5HPSURF.js} +22 -22
  37. package/dist/{chunk-DAQCIJHW.js → chunk-CFLMBFBO.js} +3 -3
  38. package/dist/{chunk-JF72AS6T.js → chunk-COKQPFLB.js} +3 -3
  39. package/dist/{chunk-TJFX5BWH.js → chunk-DO5NW46X.js} +2 -2
  40. package/dist/chunk-DYJ4VJJD.js +160 -0
  41. package/dist/chunk-DYJ4VJJD.js.map +1 -0
  42. package/dist/{chunk-SMZ7W34L.js → chunk-EPNYZJMM.js} +5 -3
  43. package/dist/{chunk-SMZ7W34L.js.map → chunk-EPNYZJMM.js.map} +1 -1
  44. package/dist/{chunk-VESYLAVA.js → chunk-FUNZ7TOS.js} +104 -217
  45. package/dist/chunk-FUNZ7TOS.js.map +1 -0
  46. package/dist/{chunk-EUAJT7FS.js → chunk-G2FE7HUB.js} +2 -2
  47. package/dist/{chunk-VDYX4R6U.js → chunk-J5CMORVD.js} +9 -9
  48. package/dist/{chunk-ZGXRWL7T.js → chunk-JIYGGN2N.js} +2 -2
  49. package/dist/{chunk-RYEPQLXQ.js → chunk-KE2TFF7B.js} +99 -2
  50. package/dist/chunk-KE2TFF7B.js.map +1 -0
  51. package/dist/{chunk-MYDQNX7W.js → chunk-KU63EHZO.js} +2 -2
  52. package/dist/{chunk-R5IJHLHA.js → chunk-KUVL75PL.js} +8 -8
  53. package/dist/{chunk-PDYO56JU.js → chunk-LDFICXOZ.js} +3 -3
  54. package/dist/{chunk-WDV6VTVI.js → chunk-LQXGNO5X.js} +3 -3
  55. package/dist/{chunk-3HJASVHJ.js → chunk-LWKFZOCJ.js} +60 -10
  56. package/dist/chunk-LWKFZOCJ.js.map +1 -0
  57. package/dist/{chunk-I5V34WWS.js → chunk-MCSEYS2J.js} +7 -7
  58. package/dist/{chunk-JUMZ5MTU.js → chunk-MGQK6BWH.js} +20 -19
  59. package/dist/chunk-MGQK6BWH.js.map +1 -0
  60. package/dist/{chunk-G635EV2D.js → chunk-O34CKSE4.js} +2 -2
  61. package/dist/{chunk-QCFINFXO.js → chunk-OFCY7RCM.js} +4 -4
  62. package/dist/{chunk-H756AOOW.js → chunk-PIKOCEWX.js} +7 -7
  63. package/dist/{chunk-56P7G2DI.js → chunk-PUTZR6F5.js} +2 -2
  64. package/dist/{chunk-2MAGDOLP.js → chunk-QGKJXCEJ.js} +14 -14
  65. package/dist/{chunk-ZO6MZNLI.js → chunk-R3DASZQF.js} +2 -2
  66. package/dist/{chunk-EYUBVLPF.js → chunk-SNRP2MC3.js} +2 -2
  67. package/dist/{chunk-4RDAWJZY.js → chunk-TBY6ZFAV.js} +3 -3
  68. package/dist/{chunk-GTVQYGY3.js → chunk-TPPTL7LA.js} +3 -3
  69. package/dist/{chunk-QKF7CNIM.js → chunk-TTTIKTNR.js} +2 -2
  70. package/dist/{chunk-4YCWUHVE.js → chunk-UHYIB6AV.js} +2 -2
  71. package/dist/{chunk-QXJ4FILG.js → chunk-USUQYM6V.js} +54 -53
  72. package/dist/chunk-USUQYM6V.js.map +1 -0
  73. package/dist/{chunk-CGVYVTGF.js → chunk-VEKEA3ER.js} +2 -2
  74. package/dist/chunk-VMBWCDBA.js +186 -0
  75. package/dist/chunk-VMBWCDBA.js.map +1 -0
  76. package/dist/{chunk-LJ3UVV4F.js → chunk-W4YWFAYC.js} +4 -4
  77. package/dist/{chunk-KWRE6HQN.js → chunk-W7WC7UA2.js} +7 -5
  78. package/dist/{chunk-KWRE6HQN.js.map → chunk-W7WC7UA2.js.map} +1 -1
  79. package/dist/{chunk-XLAGFKJE.js → chunk-WIWO3YWP.js} +2 -2
  80. package/dist/{chunk-NW2ZXAJJ.js → chunk-YJ4CAD3X.js} +5 -5
  81. package/dist/{chunk-OUUDQA7O.js → chunk-YNHIMOE7.js} +2 -2
  82. package/dist/{chunk-OUWKEJEC.js → chunk-ZGPWIBSZ.js} +7 -5
  83. package/dist/{chunk-OUWKEJEC.js.map → chunk-ZGPWIBSZ.js.map} +1 -1
  84. package/dist/chunk-ZMCU2PZN.js +79 -0
  85. package/dist/chunk-ZMCU2PZN.js.map +1 -0
  86. package/dist/{chunk-G5W6D7KQ.js → chunk-ZNXACRZ5.js} +3 -3
  87. package/dist/{chunk-4LFJM4UN.js → chunk-ZS6F6JLC.js} +10 -10
  88. package/dist/{cleanup-DTOLAQAT.js → cleanup-PWN4XZ2F.js} +29 -28
  89. package/dist/{cleanup-DTOLAQAT.js.map → cleanup-PWN4XZ2F.js.map} +1 -1
  90. package/dist/cli-UTID323G.js +17 -0
  91. package/dist/command-hook-installer-RJH5QLCD.js +97 -0
  92. package/dist/command-hook-installer-RJH5QLCD.js.map +1 -0
  93. package/dist/{config-3RONXBBL.js → config-KGDVJKQN.js} +11 -10
  94. package/dist/{config-3RONXBBL.js.map → config-KGDVJKQN.js.map} +1 -1
  95. package/dist/{diff-YXYQKDJQ.js → diff-ZORXBJDI.js} +15 -14
  96. package/dist/{diff-YXYQKDJQ.js.map → diff-ZORXBJDI.js.map} +1 -1
  97. package/dist/{digest-7PESCB5B.js → digest-PUUBJTD3.js} +12 -11
  98. package/dist/{digest-7PESCB5B.js.map → digest-PUUBJTD3.js.map} +1 -1
  99. package/dist/{fork-J5KH2M7V.js → fork-7L76HZAS.js} +32 -31
  100. package/dist/{fork-J5KH2M7V.js.map → fork-7L76HZAS.js.map} +1 -1
  101. package/dist/{history-T6ZIUHE7.js → history-YX74IRQY.js} +9 -8
  102. package/dist/{hook-JEGFGYMA.js → hook-JCD6SDB3.js} +16 -15
  103. package/dist/{hook-JEGFGYMA.js.map → hook-JCD6SDB3.js.map} +1 -1
  104. package/dist/{hydrate-UWNH7GWK.js → hydrate-W4V5RJYU.js} +11 -10
  105. package/dist/{hydrate-UWNH7GWK.js.map → hydrate-W4V5RJYU.js.map} +1 -1
  106. package/dist/{init-RMLPXKB7.js → init-5MMV2UF5.js} +11 -10
  107. package/dist/{init-RMLPXKB7.js.map → init-5MMV2UF5.js.map} +1 -1
  108. package/dist/install-skills-7EHZBANC.js +16 -0
  109. package/dist/install-skills-bin.js +5 -3
  110. package/dist/install-skills-bin.js.map +1 -1
  111. package/dist/{list-5AMTJAI6.js → list-ZS3UWOGJ.js} +11 -10
  112. package/dist/{list-5AMTJAI6.js.map → list-ZS3UWOGJ.js.map} +1 -1
  113. package/dist/{move-ELVMRSM6.js → move-ZTL7HAIU.js} +21 -20
  114. package/dist/{move-ELVMRSM6.js.map → move-ZTL7HAIU.js.map} +1 -1
  115. package/dist/{note-Q52DD2DT.js → note-B4FVZGJJ.js} +13 -12
  116. package/dist/{note-Q52DD2DT.js.map → note-B4FVZGJJ.js.map} +1 -1
  117. package/dist/{overlaps-NORA5U6L.js → overlaps-W3BLUG53.js} +11 -10
  118. package/dist/{overlaps-NORA5U6L.js.map → overlaps-W3BLUG53.js.map} +1 -1
  119. package/dist/{pin-TC6X4HDA.js → pin-YYQV5OPS.js} +13 -12
  120. package/dist/{pin-TC6X4HDA.js.map → pin-YYQV5OPS.js.map} +1 -1
  121. package/dist/{pr-NQERVORK.js → pr-HQTMQOF5.js} +17 -16
  122. package/dist/{pr-NQERVORK.js.map → pr-HQTMQOF5.js.map} +1 -1
  123. package/dist/{prune-TRPM4VQW.js → prune-6BYOFOUR.js} +28 -27
  124. package/dist/{prune-TRPM4VQW.js.map → prune-6BYOFOUR.js.map} +1 -1
  125. package/dist/{pty-host-52OZBFU5.js → pty-host-KSS45FVH.js} +18 -17
  126. package/dist/{pty-host-52OZBFU5.js.map → pty-host-KSS45FVH.js.map} +1 -1
  127. package/dist/{read-EMO5CVBL.js → read-I5TGSBPC.js} +12 -11
  128. package/dist/{read-EMO5CVBL.js.map → read-I5TGSBPC.js.map} +1 -1
  129. package/dist/{recent-XFC2CZGO.js → recent-GRKJEEKT.js} +10 -9
  130. package/dist/{recent-XFC2CZGO.js.map → recent-GRKJEEKT.js.map} +1 -1
  131. package/dist/{remove-ISNYVVEE.js → remove-64T6TMOE.js} +27 -26
  132. package/dist/{remove-ISNYVVEE.js.map → remove-64T6TMOE.js.map} +1 -1
  133. package/dist/{report-JEG2FKOB.js → report-KAS2UEXO.js} +3 -4
  134. package/dist/{restart-IKVRECL5.js → restart-WJROWFMU.js} +13 -12
  135. package/dist/{restart-IKVRECL5.js.map → restart-WJROWFMU.js.map} +1 -1
  136. package/dist/{resume-LWDUSKDJ.js → resume-634R6KNE.js} +10 -9
  137. package/dist/{resume-LWDUSKDJ.js.map → resume-634R6KNE.js.map} +1 -1
  138. package/dist/{run-TQLQ27GW.js → run-57LGOBXQ.js} +9 -8
  139. package/dist/{run-TQLQ27GW.js.map → run-57LGOBXQ.js.map} +1 -1
  140. package/dist/{screen-VSQAYCFO.js → screen-CX7WUVXM.js} +13 -12
  141. package/dist/{screen-VSQAYCFO.js.map → screen-CX7WUVXM.js.map} +1 -1
  142. package/dist/{search-MEK4ZMO6.js → search-JYAQWT6A.js} +9 -8
  143. package/dist/{search-MEK4ZMO6.js.map → search-JYAQWT6A.js.map} +1 -1
  144. package/dist/{section-C6D5NXLG.js → section-4FICXE46.js} +13 -12
  145. package/dist/{section-C6D5NXLG.js.map → section-4FICXE46.js.map} +1 -1
  146. package/dist/{send-44BXZWDO.js → send-RRTPY47A.js} +20 -19
  147. package/dist/{send-44BXZWDO.js.map → send-RRTPY47A.js.map} +1 -1
  148. package/dist/{sessions-TBAG6NMG.js → sessions-UJNUCYND.js} +22 -21
  149. package/dist/{sessions-TBAG6NMG.js.map → sessions-UJNUCYND.js.map} +1 -1
  150. package/dist/{snooze-ZZRSF3E3.js → snooze-DJEPOBT5.js} +12 -11
  151. package/dist/{snooze-ZZRSF3E3.js.map → snooze-DJEPOBT5.js.map} +1 -1
  152. package/dist/{start-3UPW2TES.js → start-YPEN5QI3.js} +13 -12
  153. package/dist/{start-3UPW2TES.js.map → start-YPEN5QI3.js.map} +1 -1
  154. package/dist/{state-2J4TR7IC.js → state-UAW6DWWU.js} +4 -5
  155. package/dist/{state-2J4TR7IC.js.map → state-UAW6DWWU.js.map} +1 -1
  156. package/dist/{status-OEGNSHMS.js → status-4EOTN33T.js} +10 -9
  157. package/dist/{status-OEGNSHMS.js.map → status-4EOTN33T.js.map} +1 -1
  158. package/dist/statusline-EUT6VZLP.js +93 -0
  159. package/dist/statusline-EUT6VZLP.js.map +1 -0
  160. package/dist/statusline-hook-TZ7M762P.js +118 -0
  161. package/dist/statusline-hook-TZ7M762P.js.map +1 -0
  162. package/dist/{stop-UJ7XWUVZ.js → stop-3UNZ22YA.js} +13 -12
  163. package/dist/{stop-UJ7XWUVZ.js.map → stop-3UNZ22YA.js.map} +1 -1
  164. package/dist/{sync-XHFJEBHL.js → sync-XXZBP6PK.js} +28 -27
  165. package/dist/{sync-XHFJEBHL.js.map → sync-XXZBP6PK.js.map} +1 -1
  166. package/dist/{time-IJXREBKU.js → time-G5Z57AE5.js} +14 -13
  167. package/dist/{time-IJXREBKU.js.map → time-G5Z57AE5.js.map} +1 -1
  168. package/dist/time-actions-H5WCOYZG.js +14 -0
  169. package/dist/{timesheet-L265X66U.js → timesheet-NA7NQUVR.js} +16 -15
  170. package/dist/{timesheet-L265X66U.js.map → timesheet-NA7NQUVR.js.map} +1 -1
  171. package/dist/{todo-FXPXLXXW.js → todo-V7EVWHF2.js} +5 -6
  172. package/dist/{todo-FXPXLXXW.js.map → todo-V7EVWHF2.js.map} +1 -1
  173. package/dist/{tree-L5QLZCTJ.js → tree-R5YXQTP7.js} +23 -22
  174. package/dist/{tree-L5QLZCTJ.js.map → tree-R5YXQTP7.js.map} +1 -1
  175. package/dist/{update-PCWQEFVF.js → update-B3MQXQJ6.js} +15 -14
  176. package/dist/{update-PCWQEFVF.js.map → update-B3MQXQJ6.js.map} +1 -1
  177. package/dist/usage-2HE4RSVM.js +79 -0
  178. package/dist/usage-2HE4RSVM.js.map +1 -0
  179. package/dist/{wait-YL2ZA6OM.js → wait-2OPYJO3K.js} +13 -12
  180. package/dist/{wait-YL2ZA6OM.js.map → wait-2OPYJO3K.js.map} +1 -1
  181. package/dist/wd-bin.js +8 -9
  182. package/dist/wd-bin.js.map +1 -1
  183. package/dist/web/assets/{PtyView-DNqCr6rR.js → PtyView-DgdSx6WG.js} +2 -2
  184. package/dist/web/assets/{PtyView-DNqCr6rR.js.map → PtyView-DgdSx6WG.js.map} +1 -1
  185. package/dist/web/assets/index-C5JNhi3-.css +1 -0
  186. package/dist/web/assets/index-O8yTaaWX.js +119 -0
  187. package/dist/web/assets/index-O8yTaaWX.js.map +1 -0
  188. package/dist/web/index.html +2 -2
  189. package/dist/{web-MIPL4BC7.js → web-QXQ4NGCJ.js} +362 -212
  190. package/dist/web-QXQ4NGCJ.js.map +1 -0
  191. package/npm-shrinkwrap.json +2 -2
  192. package/package.json +1 -1
  193. package/dist/chunk-3HJASVHJ.js.map +0 -1
  194. package/dist/chunk-75MIXOUK.js +0 -104
  195. package/dist/chunk-75MIXOUK.js.map +0 -1
  196. package/dist/chunk-JUMZ5MTU.js.map +0 -1
  197. package/dist/chunk-M2ZJ64JV.js +0 -9
  198. package/dist/chunk-QXJ4FILG.js.map +0 -1
  199. package/dist/chunk-RYEPQLXQ.js.map +0 -1
  200. package/dist/chunk-VESYLAVA.js.map +0 -1
  201. package/dist/chunk-YSGXXNBL.js.map +0 -1
  202. package/dist/cli-4CGRDNWF.js +0 -18
  203. package/dist/command-hook-installer-W7IEVT6V.js.map +0 -1
  204. package/dist/install-skills-TFP6EHI3.js +0 -14
  205. package/dist/time-actions-LMJUFDDR.js +0 -15
  206. package/dist/web/assets/index-Df-7v9bC.js +0 -119
  207. package/dist/web/assets/index-Df-7v9bC.js.map +0 -1
  208. package/dist/web/assets/index-LBhghRtA.css +0 -1
  209. package/dist/web-MIPL4BC7.js.map +0 -1
  210. /package/dist/{chunk-UNEHT6FI.js.map → chunk-2IKWNRMV.js.map} +0 -0
  211. /package/dist/{chunk-P2THO7D7.js.map → chunk-3JY3QT4J.js.map} +0 -0
  212. /package/dist/{chunk-35VLAPL2.js.map → chunk-3PLWNCRM.js.map} +0 -0
  213. /package/dist/{chunk-M2ZJ64JV.js.map → chunk-3Q5RZCQW.js.map} +0 -0
  214. /package/dist/{chunk-C6STZ6HD.js.map → chunk-3UHKPHTB.js.map} +0 -0
  215. /package/dist/{chunk-CRPV5YCC.js.map → chunk-46UTKL5L.js.map} +0 -0
  216. /package/dist/{chunk-VMLRIO4T.js.map → chunk-4PRPDACI.js.map} +0 -0
  217. /package/dist/{chunk-4IEQ7LY4.js.map → chunk-5BNNPXID.js.map} +0 -0
  218. /package/dist/{chunk-CXCMATZG.js.map → chunk-5GA3PFK5.js.map} +0 -0
  219. /package/dist/{chunk-VIWPTRRR.js.map → chunk-5WEDCEZG.js.map} +0 -0
  220. /package/dist/{chunk-YLIPAOBT.js.map → chunk-AFW7HREX.js.map} +0 -0
  221. /package/dist/{chunk-G7TS5DCS.js.map → chunk-B2HUKRWX.js.map} +0 -0
  222. /package/dist/{chunk-Z3NQJALE.js.map → chunk-B7C3RYSJ.js.map} +0 -0
  223. /package/dist/{chunk-ANWA4Z56.js.map → chunk-C5HPSURF.js.map} +0 -0
  224. /package/dist/{chunk-DAQCIJHW.js.map → chunk-CFLMBFBO.js.map} +0 -0
  225. /package/dist/{chunk-JF72AS6T.js.map → chunk-COKQPFLB.js.map} +0 -0
  226. /package/dist/{chunk-TJFX5BWH.js.map → chunk-DO5NW46X.js.map} +0 -0
  227. /package/dist/{chunk-EUAJT7FS.js.map → chunk-G2FE7HUB.js.map} +0 -0
  228. /package/dist/{chunk-VDYX4R6U.js.map → chunk-J5CMORVD.js.map} +0 -0
  229. /package/dist/{chunk-ZGXRWL7T.js.map → chunk-JIYGGN2N.js.map} +0 -0
  230. /package/dist/{chunk-MYDQNX7W.js.map → chunk-KU63EHZO.js.map} +0 -0
  231. /package/dist/{chunk-R5IJHLHA.js.map → chunk-KUVL75PL.js.map} +0 -0
  232. /package/dist/{chunk-PDYO56JU.js.map → chunk-LDFICXOZ.js.map} +0 -0
  233. /package/dist/{chunk-WDV6VTVI.js.map → chunk-LQXGNO5X.js.map} +0 -0
  234. /package/dist/{chunk-I5V34WWS.js.map → chunk-MCSEYS2J.js.map} +0 -0
  235. /package/dist/{chunk-G635EV2D.js.map → chunk-O34CKSE4.js.map} +0 -0
  236. /package/dist/{chunk-QCFINFXO.js.map → chunk-OFCY7RCM.js.map} +0 -0
  237. /package/dist/{chunk-H756AOOW.js.map → chunk-PIKOCEWX.js.map} +0 -0
  238. /package/dist/{chunk-56P7G2DI.js.map → chunk-PUTZR6F5.js.map} +0 -0
  239. /package/dist/{chunk-2MAGDOLP.js.map → chunk-QGKJXCEJ.js.map} +0 -0
  240. /package/dist/{chunk-ZO6MZNLI.js.map → chunk-R3DASZQF.js.map} +0 -0
  241. /package/dist/{chunk-EYUBVLPF.js.map → chunk-SNRP2MC3.js.map} +0 -0
  242. /package/dist/{chunk-4RDAWJZY.js.map → chunk-TBY6ZFAV.js.map} +0 -0
  243. /package/dist/{chunk-GTVQYGY3.js.map → chunk-TPPTL7LA.js.map} +0 -0
  244. /package/dist/{chunk-QKF7CNIM.js.map → chunk-TTTIKTNR.js.map} +0 -0
  245. /package/dist/{chunk-4YCWUHVE.js.map → chunk-UHYIB6AV.js.map} +0 -0
  246. /package/dist/{chunk-CGVYVTGF.js.map → chunk-VEKEA3ER.js.map} +0 -0
  247. /package/dist/{chunk-LJ3UVV4F.js.map → chunk-W4YWFAYC.js.map} +0 -0
  248. /package/dist/{chunk-XLAGFKJE.js.map → chunk-WIWO3YWP.js.map} +0 -0
  249. /package/dist/{chunk-NW2ZXAJJ.js.map → chunk-YJ4CAD3X.js.map} +0 -0
  250. /package/dist/{chunk-OUUDQA7O.js.map → chunk-YNHIMOE7.js.map} +0 -0
  251. /package/dist/{chunk-G5W6D7KQ.js.map → chunk-ZNXACRZ5.js.map} +0 -0
  252. /package/dist/{chunk-4LFJM4UN.js.map → chunk-ZS6F6JLC.js.map} +0 -0
  253. /package/dist/{cli-4CGRDNWF.js.map → cli-UTID323G.js.map} +0 -0
  254. /package/dist/{history-T6ZIUHE7.js.map → history-YX74IRQY.js.map} +0 -0
  255. /package/dist/{install-skills-TFP6EHI3.js.map → install-skills-7EHZBANC.js.map} +0 -0
  256. /package/dist/{report-JEG2FKOB.js.map → report-KAS2UEXO.js.map} +0 -0
  257. /package/dist/{time-actions-LMJUFDDR.js.map → time-actions-H5WCOYZG.js.map} +0 -0
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/platform/process.ts
4
+ import fs from "fs";
5
+ import os from "os";
6
+ import { execFile, spawn, spawnSync } from "child_process";
7
+ function detachHere(platform = process.platform) {
8
+ return platform !== "win32";
9
+ }
10
+ function isPidAlive(pid) {
11
+ try {
12
+ process.kill(pid, 0);
13
+ } catch {
14
+ return false;
15
+ }
16
+ return !isZombie(pid);
17
+ }
18
+ function isZombie(pid, read = procFs, platform = process.platform) {
19
+ if (platform !== "linux") return false;
20
+ const stat = read.file(`/proc/${pid}/stat`) ?? "";
21
+ const close = stat.lastIndexOf(")");
22
+ return close >= 0 && stat[close + 2] === "Z";
23
+ }
24
+ var procFs = {
25
+ link: (p) => {
26
+ try {
27
+ return fs.readlinkSync(p);
28
+ } catch {
29
+ return null;
30
+ }
31
+ },
32
+ file: (p) => {
33
+ try {
34
+ return fs.readFileSync(p, "utf-8");
35
+ } catch {
36
+ return null;
37
+ }
38
+ },
39
+ pids: () => {
40
+ try {
41
+ return fs.readdirSync("/proc").filter((n) => /^\d+$/.test(n)).map(Number);
42
+ } catch {
43
+ return [];
44
+ }
45
+ }
46
+ };
47
+ var baseName = (p) => p.split("/").pop() || p;
48
+ function linuxProcessName(pid, read = procFs) {
49
+ const exe = read.link(`/proc/${pid}/exe`);
50
+ if (exe) return baseName(exe.replace(/ \(deleted\)$/, ""));
51
+ const argv0 = (read.file(`/proc/${pid}/cmdline`) ?? "").split("\0")[0];
52
+ if (argv0) return baseName(argv0.split(" ")[0]);
53
+ const comm = (read.file(`/proc/${pid}/comm`) ?? "").trim();
54
+ return comm || null;
55
+ }
56
+ function linuxProcessTable(read = procFs) {
57
+ const out = /* @__PURE__ */ new Map();
58
+ for (const pid of read.pids()) {
59
+ const name = linuxProcessName(pid, read);
60
+ if (name) out.set(pid, name);
61
+ }
62
+ return out;
63
+ }
64
+ function processName(pid) {
65
+ try {
66
+ if (process.platform === "win32") {
67
+ const r2 = spawnSync("tasklist", ["/FI", `PID eq ${pid}`, "/FO", "CSV", "/NH"], {
68
+ encoding: "utf-8",
69
+ windowsHide: true,
70
+ timeout: 5e3
71
+ });
72
+ const m = /^"([^"]+)","(\d+)"/.exec((r2.stdout ?? "").trim());
73
+ return m && Number(m[2]) === pid ? m[1] : null;
74
+ }
75
+ if (process.platform === "linux") return isPidAlive(pid) ? linuxProcessName(pid) : null;
76
+ const r = spawnSync("ps", ["-o", "comm=", "-p", String(pid)], { encoding: "utf-8", timeout: 5e3, windowsHide: true });
77
+ const name = (r.stdout ?? "").trim();
78
+ return r.status === 0 && name ? name.split("/").pop() : null;
79
+ } catch {
80
+ return null;
81
+ }
82
+ }
83
+ var recentTable = null;
84
+ var refreshingTable = null;
85
+ function recentProcessTable(maxAgeMs, now = Date.now()) {
86
+ if (!recentTable || now - recentTable.at >= maxAgeMs) {
87
+ refreshingTable ??= processTableAsync().then((table) => void (table.size > 0 && (recentTable = { at: Date.now(), table }))).finally(() => void (refreshingTable = null));
88
+ }
89
+ return recentTable?.table ?? null;
90
+ }
91
+ function processTableAsync() {
92
+ if (process.platform === "linux") return Promise.resolve(linuxProcessTable());
93
+ return new Promise((resolve) => {
94
+ const win = process.platform === "win32";
95
+ const [cmd, args] = win ? ["tasklist", ["/FO", "CSV", "/NH"]] : ["ps", ["-A", "-o", "pid=,comm="]];
96
+ execFile(
97
+ cmd,
98
+ args,
99
+ { encoding: "utf-8", windowsHide: true, timeout: 8e3, maxBuffer: 16 * 1024 * 1024 },
100
+ (_err, stdout) => {
101
+ resolve(parseProcessTable(stdout ?? "", win));
102
+ }
103
+ );
104
+ });
105
+ }
106
+ function parseProcessTable(stdout, win) {
107
+ const out = /* @__PURE__ */ new Map();
108
+ for (const line of stdout.split(/\r?\n/)) {
109
+ if (win) {
110
+ const m = /^"([^"]+)","(\d+)"/.exec(line);
111
+ if (m) out.set(Number(m[2]), m[1]);
112
+ } else {
113
+ const m = /^\s*(\d+)\s+(.+)$/.exec(line);
114
+ if (m) out.set(Number(m[1]), m[2].trim().split("/").pop());
115
+ }
116
+ }
117
+ return out;
118
+ }
119
+ function processTable() {
120
+ if (process.platform === "linux") return linuxProcessTable();
121
+ try {
122
+ const win = process.platform === "win32";
123
+ const r = win ? spawnSync("tasklist", ["/FO", "CSV", "/NH"], { encoding: "utf-8", windowsHide: true, timeout: 8e3, maxBuffer: 16 * 1024 * 1024 }) : spawnSync("ps", ["-A", "-o", "pid=,comm="], { encoding: "utf-8", timeout: 8e3, windowsHide: true, maxBuffer: 16 * 1024 * 1024 });
124
+ return parseProcessTable(r.stdout ?? "", win);
125
+ } catch {
126
+ return /* @__PURE__ */ new Map();
127
+ }
128
+ }
129
+ function bootTime() {
130
+ return Date.now() - os.uptime() * 1e3;
131
+ }
132
+ function killTree(pid) {
133
+ if (process.platform === "win32") {
134
+ return spawnSync("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true }).status === 0;
135
+ }
136
+ try {
137
+ process.kill(pid);
138
+ return true;
139
+ } catch {
140
+ return false;
141
+ }
142
+ }
143
+ function killTreeAsync(pid) {
144
+ if (process.platform !== "win32") return Promise.resolve(killTree(pid) || !isPidAlive(pid));
145
+ return new Promise(
146
+ (resolve) => (
147
+ // taskkill fails the whole call when one child had already exited or won't go; the top gone is what counts.
148
+ execFile(
149
+ "taskkill",
150
+ ["/PID", String(pid), "/T", "/F"],
151
+ { windowsHide: true, timeout: 1e4 },
152
+ (err) => resolve(!err || !isPidAlive(pid))
153
+ )
154
+ )
155
+ );
156
+ }
157
+ function spawnDetachedWork(workBin, args, logFile) {
158
+ const log = fs.openSync(logFile, "a");
159
+ try {
160
+ const child = spawn(process.execPath, [workBin, ...args], {
161
+ detached: true,
162
+ stdio: ["ignore", log, log],
163
+ windowsHide: true,
164
+ // Not the caller's folder: a long-lived server working from it keeps it
165
+ // in use on Windows — a worktree then can't be removed, the desktop
166
+ // app's install folder can't be updated.
167
+ cwd: os.homedir()
168
+ });
169
+ child.unref();
170
+ } finally {
171
+ fs.closeSync(log);
172
+ }
173
+ }
174
+
175
+ export {
176
+ detachHere,
177
+ isPidAlive,
178
+ processName,
179
+ recentProcessTable,
180
+ processTable,
181
+ bootTime,
182
+ killTree,
183
+ killTreeAsync,
184
+ spawnDetachedWork
185
+ };
186
+ //# sourceMappingURL=chunk-VMBWCDBA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/platform/process.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport { execFile, spawn, spawnSync } from 'node:child_process';\n\n/**\n * Process lifecycle rules for the long-lived pieces (work web, the PTY\n * host), in one place — they differ on Windows in ways that bit us:\n *\n * - Killing: process.kill on Windows is TerminateProcess of that one\n * process — its ConPTY children (Claudes) survive, orphaned. Kill the\n * tree with taskkill /T /F. Elsewhere SIGTERM lets the process clean up\n * its own children.\n * - Liveness: `process.kill(pid, 0)` works on both, but a live PID is not\n * proof it's OURS (Windows reuses PIDs fast) — callers that act on it\n * must also verify identity (e.g. the host's /health token check).\n * - Detached `work` children: `detached` + `windowsHide` so no console\n * window flashes and the child outlives the parent's terminal; output\n * goes to a log file, never the parent's stdio.\n * - Anything else started in the background (an editor, a URL, a toast, a\n * status hook): `detached` on POSIX only (`detachHere`). On Windows a\n * detached process has no console at all, so every console program it\n * starts — cmd.exe running code.cmd, PowerShell — opens a window of its\n * own, and `windowsHide` can't stop that (measured: detached flashed a\n * Windows Terminal window every time, hidden alone never). A child there\n * outlives its parent anyway.\n */\n\n/** Start a background program detached? POSIX yes (its own process group); Windows no — see above. */\nexport function detachHere(platform: NodeJS.Platform = process.platform): boolean {\n return platform !== 'win32';\n}\n\nexport function isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n } catch {\n return false;\n }\n return !isZombie(pid);\n}\n\n/**\n * Exited, but not yet collected by its parent (a zombie): `kill(pid, 0)` still\n * succeeds, though nothing runs. A server started by a parent that never\n * waits for it — the desktop app's work web, or a test's child while the test\n * blocks in spawnSync — is one once it stops, and `work web --dev --stop`\n * waited for it to go, then said it didn't. Linux only (/proc/<pid>/stat: the\n * state letter after the command's closing parenthesis); elsewhere false.\n */\nexport function isZombie(pid: number, read: Pick<ProcReader, 'file'> = procFs, platform: NodeJS.Platform = process.platform): boolean {\n if (platform !== 'linux') return false;\n const stat = read.file(`/proc/${pid}/stat`) ?? '';\n // The state follows the command name, which is in parentheses and may hold some.\n const close = stat.lastIndexOf(')');\n return close >= 0 && stat[close + 2] === 'Z';\n}\n\n/** How /proc is read (tests pass a fake one). */\nexport interface ProcReader {\n link: (p: string) => string | null;\n file: (p: string) => string | null;\n pids: () => number[];\n}\n\nconst procFs: ProcReader = {\n link: (p) => {\n try {\n return fs.readlinkSync(p);\n } catch {\n return null;\n }\n },\n file: (p) => {\n try {\n return fs.readFileSync(p, 'utf-8');\n } catch {\n return null;\n }\n },\n pids: () => {\n try {\n return fs\n .readdirSync('/proc')\n .filter((n) => /^\\d+$/.test(n))\n .map(Number);\n } catch {\n return [];\n }\n },\n};\n\nconst baseName = (p: string) => p.split('/').pop() || p;\n\n/**\n * On Linux, the program a process runs, from /proc: its executable when it\n * can be read (our own processes), else its command line's first word, else\n * its `comm`. Not `ps -o comm` alone: that is its main thread's name, which\n * Node 24 sets to \"MainThread\" — every node process, Claude Code's included,\n * read as that, and no Claude was ever found running.\n */\nexport function linuxProcessName(pid: number, read: ProcReader = procFs): string | null {\n const exe = read.link(`/proc/${pid}/exe`);\n if (exe) return baseName(exe.replace(/ \\(deleted\\)$/, ''));\n const argv0 = (read.file(`/proc/${pid}/cmdline`) ?? '').split('\\0')[0];\n if (argv0) return baseName(argv0.split(' ')[0]);\n const comm = (read.file(`/proc/${pid}/comm`) ?? '').trim();\n return comm || null;\n}\n\n/** On Linux, every process's program by pid (linuxProcessName), from /proc: no `ps` to run. */\nexport function linuxProcessTable(read: ProcReader = procFs): Map<number, string> {\n const out = new Map<number, string>();\n for (const pid of read.pids()) {\n const name = linuxProcessName(pid, read);\n if (name) out.set(pid, name);\n }\n return out;\n}\n\n/**\n * The executable name of a live process (\"cmd.exe\", \"sh\"), or null if it\n * isn't running or can't be read. For checking a remembered pid is still\n * the process we started before acting on it — pids get reused.\n */\nexport function processName(pid: number): string | null {\n try {\n if (process.platform === 'win32') {\n const r = spawnSync('tasklist', ['/FI', `PID eq ${pid}`, '/FO', 'CSV', '/NH'], {\n encoding: 'utf-8',\n windowsHide: true,\n timeout: 5000,\n });\n const m = /^\"([^\"]+)\",\"(\\d+)\"/.exec((r.stdout ?? '').trim());\n return m && Number(m[2]) === pid ? m[1] : null;\n }\n if (process.platform === 'linux') return isPidAlive(pid) ? linuxProcessName(pid) : null;\n const r = spawnSync('ps', ['-o', 'comm=', '-p', String(pid)], { encoding: 'utf-8', timeout: 5000, windowsHide: true });\n const name = (r.stdout ?? '').trim();\n return r.status === 0 && name ? name.split('/').pop()! : null;\n } catch {\n return null;\n }\n}\n\nlet recentTable: { at: number; table: Map<number, string> } | null = null;\nlet refreshingTable: Promise<void> | null = null;\n\n/**\n * The process table as of at most `maxAgeMs` ago, without waiting: a stale\n * or missing one starts a background refresh (one at a time) and the last\n * one is returned — null before the first is in. For views that refresh\n * often (the session list); a decision that must be right now (is a Claude\n * already running, before starting one?) uses processTable().\n */\nexport function recentProcessTable(maxAgeMs: number, now = Date.now()): Map<number, string> | null {\n if (!recentTable || now - recentTable.at >= maxAgeMs) {\n refreshingTable ??= processTableAsync()\n // An empty table is a failed or timed-out listing (there is always at\n // least this process): keep the last good one, and try again next time.\n .then((table) => void (table.size > 0 && (recentTable = { at: Date.now(), table })))\n .finally(() => void (refreshingTable = null));\n }\n return recentTable?.table ?? null;\n}\n\n/** processTable(), without blocking the event loop. */\nexport function processTableAsync(): Promise<Map<number, string>> {\n if (process.platform === 'linux') return Promise.resolve(linuxProcessTable());\n return new Promise((resolve) => {\n const win = process.platform === 'win32';\n const [cmd, args] = win ? ['tasklist', ['/FO', 'CSV', '/NH']] : ['ps', ['-A', '-o', 'pid=,comm=']];\n execFile(\n cmd,\n args as string[],\n { encoding: 'utf-8', windowsHide: true, timeout: 8000, maxBuffer: 16 * 1024 * 1024 },\n (_err, stdout) => {\n resolve(parseProcessTable(stdout ?? '', win));\n },\n );\n });\n}\n\nfunction parseProcessTable(stdout: string, win: boolean): Map<number, string> {\n const out = new Map<number, string>();\n for (const line of stdout.split(/\\r?\\n/)) {\n if (win) {\n const m = /^\"([^\"]+)\",\"(\\d+)\"/.exec(line);\n if (m) out.set(Number(m[2]), m[1]);\n } else {\n const m = /^\\s*(\\d+)\\s+(.+)$/.exec(line);\n if (m) out.set(Number(m[1]), m[2].trim().split('/').pop()!);\n }\n }\n return out;\n}\n\n/**\n * Every running process's executable name, by pid, in ONE call (tasklist /\n * ps) — for checking many remembered pids at once. Empty if it can't be read.\n */\nexport function processTable(): Map<number, string> {\n if (process.platform === 'linux') return linuxProcessTable();\n try {\n const win = process.platform === 'win32';\n const r = win\n ? spawnSync('tasklist', ['/FO', 'CSV', '/NH'], { encoding: 'utf-8', windowsHide: true, timeout: 8000, maxBuffer: 16 * 1024 * 1024 })\n : spawnSync('ps', ['-A', '-o', 'pid=,comm='], { encoding: 'utf-8', timeout: 8000, windowsHide: true, maxBuffer: 16 * 1024 * 1024 });\n return parseProcessTable(r.stdout ?? '', win);\n } catch {\n return new Map(); // unreadable: nothing is known to be alive\n }\n}\n\n/** When this machine last booted (ms since epoch, ±1 s). */\nexport function bootTime(): number {\n return Date.now() - os.uptime() * 1000;\n}\n\n/** Kill a process AND its children. True if the kill was delivered. */\nexport function killTree(pid: number): boolean {\n if (process.platform === 'win32') {\n return spawnSync('taskkill', ['/PID', String(pid), '/T', '/F'], { stdio: 'ignore', windowsHide: true }).status === 0;\n }\n try {\n process.kill(pid);\n return true;\n } catch {\n return false;\n }\n}\n\n/** killTree, not blocking the event loop (taskkill takes a few hundred ms): for a server killing several at once. */\nexport function killTreeAsync(pid: number): Promise<boolean> {\n // Already gone counts as stopped, as with taskkill below: it's what the caller wanted.\n if (process.platform !== 'win32') return Promise.resolve(killTree(pid) || !isPidAlive(pid));\n return new Promise((resolve) =>\n // taskkill fails the whole call when one child had already exited or won't go; the top gone is what counts.\n execFile('taskkill', ['/PID', String(pid), '/T', '/F'], { windowsHide: true, timeout: 10_000 }, (err) =>\n resolve(!err || !isPidAlive(pid)),\n ),\n );\n}\n\n/**\n * Start `node <workBin> ...args` detached, appending its output to\n * `logFile`. Returns immediately; the caller polls for readiness (a\n * discovery file / health check), because a detached child can't report\n * back directly.\n */\nexport function spawnDetachedWork(workBin: string, args: string[], logFile: string): void {\n const log = fs.openSync(logFile, 'a');\n try {\n const child = spawn(process.execPath, [workBin, ...args], {\n detached: true,\n stdio: ['ignore', log, log],\n windowsHide: true,\n // Not the caller's folder: a long-lived server working from it keeps it\n // in use on Windows — a worktree then can't be removed, the desktop\n // app's install folder can't be updated.\n cwd: os.homedir(),\n });\n child.unref();\n } finally {\n fs.closeSync(log);\n }\n}\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,SAAS,UAAU,OAAO,iBAAiB;AA0BpC,SAAS,WAAW,WAA4B,QAAQ,UAAmB;AAChF,SAAO,aAAa;AACtB;AAEO,SAAS,WAAW,KAAsB;AAC/C,MAAI;AACF,YAAQ,KAAK,KAAK,CAAC;AAAA,EACrB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,SAAO,CAAC,SAAS,GAAG;AACtB;AAUO,SAAS,SAAS,KAAa,OAAiC,QAAQ,WAA4B,QAAQ,UAAmB;AACpI,MAAI,aAAa,QAAS,QAAO;AACjC,QAAM,OAAO,KAAK,KAAK,SAAS,GAAG,OAAO,KAAK;AAE/C,QAAM,QAAQ,KAAK,YAAY,GAAG;AAClC,SAAO,SAAS,KAAK,KAAK,QAAQ,CAAC,MAAM;AAC3C;AASA,IAAM,SAAqB;AAAA,EACzB,MAAM,CAAC,MAAM;AACX,QAAI;AACF,aAAO,GAAG,aAAa,CAAC;AAAA,IAC1B,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,MAAM,CAAC,MAAM;AACX,QAAI;AACF,aAAO,GAAG,aAAa,GAAG,OAAO;AAAA,IACnC,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,MAAM,MAAM;AACV,QAAI;AACF,aAAO,GACJ,YAAY,OAAO,EACnB,OAAO,CAAC,MAAM,QAAQ,KAAK,CAAC,CAAC,EAC7B,IAAI,MAAM;AAAA,IACf,QAAQ;AACN,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AACF;AAEA,IAAM,WAAW,CAAC,MAAc,EAAE,MAA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ElB;AAAA,QAAS;AAAA,QAAY,CAAC,QAAQ,OAAO,GAAG,GAAG,MAAM,IAAI;AAAA,QAAG,EAAE,aAAa,MAAM,SAAS,IAAO;AAAA,QAAG,CAAC,QAC/F,QAAQ,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC;AAAA,MAClC;AAAA;AAAA,EACF;AACF;AAQO,SAAS,kBAAkB,SAAiB,MAAgB,SAAuB;AACxF,QAAM,MAAM,GAAG,SAAS,SAAS,GAAG;AACpC,MAAI;AACF,UAAM,QAAQ,MAAM,QAAQ,UAAU,CAAC,SAAS,GAAG,IAAI,GAAG;AAAA,MACxD,UAAU;AAAA,MACV,OAAO,CAAC,UAAU,KAAK,GAAG;AAAA,MAC1B,aAAa;AAAA;AAAA;AAAA;AAAA,MAIb,KAAK,GAAG,QAAQ;AAAA,IAClB,CAAC;AACD,UAAM,MAAM;AAAA,EACd,UAAE;AACA,OAAG,UAAU,GAAG;AAAA,EAClB;AACF;","names":["r"]}
@@ -4,14 +4,14 @@ import {
4
4
  } from "./chunk-AH5TM3NB.js";
5
5
  import {
6
6
  spawnSpecFor
7
- } from "./chunk-4LFJM4UN.js";
7
+ } from "./chunk-ZS6F6JLC.js";
8
8
  import {
9
9
  PtyHostClient,
10
10
  ensureHost
11
- } from "./chunk-DAQCIJHW.js";
11
+ } from "./chunk-CFLMBFBO.js";
12
12
  import {
13
13
  sessionIdFor
14
- } from "./chunk-JF72AS6T.js";
14
+ } from "./chunk-COKQPFLB.js";
15
15
 
16
16
  // src/commands/shared/attach-session.ts
17
17
  import chalk from "chalk";
@@ -117,4 +117,4 @@ async function attachSession(session, launch = {}) {
117
117
  export {
118
118
  attachSession
119
119
  };
120
- //# sourceMappingURL=chunk-LJ3UVV4F.js.map
120
+ //# sourceMappingURL=chunk-W4YWFAYC.js.map
@@ -1,16 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  computeRangeDiff
4
- } from "./chunk-G7TS5DCS.js";
4
+ } from "./chunk-B2HUKRWX.js";
5
5
  import {
6
6
  loadManifest
7
- } from "./chunk-JUMZ5MTU.js";
7
+ } from "./chunk-MGQK6BWH.js";
8
8
  import {
9
9
  agentSettings,
10
10
  internalAgent,
11
- internalRunEnv,
11
+ internalRunEnv
12
+ } from "./chunk-FUNZ7TOS.js";
13
+ import {
12
14
  killTree
13
- } from "./chunk-VESYLAVA.js";
15
+ } from "./chunk-VMBWCDBA.js";
14
16
  import {
15
17
  spawn_default
16
18
  } from "./chunk-RCYI7SRA.js";
@@ -185,4 +187,4 @@ export {
185
187
  runInternal,
186
188
  summarizeCheckpoint
187
189
  };
188
- //# sourceMappingURL=chunk-KWRE6HQN.js.map
190
+ //# sourceMappingURL=chunk-W7WC7UA2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/platform/throttle.ts","../src/core/diff/checkpoint-summary.ts"],"sourcesContent":["/**\n * Call `fn` at most once per `ms`: the first call goes through at once, and\n * calls inside the window collapse into one at its end (so the last state\n * always gets through). For events that make every client refetch.\n */\nexport function throttleTrailing(\n fn: () => void,\n ms: number,\n clock: { now: () => number; setTimeout: (cb: () => void, ms: number) => unknown } = {\n now: Date.now,\n setTimeout: (cb, t) => setTimeout(cb, t),\n },\n): () => void {\n let lastAt = -Infinity;\n let pending = false;\n return () => {\n const wait = lastAt + ms - clock.now();\n if (wait <= 0) {\n lastAt = clock.now();\n fn();\n return;\n }\n if (pending) return;\n pending = true;\n clock.setTimeout(() => {\n pending = false;\n lastAt = clock.now();\n fn();\n }, wait);\n };\n}\n\n/**\n * Run jobs one at a time, in the order they came: `run(fn)` resolves with\n * `fn`'s result once every earlier job finished. A failed job doesn't stop\n * the queue.\n */\nexport function createSerialQueue(): <T>(fn: () => Promise<T>) => Promise<T> {\n let tail: Promise<unknown> = Promise.resolve();\n return <T>(fn: () => Promise<T>) => {\n const run = tail.then(fn, fn);\n tail = run.catch(() => undefined);\n return run;\n };\n}\n","/**\n * Lazy, cached one-line summaries of what changed at a checkpoint.\n *\n * The diff between checkpoint `id-1` and `id` is rendered to a compact text\n * blob and handed to `claude -p` for a terse label. The result is cached in\n * the manifest `label` (see `setCheckpointLabel`) so each checkpoint is only\n * summarised once. If Claude is unavailable or times out, a cheap heuristic\n * label (\"3 files · +52 −8\") is returned instead so the UI never blocks on\n * an external binary.\n */\nimport { internalRunEnv } from '../platform/internal-run.js';\nimport spawn from '../platform/spawn.js';\nimport path from 'node:path';\nimport { computeRangeDiff } from './diff-pipeline.js';\nimport { loadManifest } from './checkpoint.js';\nimport { internalAgent, agentSettings } from '../agents/index.js';\nimport { killTree } from '../platform/process.js';\nimport { createSerialQueue } from '../platform/throttle.js';\nimport type { ParsedFile } from './diff-parse.js';\n\nexport interface SummaryRepo {\n /** Manifest key — the full repo path (see scope-routes `scopeRepos`). */\n name: string;\n root: string;\n}\n\n/** Cap on the diff text we feed Claude — keeps the prompt small and cheap. */\nconst MAX_DIFF_CHARS = 6000;\nconst MAX_LABEL_CHARS = 80;\n\n/** Render the delta into checkpoint `id` as `{ files, added, deleted, text }`. */\nfunction buildDelta(\n scopeHash: string,\n repos: SummaryRepo[],\n id: number,\n): { files: ParsedFile[]; added: number; deleted: number; text: string } {\n const manifest = loadManifest(scopeHash);\n const entry = manifest.entries.find((e) => e.id === id);\n const prev = manifest.entries.find((e) => e.id === id - 1);\n const all: ParsedFile[] = [];\n for (const repo of repos) {\n const toRef = entry?.repos[repo.name];\n if (!toRef) continue;\n // Missing prev sha (fresh repo) → diff against the empty tree by passing\n // the well-known empty-tree object isn't available here cheaply; fall\n // back to HEAD which yields the same files for the common case.\n const fromRef = prev?.repos[repo.name] ?? 'HEAD';\n try {\n all.push(...computeRangeDiff({ root: repo.root, fromRef, toRef }));\n } catch {\n /* skip a repo that fails to diff */\n }\n }\n let added = 0;\n let deleted = 0;\n for (const f of all) {\n added += f.added;\n deleted += f.deleted;\n }\n // Compact patch text: file header lines + their changed lines, truncated.\n const parts: string[] = [];\n let budget = MAX_DIFF_CHARS;\n for (const f of all) {\n const head = `### ${f.status} ${f.path} (+${f.added} -${f.deleted})\\n`;\n if (budget - head.length < 0) break;\n parts.push(head);\n budget -= head.length;\n for (const h of f.hunks) {\n for (const ln of h.lines) {\n if (ln.kind !== 'add' && ln.kind !== 'delete') continue;\n const prefix = ln.kind === 'add' ? '+' : '-';\n const line = `${prefix}${ln.content}\\n`;\n if (budget - line.length < 0) {\n budget = -1;\n break;\n }\n parts.push(line);\n budget -= line.length;\n }\n if (budget < 0) break;\n }\n if (budget < 0) break;\n }\n return { files: all, added, deleted, text: parts.join('') };\n}\n\n/** Cheap fallback label when Claude can't be reached. */\nfunction heuristicLabel(files: ParsedFile[], added: number, deleted: number): string {\n if (files.length === 0) return 'no changes';\n if (files.length === 1) {\n return `${path.basename(files[0].path)} +${added} −${deleted}`;\n }\n return `${files.length} files · +${added} −${deleted}`;\n}\n\n/** One internal run at a time, however many turns finish together. */\nconst internalQueue = createSerialQueue();\n\n/**\n * Run work's summarising agent (config `internalAgent`, Claude Code by\n * default: agents/ `oneShot`) with the prompt on stdin; resolve its trimmed\n * stdout, or null on error, timeout, or an agent that has no one-shot runs.\n * Async (never blocks the server event loop). `small`: a few words wanted.\n */\nexport function runInternal(prompt: string, timeoutMs = 25_000, opts: { small?: boolean } = {}): Promise<string | null> {\n const oneShot = internalAgent(agentSettings()).oneShot;\n if (!oneShot) return Promise.resolve(null);\n return internalQueue(() => runNow(prompt, timeoutMs, oneShot.command(opts)));\n}\n\nfunction runNow(\n prompt: string,\n timeoutMs: number,\n run: { cmd: string; args: string[]; cwd: string; env: NodeJS.ProcessEnv },\n): Promise<string | null> {\n return new Promise((resolve) => {\n let settled = false;\n const finish = (v: string | null) => {\n if (settled) return;\n settled = true;\n resolve(v);\n };\n let out = '';\n let child: ReturnType<typeof spawn>;\n try {\n // Text-only, no tools, neutral cwd, tagged internal (so it doesn't\n // trip work's own hooks) — the agent's oneShot.command.\n child = spawn(run.cmd, run.args, {\n stdio: ['pipe', 'pipe', 'ignore'],\n windowsHide: true,\n cwd: run.cwd,\n env: { ...run.env, ...internalRunEnv() }, // tagged by work, whatever the agent's command says\n });\n } catch {\n finish(null);\n return;\n }\n const timer = setTimeout(() => {\n // The whole tree: on Windows the agent may be a .cmd shim, and killing\n // only cmd.exe left the real one running, orphaned.\n if (child.pid) killTree(child.pid);\n else {\n try {\n child.kill();\n } catch {\n /* already gone */\n }\n }\n finish(null);\n }, timeoutMs);\n child.stdout?.on('data', (d: Buffer) => {\n out += d.toString();\n });\n child.on('error', () => {\n clearTimeout(timer);\n finish(null);\n });\n child.on('close', (code: number | null) => {\n clearTimeout(timer);\n finish(code === 0 && out.trim() ? out.trim() : null);\n });\n try {\n child.stdin?.write(prompt);\n child.stdin?.end();\n } catch {\n clearTimeout(timer);\n finish(null);\n }\n });\n}\n\n/** Normalise Claude's reply to a single terse line. */\nfunction cleanLabel(raw: string): string {\n const firstLine =\n raw\n .split('\\n')\n .map((l) => l.trim())\n .find(Boolean) ?? '';\n // Strip surrounding quotes / trailing punctuation, collapse whitespace.\n const cleaned = firstLine\n .replace(/^[\"'`]+|[\"'`]+$/g, '')\n .replace(/\\s+/g, ' ')\n .replace(/[.;]+$/, '')\n .trim();\n return cleaned.slice(0, MAX_LABEL_CHARS);\n}\n\n/**\n * Produce a one-line label for checkpoint `id`. Tries Claude; falls back to\n * a heuristic. Pure (no caching) — the caller persists the result.\n */\nexport async function summarizeCheckpoint(scopeHash: string, repos: SummaryRepo[], id: number): Promise<string> {\n const { files, added, deleted, text } = buildDelta(scopeHash, repos, id);\n if (files.length === 0) return 'no changes';\n const fallback = heuristicLabel(files, added, deleted);\n if (!text.trim()) return fallback;\n const prompt =\n 'Summarise this code change in 8 words or fewer, imperative mood, ' +\n 'no trailing punctuation. Output ONLY the summary line.\\n\\n' +\n text;\n const reply = await runInternal(prompt, 25_000, { small: true });\n if (!reply) return fallback;\n const label = cleanLabel(reply);\n return label || fallback;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAKO,SAAS,iBACd,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,IACG,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,KAAK,OAAO,KAAK;AAEtB,QAAM,UAAU,UACb,QAAQ,oBAAoB,EAAE,EAC9B,QAAQ,QAAQ,GAAG,EACnB,QAAQ,UAAU,EAAE,EACpB,KAAK;AACR,SAAO,QAAQ,MAAM,GAAG,eAAe;AACzC;AAMA,eAAsB,oBAAoB,WAAmB,OAAsB,IAA6B;AAC9G,QAAM,EAAE,OAAO,OAAO,SAAS,KAAK,IAAI,WAAW,WAAW,OAAO,EAAE;AACvE,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,WAAW,eAAe,OAAO,OAAO,OAAO;AACrD,MAAI,CAAC,KAAK,KAAK,EAAG,QAAO;AACzB,QAAM,SACJ,gIAEA;AACF,QAAM,QAAQ,MAAM,YAAY,QAAQ,MAAQ,EAAE,OAAO,KAAK,CAAC;AAC/D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,QAAQ,WAAW,KAAK;AAC9B,SAAO,SAAS;AAClB;","names":[]}
1
+ {"version":3,"sources":["../src/core/platform/throttle.ts","../src/core/diff/checkpoint-summary.ts"],"sourcesContent":["/**\n * Call `fn` at most once per `ms`: the first call goes through at once, and\n * calls inside the window collapse into one at its end (so the last state\n * always gets through). For events that make every client refetch.\n */\nexport function throttleTrailing(\n fn: () => void,\n ms: number,\n clock: { now: () => number; setTimeout: (cb: () => void, ms: number) => unknown } = {\n now: Date.now,\n setTimeout: (cb, t) => setTimeout(cb, t),\n },\n): () => void {\n let lastAt = -Infinity;\n let pending = false;\n return () => {\n const wait = lastAt + ms - clock.now();\n if (wait <= 0) {\n lastAt = clock.now();\n fn();\n return;\n }\n if (pending) return;\n pending = true;\n clock.setTimeout(() => {\n pending = false;\n lastAt = clock.now();\n fn();\n }, wait);\n };\n}\n\n/**\n * Run jobs one at a time, in the order they came: `run(fn)` resolves with\n * `fn`'s result once every earlier job finished. A failed job doesn't stop\n * the queue.\n */\nexport function createSerialQueue(): <T>(fn: () => Promise<T>) => Promise<T> {\n let tail: Promise<unknown> = Promise.resolve();\n return <T>(fn: () => Promise<T>) => {\n const run = tail.then(fn, fn);\n tail = run.catch(() => undefined);\n return run;\n };\n}\n","/**\n * Lazy, cached one-line summaries of what changed at a checkpoint.\n *\n * The diff between checkpoint `id-1` and `id` is rendered to a compact text\n * blob and handed to `claude -p` for a terse label. The result is cached in\n * the manifest `label` (see `setCheckpointLabel`) so each checkpoint is only\n * summarised once. If Claude is unavailable or times out, a cheap heuristic\n * label (\"3 files · +52 −8\") is returned instead so the UI never blocks on\n * an external binary.\n */\nimport { internalRunEnv } from '../platform/internal-run.js';\nimport spawn from '../platform/spawn.js';\nimport path from 'node:path';\nimport { computeRangeDiff } from './diff-pipeline.js';\nimport { loadManifest } from './checkpoint.js';\nimport { internalAgent, agentSettings } from '../agents/index.js';\nimport { killTree } from '../platform/process.js';\nimport { createSerialQueue } from '../platform/throttle.js';\nimport type { ParsedFile } from './diff-parse.js';\n\nexport interface SummaryRepo {\n /** Manifest key — the full repo path (see scope-routes `scopeRepos`). */\n name: string;\n root: string;\n}\n\n/** Cap on the diff text we feed Claude — keeps the prompt small and cheap. */\nconst MAX_DIFF_CHARS = 6000;\nconst MAX_LABEL_CHARS = 80;\n\n/** Render the delta into checkpoint `id` as `{ files, added, deleted, text }`. */\nfunction buildDelta(\n scopeHash: string,\n repos: SummaryRepo[],\n id: number,\n): { files: ParsedFile[]; added: number; deleted: number; text: string } {\n const manifest = loadManifest(scopeHash);\n const entry = manifest.entries.find((e) => e.id === id);\n const prev = manifest.entries.find((e) => e.id === id - 1);\n const all: ParsedFile[] = [];\n for (const repo of repos) {\n const toRef = entry?.repos[repo.name];\n if (!toRef) continue;\n // Missing prev sha (fresh repo) → diff against the empty tree by passing\n // the well-known empty-tree object isn't available here cheaply; fall\n // back to HEAD which yields the same files for the common case.\n const fromRef = prev?.repos[repo.name] ?? 'HEAD';\n try {\n all.push(...computeRangeDiff({ root: repo.root, fromRef, toRef }));\n } catch {\n /* skip a repo that fails to diff */\n }\n }\n let added = 0;\n let deleted = 0;\n for (const f of all) {\n added += f.added;\n deleted += f.deleted;\n }\n // Compact patch text: file header lines + their changed lines, truncated.\n const parts: string[] = [];\n let budget = MAX_DIFF_CHARS;\n for (const f of all) {\n const head = `### ${f.status} ${f.path} (+${f.added} -${f.deleted})\\n`;\n if (budget - head.length < 0) break;\n parts.push(head);\n budget -= head.length;\n for (const h of f.hunks) {\n for (const ln of h.lines) {\n if (ln.kind !== 'add' && ln.kind !== 'delete') continue;\n const prefix = ln.kind === 'add' ? '+' : '-';\n const line = `${prefix}${ln.content}\\n`;\n if (budget - line.length < 0) {\n budget = -1;\n break;\n }\n parts.push(line);\n budget -= line.length;\n }\n if (budget < 0) break;\n }\n if (budget < 0) break;\n }\n return { files: all, added, deleted, text: parts.join('') };\n}\n\n/** Cheap fallback label when Claude can't be reached. */\nfunction heuristicLabel(files: ParsedFile[], added: number, deleted: number): string {\n if (files.length === 0) return 'no changes';\n if (files.length === 1) {\n return `${path.basename(files[0].path)} +${added} −${deleted}`;\n }\n return `${files.length} files · +${added} −${deleted}`;\n}\n\n/** One internal run at a time, however many turns finish together. */\nconst internalQueue = createSerialQueue();\n\n/**\n * Run work's summarising agent (config `internalAgent`, Claude Code by\n * default: agents/ `oneShot`) with the prompt on stdin; resolve its trimmed\n * stdout, or null on error, timeout, or an agent that has no one-shot runs.\n * Async (never blocks the server event loop). `small`: a few words wanted.\n */\nexport function runInternal(prompt: string, timeoutMs = 25_000, opts: { small?: boolean } = {}): Promise<string | null> {\n const oneShot = internalAgent(agentSettings()).oneShot;\n if (!oneShot) return Promise.resolve(null);\n return internalQueue(() => runNow(prompt, timeoutMs, oneShot.command(opts)));\n}\n\nfunction runNow(\n prompt: string,\n timeoutMs: number,\n run: { cmd: string; args: string[]; cwd: string; env: NodeJS.ProcessEnv },\n): Promise<string | null> {\n return new Promise((resolve) => {\n let settled = false;\n const finish = (v: string | null) => {\n if (settled) return;\n settled = true;\n resolve(v);\n };\n let out = '';\n let child: ReturnType<typeof spawn>;\n try {\n // Text-only, no tools, neutral cwd, tagged internal (so it doesn't\n // trip work's own hooks) — the agent's oneShot.command.\n child = spawn(run.cmd, run.args, {\n stdio: ['pipe', 'pipe', 'ignore'],\n windowsHide: true,\n cwd: run.cwd,\n env: { ...run.env, ...internalRunEnv() }, // tagged by work, whatever the agent's command says\n });\n } catch {\n finish(null);\n return;\n }\n const timer = setTimeout(() => {\n // The whole tree: on Windows the agent may be a .cmd shim, and killing\n // only cmd.exe left the real one running, orphaned.\n if (child.pid) killTree(child.pid);\n else {\n try {\n child.kill();\n } catch {\n /* already gone */\n }\n }\n finish(null);\n }, timeoutMs);\n child.stdout?.on('data', (d: Buffer) => {\n out += d.toString();\n });\n child.on('error', () => {\n clearTimeout(timer);\n finish(null);\n });\n child.on('close', (code: number | null) => {\n clearTimeout(timer);\n finish(code === 0 && out.trim() ? out.trim() : null);\n });\n try {\n child.stdin?.write(prompt);\n child.stdin?.end();\n } catch {\n clearTimeout(timer);\n finish(null);\n }\n });\n}\n\n/** Normalise Claude's reply to a single terse line. */\nfunction cleanLabel(raw: string): string {\n const firstLine =\n raw\n .split('\\n')\n .map((l) => l.trim())\n .find(Boolean) ?? '';\n // Strip surrounding quotes / trailing punctuation, collapse whitespace.\n const cleaned = firstLine\n .replace(/^[\"'`]+|[\"'`]+$/g, '')\n .replace(/\\s+/g, ' ')\n .replace(/[.;]+$/, '')\n .trim();\n return cleaned.slice(0, MAX_LABEL_CHARS);\n}\n\n/**\n * Produce a one-line label for checkpoint `id`. Tries Claude; falls back to\n * a heuristic. Pure (no caching) — the caller persists the result.\n */\nexport async function summarizeCheckpoint(scopeHash: string, repos: SummaryRepo[], id: number): Promise<string> {\n const { files, added, deleted, text } = buildDelta(scopeHash, repos, id);\n if (files.length === 0) return 'no changes';\n const fallback = heuristicLabel(files, added, deleted);\n if (!text.trim()) return fallback;\n const prompt =\n 'Summarise this code change in 8 words or fewer, imperative mood, ' +\n 'no trailing punctuation. Output ONLY the summary line.\\n\\n' +\n text;\n const reply = await runInternal(prompt, 25_000, { small: true });\n if (!reply) return fallback;\n const label = cleanLabel(reply);\n return label || fallback;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAKO,SAAS,iBACd,IACA,IACA,QAAoF;AAAA,EAClF,KAAK,KAAK;AAAA,EACV,YAAY,CAAC,IAAI,MAAM,WAAW,IAAI,CAAC;AACzC,GACY;AACZ,MAAI,SAAS;AACb,MAAI,UAAU;AACd,SAAO,MAAM;AACX,UAAM,OAAO,SAAS,KAAK,MAAM,IAAI;AACrC,QAAI,QAAQ,GAAG;AACb,eAAS,MAAM,IAAI;AACnB,SAAG;AACH;AAAA,IACF;AACA,QAAI,QAAS;AACb,cAAU;AACV,UAAM,WAAW,MAAM;AACrB,gBAAU;AACV,eAAS,MAAM,IAAI;AACnB,SAAG;AAAA,IACL,GAAG,IAAI;AAAA,EACT;AACF;AAOO,SAAS,oBAA6D;AAC3E,MAAI,OAAyB,QAAQ,QAAQ;AAC7C,SAAO,CAAI,OAAyB;AAClC,UAAM,MAAM,KAAK,KAAK,IAAI,EAAE;AAC5B,WAAO,IAAI,MAAM,MAAM,MAAS;AAChC,WAAO;AAAA,EACT;AACF;;;AChCA,OAAO,UAAU;AAejB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAGxB,SAAS,WACP,WACA,OACA,IACuE;AACvE,QAAM,WAAW,aAAa,SAAS;AACvC,QAAM,QAAQ,SAAS,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE;AACtD,QAAM,OAAO,SAAS,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,KAAK,CAAC;AACzD,QAAM,MAAoB,CAAC;AAC3B,aAAW,QAAQ,OAAO;AACxB,UAAM,QAAQ,OAAO,MAAM,KAAK,IAAI;AACpC,QAAI,CAAC,MAAO;AAIZ,UAAM,UAAU,MAAM,MAAM,KAAK,IAAI,KAAK;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AAC;AACD,QAAI;AACF,YAAM,OAAO,MAAM,MAAM;AACzB,YAAM,OAAO,IAAI;AAAA,IACnB,QAAQ;AACN,mBAAa,KAAK;AAClB,aAAO,IAAI;AAAA,IACb;AAAA,EACF,CAAC;AACH;AAGA,SAAS,WAAW,KAAqB;AACvC,QAAM,YACJ,IACG,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,KAAK,OAAO,KAAK;AAEtB,QAAM,UAAU,UACb,QAAQ,oBAAoB,EAAE,EAC9B,QAAQ,QAAQ,GAAG,EACnB,QAAQ,UAAU,EAAE,EACpB,KAAK;AACR,SAAO,QAAQ,MAAM,GAAG,eAAe;AACzC;AAMA,eAAsB,oBAAoB,WAAmB,OAAsB,IAA6B;AAC9G,QAAM,EAAE,OAAO,OAAO,SAAS,KAAK,IAAI,WAAW,WAAW,OAAO,EAAE;AACvE,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,WAAW,eAAe,OAAO,OAAO,OAAO;AACrD,MAAI,CAAC,KAAK,KAAK,EAAG,QAAO;AACzB,QAAM,SACJ,gIAEA;AACF,QAAM,QAAQ,MAAM,YAAY,QAAQ,MAAQ,EAAE,OAAO,KAAK,CAAC;AAC/D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,QAAQ,WAAW,KAAK;AAC9B,SAAO,SAAS;AAClB;","names":[]}
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readStatus
4
- } from "./chunk-JUMZ5MTU.js";
4
+ } from "./chunk-MGQK6BWH.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-XLAGFKJE.js.map
19
+ //# sourceMappingURL=chunk-WIWO3YWP.js.map
@@ -2,23 +2,23 @@
2
2
  import {
3
3
  computeDiff,
4
4
  isInsideRoot
5
- } from "./chunk-G7TS5DCS.js";
5
+ } from "./chunk-B2HUKRWX.js";
6
6
  import {
7
7
  packageRoot
8
8
  } from "./chunk-LNHSBM4L.js";
9
9
  import {
10
10
  git
11
- } from "./chunk-G635EV2D.js";
11
+ } from "./chunk-O34CKSE4.js";
12
12
  import {
13
13
  createFsWatcher,
14
14
  loadHistory
15
- } from "./chunk-JUMZ5MTU.js";
15
+ } from "./chunk-MGQK6BWH.js";
16
16
  import {
17
17
  spawn_default
18
18
  } from "./chunk-RCYI7SRA.js";
19
19
  import {
20
20
  report
21
- } from "./chunk-ZGXRWL7T.js";
21
+ } from "./chunk-JIYGGN2N.js";
22
22
 
23
23
  // src/core/diff/diff-scope.ts
24
24
  import fs from "fs";
@@ -512,4 +512,4 @@ export {
512
512
  submitReviewSchema,
513
513
  resolveSchema
514
514
  };
515
- //# sourceMappingURL=chunk-NW2ZXAJJ.js.map
515
+ //# sourceMappingURL=chunk-YJ4CAD3X.js.map
@@ -3,7 +3,7 @@ import {
3
3
  json,
4
4
  tx,
5
5
  withDb
6
- } from "./chunk-JF72AS6T.js";
6
+ } from "./chunk-COKQPFLB.js";
7
7
 
8
8
  // src/core/rail/session-notes.ts
9
9
  var MAX_NOTE_CHARS = 2e4;
@@ -51,4 +51,4 @@ export {
51
51
  saveNote,
52
52
  appendNote
53
53
  };
54
- //# sourceMappingURL=chunk-OUUDQA7O.js.map
54
+ //# sourceMappingURL=chunk-YNHIMOE7.js.map
@@ -3,15 +3,17 @@ import {
3
3
  agentFor,
4
4
  agentSettings,
5
5
  assistantAgent,
6
- detachHere,
7
6
  internalAgent
8
- } from "./chunk-VESYLAVA.js";
7
+ } from "./chunk-FUNZ7TOS.js";
8
+ import {
9
+ detachHere
10
+ } from "./chunk-VMBWCDBA.js";
9
11
  import {
10
12
  report
11
- } from "./chunk-ZGXRWL7T.js";
13
+ } from "./chunk-JIYGGN2N.js";
12
14
  import {
13
15
  debugLog
14
- } from "./chunk-75MIXOUK.js";
16
+ } from "./chunk-KE2TFF7B.js";
15
17
 
16
18
  // src/core/platform/shell-path.ts
17
19
  import { spawnSync } from "child_process";
@@ -120,4 +122,4 @@ export {
120
122
  findOnPath,
121
123
  ensureAgentPath
122
124
  };
123
- //# sourceMappingURL=chunk-OUWKEJEC.js.map
125
+ //# sourceMappingURL=chunk-ZGPWIBSZ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/platform/shell-path.ts","../src/core/platform/find-on-path.ts","../src/core/agents/agent-path.ts"],"sourcesContent":["import { spawnSync, type SpawnSyncOptionsWithStringEncoding } from 'node:child_process';\nimport path from 'node:path';\nimport { findOnPath } from './find-on-path.js';\nimport { report } from './report.js';\nimport { debugLog } from './logger.js';\nimport { detachHere } from './process.js';\n\n/**\n * The PATH of the user's login shell, for a work started without one.\n *\n * Reported from a Mac: every session ended at once with \"session exited with code 1\", and Enter\n * gave the same. The desktop app started from the Dock or Finder gets the system's minimal PATH\n * (/usr/bin:/bin:/usr/sbin:/sbin), not the one the user's shell sets up, and passes it on to work\n * web, the PTY host and every Claude: `claude` (in ~/.local/bin, /opt/homebrew/bin, an nvm folder…)\n * isn't found, and node-pty's child exits with 1 when its exec fails. So when work web or the PTY\n * host starts on macOS or Linux and the agent's command isn't on its PATH, it asks the login shell\n * for its PATH (`$SHELL -ilc`, as a terminal would set it up) and puts it first. Started from a\n * terminal, the command is found and nothing is asked.\n */\n\nconst MARK = '__WORK_SHELL_PATH__';\n\n/** The shell's PATH first, then what we had that it lacks (e.g. the app's ~/.work/bin). */\nexport function mergePath(current: string | undefined, shellPath: string, sep = path.delimiter): string {\n const out: string[] = [];\n for (const d of [...shellPath.split(sep), ...(current ?? '').split(sep)]) if (d && !out.includes(d)) out.push(d);\n return out.join(sep);\n}\n\n/** The PATH between the markers of the shell's output (an interactive shell may print a greeting around it). */\nexport function parseShellPath(stdout: string): string | null {\n const m = new RegExp(`${MARK}(.*?)${MARK}`, 's').exec(stdout);\n const p = m?.[1].trim();\n return p ? p : null;\n}\n\n/** How long the login shell may take to say its PATH. */\nexport const SHELL_PATH_TIMEOUT_MS = 5_000;\n\n/** The shell's arguments: a login, interactive shell (what a terminal runs) printing its PATH between markers. */\nexport const shellPathArgs = (): string[] => ['-ilc', `printf '%s%s%s' '${MARK}' \"$PATH\" '${MARK}'`];\n\n/**\n * How it's started. `killSignal: SIGKILL`: an interactive bash or zsh ignores SIGTERM (spawnSync's\n * default at the timeout), and Node then waits for it — a stuck profile held work web up for as long as\n * it hung (reproduced: a 2 s timeout returned after 8 s). `detached` (POSIX): its own session, so it\n * never takes this terminal's foreground group — killed while holding it, it left `work web` in the\n * background, where Ctrl+C no longer reached it (reproduced).\n */\nexport const shellPathSpawnOptions = (timeoutMs = SHELL_PATH_TIMEOUT_MS): SpawnSyncOptionsWithStringEncoding =>\n // `detached` isn't in @types/node's spawnSync options, but spawnSync honors it (spawn_sync reads it).\n ({\n encoding: 'utf8',\n timeout: timeoutMs,\n killSignal: 'SIGKILL',\n detached: detachHere(),\n stdio: ['ignore', 'pipe', 'ignore'],\n windowsHide: true,\n }) as SpawnSyncOptionsWithStringEncoding;\n\ntype ShellRun = (cmd: string, args: string[]) => { stdout?: string | null; status?: number | null; signal?: string | null; error?: Error };\n\n/** Ask the login shell for its PATH: its PATH, or why it couldn't say (a timeout, no such shell, no markers). */\nexport function readShellPath(\n shell = process.env.SHELL || '/bin/zsh',\n run: ShellRun = (cmd, args) => spawnSync(cmd, args, shellPathSpawnOptions()),\n): { path: string } | { why: string } {\n try {\n const r = run(shell, shellPathArgs());\n const p = parseShellPath(r.stdout ?? '');\n if (p) return { path: p };\n const how = r.error\n ? r.error.message\n : r.signal\n ? `stopped by ${r.signal} (over ${SHELL_PATH_TIMEOUT_MS / 1000} s?)`\n : `exit ${r.status ?? '?'}, no PATH printed`;\n return { why: `${shell} -ilc: ${how}` };\n } catch (err) {\n return { why: `${shell} -ilc: ${(err as Error).message}` };\n }\n}\n\n/**\n * Make sure the commands in `need` (the agent's binary) can be found: on macOS and Linux, when one\n * isn't on PATH, the login shell's PATH is merged into this process's (which everything it starts\n * inherits). Says what it did; never throws.\n */\nexport function ensureShellPath(\n need: string[],\n opts: {\n platform?: NodeJS.Platform;\n env?: NodeJS.ProcessEnv;\n readPath?: () => { path: string } | { why: string };\n find?: (cmd: string, env: NodeJS.ProcessEnv) => string | null;\n } = {},\n): 'found' | 'added' | 'unavailable' {\n const platform = opts.platform ?? process.platform;\n const env = opts.env ?? process.env;\n if (platform === 'win32') return 'found';\n const find = opts.find ?? ((c: string, e: NodeJS.ProcessEnv) => findOnPath(c, e, platform));\n const missing = need.filter((c) => !find(c, env));\n if (!missing.length) return 'found';\n // Said in the debug log too: started by the desktop app, nothing shows what a reporter prints.\n const say = (level: 'info' | 'warn', text: string) => {\n report(level, text);\n debugLog(level === 'warn' ? 'WARN' : 'INFO', text);\n };\n const read = (opts.readPath ?? (() => readShellPath(env.SHELL)))();\n if ('why' in read) {\n say('warn', `${missing.join(', ')} isn't on PATH (${env.PATH ?? ''}), and the login shell's PATH couldn't be read: ${read.why}`);\n return 'unavailable';\n }\n env.PATH = mergePath(env.PATH, read.path);\n const still = missing.filter((c) => !find(c, env));\n say(\n still.length ? 'warn' : 'info',\n still.length\n ? `${still.join(', ')} isn't on PATH, even with the login shell's (${env.PATH})`\n : `${missing.join(', ')} found with the login shell's PATH: using it (${env.PATH})`,\n );\n return 'added';\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * The file a command name runs, as a shell finds it: a path is itself, else the\n * first match in PATH. On Windows a name without one of PATHEXT's extensions is\n * tried with each (`claude` is `claude.exe` or `claude.cmd`; npm's extension-less\n * `claude` sh shim beside them is never run); elsewhere only an executable file\n * counts. Null when there's none.\n */\nexport function findOnPath(cmd: string, env: NodeJS.ProcessEnv = process.env, platform: NodeJS.Platform = process.platform): string | null {\n const win = platform === 'win32';\n const isFile = (p: string) => {\n try {\n const st = fs.statSync(p);\n return st.isFile() && (win || (st.mode & 0o111) !== 0);\n } catch {\n return false;\n }\n };\n const pathExt = (env.PATHEXT ?? env.Pathext ?? '.COM;.EXE;.BAT;.CMD')\n .split(';')\n .filter(Boolean)\n .map((e) => e.toLowerCase());\n const hasExt = pathExt.includes(path.extname(cmd).toLowerCase());\n const candidates = (base: string) => (!win || hasExt ? [base] : pathExt.map((e) => base + e));\n if (cmd.includes('/') || (win && cmd.includes('\\\\'))) return candidates(cmd).find(isFile) ?? null;\n const dirs = (env.PATH ?? env.Path ?? '').split(win ? ';' : path.delimiter).filter(Boolean);\n for (const dir of dirs) {\n const hit = candidates(path.join(dir, cmd)).find(isFile);\n if (hit) return hit;\n }\n return null;\n}\n","import { agentFor, agentSettings, assistantAgent, internalAgent } from './index.js';\nimport type { AgentSettings } from './index.js';\nimport { ensureShellPath } from '../platform/shell-path.js';\nimport { debugLog } from '../platform/logger.js';\n\n/**\n * The agents' commands, found on PATH before work web or the PTY host starts any of them\n * (`core/platform/shell-path.ts` says why: the Mac app from the Dock gets the system's PATH).\n */\n\n/** The commands work starts agents with, from the registry: new sessions', the Ctrl+K assistant's, the summaries'. */\nexport function agentCommands(settings: AgentSettings = agentSettings()): string[] {\n return [...new Set([agentFor(settings), assistantAgent(settings), internalAgent(settings)].map((a) => a.launch.tool(settings).cmd))];\n}\n\n/** For `work web` and the PTY host as they start (not wd's lean server: it starts no agent). Never throws. */\nexport function ensureAgentPath(\n deps: { commands?: () => string[]; ensure?: (need: string[]) => ReturnType<typeof ensureShellPath> } = {},\n): ReturnType<typeof ensureShellPath> | 'failed' {\n try {\n return (deps.ensure ?? ensureShellPath)((deps.commands ?? agentCommands)());\n } catch (err) {\n debugLog('WARN', 'finding the agents on PATH failed:', err);\n return 'failed';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,iBAA0D;AACnE,OAAOA,WAAU;;;ACDjB,OAAO,QAAQ;AACf,OAAO,UAAU;AASV,SAAS,WAAW,KAAa,MAAyB,QAAQ,KAAK,WAA4B,QAAQ,UAAyB;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AAG,CAAC;AAChD,MAAI,CAAC,QAAQ,OAAQ,QAAO;AAE5B,QAAM,MAAM,CAAC,OAAwB,SAAiB;AACpD,WAAO,OAAO,IAAI;AAClB,aAAS,UAAU,SAAS,SAAS,QAAQ,IAAI;AAAA,EACnD;AACA,QAAM,QAAQ,KAAK,aAAa,MAAM,cAAc,IAAI,KAAK,IAAI;AACjE,MAAI,SAAS,MAAM;AACjB,QAAI,QAAQ,GAAG,QAAQ,KAAK,IAAI,CAAC,mBAAmB,IAAI,QAAQ,EAAE,mDAAmD,KAAK,GAAG,EAAE;AAC/H,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,IAAI,MAAM,KAAK,IAAI;AACxC,QAAM,QAAQ,QAAQ,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;AACjD;AAAA,IACE,MAAM,SAAS,SAAS;AAAA,IACxB,MAAM,SACF,GAAG,MAAM,KAAK,IAAI,CAAC,gDAAgD,IAAI,IAAI,MAC3E,GAAG,QAAQ,KAAK,IAAI,CAAC,iDAAiD,IAAI,IAAI;AAAA,EACpF;AACA,SAAO;AACT;;;AE9GO,SAAS,cAAc,WAA0B,cAAc,GAAa;AACjF,SAAO,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,QAAQ,GAAG,eAAe,QAAQ,GAAG,cAAc,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,EAAE,GAAG,CAAC,CAAC;AACrI;AAGO,SAAS,gBACd,OAAuG,CAAC,GACzD;AAC/C,MAAI;AACF,YAAQ,KAAK,UAAU,kBAAkB,KAAK,YAAY,eAAe,CAAC;AAAA,EAC5E,SAAS,KAAK;AACZ,aAAS,QAAQ,sCAAsC,GAAG;AAC1D,WAAO;AAAA,EACT;AACF;","names":["path","path"]}
1
+ {"version":3,"sources":["../src/core/platform/shell-path.ts","../src/core/platform/find-on-path.ts","../src/core/agents/agent-path.ts"],"sourcesContent":["import { spawnSync, type SpawnSyncOptionsWithStringEncoding } from 'node:child_process';\nimport path from 'node:path';\nimport { findOnPath } from './find-on-path.js';\nimport { report } from './report.js';\nimport { debugLog } from './logger.js';\nimport { detachHere } from './process.js';\n\n/**\n * The PATH of the user's login shell, for a work started without one.\n *\n * Reported from a Mac: every session ended at once with \"session exited with code 1\", and Enter\n * gave the same. The desktop app started from the Dock or Finder gets the system's minimal PATH\n * (/usr/bin:/bin:/usr/sbin:/sbin), not the one the user's shell sets up, and passes it on to work\n * web, the PTY host and every Claude: `claude` (in ~/.local/bin, /opt/homebrew/bin, an nvm folder…)\n * isn't found, and node-pty's child exits with 1 when its exec fails. So when work web or the PTY\n * host starts on macOS or Linux and the agent's command isn't on its PATH, it asks the login shell\n * for its PATH (`$SHELL -ilc`, as a terminal would set it up) and puts it first. Started from a\n * terminal, the command is found and nothing is asked.\n */\n\nconst MARK = '__WORK_SHELL_PATH__';\n\n/** The shell's PATH first, then what we had that it lacks (e.g. the app's ~/.work/bin). */\nexport function mergePath(current: string | undefined, shellPath: string, sep = path.delimiter): string {\n const out: string[] = [];\n for (const d of [...shellPath.split(sep), ...(current ?? '').split(sep)]) if (d && !out.includes(d)) out.push(d);\n return out.join(sep);\n}\n\n/** The PATH between the markers of the shell's output (an interactive shell may print a greeting around it). */\nexport function parseShellPath(stdout: string): string | null {\n const m = new RegExp(`${MARK}(.*?)${MARK}`, 's').exec(stdout);\n const p = m?.[1].trim();\n return p ? p : null;\n}\n\n/** How long the login shell may take to say its PATH. */\nexport const SHELL_PATH_TIMEOUT_MS = 5_000;\n\n/** The shell's arguments: a login, interactive shell (what a terminal runs) printing its PATH between markers. */\nexport const shellPathArgs = (): string[] => ['-ilc', `printf '%s%s%s' '${MARK}' \"$PATH\" '${MARK}'`];\n\n/**\n * How it's started. `killSignal: SIGKILL`: an interactive bash or zsh ignores SIGTERM (spawnSync's\n * default at the timeout), and Node then waits for it — a stuck profile held work web up for as long as\n * it hung (reproduced: a 2 s timeout returned after 8 s). `detached` (POSIX): its own session, so it\n * never takes this terminal's foreground group — killed while holding it, it left `work web` in the\n * background, where Ctrl+C no longer reached it (reproduced).\n */\nexport const shellPathSpawnOptions = (timeoutMs = SHELL_PATH_TIMEOUT_MS): SpawnSyncOptionsWithStringEncoding =>\n // `detached` isn't in @types/node's spawnSync options, but spawnSync honors it (spawn_sync reads it).\n ({\n encoding: 'utf8',\n timeout: timeoutMs,\n killSignal: 'SIGKILL',\n detached: detachHere(),\n stdio: ['ignore', 'pipe', 'ignore'],\n windowsHide: true,\n }) as SpawnSyncOptionsWithStringEncoding;\n\ntype ShellRun = (cmd: string, args: string[]) => { stdout?: string | null; status?: number | null; signal?: string | null; error?: Error };\n\n/** Ask the login shell for its PATH: its PATH, or why it couldn't say (a timeout, no such shell, no markers). */\nexport function readShellPath(\n shell = process.env.SHELL || '/bin/zsh',\n run: ShellRun = (cmd, args) => spawnSync(cmd, args, shellPathSpawnOptions()),\n): { path: string } | { why: string } {\n try {\n const r = run(shell, shellPathArgs());\n const p = parseShellPath(r.stdout ?? '');\n if (p) return { path: p };\n const how = r.error\n ? r.error.message\n : r.signal\n ? `stopped by ${r.signal} (over ${SHELL_PATH_TIMEOUT_MS / 1000} s?)`\n : `exit ${r.status ?? '?'}, no PATH printed`;\n return { why: `${shell} -ilc: ${how}` };\n } catch (err) {\n return { why: `${shell} -ilc: ${(err as Error).message}` };\n }\n}\n\n/**\n * Make sure the commands in `need` (the agent's binary) can be found: on macOS and Linux, when one\n * isn't on PATH, the login shell's PATH is merged into this process's (which everything it starts\n * inherits). Says what it did; never throws.\n */\nexport function ensureShellPath(\n need: string[],\n opts: {\n platform?: NodeJS.Platform;\n env?: NodeJS.ProcessEnv;\n readPath?: () => { path: string } | { why: string };\n find?: (cmd: string, env: NodeJS.ProcessEnv) => string | null;\n } = {},\n): 'found' | 'added' | 'unavailable' {\n const platform = opts.platform ?? process.platform;\n const env = opts.env ?? process.env;\n if (platform === 'win32') return 'found';\n const find = opts.find ?? ((c: string, e: NodeJS.ProcessEnv) => findOnPath(c, e, platform));\n const missing = need.filter((c) => !find(c, env));\n if (!missing.length) return 'found';\n // Said in the debug log too: started by the desktop app, nothing shows what a reporter prints.\n const say = (level: 'info' | 'warn', text: string) => {\n report(level, text);\n debugLog(level === 'warn' ? 'WARN' : 'INFO', text);\n };\n const read = (opts.readPath ?? (() => readShellPath(env.SHELL)))();\n if ('why' in read) {\n say('warn', `${missing.join(', ')} isn't on PATH (${env.PATH ?? ''}), and the login shell's PATH couldn't be read: ${read.why}`);\n return 'unavailable';\n }\n env.PATH = mergePath(env.PATH, read.path);\n const still = missing.filter((c) => !find(c, env));\n say(\n still.length ? 'warn' : 'info',\n still.length\n ? `${still.join(', ')} isn't on PATH, even with the login shell's (${env.PATH})`\n : `${missing.join(', ')} found with the login shell's PATH: using it (${env.PATH})`,\n );\n return 'added';\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * The file a command name runs, as a shell finds it: a path is itself, else the\n * first match in PATH. On Windows a name without one of PATHEXT's extensions is\n * tried with each (`claude` is `claude.exe` or `claude.cmd`; npm's extension-less\n * `claude` sh shim beside them is never run); elsewhere only an executable file\n * counts. Null when there's none.\n */\nexport function findOnPath(cmd: string, env: NodeJS.ProcessEnv = process.env, platform: NodeJS.Platform = process.platform): string | null {\n const win = platform === 'win32';\n const isFile = (p: string) => {\n try {\n const st = fs.statSync(p);\n return st.isFile() && (win || (st.mode & 0o111) !== 0);\n } catch {\n return false;\n }\n };\n const pathExt = (env.PATHEXT ?? env.Pathext ?? '.COM;.EXE;.BAT;.CMD')\n .split(';')\n .filter(Boolean)\n .map((e) => e.toLowerCase());\n const hasExt = pathExt.includes(path.extname(cmd).toLowerCase());\n const candidates = (base: string) => (!win || hasExt ? [base] : pathExt.map((e) => base + e));\n if (cmd.includes('/') || (win && cmd.includes('\\\\'))) return candidates(cmd).find(isFile) ?? null;\n const dirs = (env.PATH ?? env.Path ?? '').split(win ? ';' : path.delimiter).filter(Boolean);\n for (const dir of dirs) {\n const hit = candidates(path.join(dir, cmd)).find(isFile);\n if (hit) return hit;\n }\n return null;\n}\n","import { agentFor, agentSettings, assistantAgent, internalAgent } from './index.js';\nimport type { AgentSettings } from './index.js';\nimport { ensureShellPath } from '../platform/shell-path.js';\nimport { debugLog } from '../platform/logger.js';\n\n/**\n * The agents' commands, found on PATH before work web or the PTY host starts any of them\n * (`core/platform/shell-path.ts` says why: the Mac app from the Dock gets the system's PATH).\n */\n\n/** The commands work starts agents with, from the registry: new sessions', the Ctrl+K assistant's, the summaries'. */\nexport function agentCommands(settings: AgentSettings = agentSettings()): string[] {\n return [...new Set([agentFor(settings), assistantAgent(settings), internalAgent(settings)].map((a) => a.launch.tool(settings).cmd))];\n}\n\n/** For `work web` and the PTY host as they start (not wd's lean server: it starts no agent). Never throws. */\nexport function ensureAgentPath(\n deps: { commands?: () => string[]; ensure?: (need: string[]) => ReturnType<typeof ensureShellPath> } = {},\n): ReturnType<typeof ensureShellPath> | 'failed' {\n try {\n return (deps.ensure ?? ensureShellPath)((deps.commands ?? agentCommands)());\n } catch (err) {\n debugLog('WARN', 'finding the agents on PATH failed:', err);\n return 'failed';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAA0D;AACnE,OAAOA,WAAU;;;ACDjB,OAAO,QAAQ;AACf,OAAO,UAAU;AASV,SAAS,WAAW,KAAa,MAAyB,QAAQ,KAAK,WAA4B,QAAQ,UAAyB;AACzI,QAAM,MAAM,aAAa;AACzB,QAAM,SAAS,CAAC,MAAc;AAC5B,QAAI;AACF,YAAM,KAAK,GAAG,SAAS,CAAC;AACxB,aAAO,GAAG,OAAO,MAAM,QAAQ,GAAG,OAAO,QAAW;AAAA,IACtD,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACA,QAAM,WAAW,IAAI,WAAW,IAAI,WAAW,uBAC5C,MAAM,GAAG,EACT,OAAO,OAAO,EACd,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;AAC7B,QAAM,S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K,GAAG,EAAE;AAC/H,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,IAAI,MAAM,KAAK,IAAI;AACxC,QAAM,QAAQ,QAAQ,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;AACjD;AAAA,IACE,MAAM,SAAS,SAAS;AAAA,IACxB,MAAM,SACF,GAAG,MAAM,KAAK,IAAI,CAAC,gDAAgD,IAAI,IAAI,MAC3E,GAAG,QAAQ,KAAK,IAAI,CAAC,iDAAiD,IAAI,IAAI;AAAA,EACpF;AACA,SAAO;AACT;;;AE9GO,SAAS,cAAc,WAA0B,cAAc,GAAa;AACjF,SAAO,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,QAAQ,GAAG,eAAe,QAAQ,GAAG,cAAc,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,EAAE,GAAG,CAAC,CAAC;AACrI;AAGO,SAAS,gBACd,OAAuG,CAAC,GACzD;AAC/C,MAAI;AACF,YAAQ,KAAK,UAAU,kBAAkB,KAAK,YAAY,eAAe,CAAC;AAAA,EAC5E,SAAS,KAAK;AACZ,aAAS,QAAQ,sCAAsC,GAAG;AAC1D,WAAO;AAAA,EACT;AACF;","names":["path","path"]}
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ atomicWriteFile,
4
+ debugLog,
5
+ getConfigDir
6
+ } from "./chunk-KE2TFF7B.js";
7
+
8
+ // src/core/usage/usage-store.ts
9
+ import fs from "fs";
10
+ import path from "path";
11
+ var REFRESH_MS = 6e4;
12
+ var usageDir = () => path.join(getConfigDir(), "usage");
13
+ var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
14
+ function isWindow(v) {
15
+ return isRecord(v) && typeof v.id === "string" && typeof v.label === "string" && typeof v.usedPercent === "number" && (v.resetsAt === null || typeof v.resetsAt === "string") && (v.reset === void 0 || v.reset === true);
16
+ }
17
+ function parseStored(text) {
18
+ let v;
19
+ try {
20
+ v = JSON.parse(text);
21
+ } catch {
22
+ return null;
23
+ }
24
+ if (!isRecord(v) || typeof v.at !== "string" || !Array.isArray(v.windows) || !v.windows.every(isWindow)) return null;
25
+ return { at: v.at, windows: v.windows };
26
+ }
27
+ var fileFor = (agent, account) => path.join(usageDir(), `${agent}-${account}.json`);
28
+ function keepHigher(stored, fresh) {
29
+ return fresh.map((w) => {
30
+ const was = w.resetsAt === null ? void 0 : stored.find((s) => s.id === w.id && s.resetsAt === w.resetsAt);
31
+ return was && was.usedPercent > w.usedPercent ? { ...w, usedPercent: was.usedPercent } : w;
32
+ });
33
+ }
34
+ function recordReading(agent, account, windows, now = Date.now()) {
35
+ if (windows.length === 0) return false;
36
+ try {
37
+ const file = fileFor(agent, account);
38
+ let stored = null;
39
+ try {
40
+ stored = parseStored(fs.readFileSync(file, "utf-8"));
41
+ } catch {
42
+ }
43
+ const kept = stored ? keepHigher(stored.windows, windows) : windows;
44
+ if (stored && JSON.stringify(stored.windows) === JSON.stringify(kept) && now - Date.parse(stored.at) < REFRESH_MS) return false;
45
+ fs.mkdirSync(usageDir(), { recursive: true });
46
+ atomicWriteFile(file, JSON.stringify({ at: new Date(now).toISOString(), windows: kept }));
47
+ return true;
48
+ } catch (e) {
49
+ const err = e;
50
+ debugLog("WARN", `[usage] reading not kept: ${err.code ? `${err.code} ` : ""}${err.message ?? String(e)}`);
51
+ return false;
52
+ }
53
+ }
54
+ function readReadings(agent) {
55
+ let names;
56
+ try {
57
+ names = fs.readdirSync(usageDir());
58
+ } catch {
59
+ return [];
60
+ }
61
+ const prefix = `${agent}-`;
62
+ const out = [];
63
+ for (const name of names) {
64
+ if (!name.startsWith(prefix) || !name.endsWith(".json")) continue;
65
+ try {
66
+ const stored = parseStored(fs.readFileSync(path.join(usageDir(), name), "utf-8"));
67
+ if (stored) out.push({ account: name.slice(prefix.length, -".json".length), ...stored });
68
+ } catch {
69
+ }
70
+ }
71
+ return out.sort((a, b) => a.account.localeCompare(b.account));
72
+ }
73
+
74
+ export {
75
+ usageDir,
76
+ recordReading,
77
+ readReadings
78
+ };
79
+ //# sourceMappingURL=chunk-ZMCU2PZN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/usage/usage-store.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { getConfigDir } from '../platform/config.js';\nimport { atomicWriteFile } from '../platform/fs-safe.js';\nimport { debugLog } from '../platform/logger.js';\nimport type { UsageAccount, UsageWindow } from './usage.js';\n\n// Readings the agents' hooks leave behind, one file per agent and account. The status-line hook calls recordReading on every refresh, so it stays cheap.\n\n/** A reading that hasn't changed is rewritten only when its time is this old: the age stays honest without a write per refresh. */\nconst REFRESH_MS = 60_000;\n\ntype Stored = Omit<UsageAccount, 'account'>;\n\nexport const usageDir = () => path.join(getConfigDir(), 'usage');\n\nconst isRecord = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);\n\nfunction isWindow(v: unknown): v is UsageWindow {\n return (\n isRecord(v) &&\n typeof v.id === 'string' &&\n typeof v.label === 'string' &&\n typeof v.usedPercent === 'number' &&\n (v.resetsAt === null || typeof v.resetsAt === 'string') &&\n (v.reset === undefined || v.reset === true)\n );\n}\n\nfunction parseStored(text: string): Stored | null {\n let v: unknown;\n try {\n v = JSON.parse(text);\n } catch {\n return null;\n }\n if (!isRecord(v) || typeof v.at !== 'string' || !Array.isArray(v.windows) || !v.windows.every(isWindow)) return null;\n return { at: v.at, windows: v.windows };\n}\n\nconst fileFor = (agent: string, account: string) => path.join(usageDir(), `${agent}-${account}.json`);\n\n/**\n * Within one window (same id, same known reset) usage only grows: an idle agent's redraw can carry an older, lower figure\n * than another session just reported, and it mustn't win.\n */\nfunction keepHigher(stored: UsageWindow[], fresh: UsageWindow[]): UsageWindow[] {\n return fresh.map((w) => {\n const was = w.resetsAt === null ? undefined : stored.find((s) => s.id === w.id && s.resetsAt === w.resetsAt);\n return was && was.usedPercent > w.usedPercent ? { ...w, usedPercent: was.usedPercent } : w;\n });\n}\n\n/** Keep a reading. Writes only when it changed (or the stored time is over a minute old); returns whether it wrote. Never throws. */\nexport function recordReading(agent: string, account: string, windows: UsageWindow[], now = Date.now()): boolean {\n if (windows.length === 0) return false;\n try {\n const file = fileFor(agent, account);\n let stored: Stored | null = null;\n try {\n stored = parseStored(fs.readFileSync(file, 'utf-8'));\n } catch {\n /* nothing stored yet */\n }\n const kept = stored ? keepHigher(stored.windows, windows) : windows;\n if (stored && JSON.stringify(stored.windows) === JSON.stringify(kept) && now - Date.parse(stored.at) < REFRESH_MS) return false;\n fs.mkdirSync(usageDir(), { recursive: true });\n atomicWriteFile(file, JSON.stringify({ at: new Date(now).toISOString(), windows: kept }));\n return true;\n } catch (e) {\n // Only the log: this runs in an agent's hook (Claude's status line), which shows nothing of ours.\n const err = e as NodeJS.ErrnoException;\n debugLog('WARN', `[usage] reading not kept: ${err.code ? `${err.code} ` : ''}${err.message ?? String(e)}`);\n return false;\n }\n}\n\n/** Every account's last reading for an agent, by account name. A file that isn't a reading is skipped. */\nexport function readReadings(agent: string): UsageAccount[] {\n let names: string[];\n try {\n names = fs.readdirSync(usageDir());\n } catch {\n return [];\n }\n const prefix = `${agent}-`;\n const out: UsageAccount[] = [];\n for (const name of names) {\n if (!name.startsWith(prefix) || !name.endsWith('.json')) continue;\n try {\n const stored = parseStored(fs.readFileSync(path.join(usageDir(), name), 'utf-8'));\n if (stored) out.push({ account: name.slice(prefix.length, -'.json'.length), ...stored });\n } catch {\n /* unreadable: skipped */\n }\n }\n return out.sort((a, b) => a.account.localeCompare(b.account));\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AASjB,IAAM,aAAa;AAIZ,IAAM,WAAW,MAAM,KAAK,KAAK,aAAa,GAAG,OAAO;AAE/D,IAAM,WAAW,CAAC,MAA6C,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC;AAEtH,SAAS,SAAS,GA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omicWriteFile,
14
14
  getConfigDir,
15
15
  getConfigPath,
16
16
  withFileLock
17
- } from "./chunk-RYEPQLXQ.js";
17
+ } from "./chunk-KE2TFF7B.js";
18
18
 
19
19
  // src/core/worktree/repo-admin.ts
20
20
  import fs from "fs";
@@ -166,4 +166,4 @@ export {
166
166
  saveGroup,
167
167
  deleteGroup
168
168
  };
169
- //# sourceMappingURL=chunk-G5W6D7KQ.js.map
169
+ //# sourceMappingURL=chunk-ZNXACRZ5.js.map