@moberg_hr/work-tree 2.0.9 → 2.0.10

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 (222) hide show
  1. package/dist/{answer-QQAEJ5N3.js → answer-6UVHVEGQ.js} +13 -12
  2. package/dist/{answer-QQAEJ5N3.js.map → answer-6UVHVEGQ.js.map} +1 -1
  3. package/dist/{attach-XG3Y7QA7.js → attach-6Q6HGPCM.js} +15 -14
  4. package/dist/{attach-XG3Y7QA7.js.map → attach-6Q6HGPCM.js.map} +1 -1
  5. package/dist/bin.js +5 -5
  6. package/dist/{block-WW4BWDN7.js → block-46DPS75I.js} +13 -12
  7. package/dist/{block-WW4BWDN7.js.map → block-46DPS75I.js.map} +1 -1
  8. package/dist/{broadcast-LEOMDVSA.js → broadcast-OGOEQX4Z.js} +10 -9
  9. package/dist/{broadcast-LEOMDVSA.js.map → broadcast-OGOEQX4Z.js.map} +1 -1
  10. package/dist/{catchup-UBHGEMED.js → catchup-TTAC3GMX.js} +16 -15
  11. package/dist/{catchup-UBHGEMED.js.map → catchup-TTAC3GMX.js.map} +1 -1
  12. package/dist/{chunk-WTR5BUGS.js → chunk-26IZBYVL.js} +2 -2
  13. package/dist/{chunk-NS3HSXF7.js → chunk-3B3UMUE6.js} +2 -2
  14. package/dist/{chunk-LXM7QFBK.js → chunk-3XY76XBD.js} +24 -11
  15. package/dist/{chunk-LXM7QFBK.js.map → chunk-3XY76XBD.js.map} +1 -1
  16. package/dist/{chunk-UNLBHYA5.js → chunk-427RB7E4.js} +6 -6
  17. package/dist/{chunk-UPR2F7QP.js → chunk-4PP27RI7.js} +9 -9
  18. package/dist/{chunk-HLXEMPEI.js → chunk-6O6765M7.js} +4 -4
  19. package/dist/{chunk-JJRPLNLN.js → chunk-7HGABVGR.js} +2 -2
  20. package/dist/{chunk-G6IJ76DW.js → chunk-ACXPSQJR.js} +3 -3
  21. package/dist/{chunk-3R4HBEIG.js → chunk-AFV5S6UV.js} +10 -10
  22. package/dist/{chunk-45XJ4JGE.js → chunk-AVRDRZ4D.js} +12 -12
  23. package/dist/{chunk-I5CDLVJY.js → chunk-D4FUDMMX.js} +9 -9
  24. package/dist/{chunk-5XMXZIJS.js → chunk-E35NZVPX.js} +2 -2
  25. package/dist/chunk-E5EPN3JI.js +656 -0
  26. package/dist/chunk-E5EPN3JI.js.map +1 -0
  27. package/dist/{chunk-IC5PFQCV.js → chunk-HBXDIRM4.js} +4 -4
  28. package/dist/{chunk-BIL3S6XH.js → chunk-HDO3PXCU.js} +5 -5
  29. package/dist/{chunk-RM6XOZMU.js → chunk-IKYZ5CJZ.js} +2 -2
  30. package/dist/{chunk-OP5ZIVXO.js → chunk-IVSMEG5M.js} +50 -49
  31. package/dist/chunk-IVSMEG5M.js.map +1 -0
  32. package/dist/{chunk-NEZNZM7K.js → chunk-JQXUIKU5.js} +2 -2
  33. package/dist/{chunk-H5LKMR45.js → chunk-JTHILJFB.js} +2 -2
  34. package/dist/{chunk-WB2BP2G5.js → chunk-LPJEV4R2.js} +4 -103
  35. package/dist/chunk-LPJEV4R2.js.map +1 -0
  36. package/dist/{chunk-SIHAOB4F.js → chunk-MIIJ2HQS.js} +7 -7
  37. package/dist/chunk-MMPR5QIV.js +9 -0
  38. package/dist/{chunk-B6V6SV2F.js.map → chunk-MMPR5QIV.js.map} +1 -1
  39. package/dist/{chunk-QKGZ65TC.js → chunk-MVU7JAKG.js} +3 -3
  40. package/dist/chunk-NEJVK5CF.js +26 -0
  41. package/dist/chunk-NEJVK5CF.js.map +1 -0
  42. package/dist/{chunk-2IE6UUUD.js → chunk-OOCMPS5L.js} +2 -2
  43. package/dist/{chunk-G5PN5NIS.js → chunk-OQAQMCHF.js} +15 -33
  44. package/dist/chunk-OQAQMCHF.js.map +1 -0
  45. package/dist/{chunk-ICVR5M6W.js → chunk-OW46TR4G.js} +5 -5
  46. package/dist/{chunk-P2U6R35K.js → chunk-PUYXTZ32.js} +7 -7
  47. package/dist/{chunk-WVZ56EJC.js → chunk-QX4LFFNS.js} +9 -3
  48. package/dist/{chunk-WVZ56EJC.js.map → chunk-QX4LFFNS.js.map} +1 -1
  49. package/dist/{chunk-7HEB6SQS.js → chunk-QXUHOISF.js} +146 -3
  50. package/dist/chunk-QXUHOISF.js.map +1 -0
  51. package/dist/chunk-R6HAD575.js +797 -0
  52. package/dist/chunk-R6HAD575.js.map +1 -0
  53. package/dist/{chunk-6AULWNAN.js → chunk-R7B46WXN.js} +4 -4
  54. package/dist/{chunk-JYWCNLZN.js → chunk-RG63ACAK.js} +4 -4
  55. package/dist/{chunk-7NAXFBFI.js → chunk-RKEY4573.js} +2 -2
  56. package/dist/{chunk-PDF3BZZH.js → chunk-RLR66XLG.js} +3 -3
  57. package/dist/{chunk-QP6LFMMK.js → chunk-RMICESXA.js} +15 -15
  58. package/dist/{chunk-TOQZODGI.js → chunk-RQE5UOIW.js} +3 -3
  59. package/dist/{chunk-WF57CF7A.js → chunk-RT4QZRTC.js} +7 -4
  60. package/dist/chunk-RT4QZRTC.js.map +1 -0
  61. package/dist/{chunk-WUWED3LV.js → chunk-SH7NSDRW.js} +2 -2
  62. package/dist/{chunk-BLLLVWEB.js → chunk-SRIYY5HL.js} +3 -3
  63. package/dist/{chunk-DW4JPVXB.js → chunk-TMNIOM4Y.js} +2 -2
  64. package/dist/{chunk-KLK6O54M.js → chunk-UAAH334K.js} +10 -10
  65. package/dist/{chunk-ULQQ6SXT.js → chunk-WG3BMHKU.js} +4 -4
  66. package/dist/{chunk-GJDXEHII.js → chunk-WH3SPT3N.js} +2 -2
  67. package/dist/{chunk-73J2ZJA6.js → chunk-YAZ3GAZY.js} +5 -5
  68. package/dist/{chunk-H2NVIZ3M.js → chunk-YJVZ5H3I.js} +2 -2
  69. package/dist/chunk-YXQIGBL6.js +106 -0
  70. package/dist/chunk-YXQIGBL6.js.map +1 -0
  71. package/dist/{chunk-7IZW6GLY.js → chunk-YZLNJQAV.js} +3 -3
  72. package/dist/{chunk-SDE3BZ6P.js → chunk-ZFPV46FA.js} +14 -14
  73. package/dist/{chunk-N4EYQKSM.js → chunk-ZWD64IDK.js} +2 -2
  74. package/dist/{cleanup-AEZKR7Q3.js → cleanup-OO3DCPGC.js} +24 -23
  75. package/dist/{cleanup-AEZKR7Q3.js.map → cleanup-OO3DCPGC.js.map} +1 -1
  76. package/dist/cli-RYEDO3OH.js +18 -0
  77. package/dist/{command-hook-installer-SGEJTZ2Y.js → command-hook-installer-7JB3AC2S.js} +4 -4
  78. package/dist/{config-RF2S4YBA.js → config-SSWYCX4C.js} +10 -9
  79. package/dist/{config-RF2S4YBA.js.map → config-SSWYCX4C.js.map} +1 -1
  80. package/dist/{diff-2PPFXZD6.js → diff-76H3Y34M.js} +15 -14
  81. package/dist/{diff-2PPFXZD6.js.map → diff-76H3Y34M.js.map} +1 -1
  82. package/dist/{digest-5CRGAAK5.js → digest-WCZD6N7M.js} +12 -11
  83. package/dist/{digest-5CRGAAK5.js.map → digest-WCZD6N7M.js.map} +1 -1
  84. package/dist/{fork-W5ZF62UP.js → fork-WTNAUILU.js} +24 -23
  85. package/dist/{fork-W5ZF62UP.js.map → fork-WTNAUILU.js.map} +1 -1
  86. package/dist/{hook-U37AFPKY.js → hook-GQQZQ6DK.js} +18 -14
  87. package/dist/hook-GQQZQ6DK.js.map +1 -0
  88. package/dist/{hydrate-MAFHTY2W.js → hydrate-Q4FWUQRC.js} +9 -8
  89. package/dist/{hydrate-MAFHTY2W.js.map → hydrate-Q4FWUQRC.js.map} +1 -1
  90. package/dist/{init-CJDDD4AS.js → init-AT3BQLXM.js} +12 -11
  91. package/dist/{init-CJDDD4AS.js.map → init-AT3BQLXM.js.map} +1 -1
  92. package/dist/{install-skills-2ZAHI73P.js → install-skills-Z76FLXOU.js} +4 -4
  93. package/dist/install-skills-bin.js +3 -3
  94. package/dist/{list-KEF73NLQ.js → list-YTK2GLND.js} +5 -5
  95. package/dist/{move-6J35JMFB.js → move-CE5NIZKL.js} +17 -16
  96. package/dist/{move-6J35JMFB.js.map → move-CE5NIZKL.js.map} +1 -1
  97. package/dist/{note-TNC633NG.js → note-2JHWK6CV.js} +13 -12
  98. package/dist/{note-TNC633NG.js.map → note-2JHWK6CV.js.map} +1 -1
  99. package/dist/{overlaps-NZL5XFC4.js → overlaps-GXSEH2LG.js} +11 -10
  100. package/dist/{overlaps-NZL5XFC4.js.map → overlaps-GXSEH2LG.js.map} +1 -1
  101. package/dist/{pin-E53PGMGD.js → pin-UOW5VW42.js} +13 -12
  102. package/dist/{pin-E53PGMGD.js.map → pin-UOW5VW42.js.map} +1 -1
  103. package/dist/{pr-CBLU6UJ2.js → pr-74X5MOPX.js} +13 -12
  104. package/dist/{pr-CBLU6UJ2.js.map → pr-74X5MOPX.js.map} +1 -1
  105. package/dist/{prune-FKNNOITA.js → prune-L3VXZUIE.js} +23 -22
  106. package/dist/{prune-FKNNOITA.js.map → prune-L3VXZUIE.js.map} +1 -1
  107. package/dist/{pty-host-36Y4XSPP.js → pty-host-5Z3GYXTW.js} +12 -11
  108. package/dist/{pty-host-36Y4XSPP.js.map → pty-host-5Z3GYXTW.js.map} +1 -1
  109. package/dist/{read-ESOOJSBO.js → read-G7CVQRH6.js} +11 -10
  110. package/dist/{read-ESOOJSBO.js.map → read-G7CVQRH6.js.map} +1 -1
  111. package/dist/{recent-3WYFF36X.js → recent-2LM44HN2.js} +9 -8
  112. package/dist/{recent-3WYFF36X.js.map → recent-2LM44HN2.js.map} +1 -1
  113. package/dist/{remove-2CQ4MRSI.js → remove-NVQ2JNMA.js} +24 -23
  114. package/dist/{remove-2CQ4MRSI.js.map → remove-NVQ2JNMA.js.map} +1 -1
  115. package/dist/{report-KM4OZCZB.js → report-335HKCCY.js} +4 -4
  116. package/dist/{resume-NDE6NKKT.js → resume-VA34T7ZR.js} +9 -8
  117. package/dist/{resume-NDE6NKKT.js.map → resume-VA34T7ZR.js.map} +1 -1
  118. package/dist/{run-UW4BJCSC.js → run-E2WZPHHK.js} +8 -7
  119. package/dist/{run-UW4BJCSC.js.map → run-E2WZPHHK.js.map} +1 -1
  120. package/dist/{screen-5BLTXIKS.js → screen-XSBZHJNW.js} +13 -12
  121. package/dist/{screen-5BLTXIKS.js.map → screen-XSBZHJNW.js.map} +1 -1
  122. package/dist/{search-MK6R5VR6.js → search-FJUZPI3P.js} +8 -7
  123. package/dist/{search-MK6R5VR6.js.map → search-FJUZPI3P.js.map} +1 -1
  124. package/dist/{section-B4BWRY7K.js → section-BWZW3E2I.js} +13 -12
  125. package/dist/{section-B4BWRY7K.js.map → section-BWZW3E2I.js.map} +1 -1
  126. package/dist/{send-OT3OXHHW.js → send-4E7CD6PL.js} +15 -14
  127. package/dist/{send-OT3OXHHW.js.map → send-4E7CD6PL.js.map} +1 -1
  128. package/dist/{sessions-6BBMLMPQ.js → sessions-4LFKWTBZ.js} +19 -18
  129. package/dist/{sessions-6BBMLMPQ.js.map → sessions-4LFKWTBZ.js.map} +1 -1
  130. package/dist/{snooze-A2BVEYWD.js → snooze-SSSA656T.js} +12 -11
  131. package/dist/{snooze-A2BVEYWD.js.map → snooze-SSSA656T.js.map} +1 -1
  132. package/dist/{start-LEYVJWZG.js → start-5LODG4WG.js} +13 -12
  133. package/dist/{start-LEYVJWZG.js.map → start-5LODG4WG.js.map} +1 -1
  134. package/dist/{state-FGYNNSDP.js → state-S776FFV5.js} +9 -7
  135. package/dist/state-S776FFV5.js.map +1 -0
  136. package/dist/{status-AO653RKW.js → status-U5HKQ7MY.js} +9 -8
  137. package/dist/{status-AO653RKW.js.map → status-U5HKQ7MY.js.map} +1 -1
  138. package/dist/{stop-QYIRUR5Y.js → stop-OFQFHRXD.js} +13 -12
  139. package/dist/{stop-QYIRUR5Y.js.map → stop-OFQFHRXD.js.map} +1 -1
  140. package/dist/{sync-FE3AEVOP.js → sync-FDXM5EFD.js} +23 -22
  141. package/dist/{sync-FE3AEVOP.js.map → sync-FDXM5EFD.js.map} +1 -1
  142. package/dist/{time-4V56YERF.js → time-IIAXBSE7.js} +18 -14
  143. package/dist/{time-4V56YERF.js.map → time-IIAXBSE7.js.map} +1 -1
  144. package/dist/time-actions-K5VITQK5.js +15 -0
  145. package/dist/time-actions-K5VITQK5.js.map +1 -0
  146. package/dist/timesheet-SS6AA5BC.js +147 -0
  147. package/dist/timesheet-SS6AA5BC.js.map +1 -0
  148. package/dist/{todo-Y2BZ65MS.js → todo-2GKRUO4D.js} +6 -6
  149. package/dist/{tree-PA7BK7F6.js → tree-7S4DUZRZ.js} +20 -19
  150. package/dist/{tree-PA7BK7F6.js.map → tree-7S4DUZRZ.js.map} +1 -1
  151. package/dist/{update-EISQJXEI.js → update-7ZE4CG7T.js} +13 -12
  152. package/dist/{update-EISQJXEI.js.map → update-7ZE4CG7T.js.map} +1 -1
  153. package/dist/{wait-FW7RARBV.js → wait-TGQLNTE7.js} +13 -12
  154. package/dist/{wait-FW7RARBV.js.map → wait-TGQLNTE7.js.map} +1 -1
  155. package/dist/wd-bin.js +7 -7
  156. package/dist/web/assets/{PtyView-Eh_9_oeq.js → PtyView-VxE2hVXZ.js} +2 -2
  157. package/dist/web/assets/{PtyView-Eh_9_oeq.js.map → PtyView-VxE2hVXZ.js.map} +1 -1
  158. package/dist/web/assets/index-DC9qRg0H.css +1 -0
  159. package/dist/web/assets/index-Dt2LS35B.js +118 -0
  160. package/dist/web/assets/index-Dt2LS35B.js.map +1 -0
  161. package/dist/web/index.html +2 -2
  162. package/dist/{web-EORTIDIA.js → web-W6BZVICE.js} +526 -190
  163. package/dist/web-W6BZVICE.js.map +1 -0
  164. package/npm-shrinkwrap.json +2 -2
  165. package/package.json +1 -1
  166. package/dist/chunk-7HEB6SQS.js.map +0 -1
  167. package/dist/chunk-B6V6SV2F.js +0 -9
  168. package/dist/chunk-G5PN5NIS.js.map +0 -1
  169. package/dist/chunk-OP5ZIVXO.js.map +0 -1
  170. package/dist/chunk-WB2BP2G5.js.map +0 -1
  171. package/dist/chunk-WF57CF7A.js.map +0 -1
  172. package/dist/cli-73A5TR5V.js +0 -18
  173. package/dist/hook-U37AFPKY.js.map +0 -1
  174. package/dist/state-FGYNNSDP.js.map +0 -1
  175. package/dist/web/assets/index-9lt7iidI.css +0 -1
  176. package/dist/web/assets/index-NvjFIXGV.js +0 -118
  177. package/dist/web/assets/index-NvjFIXGV.js.map +0 -1
  178. package/dist/web-EORTIDIA.js.map +0 -1
  179. /package/dist/{chunk-WTR5BUGS.js.map → chunk-26IZBYVL.js.map} +0 -0
  180. /package/dist/{chunk-NS3HSXF7.js.map → chunk-3B3UMUE6.js.map} +0 -0
  181. /package/dist/{chunk-UNLBHYA5.js.map → chunk-427RB7E4.js.map} +0 -0
  182. /package/dist/{chunk-UPR2F7QP.js.map → chunk-4PP27RI7.js.map} +0 -0
  183. /package/dist/{chunk-HLXEMPEI.js.map → chunk-6O6765M7.js.map} +0 -0
  184. /package/dist/{chunk-JJRPLNLN.js.map → chunk-7HGABVGR.js.map} +0 -0
  185. /package/dist/{chunk-G6IJ76DW.js.map → chunk-ACXPSQJR.js.map} +0 -0
  186. /package/dist/{chunk-3R4HBEIG.js.map → chunk-AFV5S6UV.js.map} +0 -0
  187. /package/dist/{chunk-45XJ4JGE.js.map → chunk-AVRDRZ4D.js.map} +0 -0
  188. /package/dist/{chunk-I5CDLVJY.js.map → chunk-D4FUDMMX.js.map} +0 -0
  189. /package/dist/{chunk-5XMXZIJS.js.map → chunk-E35NZVPX.js.map} +0 -0
  190. /package/dist/{chunk-IC5PFQCV.js.map → chunk-HBXDIRM4.js.map} +0 -0
  191. /package/dist/{chunk-BIL3S6XH.js.map → chunk-HDO3PXCU.js.map} +0 -0
  192. /package/dist/{chunk-RM6XOZMU.js.map → chunk-IKYZ5CJZ.js.map} +0 -0
  193. /package/dist/{chunk-NEZNZM7K.js.map → chunk-JQXUIKU5.js.map} +0 -0
  194. /package/dist/{chunk-H5LKMR45.js.map → chunk-JTHILJFB.js.map} +0 -0
  195. /package/dist/{chunk-SIHAOB4F.js.map → chunk-MIIJ2HQS.js.map} +0 -0
  196. /package/dist/{chunk-QKGZ65TC.js.map → chunk-MVU7JAKG.js.map} +0 -0
  197. /package/dist/{chunk-2IE6UUUD.js.map → chunk-OOCMPS5L.js.map} +0 -0
  198. /package/dist/{chunk-ICVR5M6W.js.map → chunk-OW46TR4G.js.map} +0 -0
  199. /package/dist/{chunk-P2U6R35K.js.map → chunk-PUYXTZ32.js.map} +0 -0
  200. /package/dist/{chunk-6AULWNAN.js.map → chunk-R7B46WXN.js.map} +0 -0
  201. /package/dist/{chunk-JYWCNLZN.js.map → chunk-RG63ACAK.js.map} +0 -0
  202. /package/dist/{chunk-7NAXFBFI.js.map → chunk-RKEY4573.js.map} +0 -0
  203. /package/dist/{chunk-PDF3BZZH.js.map → chunk-RLR66XLG.js.map} +0 -0
  204. /package/dist/{chunk-QP6LFMMK.js.map → chunk-RMICESXA.js.map} +0 -0
  205. /package/dist/{chunk-TOQZODGI.js.map → chunk-RQE5UOIW.js.map} +0 -0
  206. /package/dist/{chunk-WUWED3LV.js.map → chunk-SH7NSDRW.js.map} +0 -0
  207. /package/dist/{chunk-BLLLVWEB.js.map → chunk-SRIYY5HL.js.map} +0 -0
  208. /package/dist/{chunk-DW4JPVXB.js.map → chunk-TMNIOM4Y.js.map} +0 -0
  209. /package/dist/{chunk-KLK6O54M.js.map → chunk-UAAH334K.js.map} +0 -0
  210. /package/dist/{chunk-ULQQ6SXT.js.map → chunk-WG3BMHKU.js.map} +0 -0
  211. /package/dist/{chunk-GJDXEHII.js.map → chunk-WH3SPT3N.js.map} +0 -0
  212. /package/dist/{chunk-73J2ZJA6.js.map → chunk-YAZ3GAZY.js.map} +0 -0
  213. /package/dist/{chunk-H2NVIZ3M.js.map → chunk-YJVZ5H3I.js.map} +0 -0
  214. /package/dist/{chunk-7IZW6GLY.js.map → chunk-YZLNJQAV.js.map} +0 -0
  215. /package/dist/{chunk-SDE3BZ6P.js.map → chunk-ZFPV46FA.js.map} +0 -0
  216. /package/dist/{chunk-N4EYQKSM.js.map → chunk-ZWD64IDK.js.map} +0 -0
  217. /package/dist/{cli-73A5TR5V.js.map → cli-RYEDO3OH.js.map} +0 -0
  218. /package/dist/{command-hook-installer-SGEJTZ2Y.js.map → command-hook-installer-7JB3AC2S.js.map} +0 -0
  219. /package/dist/{install-skills-2ZAHI73P.js.map → install-skills-Z76FLXOU.js.map} +0 -0
  220. /package/dist/{list-KEF73NLQ.js.map → list-YTK2GLND.js.map} +0 -0
  221. /package/dist/{report-KM4OZCZB.js.map → report-335HKCCY.js.map} +0 -0
  222. /package/dist/{todo-Y2BZ65MS.js.map → todo-2GKRUO4D.js.map} +0 -0
