@moberg_hr/work-tree 2.0.8 → 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.
- package/dist/{answer-QQAEJ5N3.js → answer-6UVHVEGQ.js} +13 -12
- package/dist/{answer-QQAEJ5N3.js.map → answer-6UVHVEGQ.js.map} +1 -1
- package/dist/{attach-XG3Y7QA7.js → attach-6Q6HGPCM.js} +15 -14
- package/dist/{attach-XG3Y7QA7.js.map → attach-6Q6HGPCM.js.map} +1 -1
- package/dist/bin.js +5 -5
- package/dist/{block-WW4BWDN7.js → block-46DPS75I.js} +13 -12
- package/dist/{block-WW4BWDN7.js.map → block-46DPS75I.js.map} +1 -1
- package/dist/{broadcast-LEOMDVSA.js → broadcast-OGOEQX4Z.js} +10 -9
- package/dist/{broadcast-LEOMDVSA.js.map → broadcast-OGOEQX4Z.js.map} +1 -1
- package/dist/{catchup-UBHGEMED.js → catchup-TTAC3GMX.js} +16 -15
- package/dist/{catchup-UBHGEMED.js.map → catchup-TTAC3GMX.js.map} +1 -1
- package/dist/{chunk-WTR5BUGS.js → chunk-26IZBYVL.js} +2 -2
- package/dist/{chunk-NS3HSXF7.js → chunk-3B3UMUE6.js} +2 -2
- package/dist/{chunk-LXM7QFBK.js → chunk-3XY76XBD.js} +24 -11
- package/dist/{chunk-LXM7QFBK.js.map → chunk-3XY76XBD.js.map} +1 -1
- package/dist/{chunk-UNLBHYA5.js → chunk-427RB7E4.js} +6 -6
- package/dist/{chunk-5RRKVAIZ.js → chunk-4KZBZA5D.js} +3 -2
- package/dist/chunk-4KZBZA5D.js.map +1 -0
- package/dist/{chunk-BLCAZAU5.js → chunk-4MXWNDH7.js} +6 -5
- package/dist/chunk-4MXWNDH7.js.map +1 -0
- package/dist/{chunk-I5HHTEAA.js → chunk-4PP27RI7.js} +9 -9
- package/dist/{chunk-LNMIG35F.js → chunk-5PAPD6VT.js} +2 -2
- package/dist/{chunk-HLXEMPEI.js → chunk-6O6765M7.js} +4 -4
- package/dist/{chunk-JJRPLNLN.js → chunk-7HGABVGR.js} +2 -2
- package/dist/{chunk-G6IJ76DW.js → chunk-ACXPSQJR.js} +3 -3
- package/dist/{chunk-E74YIDHX.js → chunk-AFV5S6UV.js} +11 -11
- package/dist/{chunk-NIRVJMJL.js → chunk-AVRDRZ4D.js} +13 -13
- package/dist/{chunk-4V7C3O6V.js → chunk-BZA7NKWU.js} +2 -2
- package/dist/{chunk-F3SPCHLH.js → chunk-D4FUDMMX.js} +11 -11
- package/dist/{chunk-5XMXZIJS.js → chunk-E35NZVPX.js} +2 -2
- package/dist/chunk-E5EPN3JI.js +656 -0
- package/dist/chunk-E5EPN3JI.js.map +1 -0
- package/dist/{chunk-IC5PFQCV.js → chunk-HBXDIRM4.js} +4 -4
- package/dist/{chunk-PG2MPTZD.js → chunk-HDO3PXCU.js} +6 -6
- package/dist/{chunk-RM6XOZMU.js → chunk-IKYZ5CJZ.js} +2 -2
- package/dist/{chunk-WOCS6MLE.js → chunk-IVSMEG5M.js} +50 -49
- package/dist/chunk-IVSMEG5M.js.map +1 -0
- package/dist/{chunk-NEZNZM7K.js → chunk-JQXUIKU5.js} +2 -2
- package/dist/{chunk-H5LKMR45.js → chunk-JTHILJFB.js} +2 -2
- package/dist/{chunk-MFSKRN2J.js → chunk-L6RUHCKB.js} +2 -2
- package/dist/{chunk-WB2BP2G5.js → chunk-LPJEV4R2.js} +4 -103
- package/dist/chunk-LPJEV4R2.js.map +1 -0
- package/dist/{chunk-SIHAOB4F.js → chunk-MIIJ2HQS.js} +7 -7
- package/dist/chunk-MMPR5QIV.js +9 -0
- package/dist/{chunk-34QBYOHC.js.map → chunk-MMPR5QIV.js.map} +1 -1
- package/dist/{chunk-UZROMRQM.js → chunk-MVU7JAKG.js} +4 -4
- package/dist/chunk-NEJVK5CF.js +26 -0
- package/dist/chunk-NEJVK5CF.js.map +1 -0
- package/dist/{chunk-2IE6UUUD.js → chunk-OOCMPS5L.js} +2 -2
- package/dist/{chunk-G5PN5NIS.js → chunk-OQAQMCHF.js} +15 -33
- package/dist/chunk-OQAQMCHF.js.map +1 -0
- package/dist/{chunk-EN24GJCO.js → chunk-OW46TR4G.js} +6 -6
- package/dist/{chunk-P2U6R35K.js → chunk-PUYXTZ32.js} +7 -7
- package/dist/{chunk-WVZ56EJC.js → chunk-QX4LFFNS.js} +9 -3
- package/dist/{chunk-WVZ56EJC.js.map → chunk-QX4LFFNS.js.map} +1 -1
- package/dist/{chunk-7HEB6SQS.js → chunk-QXUHOISF.js} +146 -3
- package/dist/chunk-QXUHOISF.js.map +1 -0
- package/dist/chunk-R6HAD575.js +797 -0
- package/dist/chunk-R6HAD575.js.map +1 -0
- package/dist/{chunk-6AULWNAN.js → chunk-R7B46WXN.js} +4 -4
- package/dist/{chunk-JYWCNLZN.js → chunk-RG63ACAK.js} +4 -4
- package/dist/{chunk-7NAXFBFI.js → chunk-RKEY4573.js} +2 -2
- package/dist/{chunk-MXZRFWC3.js → chunk-RLR66XLG.js} +4 -4
- package/dist/{chunk-V4RQ72HY.js → chunk-RMICESXA.js} +18 -18
- package/dist/{chunk-TOQZODGI.js → chunk-RQE5UOIW.js} +3 -3
- package/dist/{chunk-WF57CF7A.js → chunk-RT4QZRTC.js} +7 -4
- package/dist/chunk-RT4QZRTC.js.map +1 -0
- package/dist/{chunk-WUWED3LV.js → chunk-SH7NSDRW.js} +2 -2
- package/dist/{chunk-BLLLVWEB.js → chunk-SRIYY5HL.js} +3 -3
- package/dist/{chunk-DW4JPVXB.js → chunk-TMNIOM4Y.js} +2 -2
- package/dist/{chunk-KLK6O54M.js → chunk-UAAH334K.js} +10 -10
- package/dist/{chunk-ULQQ6SXT.js → chunk-WG3BMHKU.js} +4 -4
- package/dist/{chunk-E72ETFAB.js → chunk-WH3SPT3N.js} +3 -3
- package/dist/{chunk-73J2ZJA6.js → chunk-YAZ3GAZY.js} +5 -5
- package/dist/{chunk-QQNI3K3V.js → chunk-YJVZ5H3I.js} +3 -3
- package/dist/chunk-YXQIGBL6.js +106 -0
- package/dist/chunk-YXQIGBL6.js.map +1 -0
- package/dist/{chunk-7IZW6GLY.js → chunk-YZLNJQAV.js} +3 -3
- package/dist/{chunk-YZSSYD2G.js → chunk-ZFPV46FA.js} +15 -15
- package/dist/{chunk-N4EYQKSM.js → chunk-ZWD64IDK.js} +2 -2
- package/dist/{cleanup-6LIZ3BQF.js → cleanup-OO3DCPGC.js} +27 -26
- package/dist/{cleanup-6LIZ3BQF.js.map → cleanup-OO3DCPGC.js.map} +1 -1
- package/dist/cli-RYEDO3OH.js +18 -0
- package/dist/{command-hook-installer-SGEJTZ2Y.js → command-hook-installer-7JB3AC2S.js} +4 -4
- package/dist/{config-DULJPECI.js → config-SSWYCX4C.js} +13 -12
- package/dist/{config-DULJPECI.js.map → config-SSWYCX4C.js.map} +1 -1
- package/dist/{diff-2PPFXZD6.js → diff-76H3Y34M.js} +15 -14
- package/dist/{diff-2PPFXZD6.js.map → diff-76H3Y34M.js.map} +1 -1
- package/dist/{digest-5CRGAAK5.js → digest-WCZD6N7M.js} +12 -11
- package/dist/{digest-5CRGAAK5.js.map → digest-WCZD6N7M.js.map} +1 -1
- package/dist/{fork-FYEV4TU2.js → fork-WTNAUILU.js} +27 -26
- package/dist/{fork-FYEV4TU2.js.map → fork-WTNAUILU.js.map} +1 -1
- package/dist/{hook-U37AFPKY.js → hook-GQQZQ6DK.js} +18 -14
- package/dist/hook-GQQZQ6DK.js.map +1 -0
- package/dist/{hydrate-MAFHTY2W.js → hydrate-Q4FWUQRC.js} +9 -8
- package/dist/{hydrate-MAFHTY2W.js.map → hydrate-Q4FWUQRC.js.map} +1 -1
- package/dist/{init-276XRZS2.js → init-AT3BQLXM.js} +15 -14
- package/dist/{init-276XRZS2.js.map → init-AT3BQLXM.js.map} +1 -1
- package/dist/{install-skills-2ZAHI73P.js → install-skills-Z76FLXOU.js} +4 -4
- package/dist/install-skills-bin.js +3 -3
- package/dist/{list-KEF73NLQ.js → list-YTK2GLND.js} +5 -5
- package/dist/{move-QHCDO2R5.js → move-CE5NIZKL.js} +21 -20
- package/dist/{move-QHCDO2R5.js.map → move-CE5NIZKL.js.map} +1 -1
- package/dist/{note-TNC633NG.js → note-2JHWK6CV.js} +13 -12
- package/dist/{note-TNC633NG.js.map → note-2JHWK6CV.js.map} +1 -1
- package/dist/{overlaps-SEK7H2YB.js → overlaps-GXSEH2LG.js} +12 -11
- package/dist/{overlaps-SEK7H2YB.js.map → overlaps-GXSEH2LG.js.map} +1 -1
- package/dist/{pin-E53PGMGD.js → pin-UOW5VW42.js} +13 -12
- package/dist/{pin-E53PGMGD.js.map → pin-UOW5VW42.js.map} +1 -1
- package/dist/{pr-JMMUGCKS.js → pr-74X5MOPX.js} +14 -13
- package/dist/{pr-JMMUGCKS.js.map → pr-74X5MOPX.js.map} +1 -1
- package/dist/{prune-MR37KLIW.js → prune-L3VXZUIE.js} +26 -25
- package/dist/{prune-MR37KLIW.js.map → prune-L3VXZUIE.js.map} +1 -1
- package/dist/{pty-host-36Y4XSPP.js → pty-host-5Z3GYXTW.js} +12 -11
- package/dist/{pty-host-36Y4XSPP.js.map → pty-host-5Z3GYXTW.js.map} +1 -1
- package/dist/{read-ESOOJSBO.js → read-G7CVQRH6.js} +11 -10
- package/dist/{read-ESOOJSBO.js.map → read-G7CVQRH6.js.map} +1 -1
- package/dist/{recent-3WYFF36X.js → recent-2LM44HN2.js} +9 -8
- package/dist/{recent-3WYFF36X.js.map → recent-2LM44HN2.js.map} +1 -1
- package/dist/{remove-5IZVMK4V.js → remove-NVQ2JNMA.js} +26 -25
- package/dist/{remove-5IZVMK4V.js.map → remove-NVQ2JNMA.js.map} +1 -1
- package/dist/{report-KM4OZCZB.js → report-335HKCCY.js} +4 -4
- package/dist/{resume-NDE6NKKT.js → resume-VA34T7ZR.js} +9 -8
- package/dist/{resume-NDE6NKKT.js.map → resume-VA34T7ZR.js.map} +1 -1
- package/dist/{run-UW4BJCSC.js → run-E2WZPHHK.js} +8 -7
- package/dist/{run-UW4BJCSC.js.map → run-E2WZPHHK.js.map} +1 -1
- package/dist/{screen-5BLTXIKS.js → screen-XSBZHJNW.js} +13 -12
- package/dist/{screen-5BLTXIKS.js.map → screen-XSBZHJNW.js.map} +1 -1
- package/dist/{search-MK6R5VR6.js → search-FJUZPI3P.js} +8 -7
- package/dist/{search-MK6R5VR6.js.map → search-FJUZPI3P.js.map} +1 -1
- package/dist/{section-B4BWRY7K.js → section-BWZW3E2I.js} +13 -12
- package/dist/{section-B4BWRY7K.js.map → section-BWZW3E2I.js.map} +1 -1
- package/dist/{send-OT3OXHHW.js → send-4E7CD6PL.js} +15 -14
- package/dist/{send-OT3OXHHW.js.map → send-4E7CD6PL.js.map} +1 -1
- package/dist/{sessions-LHMTS6KT.js → sessions-4LFKWTBZ.js} +21 -20
- package/dist/{sessions-LHMTS6KT.js.map → sessions-4LFKWTBZ.js.map} +1 -1
- package/dist/{snooze-A2BVEYWD.js → snooze-SSSA656T.js} +12 -11
- package/dist/{snooze-A2BVEYWD.js.map → snooze-SSSA656T.js.map} +1 -1
- package/dist/{start-LEYVJWZG.js → start-5LODG4WG.js} +13 -12
- package/dist/{start-LEYVJWZG.js.map → start-5LODG4WG.js.map} +1 -1
- package/dist/{state-FGYNNSDP.js → state-S776FFV5.js} +9 -7
- package/dist/state-S776FFV5.js.map +1 -0
- package/dist/{status-AO653RKW.js → status-U5HKQ7MY.js} +9 -8
- package/dist/{status-AO653RKW.js.map → status-U5HKQ7MY.js.map} +1 -1
- package/dist/{stop-QYIRUR5Y.js → stop-OFQFHRXD.js} +13 -12
- package/dist/{stop-QYIRUR5Y.js.map → stop-OFQFHRXD.js.map} +1 -1
- package/dist/{sync-SAZVBQIH.js → sync-FDXM5EFD.js} +26 -25
- package/dist/{sync-SAZVBQIH.js.map → sync-FDXM5EFD.js.map} +1 -1
- package/dist/{time-4V56YERF.js → time-IIAXBSE7.js} +18 -14
- package/dist/{time-4V56YERF.js.map → time-IIAXBSE7.js.map} +1 -1
- package/dist/time-actions-K5VITQK5.js +15 -0
- package/dist/time-actions-K5VITQK5.js.map +1 -0
- package/dist/timesheet-SS6AA5BC.js +147 -0
- package/dist/timesheet-SS6AA5BC.js.map +1 -0
- package/dist/{todo-Y2BZ65MS.js → todo-2GKRUO4D.js} +6 -6
- package/dist/{tree-WFOG72Z3.js → tree-7S4DUZRZ.js} +25 -24
- package/dist/{tree-WFOG72Z3.js.map → tree-7S4DUZRZ.js.map} +1 -1
- package/dist/{update-NU5EMISM.js → update-7ZE4CG7T.js} +14 -13
- package/dist/{update-NU5EMISM.js.map → update-7ZE4CG7T.js.map} +1 -1
- package/dist/{wait-FW7RARBV.js → wait-TGQLNTE7.js} +13 -12
- package/dist/{wait-FW7RARBV.js.map → wait-TGQLNTE7.js.map} +1 -1
- package/dist/wd-bin.js +7 -7
- package/dist/web/assets/{PtyView-DQw8g-PN.js → PtyView-VxE2hVXZ.js} +2 -2
- package/dist/web/assets/{PtyView-DQw8g-PN.js.map → PtyView-VxE2hVXZ.js.map} +1 -1
- package/dist/web/assets/index-DC9qRg0H.css +1 -0
- package/dist/web/assets/index-Dt2LS35B.js +118 -0
- package/dist/web/assets/index-Dt2LS35B.js.map +1 -0
- package/dist/web/index.html +2 -2
- package/dist/{web-DTVGZZDZ.js → web-W6BZVICE.js} +535 -195
- package/dist/web-W6BZVICE.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/chunk-34QBYOHC.js +0 -9
- package/dist/chunk-5RRKVAIZ.js.map +0 -1
- package/dist/chunk-7HEB6SQS.js.map +0 -1
- package/dist/chunk-BLCAZAU5.js.map +0 -1
- package/dist/chunk-G5PN5NIS.js.map +0 -1
- package/dist/chunk-WB2BP2G5.js.map +0 -1
- package/dist/chunk-WF57CF7A.js.map +0 -1
- package/dist/chunk-WOCS6MLE.js.map +0 -1
- package/dist/cli-R3FITDNB.js +0 -18
- package/dist/hook-U37AFPKY.js.map +0 -1
- package/dist/state-FGYNNSDP.js.map +0 -1
- package/dist/web/assets/index-CO_OtClq.js +0 -118
- package/dist/web/assets/index-CO_OtClq.js.map +0 -1
- package/dist/web/assets/index-D-_oxT3O.css +0 -1
- package/dist/web-DTVGZZDZ.js.map +0 -1
- /package/dist/{chunk-WTR5BUGS.js.map → chunk-26IZBYVL.js.map} +0 -0
- /package/dist/{chunk-NS3HSXF7.js.map → chunk-3B3UMUE6.js.map} +0 -0
- /package/dist/{chunk-UNLBHYA5.js.map → chunk-427RB7E4.js.map} +0 -0
- /package/dist/{chunk-I5HHTEAA.js.map → chunk-4PP27RI7.js.map} +0 -0
- /package/dist/{chunk-LNMIG35F.js.map → chunk-5PAPD6VT.js.map} +0 -0
- /package/dist/{chunk-HLXEMPEI.js.map → chunk-6O6765M7.js.map} +0 -0
- /package/dist/{chunk-JJRPLNLN.js.map → chunk-7HGABVGR.js.map} +0 -0
- /package/dist/{chunk-G6IJ76DW.js.map → chunk-ACXPSQJR.js.map} +0 -0
- /package/dist/{chunk-E74YIDHX.js.map → chunk-AFV5S6UV.js.map} +0 -0
- /package/dist/{chunk-NIRVJMJL.js.map → chunk-AVRDRZ4D.js.map} +0 -0
- /package/dist/{chunk-4V7C3O6V.js.map → chunk-BZA7NKWU.js.map} +0 -0
- /package/dist/{chunk-F3SPCHLH.js.map → chunk-D4FUDMMX.js.map} +0 -0
- /package/dist/{chunk-5XMXZIJS.js.map → chunk-E35NZVPX.js.map} +0 -0
- /package/dist/{chunk-IC5PFQCV.js.map → chunk-HBXDIRM4.js.map} +0 -0
- /package/dist/{chunk-PG2MPTZD.js.map → chunk-HDO3PXCU.js.map} +0 -0
- /package/dist/{chunk-RM6XOZMU.js.map → chunk-IKYZ5CJZ.js.map} +0 -0
- /package/dist/{chunk-NEZNZM7K.js.map → chunk-JQXUIKU5.js.map} +0 -0
- /package/dist/{chunk-H5LKMR45.js.map → chunk-JTHILJFB.js.map} +0 -0
- /package/dist/{chunk-MFSKRN2J.js.map → chunk-L6RUHCKB.js.map} +0 -0
- /package/dist/{chunk-SIHAOB4F.js.map → chunk-MIIJ2HQS.js.map} +0 -0
- /package/dist/{chunk-UZROMRQM.js.map → chunk-MVU7JAKG.js.map} +0 -0
- /package/dist/{chunk-2IE6UUUD.js.map → chunk-OOCMPS5L.js.map} +0 -0
- /package/dist/{chunk-EN24GJCO.js.map → chunk-OW46TR4G.js.map} +0 -0
- /package/dist/{chunk-P2U6R35K.js.map → chunk-PUYXTZ32.js.map} +0 -0
- /package/dist/{chunk-6AULWNAN.js.map → chunk-R7B46WXN.js.map} +0 -0
- /package/dist/{chunk-JYWCNLZN.js.map → chunk-RG63ACAK.js.map} +0 -0
- /package/dist/{chunk-7NAXFBFI.js.map → chunk-RKEY4573.js.map} +0 -0
- /package/dist/{chunk-MXZRFWC3.js.map → chunk-RLR66XLG.js.map} +0 -0
- /package/dist/{chunk-V4RQ72HY.js.map → chunk-RMICESXA.js.map} +0 -0
- /package/dist/{chunk-TOQZODGI.js.map → chunk-RQE5UOIW.js.map} +0 -0
- /package/dist/{chunk-WUWED3LV.js.map → chunk-SH7NSDRW.js.map} +0 -0
- /package/dist/{chunk-BLLLVWEB.js.map → chunk-SRIYY5HL.js.map} +0 -0
- /package/dist/{chunk-DW4JPVXB.js.map → chunk-TMNIOM4Y.js.map} +0 -0
- /package/dist/{chunk-KLK6O54M.js.map → chunk-UAAH334K.js.map} +0 -0
- /package/dist/{chunk-ULQQ6SXT.js.map → chunk-WG3BMHKU.js.map} +0 -0
- /package/dist/{chunk-E72ETFAB.js.map → chunk-WH3SPT3N.js.map} +0 -0
- /package/dist/{chunk-73J2ZJA6.js.map → chunk-YAZ3GAZY.js.map} +0 -0
- /package/dist/{chunk-QQNI3K3V.js.map → chunk-YJVZ5H3I.js.map} +0 -0
- /package/dist/{chunk-7IZW6GLY.js.map → chunk-YZLNJQAV.js.map} +0 -0
- /package/dist/{chunk-YZSSYD2G.js.map → chunk-ZFPV46FA.js.map} +0 -0
- /package/dist/{chunk-N4EYQKSM.js.map → chunk-ZWD64IDK.js.map} +0 -0
- /package/dist/{cli-R3FITDNB.js.map → cli-RYEDO3OH.js.map} +0 -0
- /package/dist/{command-hook-installer-SGEJTZ2Y.js.map → command-hook-installer-7JB3AC2S.js.map} +0 -0
- /package/dist/{install-skills-2ZAHI73P.js.map → install-skills-Z76FLXOU.js.map} +0 -0
- /package/dist/{list-KEF73NLQ.js.map → list-YTK2GLND.js.map} +0 -0
- /package/dist/{report-KM4OZCZB.js.map → report-335HKCCY.js.map} +0 -0
- /package/dist/{todo-Y2BZ65MS.js.map → todo-2GKRUO4D.js.map} +0 -0
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
import {
|
|
3
3
|
openBaseCheckout,
|
|
4
4
|
setupWorktree
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZFPV46FA.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveProjectTarget
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JTHILJFB.js";
|
|
9
9
|
import {
|
|
10
10
|
defaultRunner
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4KZBZA5D.js";
|
|
12
12
|
import {
|
|
13
13
|
findSession,
|
|
14
14
|
loadHistory
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-OQAQMCHF.js";
|
|
16
16
|
import {
|
|
17
17
|
spawn_default
|
|
18
18
|
} from "./chunk-RCYI7SRA.js";
|
|
19
19
|
import {
|
|
20
20
|
collectingReporter,
|
|
21
21
|
withReporter
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-TMNIOM4Y.js";
|
|
23
23
|
|
|
24
24
|
// src/core/worktree/setup-child.ts
|
|
25
25
|
import path from "path";
|
|
@@ -159,4 +159,4 @@ export {
|
|
|
159
159
|
createInChild,
|
|
160
160
|
createInProcess
|
|
161
161
|
};
|
|
162
|
-
//# sourceMappingURL=chunk-
|
|
162
|
+
//# sourceMappingURL=chunk-OW46TR4G.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
sessionStatusView
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-427RB7E4.js";
|
|
5
5
|
import {
|
|
6
6
|
buildDigest,
|
|
7
7
|
loadHistory,
|
|
@@ -11,15 +11,15 @@ import {
|
|
|
11
11
|
readStatus,
|
|
12
12
|
scopeHashForPaths,
|
|
13
13
|
workSteps
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import {
|
|
16
|
-
sessionIdFor
|
|
17
|
-
} from "./chunk-WF57CF7A.js";
|
|
14
|
+
} from "./chunk-OQAQMCHF.js";
|
|
18
15
|
import {
|
|
19
16
|
agentOf,
|
|
20
17
|
lineTimeOf,
|
|
21
18
|
readJsonlSince
|
|
22
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RQE5UOIW.js";
|
|
20
|
+
import {
|
|
21
|
+
sessionIdFor
|
|
22
|
+
} from "./chunk-RT4QZRTC.js";
|
|
23
23
|
|
|
24
24
|
// src/core/conversations/digest-source.ts
|
|
25
25
|
function digestWindow(sinceMs, now = Date.now()) {
|
|
@@ -99,4 +99,4 @@ function createDigestSource(deps = {}) {
|
|
|
99
99
|
export {
|
|
100
100
|
createDigestSource
|
|
101
101
|
};
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
102
|
+
//# sourceMappingURL=chunk-PUYXTZ32.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
isPidAlive
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RQE5UOIW.js";
|
|
5
5
|
|
|
6
6
|
// src/core/platform/web-discovery.ts
|
|
7
7
|
import fs from "fs";
|
|
@@ -132,7 +132,13 @@ async function callWorkWeb(method, route, body, timeoutMs = 15e3) {
|
|
|
132
132
|
if (res.ok && json) return { ok: true, body: json };
|
|
133
133
|
return { ok: false, status: res.status, error: typeof json?.error === "string" ? json.error : `work web answered ${res.status}` };
|
|
134
134
|
} catch (err) {
|
|
135
|
-
|
|
135
|
+
const code = err.cause?.code;
|
|
136
|
+
if (code === "ECONNREFUSED") return { ok: false, status: 0, error: "work web is not running (its address answers nothing)" };
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
status: -1,
|
|
140
|
+
error: `work web did not answer in time (${err.message}): it may still be at it \u2014 look again in a moment`
|
|
141
|
+
};
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
@@ -152,4 +158,4 @@ export {
|
|
|
152
158
|
askWorkWeb,
|
|
153
159
|
callWorkWeb
|
|
154
160
|
};
|
|
155
|
-
//# sourceMappingURL=chunk-
|
|
161
|
+
//# sourceMappingURL=chunk-QX4LFFNS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/platform/web-discovery.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { isPidAlive } from './process.js';\n\n/**\n * How everything finds the running `work web` (the singleton): the\n * `web.url` + `web.pid` files it writes in ~/.work. One module instead of\n * copies in the web command, `wd`, and the Claude hook bridge.\n *\n * The files outlive the process (crash, kill, reboot) and Windows reuses\n * PIDs, so neither file is proof of anything: `probeWeb` asks the server\n * itself, and it answers /api/context with its own pid.\n */\n\n// os.homedir() per call (not getConfigDir, which creates the dir): tests\n// mock homedir, and readers must not create ~/.work as a side effect.\n// One pair of files per server: `web` (the real one) or `web-dev` (the dev server).\ntype Stem = 'web' | 'web-dev';\nconst fileOf = (stem: Stem, ext: 'url' | 'pid') => path.join(os.homedir(), '.work', `${stem}.${ext}`);\n\nfunction readUrl(stem: Stem): string | null {\n try {\n return fs.readFileSync(fileOf(stem, 'url'), 'utf-8').trim() || null;\n } catch {\n return null;\n }\n}\n\nfunction readPid(stem: Stem): number | null {\n try {\n const n = Number(fs.readFileSync(fileOf(stem, 'pid'), 'utf-8').trim());\n return Number.isFinite(n) && n > 0 ? n : null;\n } catch {\n return null;\n }\n}\n\nfunction writeFiles(stem: Stem, url: string, pid: number): void {\n fs.mkdirSync(path.dirname(fileOf(stem, 'url')), { recursive: true });\n // The pid first: a server leaving at the same moment clears only files that name it,\n // so it never takes the url of the one that just started.\n fs.writeFileSync(fileOf(stem, 'pid'), String(pid));\n fs.writeFileSync(fileOf(stem, 'url'), url);\n}\n\n/**\n * Remove a server's files; with `ownerPid`, only while they still name that\n * server. `strict`: not when the pid can't be read either (the dev server's:\n * another may be writing its own).\n */\nfunction clearFiles(stem: Stem, ownerPid?: number, strict = false): void {\n if (ownerPid !== undefined) {\n const current = readPid(stem);\n if (current === null ? strict : current !== ownerPid) return;\n }\n for (const ext of ['pid', 'url'] as const) {\n try {\n fs.unlinkSync(fileOf(stem, ext));\n } catch {\n /* already gone */\n }\n }\n}\n\nexport function webUrlPath(): string {\n return fileOf('web', 'url');\n}\nexport function webPidPath(): string {\n return fileOf('web', 'pid');\n}\nexport const readWebUrl = (): string | null => readUrl('web');\nexport const readWebPid = (): number | null => readPid('web');\nexport const writeWebDiscovery = (url: string, pid: number): void => writeFiles('web', url, pid);\n\n/**\n * Remove the discovery files. With `ownerPid`, only if they still name that\n * server: a new one (the desktop app restarts it at once) may have written\n * its own in the meantime, and deleting those hides it from every client —\n * `wd`, the CLI, the Claude hooks.\n */\nexport const clearWebDiscovery = (ownerPid?: number): void => clearFiles('web', ownerPid);\n\n/**\n * The dev server's (`work web --dev`): a checkout's build next to the\n * installed work, found by the dev app through these files only — nothing\n * that looks for work web (`wd`, the CLI, the Claude hooks, the installed\n * app) reads them, so it never takes the dev server for the real one.\n */\nexport const devWebUrlPath = (): string => fileOf('web-dev', 'url');\n\nexport const writeDevWebDiscovery = (url: string, pid: number): void => writeFiles('web-dev', url, pid);\n/** Remove them, only while they still name `ownerPid`. */\nexport const clearDevWebDiscovery = (ownerPid: number): void => clearFiles('web-dev', ownerPid, true);\n\n/** Where the dev server stands, for `work web --dev` (start, reuse, stop). */\nexport type DevWebState =\n | { kind: 'running'; url: string; pid: number }\n /** Its process runs but it didn't answer in time: busy, never proof it's gone (as findHost). */\n | { kind: 'busy'; url: string; pid: number }\n | { kind: 'none' };\n\n/**\n * The recorded dev server, only when it answers /api/context with the\n * recorded pid and says it's the dev server: files that outlived a crash\n * can name a reused pid, and their port another work web — the real one,\n * which `--dev --stop` (run by every `npm run app:dev`) would then shut\n * down. Files that name no live dev server are removed.\n */\nexport async function findDevWeb(probe: typeof probeWeb = probeWeb, alive: (pid: number) => boolean = isPidAlive): Promise<DevWebState> {\n const url = readUrl('web-dev');\n const pid = readPid('web-dev');\n if (!url || pid === null) return { kind: 'none' };\n if (!alive(pid)) {\n clearFiles('web-dev', pid, true);\n return { kind: 'none' };\n }\n const p = await probe(url, 3000);\n if (p.kind === 'timeout') return { kind: 'busy', url, pid };\n if (p.kind === 'ours' && p.pid === pid && p.dev) return { kind: 'running', url, pid };\n clearFiles('web-dev', pid, true);\n return { kind: 'none' };\n}\n\nexport type WebProbe =\n | {\n kind: 'ours';\n pid: number | null;\n lean: boolean;\n /** null: a build before stamps. */ build: string | null;\n /** The dev server (`work web --dev`). */ dev: boolean;\n }\n /** Nothing listens there (or something that isn't work web answered). */\n | { kind: 'gone' }\n /** No answer in time — possibly just busy; never proof it's gone. */\n | { kind: 'timeout' };\n\nexport async function probeWeb(url: string, timeoutMs = 1500): Promise<WebProbe> {\n try {\n const res = await fetch(`${url}api/context`, { signal: AbortSignal.timeout(timeoutMs) });\n if (!res.ok) return { kind: 'gone' };\n const body = (await res.json().catch(() => ({}))) as { mode?: unknown; pid?: unknown; lean?: unknown; build?: unknown; dev?: unknown };\n if (typeof body.mode !== 'string') return { kind: 'gone' };\n return {\n kind: 'ours',\n pid: typeof body.pid === 'number' ? body.pid : null,\n lean: body.lean === true,\n build: typeof body.build === 'string' ? body.build : null,\n dev: body.dev === true,\n };\n } catch (err) {\n const name = (err as { name?: string }).name;\n return name === 'TimeoutError' || name === 'AbortError' ? { kind: 'timeout' } : { kind: 'gone' };\n }\n}\n\n/**\n * What to do with the recorded work web before starting one:\n * - 'reuse' it answered as work web — or it is BUSY (timed out, possibly\n * more than once): a slow server is still the running one, and\n * replacing it orphans it (the new one sees the live pid and\n * exits; the old one keeps the port and hooks but can no longer\n * be found once web.url is gone).\n * - 'start' nothing is there any more (the url file is stale).\n * Busy servers get `patienceMs` of re-probing before being reused anyway.\n */\nexport async function existingWebDecision(\n url: string,\n opts: { patienceMs?: number; probe?: typeof probeWeb } = {},\n): Promise<'reuse' | 'start'> {\n const probe = opts.probe ?? probeWeb;\n const until = Date.now() + (opts.patienceMs ?? 6000);\n for (let first = true; ; first = false) {\n const r = await probe(url, first ? 1500 : 3000);\n if (r.kind === 'ours') return 'reuse';\n if (r.kind === 'gone') return 'start';\n if (Date.now() >= until) return 'reuse';\n }\n}\n\n/**\n * A running work web checks, now and then, that it is still THE one:\n * - 'keep' web.pid names us.\n * - 'retire' web.pid names another work web that answers as itself: two\n * were started at once (a restart racing the desktop app's\n * watchdog, which starts one when none answers) and the other\n * won the discovery files. Ours can no longer be found, but it\n * kept its PR watch and gh calls going — twice the GitHub API\n * use — and the desktop app stayed on it, an old build.\n * - 'reclaim' nothing recorded (or a dead pid): write ours back, so `wd`,\n * the app and `work web --stop` find the one that runs.\n * A busy or silent other is never reason to retire (see existingWebDecision).\n */\nexport async function discoveryCheck(\n self: { pid: number; url: string },\n deps: { readPid?: () => number | null; readUrl?: () => string | null; alive?: (pid: number) => boolean; probe?: typeof probeWeb } = {},\n): Promise<'keep' | 'retire' | 'reclaim'> {\n const pid = (deps.readPid ?? readWebPid)();\n if (pid === self.pid) return 'keep';\n const alive = deps.alive ?? isPidAlive;\n if (pid === null || !alive(pid)) return 'reclaim';\n const url = (deps.readUrl ?? readWebUrl)();\n if (!url || url === self.url) return 'keep';\n const r = await (deps.probe ?? probeWeb)(url, 3000);\n return r.kind === 'ours' && r.pid === pid ? 'retire' : 'keep';\n}\n\n/**\n * Liveness only: is a server serving the recorded URL (any 2xx at\n * api/context)? Enough for \"reuse it / autostart one\". Identity — is it\n * work web, with the recorded pid — is probeWeb's job, and only matters\n * before killing something.\n */\nexport async function webServerResponds(url: string, timeoutMs = 1500): Promise<boolean> {\n try {\n const res = await fetch(`${url}api/context`, { signal: AbortSignal.timeout(timeoutMs) });\n return res.ok;\n } catch {\n return false;\n }\n}\n\n/**\n * GET a JSON route from the running work web, for what only it holds (the\n * PR watch's cache, which PTYs are live). Null when none runs or it doesn't\n * answer in time: callers go without that part rather than fail.\n */\nexport async function askWorkWeb<T>(route: string, timeoutMs = 3000): Promise<T | null> {\n const url = readWebUrl();\n if (!url) return null;\n try {\n const res = await fetch(`${url}${route.replace(/^\\//, '')}`, { signal: AbortSignal.timeout(timeoutMs) });\n return res.ok ? ((await res.json()) as T) : null;\n } catch {\n return null;\n }\n}\n\nexport type WorkWebAnswer<T> =\n { ok: true; body: T } | { ok: false; status: number; error: string } | { ok: false; status: 0; error: string };\n\n/**\n * Call a route of the running work web (what only it can do: type into a\n * terminal it owns, start a Claude in the PTY host). Unlike askWorkWeb, a\n * refusal comes back with its reason, and \"no work web\" is its own answer\n * (status 0), so the caller can say how to start one.\n */\nexport async function callWorkWeb<T>(method: 'GET' | 'POST', route: string, body?: unknown, timeoutMs = 15_000): Promise<WorkWebAnswer<T>> {\n const url = readWebUrl();\n if (!url) return { ok: false, status: 0, error: 'work web is not running (start it with `work web`, or open the desktop app)' };\n try {\n const res = await fetch(`${url}${route.replace(/^\\//, '')}`, {\n method,\n signal: AbortSignal.timeout(timeoutMs),\n ...(body !== undefined ? { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : {}),\n });\n const json = (await res.json().catch(() => null)) as (T & { error?: unknown }) | null;\n if (res.ok && json) return { ok: true, body: json };\n return { ok: false, status: res.status, error: typeof json?.error === 'string' ? json.error : `work web answered ${res.status}` };\n } catch (err) {\n return { ok: false, status: 0, error: `work web did not answer (${(err as Error).message})` };\n }\n}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path';\nimport { isPidAlive } from './process.js';\n\n/**\n * How everything finds the running `work web` (the singleton): the\n * `web.url` + `web.pid` files it writes in ~/.work. One module instead of\n * copies in the web command, `wd`, and the Claude hook bridge.\n *\n * The files outlive the process (crash, kill, reboot) and Windows reuses\n * PIDs, so neither file is proof of anything: `probeWeb` asks the server\n * itself, and it answers /api/context with its own pid.\n */\n\n// os.homedir() per call (not getConfigDir, which creates the dir): tests\n// mock homedir, and readers must not create ~/.work as a side effect.\n// One pair of files per server: `web` (the real one) or `web-dev` (the dev server).\ntype Stem = 'web' | 'web-dev';\nconst fileOf = (stem: Stem, ext: 'url' | 'pid') => path.join(os.homedir(), '.work', `${stem}.${ext}`);\n\nfunction readUrl(stem: Stem): string | null {\n try {\n return fs.readFileSync(fileOf(stem, 'url'), 'utf-8').trim() || null;\n } catch {\n return null;\n }\n}\n\nfunction readPid(stem: Stem): number | null {\n try {\n const n = Number(fs.readFileSync(fileOf(stem, 'pid'), 'utf-8').trim());\n return Number.isFinite(n) && n > 0 ? n : null;\n } catch {\n return null;\n }\n}\n\nfunction writeFiles(stem: Stem, url: string, pid: number): void {\n fs.mkdirSync(path.dirname(fileOf(stem, 'url')), { recursive: true });\n // The pid first: a server leaving at the same moment clears only files that name it,\n // so it never takes the url of the one that just started.\n fs.writeFileSync(fileOf(stem, 'pid'), String(pid));\n fs.writeFileSync(fileOf(stem, 'url'), url);\n}\n\n/**\n * Remove a server's files; with `ownerPid`, only while they still name that\n * server. `strict`: not when the pid can't be read either (the dev server's:\n * another may be writing its own).\n */\nfunction clearFiles(stem: Stem, ownerPid?: number, strict = false): void {\n if (ownerPid !== undefined) {\n const current = readPid(stem);\n if (current === null ? strict : current !== ownerPid) return;\n }\n for (const ext of ['pid', 'url'] as const) {\n try {\n fs.unlinkSync(fileOf(stem, ext));\n } catch {\n /* already gone */\n }\n }\n}\n\nexport function webUrlPath(): string {\n return fileOf('web', 'url');\n}\nexport function webPidPath(): string {\n return fileOf('web', 'pid');\n}\nexport const readWebUrl = (): string | null => readUrl('web');\nexport const readWebPid = (): number | null => readPid('web');\nexport const writeWebDiscovery = (url: string, pid: number): void => writeFiles('web', url, pid);\n\n/**\n * Remove the discovery files. With `ownerPid`, only if they still name that\n * server: a new one (the desktop app restarts it at once) may have written\n * its own in the meantime, and deleting those hides it from every client —\n * `wd`, the CLI, the Claude hooks.\n */\nexport const clearWebDiscovery = (ownerPid?: number): void => clearFiles('web', ownerPid);\n\n/**\n * The dev server's (`work web --dev`): a checkout's build next to the\n * installed work, found by the dev app through these files only — nothing\n * that looks for work web (`wd`, the CLI, the Claude hooks, the installed\n * app) reads them, so it never takes the dev server for the real one.\n */\nexport const devWebUrlPath = (): string => fileOf('web-dev', 'url');\n\nexport const writeDevWebDiscovery = (url: string, pid: number): void => writeFiles('web-dev', url, pid);\n/** Remove them, only while they still name `ownerPid`. */\nexport const clearDevWebDiscovery = (ownerPid: number): void => clearFiles('web-dev', ownerPid, true);\n\n/** Where the dev server stands, for `work web --dev` (start, reuse, stop). */\nexport type DevWebState =\n | { kind: 'running'; url: string; pid: number }\n /** Its process runs but it didn't answer in time: busy, never proof it's gone (as findHost). */\n | { kind: 'busy'; url: string; pid: number }\n | { kind: 'none' };\n\n/**\n * The recorded dev server, only when it answers /api/context with the\n * recorded pid and says it's the dev server: files that outlived a crash\n * can name a reused pid, and their port another work web — the real one,\n * which `--dev --stop` (run by every `npm run app:dev`) would then shut\n * down. Files that name no live dev server are removed.\n */\nexport async function findDevWeb(probe: typeof probeWeb = probeWeb, alive: (pid: number) => boolean = isPidAlive): Promise<DevWebState> {\n const url = readUrl('web-dev');\n const pid = readPid('web-dev');\n if (!url || pid === null) return { kind: 'none' };\n if (!alive(pid)) {\n clearFiles('web-dev', pid, true);\n return { kind: 'none' };\n }\n const p = await probe(url, 3000);\n if (p.kind === 'timeout') return { kind: 'busy', url, pid };\n if (p.kind === 'ours' && p.pid === pid && p.dev) return { kind: 'running', url, pid };\n clearFiles('web-dev', pid, true);\n return { kind: 'none' };\n}\n\nexport type WebProbe =\n | {\n kind: 'ours';\n pid: number | null;\n lean: boolean;\n /** null: a build before stamps. */ build: string | null;\n /** The dev server (`work web --dev`). */ dev: boolean;\n }\n /** Nothing listens there (or something that isn't work web answered). */\n | { kind: 'gone' }\n /** No answer in time — possibly just busy; never proof it's gone. */\n | { kind: 'timeout' };\n\nexport async function probeWeb(url: string, timeoutMs = 1500): Promise<WebProbe> {\n try {\n const res = await fetch(`${url}api/context`, { signal: AbortSignal.timeout(timeoutMs) });\n if (!res.ok) return { kind: 'gone' };\n const body = (await res.json().catch(() => ({}))) as { mode?: unknown; pid?: unknown; lean?: unknown; build?: unknown; dev?: unknown };\n if (typeof body.mode !== 'string') return { kind: 'gone' };\n return {\n kind: 'ours',\n pid: typeof body.pid === 'number' ? body.pid : null,\n lean: body.lean === true,\n build: typeof body.build === 'string' ? body.build : null,\n dev: body.dev === true,\n };\n } catch (err) {\n const name = (err as { name?: string }).name;\n return name === 'TimeoutError' || name === 'AbortError' ? { kind: 'timeout' } : { kind: 'gone' };\n }\n}\n\n/**\n * What to do with the recorded work web before starting one:\n * - 'reuse' it answered as work web — or it is BUSY (timed out, possibly\n * more than once): a slow server is still the running one, and\n * replacing it orphans it (the new one sees the live pid and\n * exits; the old one keeps the port and hooks but can no longer\n * be found once web.url is gone).\n * - 'start' nothing is there any more (the url file is stale).\n * Busy servers get `patienceMs` of re-probing before being reused anyway.\n */\nexport async function existingWebDecision(\n url: string,\n opts: { patienceMs?: number; probe?: typeof probeWeb } = {},\n): Promise<'reuse' | 'start'> {\n const probe = opts.probe ?? probeWeb;\n const until = Date.now() + (opts.patienceMs ?? 6000);\n for (let first = true; ; first = false) {\n const r = await probe(url, first ? 1500 : 3000);\n if (r.kind === 'ours') return 'reuse';\n if (r.kind === 'gone') return 'start';\n if (Date.now() >= until) return 'reuse';\n }\n}\n\n/**\n * A running work web checks, now and then, that it is still THE one:\n * - 'keep' web.pid names us.\n * - 'retire' web.pid names another work web that answers as itself: two\n * were started at once (a restart racing the desktop app's\n * watchdog, which starts one when none answers) and the other\n * won the discovery files. Ours can no longer be found, but it\n * kept its PR watch and gh calls going — twice the GitHub API\n * use — and the desktop app stayed on it, an old build.\n * - 'reclaim' nothing recorded (or a dead pid): write ours back, so `wd`,\n * the app and `work web --stop` find the one that runs.\n * A busy or silent other is never reason to retire (see existingWebDecision).\n */\nexport async function discoveryCheck(\n self: { pid: number; url: string },\n deps: { readPid?: () => number | null; readUrl?: () => string | null; alive?: (pid: number) => boolean; probe?: typeof probeWeb } = {},\n): Promise<'keep' | 'retire' | 'reclaim'> {\n const pid = (deps.readPid ?? readWebPid)();\n if (pid === self.pid) return 'keep';\n const alive = deps.alive ?? isPidAlive;\n if (pid === null || !alive(pid)) return 'reclaim';\n const url = (deps.readUrl ?? readWebUrl)();\n if (!url || url === self.url) return 'keep';\n const r = await (deps.probe ?? probeWeb)(url, 3000);\n return r.kind === 'ours' && r.pid === pid ? 'retire' : 'keep';\n}\n\n/**\n * Liveness only: is a server serving the recorded URL (any 2xx at\n * api/context)? Enough for \"reuse it / autostart one\". Identity — is it\n * work web, with the recorded pid — is probeWeb's job, and only matters\n * before killing something.\n */\nexport async function webServerResponds(url: string, timeoutMs = 1500): Promise<boolean> {\n try {\n const res = await fetch(`${url}api/context`, { signal: AbortSignal.timeout(timeoutMs) });\n return res.ok;\n } catch {\n return false;\n }\n}\n\n/**\n * GET a JSON route from the running work web, for what only it holds (the\n * PR watch's cache, which PTYs are live). Null when none runs or it doesn't\n * answer in time: callers go without that part rather than fail.\n */\nexport async function askWorkWeb<T>(route: string, timeoutMs = 3000): Promise<T | null> {\n const url = readWebUrl();\n if (!url) return null;\n try {\n const res = await fetch(`${url}${route.replace(/^\\//, '')}`, { signal: AbortSignal.timeout(timeoutMs) });\n return res.ok ? ((await res.json()) as T) : null;\n } catch {\n return null;\n }\n}\n\nexport type WorkWebAnswer<T> =\n { ok: true; body: T } | { ok: false; status: number; error: string } | { ok: false; status: 0; error: string };\n\n/**\n * Call a route of the running work web (what only it can do: type into a\n * terminal it owns, start a Claude in the PTY host). Unlike askWorkWeb, a\n * refusal comes back with its reason, and \"no work web\" is its own answer\n * (status 0: none recorded, or the connection refused), so the caller can say\n * how to start one — or do it itself. A work web that didn't answer in time\n * (or dropped the connection) is NOT \"none\" (status -1): it may still be doing\n * it, and doing it here too would do it twice (two posts to Tempo).\n */\nexport async function callWorkWeb<T>(\n method: 'GET' | 'POST' | 'PUT',\n route: string,\n body?: unknown,\n timeoutMs = 15_000,\n): Promise<WorkWebAnswer<T>> {\n const url = readWebUrl();\n if (!url) return { ok: false, status: 0, error: 'work web is not running (start it with `work web`, or open the desktop app)' };\n try {\n const res = await fetch(`${url}${route.replace(/^\\//, '')}`, {\n method,\n signal: AbortSignal.timeout(timeoutMs),\n ...(body !== undefined ? { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : {}),\n });\n const json = (await res.json().catch(() => null)) as (T & { error?: unknown }) | null;\n if (res.ok && json) return { ok: true, body: json };\n return { ok: false, status: res.status, error: typeof json?.error === 'string' ? json.error : `work web answered ${res.status}` };\n } catch (err) {\n const code = (err as { cause?: { code?: string } }).cause?.code;\n if (code === 'ECONNREFUSED') return { ok: false, status: 0, error: 'work web is not running (its address answers nothing)' };\n return {\n ok: false,\n status: -1,\n error: `work web did not answer in time (${(err as Error).message}): it may still be at it — look again in a moment`,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AAiBjB,IAAM,SAAS,CAAC,MAAY,QAAuB,KAAK,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,IAAI,GAAG,EAAE;AAEpG,SAAS,QAAQ,MAA2B;AAC1C,MAAI;AACF,WAAO,GAAG,aAAa,OAAO,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,KAAK;AAAA,EACjE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,QAAQ,MAA2B;AAC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MACe;AAC3B,QAAM,MAAM,WAAW;AACvB,MAAI,CAAC,IAAK,QAAO,EAAE,IAAI,OAAO,QAAQ,GAAG,OAAO,8EAA8E;AAC9H,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,GAAG,GAAG,GAAG,MAAM,QAAQ,OAAO,EAAE,CAAC,IAAI;AAAA,MAC3D;AAAA,MACA,QAAQ,YAAY,QAAQ,SAAS;AAAA,MACrC,GAAI,SAAS,SAAY,EAAE,SAAS,EAAE,gBAAgB,mBAAmB,GAAG,MAAM,KAAK,UAAU,IAAI,EAAE,IAAI,CAAC;AAAA,IAC9G,CAAC;AACD,UAAM,OAAQ,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI;AAC/C,QAAI,IAAI,MAAM,KAAM,QAAO,EAAE,IAAI,MAAM,MAAM,KAAK;AAClD,WAAO,EAAE,IAAI,OAAO,QAAQ,IAAI,QAAQ,OAAO,OAAO,MAAM,UAAU,WAAW,KAAK,QAAQ,qBAAqB,IAAI,MAAM,GAAG;AAAA,EAClI,SAAS,KAAK;AACZ,UAAM,OAAQ,IAAsC,OAAO;AAC3D,QAAI,SAAS,eAAgB,QAAO,EAAE,IAAI,OAAO,QAAQ,GAAG,OAAO,wDAAwD;AAC3H,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,OAAO,oCAAqC,IAAc,OAAO;AAAA,IACnE;AAAA,EACF;AACF;","names":[]}
|
|
@@ -27,11 +27,17 @@ function resolveLinkTarget(filePath) {
|
|
|
27
27
|
function atomicWriteFile(filePath, content, renameSync = fs.renameSync) {
|
|
28
28
|
const target = resolveLinkTarget(filePath);
|
|
29
29
|
const tmpPath = `${target}.tmp-${process.pid}`;
|
|
30
|
-
|
|
30
|
+
let mode;
|
|
31
31
|
try {
|
|
32
|
-
|
|
32
|
+
mode = fs.statSync(target).mode & 511;
|
|
33
33
|
} catch {
|
|
34
34
|
}
|
|
35
|
+
fs.writeFileSync(tmpPath, content, { encoding: "utf-8", ...mode !== void 0 ? { mode } : {} });
|
|
36
|
+
if (mode !== void 0)
|
|
37
|
+
try {
|
|
38
|
+
fs.chmodSync(tmpPath, mode);
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
35
41
|
for (let attempt = 0; ; attempt++) {
|
|
36
42
|
try {
|
|
37
43
|
renameSync(tmpPath, target);
|
|
@@ -140,6 +146,82 @@ function validatePrompts(raw) {
|
|
|
140
146
|
return out;
|
|
141
147
|
}
|
|
142
148
|
|
|
149
|
+
// src/core/time/allocate.ts
|
|
150
|
+
var DEFAULT_TIME_SETTINGS = {
|
|
151
|
+
dayHours: 7.5,
|
|
152
|
+
multiplier: 5,
|
|
153
|
+
capHours: 7,
|
|
154
|
+
stepHours: 0.25,
|
|
155
|
+
minHours: 0.5,
|
|
156
|
+
gapTicket: null,
|
|
157
|
+
timeOffTicket: null,
|
|
158
|
+
holidays: [],
|
|
159
|
+
vacation: [],
|
|
160
|
+
effort: false
|
|
161
|
+
};
|
|
162
|
+
function suggestDay(activity, s, opts = {}) {
|
|
163
|
+
const units = (h) => Math.round(h / s.stepHours);
|
|
164
|
+
const day = units(s.dayHours);
|
|
165
|
+
const hours = (u) => Math.round(u * s.stepHours * 100) / 100;
|
|
166
|
+
if (opts.dayOff)
|
|
167
|
+
return s.timeOffTicket ? { entries: [{ key: s.timeOffTicket, hours: s.dayHours }], unallocated: 0 } : { entries: [], unallocated: s.dayHours };
|
|
168
|
+
const minutes = /* @__PURE__ */ new Map();
|
|
169
|
+
for (const a of activity) {
|
|
170
|
+
if (!a.key || a.key === s.gapTicket) continue;
|
|
171
|
+
const m = minutes.get(a.key) ?? { claude: 0, direct: 0 };
|
|
172
|
+
m.claude += Math.max(0, a.minutes);
|
|
173
|
+
m.direct += Math.max(0, a.direct ?? 0);
|
|
174
|
+
minutes.set(a.key, m);
|
|
175
|
+
}
|
|
176
|
+
const min = s.effort ? 1 : Math.max(1, units(s.minHours));
|
|
177
|
+
const multiplier = s.effort ? 1 : s.multiplier;
|
|
178
|
+
const reserve = s.gapTicket ? Math.max(min, units((opts.reserveMinutes ?? 0) / 60)) : 0;
|
|
179
|
+
const room = Math.max(0, Math.min(units(s.capHours), day - reserve));
|
|
180
|
+
const raw = [...minutes].map(([key, m]) => {
|
|
181
|
+
const h = m.claude / 60 * multiplier + m.direct / 60;
|
|
182
|
+
return { key, raw: h > 0 ? h : s.effort ? 0 : s.minHours };
|
|
183
|
+
});
|
|
184
|
+
const total = raw.reduce((n, r) => n + r.raw, 0);
|
|
185
|
+
const scale = total > room * s.stepHours && total > 0 ? room * s.stepHours / total : 1;
|
|
186
|
+
let rows = raw.map((r) => {
|
|
187
|
+
const scaled = r.raw * scale;
|
|
188
|
+
const u = units(scaled);
|
|
189
|
+
return { key: r.key, raw: scaled, u: u >= min ? u : scaled >= s.stepHours ? min : 0 };
|
|
190
|
+
}).filter((r) => r.u > 0);
|
|
191
|
+
let used = rows.reduce((n, r) => n + r.u, 0);
|
|
192
|
+
while (used > room && rows.length) {
|
|
193
|
+
const big = rows.filter((r) => r.u > min).sort((a, b) => b.u - a.u || a.key.localeCompare(b.key))[0];
|
|
194
|
+
if (big) big.u--;
|
|
195
|
+
else rows = rows.sort((a, b) => a.raw - b.raw).slice(1);
|
|
196
|
+
used = rows.reduce((n, r) => n + r.u, 0);
|
|
197
|
+
}
|
|
198
|
+
const entries = rows.sort((a, b) => b.u - a.u || a.key.localeCompare(b.key)).map((r) => ({ key: r.key, hours: hours(r.u) }));
|
|
199
|
+
const left = day - used;
|
|
200
|
+
if (s.gapTicket && left > 0) return { entries: [...entries, { key: s.gapTicket, hours: hours(left) }], unallocated: 0 };
|
|
201
|
+
return { entries, unallocated: hours(Math.max(0, left)) };
|
|
202
|
+
}
|
|
203
|
+
function totalHours(entries) {
|
|
204
|
+
return Math.round(entries.reduce((n, e) => n + e.hours, 0) * 100) / 100;
|
|
205
|
+
}
|
|
206
|
+
function isWorkday(day, s) {
|
|
207
|
+
const d = /* @__PURE__ */ new Date(`${day}T12:00:00`);
|
|
208
|
+
const wd = d.getDay();
|
|
209
|
+
return wd !== 0 && wd !== 6 && !s.holidays.includes(day);
|
|
210
|
+
}
|
|
211
|
+
var ISSUE_KEY = /\b([A-Z][A-Z0-9]{1,9}-\d+)\b/g;
|
|
212
|
+
function isIssueKey(s) {
|
|
213
|
+
return new RegExp(`^${ISSUE_KEY.source}$`).test(s);
|
|
214
|
+
}
|
|
215
|
+
function issueKeys(text, projects) {
|
|
216
|
+
const out = [];
|
|
217
|
+
for (const m of text.matchAll(ISSUE_KEY)) {
|
|
218
|
+
const key = m[1];
|
|
219
|
+
if (projects && projects.size && !projects.has(key.split("-")[0])) continue;
|
|
220
|
+
if (!out.includes(key)) out.push(key);
|
|
221
|
+
}
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
|
|
143
225
|
// src/core/platform/config.ts
|
|
144
226
|
var MIN_PORT = 1024;
|
|
145
227
|
var MAX_PORT = 65535;
|
|
@@ -171,6 +253,60 @@ function validateDevCommands(raw) {
|
|
|
171
253
|
for (const [alias, cmd] of Object.entries(raw)) if (typeof cmd === "string" && cmd.trim()) out[alias] = cmd;
|
|
172
254
|
return out;
|
|
173
255
|
}
|
|
256
|
+
function validateTime(raw) {
|
|
257
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
258
|
+
const t = raw;
|
|
259
|
+
const num = (k, min) => typeof t[k] === "number" && t[k] >= min ? { [k]: t[k] } : {};
|
|
260
|
+
const key = (k) => typeof t[k] === "string" && isIssueKey(t[k]) ? { [k]: t[k] } : {};
|
|
261
|
+
const strs = (o, keys) => {
|
|
262
|
+
if (!o || typeof o !== "object") return void 0;
|
|
263
|
+
const out = {};
|
|
264
|
+
for (const k of keys) {
|
|
265
|
+
const v = o[k];
|
|
266
|
+
if (typeof v === "string" && v.trim()) out[k] = v.trim();
|
|
267
|
+
}
|
|
268
|
+
return Object.keys(out).length ? out : void 0;
|
|
269
|
+
};
|
|
270
|
+
const days = stringList(t.holidays)?.filter((d) => /^\d{4}-\d{2}-\d{2}$/.test(d));
|
|
271
|
+
const vacation = stringList(t.vacation)?.filter((d) => /^\d{4}-\d{2}-\d{2}$/.test(d));
|
|
272
|
+
const hints = validateHints(t.hints);
|
|
273
|
+
const catchUp = typeof t.catchUpDays === "number" && t.catchUpDays >= 1 ? { catchUpDays: Math.min(92, Math.floor(t.catchUpDays)) } : {};
|
|
274
|
+
const projects = stringList(t.projects)?.filter((p) => /^[A-Z][A-Z0-9]{1,9}$/.test(p));
|
|
275
|
+
const tempo = strs(t.tempo, ["tokenEnv", "accountId"]);
|
|
276
|
+
const graph = strs(t.graph, ["clientId", "tenantId"]);
|
|
277
|
+
return {
|
|
278
|
+
...num("dayHours", 0.25),
|
|
279
|
+
...num("multiplier", 0),
|
|
280
|
+
...num("capHours", 0),
|
|
281
|
+
...num("stepHours", 0.01),
|
|
282
|
+
...num("minHours", 0),
|
|
283
|
+
...key("gapTicket"),
|
|
284
|
+
...key("timeOffTicket"),
|
|
285
|
+
...days ? { holidays: days } : {},
|
|
286
|
+
...vacation ? { vacation } : {},
|
|
287
|
+
...typeof t.effort === "boolean" ? { effort: t.effort } : {},
|
|
288
|
+
...catchUp,
|
|
289
|
+
...hints ? { hints } : {},
|
|
290
|
+
...projects ? { projects } : {},
|
|
291
|
+
...tempo ? { tempo } : {},
|
|
292
|
+
...graph ? { graph } : {}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function validateHints(raw) {
|
|
296
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
297
|
+
const out = {};
|
|
298
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
299
|
+
const h = v;
|
|
300
|
+
const matches = stringList(h?.matches)?.map((m) => m.trim()).filter((m) => m.length >= 3);
|
|
301
|
+
if (!isIssueKey(k) || !matches?.length) continue;
|
|
302
|
+
out[k] = {
|
|
303
|
+
matches,
|
|
304
|
+
...typeof h?.summary === "string" && h.summary.trim() ? { summary: h.summary.trim() } : {},
|
|
305
|
+
...h?.placeholder === true ? { placeholder: true } : {}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
return Object.keys(out).length ? out : void 0;
|
|
309
|
+
}
|
|
174
310
|
function stringList(raw) {
|
|
175
311
|
return Array.isArray(raw) ? raw.filter((x) => typeof x === "string" && x.trim().length > 0) : void 0;
|
|
176
312
|
}
|
|
@@ -199,6 +335,7 @@ function loadConfig() {
|
|
|
199
335
|
devCommands: validateDevCommands(parsed.devCommands),
|
|
200
336
|
sleepIdleAfterMinutes: typeof parsed.sleepIdleAfterMinutes === "number" && parsed.sleepIdleAfterMinutes >= 0 ? parsed.sleepIdleAfterMinutes : void 0,
|
|
201
337
|
prompts: validatePrompts(parsed.prompts),
|
|
338
|
+
time: validateTime(parsed.time),
|
|
202
339
|
archive: parsed.archive && typeof parsed.archive === "object" ? {
|
|
203
340
|
...typeof parsed.archive.compressAfterDays === "number" && parsed.archive.compressAfterDays >= 0 ? { compressAfterDays: parsed.archive.compressAfterDays } : {},
|
|
204
341
|
...typeof parsed.archive.dropTranscriptsAfterDays === "number" && parsed.archive.dropTranscriptsAfterDays >= 0 ? { dropTranscriptsAfterDays: parsed.archive.dropTranscriptsAfterDays } : {}
|
|
@@ -247,6 +384,12 @@ export {
|
|
|
247
384
|
withFileLock,
|
|
248
385
|
withFileLockSync,
|
|
249
386
|
DEFAULT_PROMPTS,
|
|
387
|
+
DEFAULT_TIME_SETTINGS,
|
|
388
|
+
suggestDay,
|
|
389
|
+
totalHours,
|
|
390
|
+
isWorkday,
|
|
391
|
+
isIssueKey,
|
|
392
|
+
issueKeys,
|
|
250
393
|
getConfigDir,
|
|
251
394
|
isAgentId,
|
|
252
395
|
getConfigPath,
|
|
@@ -254,4 +397,4 @@ export {
|
|
|
254
397
|
saveConfig,
|
|
255
398
|
ensureConfig
|
|
256
399
|
};
|
|
257
|
-
//# sourceMappingURL=chunk-
|
|
400
|
+
//# sourceMappingURL=chunk-QXUHOISF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/platform/fs-safe.ts","../src/core/platform/config.ts","../src/core/sessions/saved-prompts.ts","../src/core/time/allocate.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { createRequire } from 'node:module';\nimport type ProperLockfile from 'proper-lockfile';\n\n/** proper-lockfile, loaded on the first lock: most `work` processes (a hook) never take one. */\nlet lockfileModule: typeof ProperLockfile | null = null;\nconst lockfile = () => (lockfileModule ??= createRequire(import.meta.url)('proper-lockfile') as typeof ProperLockfile);\n\n/**\n * Resolve a path through any symlinks so a tmp-file + rename write replaces\n * the LINK TARGET, not the link. Users routinely symlink config into a\n * dotfiles repo (`~/.claude/settings.json` -> `~/.dotfiles/.../settings.json`);\n * renaming over the link silently detaches it, so our edit lands in a new\n * regular file and the dotfiles copy stops being the live one.\n *\n * Walks links by hand instead of `fs.realpathSync` so a dangling link (target\n * not created yet) still resolves to where it points. Falls back to the path\n * as given when there's nothing there or the links form a cycle. Resolving\n * also keeps the tmp file on the target's filesystem, so the rename can't\n * fail with EXDEV when the link crosses a mount.\n */\nexport function resolveLinkTarget(filePath: string): string {\n let current = filePath;\n const seen = new Set<string>([current]);\n for (let i = 0; i < 32; i++) {\n let stat;\n try {\n stat = fs.lstatSync(current);\n } catch {\n return current; // nothing there — write where we were told\n }\n if (!stat.isSymbolicLink()) return current;\n const next = path.resolve(path.dirname(current), fs.readlinkSync(current));\n if (seen.has(next)) return filePath; // link cycle — don't touch it\n seen.add(next);\n current = next;\n }\n return filePath;\n}\n\n/**\n * Write a file atomically. Writes to a sibling tmp file and renames\n * over the target, so a crash mid-write can't leave a truncated file.\n * Symlinks are followed first (see {@link resolveLinkTarget}) and the\n * existing file's mode is preserved across the replace.\n *\n * On Windows the rename fails (EPERM/EACCES/EBUSY) while another process\n * has the target open without delete sharing — a Claude Code reading\n * `~/.claude/settings.json`, an editor, an antivirus scan — which lasts\n * milliseconds, so it's retried for a few seconds. If it still fails\n * the tmp file is removed rather than left beside the target.\n */\nexport function atomicWriteFile(filePath: string, content: string, renameSync: (from: string, to: string) => void = fs.renameSync): void {\n const target = resolveLinkTarget(filePath);\n const tmpPath = `${target}.tmp-${process.pid}`;\n let mode: number | undefined;\n try {\n mode = fs.statSync(target).mode & 0o777;\n } catch {\n /* target is new — default umask is right */\n }\n // Created with the target's mode, so a private file (graph-token.json, 0600) is never readable by others meanwhile.\n fs.writeFileSync(tmpPath, content, { encoding: 'utf-8', ...(mode !== undefined ? { mode } : {}) });\n // A leftover temp file from a crash keeps its old mode: set it. A filesystem without modes (an SMB share) refuses: fine.\n if (mode !== undefined)\n try {\n fs.chmodSync(tmpPath, mode);\n } catch {\n /* no modes here */\n }\n for (let attempt = 0; ; attempt++) {\n try {\n renameSync(tmpPath, target);\n return;\n } catch (err) {\n const code = (err as { code?: string }).code;\n if ((code === 'EPERM' || code === 'EACCES' || code === 'EBUSY') && attempt < 12) {\n sleepSync(Math.min(20 * 2 ** attempt, 400));\n continue;\n }\n try {\n fs.unlinkSync(tmpPath);\n } catch {\n /* already gone */\n }\n throw err;\n }\n }\n}\n\n/**\n * Ensure a file exists (creating with the given initial content if missing).\n * Required before `withFileLock` can acquire a lock on it — proper-lockfile\n * resolves the target file's realpath before creating the sibling .lock dir.\n */\nexport function ensureFile(filePath: string, initialContent: string): void {\n if (!fs.existsSync(filePath)) {\n fs.writeFileSync(filePath, initialContent, 'utf-8');\n }\n}\n\n/**\n * Serialize a read-modify-write sequence across processes using the same\n * advisory-lock mechanism as npm/yarn/pnpm. Caller is responsible for\n * ensuring the target file exists first (see `ensureFile`).\n */\nexport async function withFileLock<T>(filePath: string, fn: () => T | Promise<T>): Promise<T> {\n const release = await lockfile().lock(filePath, {\n retries: { retries: 20, minTimeout: 25, maxTimeout: 500, factor: 2 },\n stale: 10_000,\n });\n try {\n return await fn();\n } finally {\n await release();\n }\n}\n\n/**\n * Synchronous sibling of {@link withFileLock}. Serializes a read-modify-write\n * across processes using the same advisory-lock mechanism, but without an\n * `await` so it can be called from synchronous code paths (e.g. the\n * file-backed comment store, whose API is sync and consumed by sync Hono\n * route handlers). Caller is responsible for ensuring the target file exists\n * first (see `ensureFile`).\n */\nexport function withFileLockSync<T>(filePath: string, fn: () => T): T {\n // proper-lockfile's sync API forbids its own retry config (it requires an\n // async flow), so we hand-roll a bounded retry: try to acquire, and on a\n // contended lock (ELOCKED) sleep synchronously and try again.\n const maxAttempts = 30;\n let release: (() => void) | undefined;\n for (let attempt = 0; ; attempt++) {\n try {\n release = lockfile().lockSync(filePath, { stale: 10_000 });\n break;\n } catch (err) {\n const code = (err as { code?: string }).code;\n if (code !== 'ELOCKED' || attempt >= maxAttempts) throw err;\n sleepSync(Math.min(25 * 2 ** Math.min(attempt, 4), 500));\n }\n }\n try {\n return fn();\n } finally {\n release();\n }\n}\n\n/** Block the current thread for `ms` milliseconds without spinning the CPU.\n * Used by `withFileLockSync`'s contention backoff and `atomicWriteFile`'s rename retry. */\nfunction sleepSync(ms: number): void {\n const shared = new Int32Array(new SharedArrayBuffer(4));\n Atomics.wait(shared, 0, 0, ms);\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\nimport { atomicWriteFile } from './fs-safe.js';\nimport { validatePrompts } from '../sessions/saved-prompts.js';\nimport { isIssueKey } from '../time/allocate.js';\nimport type { SavedPrompt } from '../api-types.js';\n\n/**\n * An opt-in shell command that runs when a session changes status. The command\n * runs with the session's directory as its cwd (passed as the spawn `cwd`\n * option, never interpolated into the command string).\n */\nexport interface StatusHook {\n on: 'idle' | 'needs_input';\n command: string;\n}\n\nexport interface WorkConfig {\n worktreesRoot: string;\n repos: Record<string, string>;\n groups: Record<string, string[]>;\n copyFiles: string[];\n /** Folders the Repos page scans for git repos (repo-scan.ts); default: the one the worktrees root sits in. */\n scanRoots?: string[];\n /** Repos you chose not to enrol (paths), so the Repos page stops offering them. */\n ignoredRepos?: string[];\n /** The Jira watch (jira-watch.ts; turned on and off in the Jira tab): at most this many automatic starts a day (default 5). */\n jiraWatch?: { maxPerDay?: number };\n /** The Time tab's rules (core/time/allocate.ts, defaults in DEFAULT_TIME_SETTINGS), and the Jira\n * projects whose keys count in commit subjects (default: the projects of your sessions' keys). */\n time?: Partial<import('../time/allocate.js').TimeSettings> & {\n projects?: string[];\n /** How many days back the Time tab gathers (default 14, at most 92; Claude's own transcripts go back about 30). */\n catchUpDays?: number;\n /** Tickets a workstream maps to when nothing names them (the timesheet tool's TICKET_HINTS), by key. */\n hints?: Record<string, import('../time/hints.js').TicketHint>;\n /** Posting to Tempo: the env variable with the token (default TEMPO_API_TOKEN) and your Jira account id (else JIRA_ACCOUNT_ID). */\n tempo?: { tokenEnv?: string; accountId?: string };\n /** Outlook and Teams through Microsoft Graph: the app registration to sign in with (else GRAPH_CLIENT_ID / GRAPH_TENANT_ID). */\n graph?: { clientId?: string; tenantId?: string };\n };\n /** Stacked sessions (stack-sync.ts): bring a parent's new commits into the sessions stacked on it (default true). */\n stacks?: { autoUpdate?: boolean };\n /** The agent that writes work's own summaries — checkpoint names, catch-up, archive summaries, the Jira watch's choice (default `claude`; one without one-shot runs writes none). */\n internalAgent?: string;\n /** The agent the Ctrl+K assistant runs (an adapter's id; Claude Code by default). */\n assistantAgent?: string;\n /** Environment variable names to keep for a session restored after a reboot (the launching shell's values; secret-looking names are never kept). */\n hostEnv?: string[];\n /** Writing session time to Jira as worklogs (jira-worklog.ts): the site, your email, and the API token (from the env var `tokenEnv`, default JIRA_API_TOKEN, or `token`). */\n jiraWorklog?: { site: string; email: string; tokenEnv?: string; token?: string };\n /**\n * AI tool command to launch in worktrees. May include extra args, e.g.\n * \"claude\" (default), \"gemini\", \"codex\", or \"my-tool --some-flag\".\n */\n aiCommand?: string;\n /**\n * Launch `work tree`'s AI session inside the PTY host and attach this\n * terminal to it (like `work attach`), so it survives closing the tab and\n * the dashboard shows the same screen. Default on; `false` launches\n * directly in the terminal. Per call: `--host` / `--no-host`.\n */\n launchViaHost?: boolean;\n /**\n * Per-tool flag overrides. Defaults come from the preset matching the\n * binary in `aiCommand` (see AI_TOOL_PRESETS in core/ai-launcher.ts).\n * Set any value to an empty string to disable that flag for the configured tool.\n */\n aiCommandFlags?: {\n /** Flag for skipping permission checks. */\n unsafe?: string;\n /** Flag for resuming the most recent session. */\n resume?: string;\n /** Flag for passing an initial prompt as a file path. */\n promptFile?: string;\n /** Flag for passing an inline prompt; empty string = positional arg. */\n prompt?: string;\n };\n /** Editor command for opening worktrees. Default: \"code\" */\n editor?: string;\n /**\n * Range of dev-server ports to allocate to worktrees (inclusive).\n * Each worktree gets a stable port exposed as $PORT to the launched process.\n * Default when unset: { start: 3000, end: 3099 }.\n */\n portRange?: { start: number; end: number };\n /**\n * Dev-server command per repo alias, run from the dashboard with this\n * worktree's $PORT (e.g. `{ \"web\": \"npm run dev -- --port $PORT\" }`).\n */\n devCommands?: Record<string, string>;\n /**\n * Stop a session's Claude in the PTY host after this many minutes idle with\n * no window attached; opening the session resumes its conversation. Frees\n * memory (each Claude holds a few hundred MB). Default 240; 0 = never.\n */\n sleepIdleAfterMinutes?: number;\n /**\n * Archived conversations (archive-retention.ts): gzip them once this many\n * days old (default 30; 0 = never; lossless), and delete them after this\n * many (default 0 = never; the summary and prompts stay).\n */\n archive?: { compressAfterDays?: number; dropTranscriptsAfterDays?: number };\n /**\n * Background PR watch in `work web` (both default on): archive a session\n * once all its PRs merged, and tell its Claude when CI fails or reviewers\n * leave feedback.\n */\n prWatch?: {\n autoArchive?: boolean;\n fixCi?: boolean;\n reviewComments?: boolean;\n /** Review bots whose comments go to Claude like a colleague's (logins,\n * e.g. \"copilot-pull-request-reviewer\"). Default: Copilot and\n * github-actions (pr-review.ts DEFAULT_TRUSTED_BOTS); [] = none. */\n trustedBots?: string[];\n /** Start a session's Claude (resuming its conversation) when feedback\n * arrives and it isn't running, so it works on it at once. Default on. */\n wakeClaude?: boolean;\n };\n /**\n * Opt-in desktop notifications. When true, the dashboard fires an OS\n * notification when a session goes idle or needs input. Default: off.\n */\n notifications?: boolean;\n /**\n * Opt-in shell commands run when a session changes status (idle /\n * needs_input). Each command runs with the session dir as its cwd.\n * Generalizes `notifications`; both paths work independently. Default: none.\n */\n statusHooks?: StatusHook[];\n /**\n * One-click instructions in a session's \"Prompts ▾\" menu, replacing the\n * built-in ones: `[{ \"label\": \"Add tests\", \"prompt\": \"…\", \"repos\": [\"api\"] }]`\n * (`repos` optional: only for those repo aliases / group names).\n */\n prompts?: SavedPrompt[];\n}\n\n/** Lowest port we allow to be configured (avoid privileged ports < 1024). */\nconst MIN_PORT = 1024;\n/** Highest valid TCP port. */\nconst MAX_PORT = 65535;\n\n/**\n * Validate a configured port range. Returns the normalized range when it is a\n * pair of integers with `MIN_PORT <= start <= end <= MAX_PORT`, otherwise\n * undefined (callers then fall back to the default range). Rejects non-integers,\n * privileged/out-of-bounds ports, and reversed ranges.\n */\nexport function validatePortRange(value: unknown): { start: number; end: number } | undefined {\n if (!value || typeof value !== 'object') return undefined;\n const { start, end } = value as { start?: unknown; end?: unknown };\n if (typeof start !== 'number' || typeof end !== 'number') return undefined;\n if (!Number.isInteger(start) || !Number.isInteger(end)) return undefined;\n if (start < MIN_PORT || end > MAX_PORT) return undefined;\n if (start > end) return undefined;\n return { start, end };\n}\n\nexport function getConfigDir(): string {\n const dir = path.join(os.homedir(), '.work');\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n return dir;\n}\n\n/** An agent named in config (`internalAgent`, `assistantAgent`): an adapter's id, a plain word — never a path or a command line. */\nexport function isAgentId(v: unknown): v is string {\n return typeof v === 'string' && /^[\\w.-]+$/.test(v);\n}\n\nexport function getConfigPath(): string {\n return path.join(getConfigDir(), 'config.json');\n}\n\nfunction validateDevCommands(raw: unknown): Record<string, string> | undefined {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return undefined;\n const out: Record<string, string> = {};\n for (const [alias, cmd] of Object.entries(raw)) if (typeof cmd === 'string' && cmd.trim()) out[alias] = cmd;\n return out;\n}\n\n/** The Time tab's section as written: only well-formed values (a bad one is left to its default). */\nexport function validateTime(raw: unknown): WorkConfig['time'] {\n if (!raw || typeof raw !== 'object') return undefined;\n const t = raw as Record<string, unknown>;\n const num = (k: string, min: number) => (typeof t[k] === 'number' && (t[k] as number) >= min ? { [k]: t[k] as number } : {});\n const key = (k: string) => (typeof t[k] === 'string' && isIssueKey(t[k] as string) ? { [k]: t[k] as string } : {});\n const strs = (o: unknown, keys: string[]) => {\n if (!o || typeof o !== 'object') return undefined;\n const out: Record<string, string> = {};\n for (const k of keys) {\n const v = (o as Record<string, unknown>)[k];\n if (typeof v === 'string' && v.trim()) out[k] = v.trim();\n }\n return Object.keys(out).length ? out : undefined;\n };\n const days = stringList(t.holidays)?.filter((d) => /^\\d{4}-\\d{2}-\\d{2}$/.test(d));\n const vacation = stringList(t.vacation)?.filter((d) => /^\\d{4}-\\d{2}-\\d{2}$/.test(d));\n const hints = validateHints(t.hints);\n const catchUp = typeof t.catchUpDays === 'number' && t.catchUpDays >= 1 ? { catchUpDays: Math.min(92, Math.floor(t.catchUpDays)) } : {};\n const projects = stringList(t.projects)?.filter((p) => /^[A-Z][A-Z0-9]{1,9}$/.test(p));\n const tempo = strs(t.tempo, ['tokenEnv', 'accountId']);\n const graph = strs(t.graph, ['clientId', 'tenantId']);\n return {\n ...num('dayHours', 0.25),\n ...num('multiplier', 0),\n ...num('capHours', 0),\n ...num('stepHours', 0.01),\n ...num('minHours', 0),\n ...key('gapTicket'),\n ...key('timeOffTicket'),\n ...(days ? { holidays: days } : {}),\n ...(vacation ? { vacation } : {}),\n ...(typeof t.effort === 'boolean' ? { effort: t.effort } : {}),\n ...catchUp,\n ...(hints ? { hints } : {}),\n ...(projects ? { projects } : {}),\n ...(tempo ? { tempo } : {}),\n ...(graph ? { graph } : {}),\n };\n}\n\n/** `time.hints`: each a real issue key with what matches it (text found in a session, commit, meeting or chat). */\nfunction validateHints(raw: unknown): Record<string, import('../time/hints.js').TicketHint> | undefined {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return undefined;\n const out: Record<string, import('../time/hints.js').TicketHint> = {};\n for (const [k, v] of Object.entries(raw as Record<string, unknown>)) {\n const h = v as Record<string, unknown> | null;\n const matches = stringList(h?.matches)\n ?.map((m) => m.trim())\n .filter((m) => m.length >= 3);\n if (!isIssueKey(k) || !matches?.length) continue;\n out[k] = {\n matches,\n ...(typeof h?.summary === 'string' && h.summary.trim() ? { summary: h.summary.trim() } : {}),\n ...(h?.placeholder === true ? { placeholder: true } : {}),\n };\n }\n return Object.keys(out).length ? out : undefined;\n}\n\n/** A list of non-empty strings, or undefined (not a list). */\nfunction stringList(raw: unknown): string[] | undefined {\n return Array.isArray(raw) ? raw.filter((x): x is string => typeof x === 'string' && x.trim().length > 0) : undefined;\n}\n\nexport function loadConfig(): WorkConfig | null {\n const configPath = getConfigPath();\n if (!fs.existsSync(configPath)) {\n return null;\n }\n\n try {\n const raw = fs.readFileSync(configPath, 'utf-8');\n const parsed = JSON.parse(raw);\n return {\n worktreesRoot: parsed.worktreesRoot ?? '',\n repos: parsed.repos ?? {},\n groups: parsed.groups ?? {},\n copyFiles: parsed.copyFiles ?? [],\n scanRoots: stringList(parsed.scanRoots),\n ignoredRepos: stringList(parsed.ignoredRepos),\n aiCommand: parsed.aiCommand,\n aiCommandFlags: parsed.aiCommandFlags,\n editor: parsed.editor,\n portRange: validatePortRange(parsed.portRange),\n notifications: parsed.notifications === true,\n statusHooks: Array.isArray(parsed.statusHooks) ? parsed.statusHooks : [],\n launchViaHost: typeof parsed.launchViaHost === 'boolean' ? parsed.launchViaHost : undefined,\n devCommands: validateDevCommands(parsed.devCommands),\n sleepIdleAfterMinutes:\n typeof parsed.sleepIdleAfterMinutes === 'number' && parsed.sleepIdleAfterMinutes >= 0 ? parsed.sleepIdleAfterMinutes : undefined,\n prompts: validatePrompts(parsed.prompts),\n time: validateTime(parsed.time),\n archive:\n parsed.archive && typeof parsed.archive === 'object'\n ? {\n ...(typeof parsed.archive.compressAfterDays === 'number' && parsed.archive.compressAfterDays >= 0\n ? { compressAfterDays: parsed.archive.compressAfterDays }\n : {}),\n ...(typeof parsed.archive.dropTranscriptsAfterDays === 'number' && parsed.archive.dropTranscriptsAfterDays >= 0\n ? { dropTranscriptsAfterDays: parsed.archive.dropTranscriptsAfterDays }\n : {}),\n }\n : undefined,\n stacks: parsed.stacks && typeof parsed.stacks === 'object' ? { autoUpdate: parsed.stacks.autoUpdate !== false } : undefined,\n internalAgent: isAgentId(parsed.internalAgent) ? parsed.internalAgent : undefined,\n assistantAgent: isAgentId(parsed.assistantAgent) ? parsed.assistantAgent : undefined,\n hostEnv: Array.isArray(parsed.hostEnv)\n ? parsed.hostEnv.filter((n: unknown): n is string => typeof n === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(n))\n : undefined,\n jiraWorklog:\n parsed.jiraWorklog &&\n typeof parsed.jiraWorklog === 'object' &&\n typeof parsed.jiraWorklog.site === 'string' &&\n typeof parsed.jiraWorklog.email === 'string'\n ? {\n site: parsed.jiraWorklog.site,\n email: parsed.jiraWorklog.email,\n ...(typeof parsed.jiraWorklog.tokenEnv === 'string' ? { tokenEnv: parsed.jiraWorklog.tokenEnv } : {}),\n ...(typeof parsed.jiraWorklog.token === 'string' ? { token: parsed.jiraWorklog.token } : {}),\n }\n : undefined,\n prWatch:\n parsed.prWatch && typeof parsed.prWatch === 'object'\n ? {\n autoArchive: parsed.prWatch.autoArchive !== false,\n fixCi: parsed.prWatch.fixCi !== false,\n reviewComments: parsed.prWatch.reviewComments !== false,\n ...(Array.isArray(parsed.prWatch.trustedBots)\n ? {\n trustedBots: parsed.prWatch.trustedBots.filter(\n (b: unknown): b is string => typeof b === 'string' && b.trim().length > 0,\n ),\n }\n : {}),\n wakeClaude: parsed.prWatch.wakeClaude !== false,\n }\n : undefined,\n };\n } catch {\n return null;\n }\n}\n\nexport function saveConfig(config: WorkConfig): void {\n // Atomic (write temp + rename): a crash or a concurrent reader can never\n // see a half-written config (§5.3 — history/tasks already did this).\n atomicWriteFile(getConfigPath(), JSON.stringify(config, null, 2));\n}\n\nexport function ensureConfig(): WorkConfig {\n const config = loadConfig();\n if (!config) {\n throw new Error('Configuration not found. Run \"work init\" to set up.');\n }\n return config;\n}\n","import type { SavedPrompt } from '../api-types.js';\n\nexport type { SavedPrompt } from '../api-types.js';\n\n/**\n * One-click instructions for a session (\"Prompts ▾\" in its header). Sent\n * like a review comment, so they reach Claude the same safe way: pushed to\n * a terminal the dashboard owns, or on the session's next turn — never\n * typed over a permission prompt. Pure (the demo uses it too).\n *\n * `prompts` in config.json replaces these defaults; `repos` limits one to\n * those repo aliases / group names.\n */\nexport const DEFAULT_PROMPTS: SavedPrompt[] = [\n {\n label: 'Review your changes',\n prompt:\n 'Review the changes on this branch as a strict reviewer would: bugs, missing edge cases, missing tests, leftovers (debug output, TODOs, dead code). Fix what you find, then tell me briefly what you changed.',\n },\n {\n label: 'Add tests',\n prompt:\n 'Add tests for what changed on this branch, following the existing test patterns in this repo. Run them and fix anything that fails.',\n },\n {\n label: 'Run checks and fix',\n prompt:\n \"Run this repo's type check, lint and tests (whatever it has). Fix what fails, and tell me if something is failing for a reason outside this change.\",\n },\n {\n label: 'Commit',\n prompt: \"Commit the current changes with a clear message in this repo's commit style. Don't push.\",\n },\n {\n label: 'Open a pull request',\n prompt:\n 'Push this branch and open a pull request for it with `gh pr create`. Write the title and description yourself from what we did in this conversation: what changed and why, how it was tested, anything a reviewer should look at first. Put the Jira key in the title if the branch or our conversation has one. Open it ready for review, not as a draft, and give me its link.',\n },\n {\n label: 'Rebase on the default branch',\n prompt:\n \"Fetch, then rebase this branch on origin's default branch. Resolve conflicts keeping both sides' intent, run the tests, and tell me about any conflict you weren't sure of.\",\n },\n];\n\nconst MAX_PROMPT = 20_000;\n\n/** The configured list, validated; undefined (use the defaults) when absent. */\nexport function validatePrompts(raw: unknown): SavedPrompt[] | undefined {\n if (!Array.isArray(raw)) return undefined;\n const out: SavedPrompt[] = [];\n for (const p of raw) {\n if (!p || typeof p !== 'object') continue;\n const { label, prompt, repos } = p as Record<string, unknown>;\n if (typeof label !== 'string' || !label.trim() || typeof prompt !== 'string' || !prompt.trim()) continue;\n const item: SavedPrompt = { label: label.trim(), prompt: prompt.trim().slice(0, MAX_PROMPT) };\n if (Array.isArray(repos)) {\n const names = repos.filter((r): r is string => typeof r === 'string' && r.length > 0);\n if (names.length) item.repos = names;\n }\n out.push(item);\n }\n return out;\n}\n\n/** The prompts that apply to a session: unscoped ones, and those naming\n * its target (a repo alias or group name) or one of its repos. */\nexport function promptsForSession(prompts: SavedPrompt[], target: string, repoNames: string[] = []): SavedPrompt[] {\n const names = new Set([target, ...repoNames]);\n return prompts.filter((p) => !p.repos || p.repos.some((r) => names.has(r)));\n}\n","/**\n * A day's suggested hours, from what was worked on (pure; the SPA and the\n * demo use it too). The timesheet tool's rules, as settings: a day of\n * `dayHours`, measured Claude time scaled by `multiplier` (an hour of Claude\n * at work stands for more of yours: reading, testing, talking), all of it\n * capped at `capHours`, in `stepHours` steps with at least `minHours` a\n * ticket, and what's left to the `gapTicket` (meetings, reviews, the rest).\n * A ticket touched with no measured time (a commit, an issue moved) gets the\n * minimum. Unlike the tool, it never goes over the day — too many tickets\n * trim the biggest first, then drop the smallest — and nothing is taken out\n * of one entry alone.\n */\n\nexport interface TimeSettings {\n /** A workday's hours. */\n dayHours: number;\n /** Measured Claude minutes × this = your hours on it. */\n multiplier: number;\n /** At most this much of a day to tickets (the gap ticket keeps the rest). */\n capHours: number;\n stepHours: number;\n /** A ticket that gets time gets at least this. */\n minHours: number;\n /** Gets what's left of the day (null: left unallocated). */\n gapTicket: string | null;\n /** A day off is booked to it (null: a day off books nothing). */\n timeOffTicket: string | null;\n /** Days that aren't workdays besides weekends (`YYYY-MM-DD`). */\n holidays: string[];\n /** Your days off (`YYYY-MM-DD`): booked whole to the time-off ticket, whatever else happened (the timesheet tool's VACATION_DAYS). */\n vacation: string[];\n /**\n * Hours as measured (the timesheet tool's `build --effort`): Claude minutes 1:1 in steps, no multiplier and no\n * minimum beyond a step, a ticket only touched gets no row; the gap ticket takes the rest of the day.\n */\n effort: boolean;\n}\n\nexport const DEFAULT_TIME_SETTINGS: TimeSettings = {\n dayHours: 7.5,\n multiplier: 5,\n capHours: 7,\n stepHours: 0.25,\n minHours: 0.5,\n gapTicket: null,\n timeOffTicket: null,\n holidays: [],\n vacation: [],\n effort: false,\n};\n\n/** What a ticket got that day: measured Claude minutes (× multiplier), your own minutes on it (a meeting: 1:1), or only touched (0). */\nexport interface TicketActivity {\n key: string;\n minutes: number;\n direct?: number;\n}\n\nexport interface TimeEntry {\n key: string;\n hours: number;\n}\n\nexport interface DaySuggestion {\n entries: TimeEntry[];\n /** Hours of the day no ticket got (no gap ticket set). */\n unallocated: number;\n}\n\n/**\n * A day's suggestion. `dayOff`: all of it to the time-off ticket.\n * `reserveMinutes`: meetings no ticket got — kept for the gap ticket, so\n * the tickets' share shrinks to leave them room.\n */\nexport function suggestDay(\n activity: readonly TicketActivity[],\n s: TimeSettings,\n opts: { dayOff?: boolean; reserveMinutes?: number } = {},\n): DaySuggestion {\n // Whole steps, so sums are exact.\n const units = (h: number) => Math.round(h / s.stepHours);\n const day = units(s.dayHours);\n const hours = (u: number) => Math.round(u * s.stepHours * 100) / 100;\n if (opts.dayOff)\n return s.timeOffTicket\n ? { entries: [{ key: s.timeOffTicket, hours: s.dayHours }], unallocated: 0 }\n : { entries: [], unallocated: s.dayHours };\n\n // One row per ticket; the gap ticket's own time goes into what it gets at the end.\n const minutes = new Map<string, { claude: number; direct: number }>();\n for (const a of activity) {\n if (!a.key || a.key === s.gapTicket) continue;\n const m = minutes.get(a.key) ?? { claude: 0, direct: 0 };\n m.claude += Math.max(0, a.minutes);\n m.direct += Math.max(0, a.direct ?? 0);\n minutes.set(a.key, m);\n }\n const min = s.effort ? 1 : Math.max(1, units(s.minHours));\n const multiplier = s.effort ? 1 : s.multiplier;\n // Room for tickets: the cap, and the day less what the gap ticket keeps (its minimum, or the meetings it has).\n const reserve = s.gapTicket ? Math.max(min, units((opts.reserveMinutes ?? 0) / 60)) : 0;\n const room = Math.max(0, Math.min(units(s.capHours), day - reserve));\n const raw = [...minutes].map(([key, m]) => {\n const h = (m.claude / 60) * multiplier + m.direct / 60;\n // Only touched (a commit, an issue moved): the minimum — or, measuring effort, nothing.\n return { key, raw: h > 0 ? h : s.effort ? 0 : s.minHours };\n });\n const total = raw.reduce((n, r) => n + r.raw, 0);\n const scale = total > room * s.stepHours && total > 0 ? (room * s.stepHours) / total : 1;\n let rows = raw\n .map((r) => {\n const scaled = r.raw * scale;\n const u = units(scaled);\n // Under the minimum: the minimum when it's at least a step's worth, else nothing.\n return { key: r.key, raw: scaled, u: u >= min ? u : scaled >= s.stepHours ? min : 0 };\n })\n .filter((r) => r.u > 0);\n // Rounding up to minimums can overshoot the room: trim the biggest a step at a time, then drop the smallest.\n let used = rows.reduce((n, r) => n + r.u, 0);\n while (used > room && rows.length) {\n const big = rows.filter((r) => r.u > min).sort((a, b) => b.u - a.u || a.key.localeCompare(b.key))[0];\n if (big) big.u--;\n else rows = rows.sort((a, b) => a.raw - b.raw).slice(1);\n used = rows.reduce((n, r) => n + r.u, 0);\n }\n const entries = rows.sort((a, b) => b.u - a.u || a.key.localeCompare(b.key)).map((r) => ({ key: r.key, hours: hours(r.u) }));\n const left = day - used;\n if (s.gapTicket && left > 0) return { entries: [...entries, { key: s.gapTicket, hours: hours(left) }], unallocated: 0 };\n return { entries, unallocated: hours(Math.max(0, left)) };\n}\n\n/** Sum of a day's entries, in hours (to two decimals). */\nexport function totalHours(entries: readonly TimeEntry[]): number {\n return Math.round(entries.reduce((n, e) => n + e.hours, 0) * 100) / 100;\n}\n\n/** Monday to Friday, and not a holiday. */\nexport function isWorkday(day: string, s: Pick<TimeSettings, 'holidays'>): boolean {\n const d = new Date(`${day}T12:00:00`);\n const wd = d.getDay();\n return wd !== 0 && wd !== 6 && !s.holidays.includes(day);\n}\n\n/** A Jira issue key, as found in a branch, a commit subject or a title. */\nexport const ISSUE_KEY = /\\b([A-Z][A-Z0-9]{1,9}-\\d+)\\b/g;\n\n/** Whether a string is one issue key, whole (a row's key, a configured ticket). */\nexport function isIssueKey(s: string): boolean {\n return new RegExp(`^${ISSUE_KEY.source}$`).test(s);\n}\n\n/** The issue keys in a text, only of the given projects when any are given (`UTF-8` isn't an issue). */\nexport function issueKeys(text: string, projects?: ReadonlySet<string>): string[] {\n const out: string[] = [];\n for (const m of text.matchAll(ISSUE_KEY)) {\n const key = m[1];\n if (projects && projects.size && !projects.has(key.split('-')[0])) continue;\n if (!out.includes(key)) out.push(key);\n }\n return out;\n}\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAI9B,IAAI,iBAA+C;AACnD,IAAM,WAAW,MAAO,mBAAmB,cAAc,YAAY,GAAG,EAAE,iBAAiB;AAepF,SAAS,kBAAkB,UAA0B;AAC1D,MAAI,UAAU;AACd,QAAM,OAAO,oBAAI,IAAY,CAAC,OAAO,CAAC;AACtC,WAAS,IAAI,GAAG,IAAI,IAAI,KAAK;AAC3B,QAAI;AACJ,QAAI;AACF,aAAO,GAAG,UAAU,OAAO;AAAA,IAC7B,QAAQ;AACN,aAAO;AAAA,IACT;AACA,QAAI,CAAC,KAAK,eAAe,EAAG,QAAO;AACnC,UAAM,OAAO,KAAK,QAAQ,KAAK,QAAQ,OAAO,GAAG,GAAG,aAAa,OAAO,CAAC;AACzE,QAAI,KAAK,IAAI,IAAI,EAAG,QAAO;AAC3B,SAAK,IAAI,IAAI;AACb,cAAU;AAAA,EACZ;AACA,SAAO;AACT;AAcO,SAAS,gBAAgB,UAAkB,SAAiB,aAAiD,GAAG,YAAkB;AACvI,QAAM,SAAS,kBAAkB,QAAQ;AACzC,QAAM,UAAU,GAAG,MAAM,QAAQ,QAAQ,GAAG;AAC5C,MAAI;AACJ,MAAI;AACF,WAAO,GAAG,SAAS,MAAM,EAAE,OAAO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