@@ -0,0 +1,656 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ sessionWorkTime
4
+ } from "./chunk-YXQIGBL6.js";
5
+ import {
6
+ runInternal
7
+ } from "./chunk-R7B46WXN.js";
8
+ import {
9
+ DEFAULT_CATCH_UP_DAYS,
10
+ addDays,
11
+ localDay,
12
+ readIssueIds,
13
+ rememberIssueId,
14
+ timeSettings
15
+ } from "./chunk-R6HAD575.js";
16
+ import {
17
+ loadHistory,
18
+ runGitAsync
19
+ } from "./chunk-OQAQMCHF.js";
20
+ import {
21
+ sessionIdFor
22
+ } from "./chunk-RT4QZRTC.js";
23
+ import {
24
+ atomicWriteFile,
25
+ ensureFile,
26
+ getConfigDir,
27
+ isIssueKey,
28
+ issueKeys,
29
+ loadConfig,
30
+ withFileLockSync
31
+ } from "./chunk-QXUHOISF.js";
32
+
33
+ // src/core/time/time-deps.ts
34
+ import fs2 from "fs";
35
+
36
+ // src/core/jira/jira.ts
37
+ import { execFile } from "child_process";
38
+ function execAsync(cmd, args, timeout) {
39
+ return new Promise((resolve, reject) => {
40
+ execFile(cmd, args, { encoding: "utf-8", timeout, windowsHide: true }, (err, stdout) => {
41
+ if (err) reject(err);
42
+ else resolve(stdout ?? "");
43
+ });
44
+ });
45
+ }
46
+ async function probeAcli() {
47
+ try {
48
+ const stdout = await execAsync("acli", ["jira", "auth", "status"], 5e3);
49
+ const match = stdout.match(/Site:\s+(\S+)/);
50
+ return {
51
+ available: true,
52
+ siteUrl: match ? `https://${match[1]}` : ""
53
+ };
54
+ } catch {
55
+ return { available: false, siteUrl: "" };
56
+ }
57
+ }
58
+ function isStatusCategory(k) {
59
+ return k === "new" || k === "indeterminate" || k === "done";
60
+ }
61
+ function parseIssuesJson(stdout, siteUrl) {
62
+ const parsed = JSON.parse(stdout);
63
+ const issues = (Array.isArray(parsed) ? parsed : parsed?.issues) ?? [];
64
+ return issues.map((issue) => {
65
+ const fields = issue.fields ?? {};
66
+ return {
67
+ key: issue.key ?? "",
68
+ summary: fields.summary ?? "",
69
+ status: fields.status?.name ?? "",
70
+ ...isStatusCategory(fields.status?.statusCategory?.key) ? { statusCategory: fields.status.statusCategory.key } : {},
71
+ issuetype: fields.issuetype?.name ?? "",
72
+ priority: fields.priority?.name ?? "",
73
+ url: siteUrl ? `${siteUrl}/browse/${issue.key}` : ""
74
+ };
75
+ });
76
+ }
77
+ var MY_ISSUES_JQL = "assignee = currentUser() AND statusCategory != Done AND status NOT IN (Archived) ORDER BY updated DESC";
78
+ async function searchMyIssues(siteUrl) {
79
+ try {
80
+ const stdout = await execAsync("acli", ["jira", "workitem", "search", "--jql", MY_ISSUES_JQL, "--json", "--limit", "50"], 15e3);
81
+ if (!stdout) return [];
82
+ return parseIssuesJson(stdout, siteUrl);
83
+ } catch {
84
+ return [];
85
+ }
86
+ }
87
+ async function fetchMyIssuesOrThrow() {
88
+ const probe = await probeAcli();
89
+ if (!probe.available) throw new Error("acli is not available (installed and signed in?)");
90
+ const stdout = await execAsync("acli", ["jira", "workitem", "search", "--jql", MY_ISSUES_JQL, "--json", "--paginate"], 6e4);
91
+ return stdout ? parseIssuesJson(stdout, probe.siteUrl) : [];
92
+ }
93
+ async function issueIdOf(key) {
94
+ try {
95
+ const stdout = await execAsync("acli", ["jira", "workitem", "view", key, "--json"], 15e3);
96
+ const j = JSON.parse(stdout);
97
+ const id = typeof j.id === "string" ? Number(j.id) : j.id;
98
+ return typeof id === "number" && Number.isFinite(id) ? id : null;
99
+ } catch {
100
+ return null;
101
+ }
102
+ }
103
+ var accountIdCache = null;
104
+ var accountIdMissedAt = 0;
105
+ var ACCOUNT_RETRY_MS = 10 * 6e4;
106
+ async function myAccountId() {
107
+ if (accountIdCache) return accountIdCache;
108
+ if (Date.now() - accountIdMissedAt < ACCOUNT_RETRY_MS) return null;
109
+ try {
110
+ const stdout = await execAsync(
111
+ "acli",
112
+ [
113
+ "jira",
114
+ "workitem",
115
+ "search",
116
+ "--jql",
117
+ "assignee = currentUser() ORDER BY updated DESC",
118
+ "--fields",
119
+ "assignee",
120
+ "--json",
121
+ "--limit",
122
+ "1"
123
+ ],
124
+ 15e3
125
+ );
126
+ const parsed = JSON.parse(stdout);
127
+ const list = (Array.isArray(parsed) ? parsed : parsed?.issues) ?? [];
128
+ const id = list[0]?.fields?.assignee?.accountId;
129
+ accountIdCache = typeof id === "string" && id ? id : null;
130
+ } catch {
131
+ accountIdCache = null;
132
+ }
133
+ if (!accountIdCache) accountIdMissedAt = Date.now();
134
+ return accountIdCache;
135
+ }
136
+ async function searchIssuesOrThrow(jql, limit = 50) {
137
+ const stdout = await execAsync("acli", ["jira", "workitem", "search", "--jql", jql, "--json", "--limit", String(limit)], 15e3);
138
+ return stdout ? parseIssuesJson(stdout, "") : [];
139
+ }
140
+ async function fetchJiraPane() {
141
+ const probe = await probeAcli();
142
+ if (!probe.available) return { available: false, issues: [] };
143
+ const issues = await searchMyIssues(probe.siteUrl);
144
+ return { available: true, issues };
145
+ }
146
+ function adfText(node, max = 4e3) {
147
+ const out = [];
148
+ const walk = (n) => {
149
+ if (!n || typeof n !== "object") return;
150
+ const o = n;
151
+ if (o.type === "text" && typeof o.text === "string") out.push(o.text);
152
+ if (Array.isArray(o.content)) for (const c of o.content) walk(c);
153
+ if (o.type === "paragraph" || o.type === "heading" || o.type === "listItem" || o.type === "codeBlock") out.push("\n");
154
+ };
155
+ walk(node);
156
+ const text = out.join("").replace(/\n{3,}/g, "\n\n").trim();
157
+ return text.length > max ? text.slice(0, max) + "\u2026" : text;
158
+ }
159
+ async function fetchIssueDetail(key) {
160
+ if (!/^[A-Z][A-Z0-9_]*-\d+$/.test(key)) return null;
161
+ try {
162
+ const stdout = await execAsync(
163
+ "acli",
164
+ ["jira", "workitem", "view", key, "--json", "--fields", "summary,description,project,components,labels,created"],
165
+ 15e3
166
+ );
167
+ const f = JSON.parse(stdout).fields ?? {};
168
+ const p = f.project;
169
+ const names = (v) => Array.isArray(v) ? v.map((c) => typeof c === "string" ? c : c?.name).filter((s) => typeof s === "string") : [];
170
+ return {
171
+ project: p && typeof p.key === "string" ? { key: p.key, name: typeof p.name === "string" ? p.name : p.key } : null,
172
+ components: names(f.components),
173
+ labels: names(f.labels),
174
+ description: adfText(f.description),
175
+ created: typeof f.created === "string" ? f.created : null
176
+ };
177
+ } catch {
178
+ return null;
179
+ }
180
+ }
181
+ async function fetchMyIssues() {
182
+ const r = await fetchJiraPane();
183
+ return r.issues;
184
+ }
185
+
186
+ // src/core/time/graph.ts
187
+ import fs from "fs";
188
+ import path from "path";
189
+ var GRAPH_SCOPES = "offline_access User.Read Calendars.Read Chat.Read";
190
+ var GRAPH = "https://graph.microsoft.com/v1.0";
191
+ var loginUrl = (tenant, what) => `https://login.microsoftonline.com/${encodeURIComponent(tenant)}/oauth2/v2.0/${what}`;
192
+ function graphApp(cfg, env) {
193
+ const clientId = cfg?.clientId?.trim() || env.GRAPH_CLIENT_ID?.trim();
194
+ if (!clientId) return { why: "No app to sign in to Microsoft with: set time.graph.clientId (and tenantId) in config.json." };
195
+ return { clientId, tenantId: cfg?.tenantId?.trim() || env.GRAPH_TENANT_ID?.trim() || "organizations" };
196
+ }
197
+ var tokenPath = () => path.join(getConfigDir(), "graph-token.json");
198
+ function readTokens() {
199
+ try {
200
+ const v = JSON.parse(fs.readFileSync(tokenPath(), "utf8"));
201
+ return typeof v.refreshToken === "string" && typeof v.accessToken === "string" && typeof v.expiresAt === "number" ? {
202
+ refreshToken: v.refreshToken,
203
+ accessToken: v.accessToken,
204
+ expiresAt: v.expiresAt,
205
+ account: v.account ?? "",
206
+ clientId: v.clientId ?? "",
207
+ ...typeof v.problem === "string" ? { problem: v.problem } : {}
208
+ } : null;
209
+ } catch {
210
+ return null;
211
+ }
212
+ }
213
+ function writeTokens(t) {
214
+ const file = tokenPath();
215
+ fs.mkdirSync(path.dirname(file), { recursive: true });
216
+ ensureFile(file, "{}");
217
+ fs.chmodSync(file, 384);
218
+ withFileLockSync(file, () => atomicWriteFile(file, JSON.stringify(t)));
219
+ }
220
+ function updateTokens(change) {
221
+ const file = tokenPath();
222
+ if (!fs.existsSync(file)) return;
223
+ withFileLockSync(file, () => {
224
+ const cur = readTokens();
225
+ const next = cur && change(cur);
226
+ if (next) atomicWriteFile(file, JSON.stringify(next));
227
+ });
228
+ }
229
+ function graphAccount() {
230
+ return readTokens()?.account || null;
231
+ }
232
+ var EXPIRED = "The Microsoft sign-in stopped working (expired or revoked): connect again.";
233
+ var OTHER_APP = "Signed in with another app registration than time.graph names now: connect again.";
234
+ function graphProblem(app) {
235
+ const t = readTokens();
236
+ if (!t) return null;
237
+ if (t.problem) return t.problem;
238
+ if (!("why" in app) && t.clientId && t.clientId !== app.clientId) return OTHER_APP;
239
+ return null;
240
+ }
241
+ function signOutGraph() {
242
+ const file = tokenPath();
243
+ if (!fs.existsSync(file)) return;
244
+ withFileLockSync(file, () => fs.rmSync(file, { force: true }));
245
+ }
246
+ var TIMEOUT_MS = 3e4;
247
+ var SIGN_IN_GONE = /* @__PURE__ */ new Set(["invalid_grant", "interaction_required", "invalid_client", "unauthorized_client", "consent_required"]);
248
+ var postForm = (fetchImpl, url, form) => fetchImpl(url, {
249
+ method: "POST",
250
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
251
+ body: new URLSearchParams(form).toString(),
252
+ signal: AbortSignal.timeout(TIMEOUT_MS)
253
+ });
254
+ async function startDeviceLogin(app, fetchImpl = fetch, now = Date.now()) {
255
+ const res = await postForm(fetchImpl, loginUrl(app.tenantId, "devicecode"), { client_id: app.clientId, scope: GRAPH_SCOPES });
256
+ const j = await res.json().catch(() => ({}));
257
+ if (!res.ok || !j.user_code || !j.device_code) throw new Error(`Microsoft sign-in: ${j.error_description?.split("\n")[0] ?? res.status}`);
258
+ return {
259
+ userCode: j.user_code,
260
+ verificationUri: j.verification_uri ?? "https://microsoft.com/devicelogin",
261
+ deviceCode: j.device_code,
262
+ expiresAt: now + (j.expires_in ?? 900) * 1e3,
263
+ intervalMs: (j.interval ?? 5) * 1e3
264
+ };
265
+ }
266
+ var CANCELLED = "The sign-in was cancelled.";
267
+ var NEW_ACCOUNT = "your Microsoft account";
268
+ async function finishDeviceLogin(app, login, opts = {}) {
269
+ const fetchImpl = opts.fetchImpl ?? fetch;
270
+ const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
271
+ const now = opts.now ?? (() => Date.now());
272
+ let interval = login.intervalMs;
273
+ while (now() < login.expiresAt) {
274
+ await sleep(interval);
275
+ if (opts.cancelled?.()) throw new Error(CANCELLED);
276
+ const res = await postForm(fetchImpl, loginUrl(app.tenantId, "token"), {
277
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
278
+ client_id: app.clientId,
279
+ device_code: login.deviceCode
280
+ });
281
+ const j = await res.json().catch(() => ({}));
282
+ if (res.ok && j.access_token) {
283
+ if (opts.cancelled?.()) throw new Error(CANCELLED);
284
+ return keep(app, j, now(), fetchImpl);
285
+ }
286
+ if (j.error === "authorization_pending") continue;
287
+ if (j.error === "slow_down") {
288
+ interval += 5e3;
289
+ continue;
290
+ }
291
+ throw new Error(
292
+ j.error === "expired_token" ? "The sign-in code expired: connect again." : `Microsoft sign-in: ${j.error_description?.split("\n")[0] ?? j.error ?? res.status}`
293
+ );
294
+ }
295
+ throw new Error("The sign-in code expired: connect again.");
296
+ }
297
+ async function keep(app, j, now, fetchImpl, opts = {}) {
298
+ const before = readTokens();
299
+ const tokens = {
300
+ refreshToken: j.refresh_token ?? before?.refreshToken ?? "",
301
+ accessToken: j.access_token,
302
+ expiresAt: now + ((j.expires_in ?? 3600) - 60) * 1e3,
303
+ // A refresh keeps who it was; a new sign-in may be another account: not the old one's name (until /me says).
304
+ account: opts.refresh ? before?.account ?? "" : NEW_ACCOUNT,
305
+ clientId: app.clientId
306
+ };
307
+ if (opts.refresh) updateTokens(() => tokens);
308
+ else writeTokens(tokens);
309
+ const who = await fetchImpl(`${GRAPH}/me?$select=userPrincipalName,id`, {
310
+ headers: { Authorization: `Bearer ${j.access_token}` },
311
+ signal: AbortSignal.timeout(TIMEOUT_MS)
312
+ }).then((me) => me.json()).catch(() => ({}));
313
+ if (who.userPrincipalName && who.userPrincipalName !== tokens.account)
314
+ updateTokens((cur) => cur.accessToken === tokens.accessToken ? { ...cur, account: who.userPrincipalName } : null);
315
+ return who.userPrincipalName ?? tokens.account;
316
+ }
317
+ async function graphToken(app, fetchImpl = fetch, now = Date.now()) {
318
+ const t = readTokens();
319
+ if (!t) return null;
320
+ if (t.problem) throw new Error(t.problem);
321
+ if (t.clientId && t.clientId !== app.clientId) throw new Error(OTHER_APP);
322
+ if (t.expiresAt > now) return t.accessToken;
323
+ const res = await postForm(fetchImpl, loginUrl(app.tenantId, "token"), {
324
+ grant_type: "refresh_token",
325
+ client_id: app.clientId,
326
+ refresh_token: t.refreshToken,
327
+ scope: GRAPH_SCOPES
328
+ });
329
+ const j = await res.json().catch(() => ({}));
330
+ if (!res.ok || !j.access_token) {
331
+ const gone = !!j.error && SIGN_IN_GONE.has(j.error);
332
+ if (gone) {
333
+ let renewed = null;
334
+ updateTokens((cur) => {
335
+ if (cur.refreshToken !== t.refreshToken) {
336
+ renewed = cur.expiresAt > now ? cur.accessToken : null;
337
+ return null;
338
+ }
339
+ return { ...cur, problem: EXPIRED };
340
+ });
341
+ if (renewed) return renewed;
342
+ }
343
+ throw new Error(gone ? EXPIRED : `Microsoft sign-in: ${res.status}${j.error ? ` ${j.error}` : ""}`);
344
+ }
345
+ await keep(app, j, now, fetchImpl, { refresh: true });
346
+ return j.access_token;
347
+ }
348
+ async function getJson(url, token, fetchImpl, headers = {}) {
349
+ const res = await fetchImpl(url, { headers: { Authorization: `Bearer ${token}`, ...headers }, signal: AbortSignal.timeout(TIMEOUT_MS) });
350
+ if (!res.ok) throw new Error(`Microsoft Graph: ${res.status} ${(await res.text().catch(() => "")).slice(0, 200)}`);
351
+ return await res.json();
352
+ }
353
+ var dayBounds = (day) => {
354
+ const from = /* @__PURE__ */ new Date(`${day}T00:00:00`);
355
+ const to = new Date(from);
356
+ to.setDate(to.getDate() + 1);
357
+ return { from, to };
358
+ };
359
+ async function meetingsOn(day, token, fetchImpl = fetch) {
360
+ const { from, to } = dayBounds(day);
361
+ const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
362
+ const all = [];
363
+ let next = `${GRAPH}/me/calendarView?startDateTime=${from.toISOString()}&endDateTime=${to.toISOString()}&$select=id,subject,start,end,isAllDay,isCancelled,showAs,responseStatus&$top=100`;
364
+ for (let page = 0; next && page < MAX_PAGES; page++) {
365
+ const p = await getJson(next, token, fetchImpl, { Prefer: `outlook.timezone="${tz}"` });
366
+ all.push(...p.value ?? []);
367
+ next = p["@odata.nextLink"];
368
+ }
369
+ if (next) throw new Error(`more calendar items than ${MAX_PAGES} pages`);
370
+ const events = all.filter((e) => !(e.isAllDay || e.isCancelled || e.showAs === "free" || e.responseStatus?.response === "declined")).map((e) => ({
371
+ e,
372
+ start: Math.max(graphTime(e.start), from.getTime()),
373
+ end: Math.min(graphTime(e.end), to.getTime())
374
+ })).filter((x) => x.end > x.start).sort((a, b) => a.start - b.start);
375
+ const out = [];
376
+ let covered = -Infinity;
377
+ for (const { e, start, end } of events) {
378
+ const minutes = Math.round((end - Math.max(start, Math.min(covered, end))) / 6e4);
379
+ covered = Math.max(covered, end);
380
+ if (!(minutes > 0)) continue;
381
+ out.push({
382
+ ...e.id ? { id: e.id } : {},
383
+ subject: e.subject?.trim() || "(no subject)",
384
+ start: hhmm(start),
385
+ end: end >= to.getTime() ? "24:00" : hhmm(end),
386
+ minutes
387
+ });
388
+ }
389
+ return out;
390
+ }
391
+ var hhmm = (ms) => {
392
+ const d = new Date(ms);
393
+ return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
394
+ };
395
+ function graphTime(t) {
396
+ const dt = t?.dateTime ?? "";
397
+ if (!dt) return NaN;
398
+ if (/[zZ]|[+-]\d\d:?\d\d$/.test(dt.slice(19))) return Date.parse(dt);
399
+ return /^(utc|etc\/utc|coordinated universal time|gmt)$/i.test(t?.timeZone ?? "") ? Date.parse(`${dt}Z`) : Date.parse(dt);
400
+ }
401
+ var MAX_PAGES = 10;
402
+ var oldestAt = (times) => {
403
+ const ms = times.map((t) => Date.parse(t ?? "")).filter((n) => !Number.isNaN(n));
404
+ return ms.length ? Math.min(...ms) : -Infinity;
405
+ };
406
+ function chatsOf(r, day) {
407
+ if (r.incompleteThrough && day <= r.incompleteThrough) throw new Error("more Teams messages than were read for that day");
408
+ return r.byDay.get(day) ?? [];
409
+ }
410
+ async function chatsSince(firstDay, token, fetchImpl = fetch) {
411
+ const from = dayBounds(firstDay).from.getTime();
412
+ const me = await getJson(`${GRAPH}/me?$select=id`, token, fetchImpl);
413
+ if (!me.id) throw new Error("Microsoft Graph: no id for you");
414
+ const active = [];
415
+ let next = `${GRAPH}/me/chats?$top=50&$expand=lastMessagePreview&$orderby=lastMessagePreview/createdDateTime desc`;
416
+ for (let page = 0; next && page < MAX_PAGES; page++) {
417
+ const j = await getJson(next, token, fetchImpl);
418
+ const value = j.value ?? [];
419
+ active.push(...value.filter((c) => Date.parse(c.lastMessagePreview?.createdDateTime ?? "") >= from));
420
+ next = oldestAt(value.map((c) => c.lastMessagePreview?.createdDateTime)) >= from ? j["@odata.nextLink"] : void 0;
421
+ }
422
+ const out = /* @__PURE__ */ new Map();
423
+ let incompleteThrough = null;
424
+ for (const c of active) {
425
+ if (!c.id) continue;
426
+ const msgs = [];
427
+ let more = `${GRAPH}/me/chats/${encodeURIComponent(c.id)}/messages?$top=50`;
428
+ for (let page = 0; more && page < MAX_PAGES; page++) {
429
+ const j = await getJson(more, token, fetchImpl);
430
+ const value = j.value ?? [];
431
+ msgs.push(...value);
432
+ more = oldestAt(value.map((m) => m.lastModifiedDateTime ?? m.createdDateTime)) >= from ? j["@odata.nextLink"] : void 0;
433
+ }
434
+ if (more) {
435
+ const reached = localDay(oldestAt(msgs.map((m) => m.lastModifiedDateTime ?? m.createdDateTime)));
436
+ if (!incompleteThrough || reached > incompleteThrough) incompleteThrough = reached;
437
+ }
438
+ const byDay = /* @__PURE__ */ new Map();
439
+ for (const m of msgs) {
440
+ const at = Date.parse(m.createdDateTime ?? "");
441
+ if (!(at >= from)) continue;
442
+ const d = localDay(at);
443
+ byDay.set(d, [...byDay.get(d) ?? [], m]);
444
+ }
445
+ for (const [d, dayMsgs] of byDay) {
446
+ const mine = dayMsgs.filter((m) => m.from?.user?.id === me.id);
447
+ if (!mine.length) continue;
448
+ const list = out.get(d) ?? [];
449
+ if (list.length >= 20) continue;
450
+ const mentions = [...new Set(dayMsgs.flatMap((m) => issueKeys(plain(m.body?.content ?? ""))))];
451
+ list.push({
452
+ id: c.id,
453
+ chat: c.topic?.trim() || (c.chatType === "oneOnOne" ? "a one-on-one chat" : "a group chat"),
454
+ messages: mine.length,
455
+ sample: mine.slice(0, 5).map((m) => plain(m.body?.content ?? "").slice(0, 200)),
456
+ ...mentions.length ? { mentions } : {}
457
+ });
458
+ out.set(d, list);
459
+ }
460
+ }
461
+ return { byDay: out, incompleteThrough };
462
+ }
463
+ function plain(html) {
464
+ return html.replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&amp;/g, "&").replace(/\s+/g, " ").trim();
465
+ }
466
+
467
+ // src/core/time/time-deps.ts
468
+ async function graphTokenNow() {
469
+ const app = graphApp(loadConfig()?.time?.graph, process.env);
470
+ return "why" in app ? null : graphToken(app);
471
+ }
472
+ function commitsWrittenOn(stdout, day) {
473
+ const out = [];
474
+ for (const line of stdout.split("\n").filter(Boolean)) {
475
+ const [sha, authored, committer, ...rest] = line.split(" ");
476
+ if (committer === "noreply@github.com") continue;
477
+ if (/^(index|untracked files) on /.test(rest.join(" "))) continue;
478
+ const at = Date.parse(authored ?? "");
479
+ if (Number.isNaN(at) || localDay(at) !== day) continue;
480
+ out.push({ sha, subject: rest.join(" ") });
481
+ }
482
+ return out;
483
+ }
484
+ var READ_FRESH_MS = 30 * 6e4;
485
+ var JIRA_DAY_LIMIT = 500;
486
+ async function jiraOn(day) {
487
+ const d = day.replace(/-/g, "/");
488
+ const end = addDays(day, 1).replace(/-/g, "/");
489
+ const moved = await searchIssuesOrThrow(`status CHANGED BY currentUser() DURING ("${d} 00:00", "${end} 00:00")`, JIRA_DAY_LIMIT);
490
+ const out = moved.map((i) => ({ key: i.key, summary: i.summary, what: `moved (now ${i.status || "changed"})` }));
491
+ const account = loadConfig()?.time?.tempo?.accountId || process.env.JIRA_ACCOUNT_ID || await myAccountId();
492
+ if (account && /^[\w:-]+$/.test(account)) {
493
+ const updated = await searchIssuesOrThrow(`issuekey IN updatedBy("${account}", "${d} 00:00", "${end} 00:00")`, JIRA_DAY_LIMIT);
494
+ for (const i of updated)
495
+ if (!out.some((o) => o.key === i.key)) out.push({ key: i.key, summary: i.summary, what: "updated by you (a comment or an edit)" });
496
+ }
497
+ return out;
498
+ }
499
+ async function titlesOf(keys, search, now = Date.now()) {
500
+ for (const [k, at] of refused) if (now - at > REFUSED_FOR_MS) refused.delete(k);
501
+ const valid = keys.filter((k) => isIssueKey(k) && !refused.has(k));
502
+ if (!valid.length) return {};
503
+ const of = (issues) => issues.map((i) => [i.key, { title: i.summary, done: i.statusCategory === "done" }]);
504
+ try {
505
+ return Object.fromEntries(of(await search(`key in (${valid.join(", ")})`, valid.length)));
506
+ } catch (err) {
507
+ if (valid.length === 1) throw err;
508
+ const one = [];
509
+ for (let i = 0; i < valid.length; i += TITLES_AT_ONCE)
510
+ one.push(...await Promise.all(valid.slice(i, i + TITLES_AT_ONCE).map((k) => search(`key = ${k}`, 1).then(of, () => null))));
511
+ if (one.every((r) => r === null)) throw err;
512
+ one.forEach((r, i) => r === null && refused.set(valid[i], now));
513
+ return Object.fromEntries(one.flatMap((r) => r ?? []));
514
+ }
515
+ }
516
+ var TITLES_AT_ONCE = 3;
517
+ var REFUSED_FOR_MS = 60 * 6e4;
518
+ var refused = /* @__PURE__ */ new Map();
519
+ var realIo = {
520
+ git: (cwd, args) => runGitAsync(cwd, { args }),
521
+ workTime: (s, now, days) => sessionWorkTime(s, now, days),
522
+ repos: () => loadConfig()?.repos ?? {},
523
+ exists: (folder) => fs2.existsSync(folder)
524
+ };
525
+ async function commitLog(git, repo, from) {
526
+ const email = (await git(repo, ["config", "user.email"])).stdout.trim();
527
+ if (!email) return "";
528
+ const log = await git(repo, [
529
+ "log",
530
+ "--exclude=refs/stash",
531
+ "--all",
532
+ "--no-merges",
533
+ "--fixed-strings",
534
+ `--since=${from} 00:00:00`,
535
+ // The address in its angle brackets: --author matches anywhere in "Name <email>", and `an@corp` is in `ivan@corp`.
536
+ `--author=<${email}>`,
537
+ "--format=%H%x09%aI%x09%ce%x09%s"
538
+ ]);
539
+ if (log.status !== 0) throw new Error(`git log failed in ${repo}`);
540
+ return log.stdout;
541
+ }
542
+ function defaultTimeDeps(io = realIo) {
543
+ const catchUpDays = () => timeSettings(loadConfig()?.time).catchUpDays ?? DEFAULT_CATCH_UP_DAYS;
544
+ const workTime = /* @__PURE__ */ new Map();
545
+ const logs = /* @__PURE__ */ new Map();
546
+ let chats = null;
547
+ let assigned = null;
548
+ const slow = /* @__PURE__ */ new Map();
549
+ const once = (key, read) => {
550
+ const c = slow.get(key);
551
+ if (c && Date.now() - c.at <= READ_FRESH_MS) return c.read;
552
+ const p = read();
553
+ slow.set(key, { at: Date.now(), read: p });
554
+ p.catch(() => slow.delete(key));
555
+ return p;
556
+ };
557
+ return {
558
+ fresh: (what = "all") => {
559
+ workTime.clear();
560
+ logs.clear();
561
+ if (what === "local") return;
562
+ chats = null;
563
+ slow.clear();
564
+ assigned = null;
565
+ },
566
+ sessions: () => loadHistory(),
567
+ minutesOn: async (s, day) => {
568
+ const id = sessionIdFor(s);
569
+ let w = workTime.get(id);
570
+ if (!w || Date.now() - w.at > READ_FRESH_MS) {
571
+ const byDay = io.workTime(s, Date.now(), catchUpDays()).then((t) => new Map(t.byDay.map((d) => [d.day, d.ms])));
572
+ w = { at: Date.now(), byDay };
573
+ workTime.set(id, w);
574
+ byDay.catch(() => workTime.delete(id));
575
+ }
576
+ return ((await w.byDay).get(day) ?? 0) / 6e4;
577
+ },
578
+ minutesFrom: () => addDays(localDay(), -(catchUpDays() - 1)),
579
+ commits: async (day) => {
580
+ const repos = io.repos();
581
+ const aliasOf = /* @__PURE__ */ new Map();
582
+ for (const [alias, folder] of Object.entries(repos)) if (!aliasOf.has(folder)) aliasOf.set(folder, alias);
583
+ const seen = /* @__PURE__ */ new Set();
584
+ const out = [];
585
+ const reads = [...aliasOf.keys()].filter((repo) => io.exists(repo)).map((repo) => {
586
+ let l = logs.get(repo);
587
+ if (!l || day < l.from || Date.now() - l.at > READ_FRESH_MS) {
588
+ const read = commitLog(io.git, repo, day);
589
+ l = { from: day, at: Date.now(), out: read };
590
+ logs.set(repo, l);
591
+ read.catch(() => logs.delete(repo));
592
+ }
593
+ return { repo, out: l.out };
594
+ });
595
+ for (const { repo, out: log } of reads) {
596
+ for (const c of commitsWrittenOn(await log, day)) {
597
+ if (seen.has(c.sha)) continue;
598
+ seen.add(c.sha);
599
+ out.push({ repo: aliasOf.get(repo) ?? repo, ...c });
600
+ }
601
+ }
602
+ return out;
603
+ },
604
+ jiraMoved: (day) => once(`jira:${day}`, () => jiraOn(day)),
605
+ titles: (keys) => once(`titles:${[...keys].sort().join(",")}`, () => titlesOf(keys, searchIssuesOrThrow)),
606
+ settings: () => timeSettings(loadConfig()?.time),
607
+ // Outlook and Teams only once you signed in (the Time tab's Connect): none otherwise. A sign-in that stopped
608
+ // working, or no network, throws (graphToken): the day keeps the meetings and chats it had.
609
+ meetings: async (day) => {
610
+ const token = await graphTokenNow();
611
+ return token ? once(`meetings:${day}`, () => meetingsOn(day, token)) : void 0;
612
+ },
613
+ chats: async (day) => {
614
+ const token = await graphTokenNow();
615
+ if (!token) return void 0;
616
+ if (!chats || day < chats.from || Date.now() - chats.at > READ_FRESH_MS) {
617
+ const read = chatsSince(day, token);
618
+ chats = { from: day, at: Date.now(), read };
619
+ read.catch(() => chats = null);
620
+ }
621
+ return chatsOf(await chats.read, day);
622
+ },
623
+ // Throws when acli can't list them: the day keeps its AI answer and the projects it knew (time-days.ts).
624
+ candidates: () => {
625
+ if (!assigned || Date.now() - assigned.at > READ_FRESH_MS) {
626
+ const list = fetchMyIssuesOrThrow().then((is) => is.map((i) => ({ key: i.key, title: i.summary })));
627
+ assigned = { at: Date.now(), list };
628
+ list.catch(() => assigned = null);
629
+ }
630
+ return assigned.list;
631
+ },
632
+ classify: (prompt) => runInternal(prompt, 6e4, { small: true }),
633
+ issueId: async (key) => {
634
+ const known = readIssueIds()[key];
635
+ if (known !== void 0) return known;
636
+ const id = await issueIdOf(key);
637
+ if (id !== null) rememberIssueId(key, id);
638
+ return id;
639
+ }
640
+ };
641
+ }
642
+
643
+ export {
644
+ fetchMyIssuesOrThrow,
645
+ fetchJiraPane,
646
+ fetchIssueDetail,
647
+ fetchMyIssues,
648
+ graphApp,
649
+ graphAccount,
650
+ graphProblem,
651
+ signOutGraph,
652
+ startDeviceLogin,
653
+ finishDeviceLogin,
654
+ defaultTimeDeps
655
+ };
656
+ //# sourceMappingURL=chunk-E5EPN3JI.js.map