@moberg_hr/work-tree 2.15.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{account-X42JQCYT.js → account-MYGAXTF6.js} +17 -17
- package/dist/{add-repo-UZHIG6LN.js → add-repo-7PLONSB6.js} +11 -11
- package/dist/{answer-NDX2DNXK.js → answer-H3D6OLHJ.js} +8 -8
- package/dist/{attach-ETPEGXYM.js → attach-Z2HEZVZW.js} +15 -15
- package/dist/bin.js +3 -3
- package/dist/{block-5HJQWQNX.js → block-BWRLOTSM.js} +10 -10
- package/dist/{broadcast-TMCWRTIY.js → broadcast-RY6NAYGN.js} +6 -6
- package/dist/{catchup-BBJ43GWY.js → catchup-K5ICNWDH.js} +11 -11
- package/dist/{chunk-XMKYQVJU.js → chunk-2CVBAJH7.js} +2 -2
- package/dist/{chunk-O32OINY3.js → chunk-2H3H23W5.js} +2 -2
- package/dist/{chunk-TZLCBDJZ.js → chunk-2L2TNYQA.js} +2 -2
- package/dist/{chunk-K2OOUNXH.js → chunk-3JANKWY2.js} +2 -2
- package/dist/{chunk-JVJ5IJSF.js → chunk-3L5VDONX.js} +2 -2
- package/dist/chunk-3TNVVBVG.js +9 -0
- package/dist/{chunk-R6KQDWHC.js → chunk-42WCSVBK.js} +4 -4
- package/dist/chunk-42WCSVBK.js.map +1 -0
- package/dist/{chunk-DBGHDWM7.js → chunk-45QJQIWF.js} +7 -7
- package/dist/chunk-45QJQIWF.js.map +1 -0
- package/dist/{chunk-UCNYEHQY.js → chunk-4HNMJIUZ.js} +2 -2
- package/dist/{chunk-R5HG665I.js → chunk-4YO2PDUC.js} +3 -3
- package/dist/{chunk-2PAHTJ3B.js → chunk-63NT2NZD.js} +6 -6
- package/dist/{chunk-C6OEPSH2.js → chunk-C5F36EGT.js} +4 -4
- package/dist/{chunk-GPLCT5TZ.js → chunk-CJQPKHDO.js} +4 -4
- package/dist/{chunk-4WTY3SFZ.js → chunk-EQJZ2GXX.js} +3 -3
- package/dist/{chunk-MZY557LZ.js → chunk-EVZUJLZH.js} +6 -6
- package/dist/{chunk-ITY6R2LC.js → chunk-EX6ELNTN.js} +3 -3
- package/dist/{chunk-CVTM4TCZ.js → chunk-GT3KUREW.js} +5 -5
- package/dist/{chunk-CYUSOVO5.js → chunk-H3WBTKPB.js} +6 -6
- package/dist/{chunk-2IDWQ5NO.js → chunk-HT52LVYU.js} +3 -3
- package/dist/{chunk-3YON263F.js → chunk-HWMQV4YD.js} +4 -4
- package/dist/{chunk-QHA4VF4B.js → chunk-I5YQ7AC5.js} +3 -3
- package/dist/{chunk-BZGIKO6I.js → chunk-IKGSTBTG.js} +2 -1
- package/dist/chunk-IKGSTBTG.js.map +1 -0
- package/dist/{chunk-KCYYIUUQ.js → chunk-LBPYBBXX.js} +2 -2
- package/dist/{chunk-ZNGR2CB6.js → chunk-LMD2J2JN.js} +3 -3
- package/dist/{chunk-5LAFHPNB.js → chunk-LMSKMRNU.js} +7 -7
- package/dist/chunk-LMSKMRNU.js.map +1 -0
- package/dist/{chunk-LMP3WGRW.js → chunk-MH4D37RT.js} +2 -2
- package/dist/{chunk-UIIEP6VP.js → chunk-N5P2OY5O.js} +2 -2
- package/dist/{chunk-AHGMXBY3.js → chunk-NIAXRF5E.js} +2 -2
- package/dist/{chunk-BRUYXYO2.js → chunk-O2IARWVM.js} +2 -2
- package/dist/{chunk-S2MOK3CT.js → chunk-OA3TYOAY.js} +3 -3
- package/dist/{chunk-EQD3YBGA.js → chunk-P5633SI2.js} +7 -7
- package/dist/{chunk-WNWSO4VO.js → chunk-PJPYRXKJ.js} +6 -6
- package/dist/{chunk-QP7VLMFJ.js → chunk-QTUYNY3F.js} +2 -2
- package/dist/{chunk-6SYQQXPQ.js → chunk-QUL26RYB.js} +10 -10
- package/dist/{chunk-FIEBI3UB.js → chunk-RJAGFLAP.js} +2 -2
- package/dist/{chunk-X6EMCJ2L.js → chunk-SMARTMBW.js} +4 -4
- package/dist/{chunk-U64SNFIZ.js → chunk-SRGOCF73.js} +2 -2
- package/dist/{chunk-7QDZGVIT.js → chunk-SSXKC635.js} +3 -3
- package/dist/{chunk-MXH7DV4Q.js → chunk-SWAFQ343.js} +3 -3
- package/dist/{chunk-Z3OHGPIN.js → chunk-TLXZUE4T.js} +3 -3
- package/dist/{chunk-PSFOA7P6.js → chunk-UAXKMJYA.js} +6 -6
- package/dist/{chunk-FNWPOM4B.js → chunk-UN33JXAD.js} +134 -14
- package/dist/chunk-UN33JXAD.js.map +1 -0
- package/dist/{chunk-4ZP6NN2X.js → chunk-VH6EUWX7.js} +13 -13
- package/dist/chunk-VH6EUWX7.js.map +1 -0
- package/dist/{chunk-UJWYQVXI.js → chunk-VHYFFFZU.js} +2 -2
- package/dist/{chunk-QMHFXIMX.js → chunk-WLU7EWPD.js} +13 -10
- package/dist/chunk-WLU7EWPD.js.map +1 -0
- package/dist/{chunk-46WW3Z6C.js → chunk-WMIQOBHU.js} +4 -4
- package/dist/{chunk-GGE55DO3.js → chunk-WPHTWUNV.js} +16 -11
- package/dist/{chunk-GGE55DO3.js.map → chunk-WPHTWUNV.js.map} +1 -1
- package/dist/{chunk-OL7S2KFH.js → chunk-X2EMWCFQ.js} +57 -57
- package/dist/{chunk-RXORNKSJ.js → chunk-XHUKX3HO.js} +3 -3
- package/dist/{chunk-7S3NPGVM.js → chunk-XHVRFFOY.js} +4 -4
- package/dist/{chunk-XPWWOR7Z.js → chunk-XIOGNTUA.js} +2 -2
- package/dist/{chunk-TI6AR4QF.js → chunk-YLB2QGAR.js} +4 -4
- package/dist/{chunk-EQFDUC6F.js → chunk-Z3HC36JK.js} +2 -2
- package/dist/{chunk-BWUN33QN.js → chunk-ZAAWSVTU.js} +6 -6
- package/dist/{chunk-REAZAE5C.js → chunk-ZWBXRP2V.js} +6 -6
- package/dist/{chunk-MVME4LH7.js → chunk-ZXDRQ2MV.js} +6 -6
- package/dist/{cleanup-BD44PDRE.js → cleanup-HXZ4S2IO.js} +28 -28
- package/dist/{cli-OMADLGGY.js → cli-M6RBYAO6.js} +4 -4
- package/dist/{color-IZ2J3CT2.js → color-E73MIJWD.js} +8 -8
- package/dist/{config-65HXBCMW.js → config-24BNXN5C.js} +8 -8
- package/dist/{diff-CJNSUX25.js → diff-NAL5334E.js} +9 -9
- package/dist/{digest-FH3JBHSO.js → digest-NU6XNA7D.js} +8 -8
- package/dist/{fork-O6NS34MV.js → fork-QVFWYP2Z.js} +25 -25
- package/dist/{history-URHFR4MO.js → history-W5DQNAY3.js} +6 -6
- package/dist/{hook-6PWP3JVL.js → hook-OIAJHLTJ.js} +13 -13
- package/dist/{hydrate-V6PVQ6OO.js → hydrate-VAJO2JGT.js} +6 -6
- package/dist/{init-SENRHJ4R.js → init-2IHQUZ4E.js} +11 -11
- package/dist/{install-skills-DJE7LU66.js → install-skills-RJPZOV37.js} +6 -6
- package/dist/install-skills-bin.js +5 -5
- package/dist/{keep-M7E7UMRL.js → keep-IJDON5AL.js} +8 -8
- package/dist/{list-YPKCU3GB.js → list-6LPLVUUD.js} +6 -6
- package/dist/{move-ME7JMNJI.js → move-GY5G47JO.js} +14 -14
- package/dist/{note-JFZ3F7UY.js → note-6Q3AT7W6.js} +8 -8
- package/dist/{overlaps-ZN3WA35A.js → overlaps-JQVWZXEB.js} +12 -12
- package/dist/{pin-3S2MQQPM.js → pin-MIWOAQ7R.js} +8 -8
- package/dist/{pr-KNJ2TVC3.js → pr-3F3PJCQN.js} +19 -19
- package/dist/{prune-2GAXXNPM.js → prune-RKQQWEU6.js} +26 -26
- package/dist/{pty-host-WZZIQIKX.js → pty-host-5GYGW43F.js} +13 -13
- package/dist/{read-UIV42F5D.js → read-RFLYBHLU.js} +8 -8
- package/dist/{recent-SJPAIY2T.js → recent-R24GG3OG.js} +13 -13
- package/dist/{remove-KQW35I5D.js → remove-ULIYLBRK.js} +27 -27
- package/dist/{restart-7VTSNTZ3.js → restart-VKQEQEU3.js} +8 -8
- package/dist/{resume-MPBXIF7C.js → resume-LE3SXWGI.js} +13 -13
- package/dist/{review-IRVOI4ZK.js → review-QGBSWK2M.js} +7 -7
- package/dist/{review-now-QAAL5C6N.js → review-now-74ISYEFP.js} +2 -2
- package/dist/{run-2EKY2R5R.js → run-RXCZSZKP.js} +6 -6
- package/dist/{screen-GQTKTUTD.js → screen-27WNAGP5.js} +8 -8
- package/dist/{search-N7XUYKYV.js → search-OSNZYFMI.js} +6 -6
- package/dist/{section-6MDCSJS5.js → section-HIYOC5HZ.js} +8 -8
- package/dist/{send-32U465SB.js → send-BFS32VDO.js} +9 -9
- package/dist/{sessions-E5OEZF2C.js → sessions-Q5EVPLLK.js} +23 -23
- package/dist/{show-AQQDICKX.js → show-JYXEQQM2.js} +7 -7
- package/dist/{snooze-LXHYYV5G.js → snooze-YDBFRJYB.js} +8 -8
- package/dist/{start-OCGLP6N6.js → start-KWQLMKAL.js} +8 -8
- package/dist/{state-FSZ6TIYE.js → state-NXTIYKP5.js} +2 -2
- package/dist/{status-35FEMHVO.js → status-ROO4SRGQ.js} +10 -10
- package/dist/{statusline-WEZSDGOU.js → statusline-AMFMWPTV.js} +3 -3
- package/dist/{stop-6QOVDV2A.js → stop-FMBFJUXI.js} +8 -8
- package/dist/{sync-GEG3O54C.js → sync-2DVHV7FT.js} +26 -26
- package/dist/{time-UXSYQHN4.js → time-LMBQVMQG.js} +13 -13
- package/dist/time-LMBQVMQG.js.map +1 -0
- package/dist/{time-actions-3KLS5WGD.js → time-actions-4GZLAV4C.js} +3 -3
- package/dist/{timesheet-RNUTAWR4.js → timesheet-DWWIBU5Y.js} +12 -12
- package/dist/{todo-MP4WUDMW.js → todo-SECMZCGC.js} +2 -2
- package/dist/{tree-U2LS4NHP.js → tree-NH43RR6O.js} +29 -29
- package/dist/tree-NH43RR6O.js.map +1 -0
- package/dist/{update-PHTB3AB5.js → update-THIANISA.js} +14 -14
- package/dist/{usage-2Z7354NZ.js → usage-CZZOI34H.js} +8 -8
- package/dist/{version-G2HN4GTL.js → version-2YUMQ4EN.js} +4 -4
- package/dist/{wait-MEMUQGDV.js → wait-QBBM7MR5.js} +9 -9
- package/dist/wd-bin.js +3 -3
- package/dist/web/assets/{PtyView-CyqsvkBt.js → PtyView-8godLDSh.js} +2 -2
- package/dist/web/assets/{PtyView-CyqsvkBt.js.map → PtyView-8godLDSh.js.map} +1 -1
- package/dist/web/assets/index-C0ZT-YWI.js +126 -0
- package/dist/web/assets/index-C0ZT-YWI.js.map +1 -0
- package/dist/web/assets/index-CBymxw_N.css +1 -0
- package/dist/web/index.html +2 -2
- package/dist/{web-P7TKPZFB.js → web-FT3AEB3E.js} +249 -87
- package/dist/web-FT3AEB3E.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/chunk-4ZP6NN2X.js.map +0 -1
- package/dist/chunk-5LAFHPNB.js.map +0 -1
- package/dist/chunk-BZGIKO6I.js.map +0 -1
- package/dist/chunk-DBGHDWM7.js.map +0 -1
- package/dist/chunk-FNWPOM4B.js.map +0 -1
- package/dist/chunk-OX33X3NH.js +0 -9
- package/dist/chunk-QMHFXIMX.js.map +0 -1
- package/dist/chunk-R6KQDWHC.js.map +0 -1
- package/dist/time-UXSYQHN4.js.map +0 -1
- package/dist/tree-U2LS4NHP.js.map +0 -1
- package/dist/web/assets/index-DXP8G0eh.css +0 -1
- package/dist/web/assets/index-DjFmAhbY.js +0 -126
- package/dist/web/assets/index-DjFmAhbY.js.map +0 -1
- package/dist/web-P7TKPZFB.js.map +0 -1
- /package/dist/{account-X42JQCYT.js.map → account-MYGAXTF6.js.map} +0 -0
- /package/dist/{add-repo-UZHIG6LN.js.map → add-repo-7PLONSB6.js.map} +0 -0
- /package/dist/{answer-NDX2DNXK.js.map → answer-H3D6OLHJ.js.map} +0 -0
- /package/dist/{attach-ETPEGXYM.js.map → attach-Z2HEZVZW.js.map} +0 -0
- /package/dist/{block-5HJQWQNX.js.map → block-BWRLOTSM.js.map} +0 -0
- /package/dist/{broadcast-TMCWRTIY.js.map → broadcast-RY6NAYGN.js.map} +0 -0
- /package/dist/{catchup-BBJ43GWY.js.map → catchup-K5ICNWDH.js.map} +0 -0
- /package/dist/{chunk-XMKYQVJU.js.map → chunk-2CVBAJH7.js.map} +0 -0
- /package/dist/{chunk-O32OINY3.js.map → chunk-2H3H23W5.js.map} +0 -0
- /package/dist/{chunk-TZLCBDJZ.js.map → chunk-2L2TNYQA.js.map} +0 -0
- /package/dist/{chunk-K2OOUNXH.js.map → chunk-3JANKWY2.js.map} +0 -0
- /package/dist/{chunk-JVJ5IJSF.js.map → chunk-3L5VDONX.js.map} +0 -0
- /package/dist/{chunk-OX33X3NH.js.map → chunk-3TNVVBVG.js.map} +0 -0
- /package/dist/{chunk-UCNYEHQY.js.map → chunk-4HNMJIUZ.js.map} +0 -0
- /package/dist/{chunk-R5HG665I.js.map → chunk-4YO2PDUC.js.map} +0 -0
- /package/dist/{chunk-2PAHTJ3B.js.map → chunk-63NT2NZD.js.map} +0 -0
- /package/dist/{chunk-C6OEPSH2.js.map → chunk-C5F36EGT.js.map} +0 -0
- /package/dist/{chunk-GPLCT5TZ.js.map → chunk-CJQPKHDO.js.map} +0 -0
- /package/dist/{chunk-4WTY3SFZ.js.map → chunk-EQJZ2GXX.js.map} +0 -0
- /package/dist/{chunk-MZY557LZ.js.map → chunk-EVZUJLZH.js.map} +0 -0
- /package/dist/{chunk-ITY6R2LC.js.map → chunk-EX6ELNTN.js.map} +0 -0
- /package/dist/{chunk-CVTM4TCZ.js.map → chunk-GT3KUREW.js.map} +0 -0
- /package/dist/{chunk-CYUSOVO5.js.map → chunk-H3WBTKPB.js.map} +0 -0
- /package/dist/{chunk-2IDWQ5NO.js.map → chunk-HT52LVYU.js.map} +0 -0
- /package/dist/{chunk-3YON263F.js.map → chunk-HWMQV4YD.js.map} +0 -0
- /package/dist/{chunk-QHA4VF4B.js.map → chunk-I5YQ7AC5.js.map} +0 -0
- /package/dist/{chunk-KCYYIUUQ.js.map → chunk-LBPYBBXX.js.map} +0 -0
- /package/dist/{chunk-ZNGR2CB6.js.map → chunk-LMD2J2JN.js.map} +0 -0
- /package/dist/{chunk-LMP3WGRW.js.map → chunk-MH4D37RT.js.map} +0 -0
- /package/dist/{chunk-UIIEP6VP.js.map → chunk-N5P2OY5O.js.map} +0 -0
- /package/dist/{chunk-AHGMXBY3.js.map → chunk-NIAXRF5E.js.map} +0 -0
- /package/dist/{chunk-BRUYXYO2.js.map → chunk-O2IARWVM.js.map} +0 -0
- /package/dist/{chunk-S2MOK3CT.js.map → chunk-OA3TYOAY.js.map} +0 -0
- /package/dist/{chunk-EQD3YBGA.js.map → chunk-P5633SI2.js.map} +0 -0
- /package/dist/{chunk-WNWSO4VO.js.map → chunk-PJPYRXKJ.js.map} +0 -0
- /package/dist/{chunk-QP7VLMFJ.js.map → chunk-QTUYNY3F.js.map} +0 -0
- /package/dist/{chunk-6SYQQXPQ.js.map → chunk-QUL26RYB.js.map} +0 -0
- /package/dist/{chunk-FIEBI3UB.js.map → chunk-RJAGFLAP.js.map} +0 -0
- /package/dist/{chunk-X6EMCJ2L.js.map → chunk-SMARTMBW.js.map} +0 -0
- /package/dist/{chunk-U64SNFIZ.js.map → chunk-SRGOCF73.js.map} +0 -0
- /package/dist/{chunk-7QDZGVIT.js.map → chunk-SSXKC635.js.map} +0 -0
- /package/dist/{chunk-MXH7DV4Q.js.map → chunk-SWAFQ343.js.map} +0 -0
- /package/dist/{chunk-Z3OHGPIN.js.map → chunk-TLXZUE4T.js.map} +0 -0
- /package/dist/{chunk-PSFOA7P6.js.map → chunk-UAXKMJYA.js.map} +0 -0
- /package/dist/{chunk-UJWYQVXI.js.map → chunk-VHYFFFZU.js.map} +0 -0
- /package/dist/{chunk-46WW3Z6C.js.map → chunk-WMIQOBHU.js.map} +0 -0
- /package/dist/{chunk-OL7S2KFH.js.map → chunk-X2EMWCFQ.js.map} +0 -0
- /package/dist/{chunk-RXORNKSJ.js.map → chunk-XHUKX3HO.js.map} +0 -0
- /package/dist/{chunk-7S3NPGVM.js.map → chunk-XHVRFFOY.js.map} +0 -0
- /package/dist/{chunk-XPWWOR7Z.js.map → chunk-XIOGNTUA.js.map} +0 -0
- /package/dist/{chunk-TI6AR4QF.js.map → chunk-YLB2QGAR.js.map} +0 -0
- /package/dist/{chunk-EQFDUC6F.js.map → chunk-Z3HC36JK.js.map} +0 -0
- /package/dist/{chunk-BWUN33QN.js.map → chunk-ZAAWSVTU.js.map} +0 -0
- /package/dist/{chunk-REAZAE5C.js.map → chunk-ZWBXRP2V.js.map} +0 -0
- /package/dist/{chunk-MVME4LH7.js.map → chunk-ZXDRQ2MV.js.map} +0 -0
- /package/dist/{cleanup-BD44PDRE.js.map → cleanup-HXZ4S2IO.js.map} +0 -0
- /package/dist/{cli-OMADLGGY.js.map → cli-M6RBYAO6.js.map} +0 -0
- /package/dist/{color-IZ2J3CT2.js.map → color-E73MIJWD.js.map} +0 -0
- /package/dist/{config-65HXBCMW.js.map → config-24BNXN5C.js.map} +0 -0
- /package/dist/{diff-CJNSUX25.js.map → diff-NAL5334E.js.map} +0 -0
- /package/dist/{digest-FH3JBHSO.js.map → digest-NU6XNA7D.js.map} +0 -0
- /package/dist/{fork-O6NS34MV.js.map → fork-QVFWYP2Z.js.map} +0 -0
- /package/dist/{history-URHFR4MO.js.map → history-W5DQNAY3.js.map} +0 -0
- /package/dist/{hook-6PWP3JVL.js.map → hook-OIAJHLTJ.js.map} +0 -0
- /package/dist/{hydrate-V6PVQ6OO.js.map → hydrate-VAJO2JGT.js.map} +0 -0
- /package/dist/{init-SENRHJ4R.js.map → init-2IHQUZ4E.js.map} +0 -0
- /package/dist/{install-skills-DJE7LU66.js.map → install-skills-RJPZOV37.js.map} +0 -0
- /package/dist/{keep-M7E7UMRL.js.map → keep-IJDON5AL.js.map} +0 -0
- /package/dist/{list-YPKCU3GB.js.map → list-6LPLVUUD.js.map} +0 -0
- /package/dist/{move-ME7JMNJI.js.map → move-GY5G47JO.js.map} +0 -0
- /package/dist/{note-JFZ3F7UY.js.map → note-6Q3AT7W6.js.map} +0 -0
- /package/dist/{overlaps-ZN3WA35A.js.map → overlaps-JQVWZXEB.js.map} +0 -0
- /package/dist/{pin-3S2MQQPM.js.map → pin-MIWOAQ7R.js.map} +0 -0
- /package/dist/{pr-KNJ2TVC3.js.map → pr-3F3PJCQN.js.map} +0 -0
- /package/dist/{prune-2GAXXNPM.js.map → prune-RKQQWEU6.js.map} +0 -0
- /package/dist/{pty-host-WZZIQIKX.js.map → pty-host-5GYGW43F.js.map} +0 -0
- /package/dist/{read-UIV42F5D.js.map → read-RFLYBHLU.js.map} +0 -0
- /package/dist/{recent-SJPAIY2T.js.map → recent-R24GG3OG.js.map} +0 -0
- /package/dist/{remove-KQW35I5D.js.map → remove-ULIYLBRK.js.map} +0 -0
- /package/dist/{restart-7VTSNTZ3.js.map → restart-VKQEQEU3.js.map} +0 -0
- /package/dist/{resume-MPBXIF7C.js.map → resume-LE3SXWGI.js.map} +0 -0
- /package/dist/{review-IRVOI4ZK.js.map → review-QGBSWK2M.js.map} +0 -0
- /package/dist/{review-now-QAAL5C6N.js.map → review-now-74ISYEFP.js.map} +0 -0
- /package/dist/{run-2EKY2R5R.js.map → run-RXCZSZKP.js.map} +0 -0
- /package/dist/{screen-GQTKTUTD.js.map → screen-27WNAGP5.js.map} +0 -0
- /package/dist/{search-N7XUYKYV.js.map → search-OSNZYFMI.js.map} +0 -0
- /package/dist/{section-6MDCSJS5.js.map → section-HIYOC5HZ.js.map} +0 -0
- /package/dist/{send-32U465SB.js.map → send-BFS32VDO.js.map} +0 -0
- /package/dist/{sessions-E5OEZF2C.js.map → sessions-Q5EVPLLK.js.map} +0 -0
- /package/dist/{show-AQQDICKX.js.map → show-JYXEQQM2.js.map} +0 -0
- /package/dist/{snooze-LXHYYV5G.js.map → snooze-YDBFRJYB.js.map} +0 -0
- /package/dist/{start-OCGLP6N6.js.map → start-KWQLMKAL.js.map} +0 -0
- /package/dist/{state-FSZ6TIYE.js.map → state-NXTIYKP5.js.map} +0 -0
- /package/dist/{status-35FEMHVO.js.map → status-ROO4SRGQ.js.map} +0 -0
- /package/dist/{statusline-WEZSDGOU.js.map → statusline-AMFMWPTV.js.map} +0 -0
- /package/dist/{stop-6QOVDV2A.js.map → stop-FMBFJUXI.js.map} +0 -0
- /package/dist/{sync-GEG3O54C.js.map → sync-2DVHV7FT.js.map} +0 -0
- /package/dist/{time-actions-3KLS5WGD.js.map → time-actions-4GZLAV4C.js.map} +0 -0
- /package/dist/{timesheet-RNUTAWR4.js.map → timesheet-DWWIBU5Y.js.map} +0 -0
- /package/dist/{todo-MP4WUDMW.js.map → todo-SECMZCGC.js.map} +0 -0
- /package/dist/{update-PHTB3AB5.js.map → update-THIANISA.js.map} +0 -0
- /package/dist/{usage-2Z7354NZ.js.map → usage-CZZOI34H.js.map} +0 -0
- /package/dist/{version-G2HN4GTL.js.map → version-2YUMQ4EN.js.map} +0 -0
- /package/dist/{wait-MEMUQGDV.js.map → wait-QBBM7MR5.js.map} +0 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moberg_hr/work-tree",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@moberg_hr/work-tree",
|
|
9
|
-
"version": "2.
|
|
9
|
+
"version": "2.17.0",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/git/base-spec.ts","../src/core/worktree/worktree.ts","../src/core/archive/archive-restore.ts","../src/core/archive/archive-ignored.ts","../src/core/worktree/session-instructions.ts","../src/core/worktree/copy-files.ts"],"sourcesContent":["/**\n * Parsing for `work tree --base`. A base can be specified two ways, and\n * they compose:\n *\n * --base dev → default base for every repo\n * --base backend=dev --base front=x → per-repo overrides\n * --base dev --base front=x → dev for all, front overridden to x\n *\n * yargs collects repeated `--base` flags into an array (a single flag stays\n * a string), so this accepts `string | string[] | undefined`.\n */\n\nexport interface BaseSpec {\n /** Base applied to any repo without a per-repo override. */\n default?: string;\n /** alias → base branch overrides. */\n perRepo: Record<string, string>;\n}\n\n/** Thrown by {@link parseBaseSpec} on malformed or conflicting input. */\nexport class BaseSpecError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'BaseSpecError';\n }\n}\n\n/**\n * Parse raw `--base` values into a {@link BaseSpec}. A value containing `=`\n * is treated as an `alias=branch` override; anything else is a bare default.\n * Throws {@link BaseSpecError} on empty halves or conflicting duplicates.\n */\nexport function parseBaseSpec(raw: string | string[] | undefined): BaseSpec {\n const spec: BaseSpec = { perRepo: {} };\n if (raw === undefined) return spec;\n const values = Array.isArray(raw) ? raw : [raw];\n\n for (const value of values) {\n const v = value.trim();\n if (!v) continue;\n const eq = v.indexOf('=');\n if (eq === -1) {\n if (spec.default !== undefined && spec.default !== v) {\n throw new BaseSpecError(`Conflicting default --base values: '${spec.default}' and '${v}'`);\n }\n spec.default = v;\n } else {\n const alias = v.slice(0, eq).trim();\n const branch = v.slice(eq + 1).trim();\n if (!alias || !branch) {\n throw new BaseSpecError(`Invalid --base '${value}'. Use 'alias=branch' or a bare 'branch'.`);\n }\n const prior = spec.perRepo[alias];\n if (prior !== undefined && prior !== branch) {\n throw new BaseSpecError(`Conflicting --base for '${alias}': '${prior}' and '${branch}'`);\n }\n spec.perRepo[alias] = branch;\n }\n }\n\n return spec;\n}\n\n/** The resolved base for one repo alias: its override, else the default. */\nexport function baseForAlias(spec: BaseSpec, alias: string): string | undefined {\n return spec.perRepo[alias] ?? spec.default;\n}\n\n/** True when no base was requested at all (plain HEAD-fork behavior). */\nexport function isEmptyBaseSpec(spec: BaseSpec): boolean {\n return spec.default === undefined && Object.keys(spec.perRepo).length === 0;\n}\n\n/** The alias keys carrying a per-repo override. */\nexport function baseSpecOverrideAliases(spec: BaseSpec): string[] {\n return Object.keys(spec.perRepo);\n}\n\n/** Normalize the loose `setupWorktree` parameter into a {@link BaseSpec}. */\nexport function toBaseSpec(base: string | BaseSpec | undefined): BaseSpec {\n if (base === undefined) return { perRepo: {} };\n if (typeof base === 'string') return { default: base, perRepo: {} };\n return base;\n}\n","import fs from 'node:fs';\nimport { agentFor } from '../agents/index.js';\nimport { DEFAULT_ACCOUNT, getConfigDir } from '../platform/config.js';\nimport { restoreArchivedIgnored, restoreArchivedUncommitted } from '../archive/archive-restore.js';\nimport { isLeftover, putLeftoverBack, setLeftoverAside, takeLeftover } from './leftover.js';\nimport path from 'node:path';\nimport { debug } from '../platform/logger.js';\nimport type { WorkConfig } from '../platform/config.js';\nimport type { WorktreeSession } from '../sessions/session-types.js';\nimport { resolveProjectTarget } from './resolve.js';\nimport {\n findSession,\n loadHistory,\n upsertSession,\n upsertSessionWithPort,\n setSessionTitle,\n forgetOtherBaseCheckoutEntries,\n} from '../sessions/history.js';\nimport { bestEffort } from '../platform/best-effort.js';\nimport { recordCheckedOutBranches } from '../sessions/session-branches.js';\nimport { isFolderSession, recordedRepos, sessionRepos, type SessionRepo } from '../sessions/session-repos.js';\nimport { hasInstructionsBlock, writeSessionInstructions } from './session-instructions.js';\nimport { sessionFolderPath } from './session-folder.js';\nimport { readArchive, restoreArchivedTranscripts } from '../archive/session-archive.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport {\n git,\n parseWorktreeList,\n localBranchExists,\n remoteBranchExists,\n isGitRepo,\n getCurrentBranch,\n getStatusChecked,\n repoState,\n getUnpushedCommits,\n fetchRemoteAsync,\n} from '../git/git.js';\nimport { copyConfigFiles } from './copy-files.js';\nimport { type BaseSpec, baseForAlias, baseSpecOverrideAliases, isEmptyBaseSpec, toBaseSpec } from '../git/base-spec.js';\nimport { report } from '../platform/report.js';\nimport { makeFolder, worktreeFolderMessage } from './worktrees-root.js';\n\n/**\n * Pull latest changes for a checkout we're switching into (a worktree that\n * already existed, or the base repo). Runs fetch + pull in that directory.\n * Best-effort: a branch with no upstream is skipped silently; a failed pull\n * (dirty tree, conflicts) only warns and never blocks the switch.\n */\nexport function pullLatestForBranch(worktreePath: string, branchName: string): void {\n // Skip purely local branches — `git pull` would print a \"no tracking\n // information\" error that reads as a failure rather than a no-op.\n const upstream = git(['rev-parse', '--abbrev-ref', `${branchName}@{upstream}`], worktreePath);\n if (upstream.exitCode !== 0) return;\n\n report('info', ` Pulling latest changes for ${branchName}...`);\n // Fetch first so origin/* is fresh even if the pull below can't fast-forward.\n git(['fetch', '--quiet'], worktreePath);\n const pull = git(['pull', '--quiet'], worktreePath);\n if (pull.exitCode !== 0) {\n report('warn', ` ⚠ Could not pull '${branchName}' (uncommitted changes or conflicts). Worktree may be behind origin.`);\n const firstErrLine = pull.stderr.split('\\n')[0];\n if (firstErrLine) report('detail', ` ${firstErrLine}`);\n }\n}\n\n/**\n * `git worktree add` writing its files in parallel, one worker per core\n * (`checkout.workers=0`): measured on this repo's shape (5,128 files) on\n * Windows, 6-8.6 s became 2 s. A git without parallel checkout ignores it.\n */\nconst WORKTREE_ADD = ['-c', 'checkout.workers=0', 'worktree', 'add'];\n\n/**\n * The freshest of a branch's two copies, for a new branch to start from: the\n * local one when it has commits origin lacks (yours), else `origin/<branch>`\n * when that is ahead — so a base that was never pulled (`--base main` with\n * `main` not checked out) doesn't fork weeks back. Null when neither exists.\n */\nexport function freshestRef(repoPath: string, branch: string): string | null {\n const local = git(['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`], repoPath).stdout;\n const remote = git(['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branch}`], repoPath).stdout;\n if (!local) return remote ? `origin/${branch}` : null;\n if (!remote || local === remote) return branch;\n // Behind (an ancestor of origin's): origin's is the same work and more.\n return git(['merge-base', '--is-ancestor', local, remote], repoPath).exitCode === 0 ? `origin/${branch}` : branch;\n}\n\n/**\n * Bring a local branch up to its published copy, `origin/<branch>` (after a\n * fetch), by moving its ref: a fast-forward only, nothing checked out. Not\n * `@{upstream}`: work leaves new branches tracking their base (`origin/main`),\n * which is not the branch's own work. A branch never pushed, or already\n * there, is left as it is; one with commits origin's lacks (diverged) is left\n * too, with a warning, and so is one git can't compare or move. Returns what\n * it did.\n */\nexport function fastForwardBranch(repoPath: string, branchName: string): 'none' | 'current' | 'forwarded' | 'diverged' | 'failed' {\n const remote = git(['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branchName}`], repoPath).stdout;\n if (!remote) return 'none';\n const local = git(['rev-parse', '--verify', '--quiet', `refs/heads/${branchName}`], repoPath).stdout;\n if (!local || local === remote) return 'current';\n const ancestor = git(['merge-base', '--is-ancestor', local, remote], repoPath).exitCode;\n if (ancestor === 1) {\n report('warn', ` ⚠ '${branchName}' has commits origin/${branchName} lacks: not updated. The worktree may be behind origin.`);\n return 'diverged';\n }\n if (ancestor !== 0) {\n report('warn', ` ⚠ Couldn't compare '${branchName}' with origin/${branchName}: not updated. The worktree may be behind origin.`);\n return 'failed';\n }\n report('info', ` Bringing ${branchName} up to date with origin/${branchName}...`);\n const moved = git(['update-ref', `refs/heads/${branchName}`, remote, local], repoPath);\n if (moved.exitCode !== 0) {\n report(\n 'warn',\n ` ⚠ Couldn't move '${branchName}' to origin/${branchName} (${moved.stderr.split('\\n')[0] || 'update-ref failed'}). The worktree may be behind origin.`,\n );\n return 'failed';\n }\n return 'forwarded';\n}\n\n/**\n * Create a single git worktree for one repo.\n * Returns true on success, false on failure.\n *\n * When `baseBranch` is provided, the new branch is created from that base\n * instead of HEAD. Only valid for new branches — errors if the target branch\n * already exists locally or on remote.\n *\n * `pull` (default true) only affects the already-exists path: a freshly created\n * worktree is at its branch tip anyway.\n */\n/** Same folder: git prints forward slashes and long names on Windows, where a path may come as a short 8.3 name or in another case. */\nfunction samePath(a: string, b: string): boolean {\n const norm = (p: string) => {\n let r = path.resolve(p);\n try {\n r = fs.realpathSync.native(r);\n } catch {\n /* not there: as given */\n }\n return process.platform === 'win32' ? r.toLowerCase() : r;\n };\n return norm(a) === norm(b);\n}\n\nexport function createSingleWorktree(\n repoPath: string,\n worktreePath: string,\n branchName: string,\n config: WorkConfig,\n baseBranch?: string,\n pull = true,\n /** Its repo was fetched just now (a group fetches every repo at once first). */\n fetched = false,\n /** Told which branch a new branch was made from when no base was given (the main checkout's), so the session can record it. */\n created?: { from?: string },\n): boolean {\n debug('createSingleWorktree', { repoPath, worktreePath, branchName, baseBranch });\n\n // What a removal that stopped halfway left (a file in use): no longer a checkout, and in\n // git's way. Set aside; setupWorktree copies it back into the new worktree (leftover.ts).\n let aside: string | null = null;\n if (isLeftover(worktreePath)) {\n try {\n aside = setLeftoverAside(worktreePath);\n report('warn', ` ${worktreePath} was left half-removed (no git in it): making it again, its files set aside in ${aside}`);\n git(['worktree', 'prune'], repoPath);\n } catch (err) {\n report('error', ` ${(err as Error).message}`);\n return false;\n }\n }\n const made = makeSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch, pull, fetched, created);\n // It couldn't be made: the leftover goes back where it was, not stranded beside it.\n if (!made && aside && !fs.existsSync(worktreePath)) {\n try {\n fs.renameSync(aside, worktreePath);\n takeLeftover(worktreePath);\n } catch {\n report('warn', ` what was left of it is still at ${aside}`);\n }\n }\n return made;\n}\n\nfunction makeSingleWorktree(\n repoPath: string,\n worktreePath: string,\n branchName: string,\n config: WorkConfig,\n baseBranch: string | undefined,\n pull: boolean,\n fetched: boolean,\n created: { from?: string } | undefined,\n): boolean {\n // Check if the worktree already exists at the target path (idempotent re-run)\n if (fs.existsSync(worktreePath)) {\n if (isGitRepo(worktreePath)) {\n const currentBranch = getCurrentBranch(worktreePath);\n if (currentBranch === branchName) {\n // Coming back to it is the common case, not a warning (the dashboard shows warnings).\n report('info', ` Worktree already exists at: ${worktreePath}`);\n if (pull) pullLatestForBranch(worktreePath, branchName);\n return true;\n }\n // This repo's worktree, on another branch now (Claude or you switched\n // it): it is the session's checkout, used as it is. `git worktree add`\n // into it would fail, and re-entering or restoring the session with it.\n const ours = parseWorktreeList(repoPath).some((wt) => samePath(wt.path, worktreePath));\n if (ours) {\n report(\n 'warn',\n ` Worktree already exists at: ${worktreePath} (on ${currentBranch ?? 'a detached HEAD'}, not ${branchName}: using it as it is)`,\n );\n if (pull && currentBranch) pullLatestForBranch(worktreePath, currentBranch);\n return true;\n }\n }\n }\n\n // Check if the branch is already checked out in another worktree\n const worktrees = parseWorktreeList(repoPath);\n const existingForBranch = worktrees.find((wt) => wt.branch === branchName && wt.path !== worktreePath);\n\n if (existingForBranch) {\n report('error', ` Branch '${branchName}' is already checked out in a worktree at: ${existingForBranch.path}`);\n report('error', ' Remove that worktree first, or use the existing one.');\n return false;\n }\n\n // Create parent directory\n const parentDir = path.dirname(worktreePath);\n const cantMake = makeFolder(parentDir);\n if (cantMake) {\n report('error', worktreeFolderMessage(parentDir, config.worktreesRoot, cantMake));\n return false;\n }\n\n // Fetch remote refs first so origin/* is up to date even if pull fails below\n if (!fetched) git(['fetch', '--quiet'], repoPath);\n\n const hasLocal = localBranchExists(branchName, repoPath);\n const hasRemote = remoteBranchExists(branchName, repoPath);\n\n // --base requires a brand-new branch\n if (baseBranch && (hasLocal || hasRemote)) {\n report('error', ` Cannot use --base: branch '${branchName}' already exists ${hasLocal ? 'locally' : 'on remote'}`);\n return false;\n }\n\n // The main checkout is pulled only when the new branch starts from it: an\n // existing branch, or one from --base, doesn't need it (2-3 s a repo).\n const fromMainCheckout = !hasLocal && !hasRemote && !baseBranch;\n const baseRepoBranch = fromMainCheckout ? getCurrentBranch(repoPath) : null;\n let baseRepoPullFailed = false;\n if (fromMainCheckout) {\n const baseBranchLabel = baseRepoBranch ?? '(detached HEAD)';\n report('info', ` Pulling latest changes for main repo (on ${baseBranchLabel})...`);\n if (baseRepoBranch && !['master', 'main', 'dev'].includes(baseRepoBranch)) {\n // Where the new branch comes from, said; not a warning (a team on `develop` would see it on every worktree).\n report('detail', ` Note: base repo is on '${baseRepoBranch}', not master/main/dev`);\n }\n const baseRepoPull = git(['pull', '--quiet'], repoPath);\n baseRepoPullFailed = baseRepoPull.exitCode !== 0;\n if (baseRepoPullFailed) {\n report('warn', ` ⚠ Could not pull '${baseBranchLabel}' (uncommitted changes, conflicts, or no upstream).`);\n const firstErrLine = baseRepoPull.stderr.split('\\n')[0];\n if (firstErrLine) report('detail', ` ${firstErrLine}`);\n }\n }\n\n // An existing local branch: brought up to its upstream by moving its ref —\n // never by checking it out in the main checkout (that switched your checkout\n // twice, ~4 s each, and pulled branches that have no upstream at all).\n if (hasLocal) fastForwardBranch(repoPath, branchName);\n\n // Create worktree\n let result;\n let branchSource: 'local' | 'remote' | 'new' = 'new';\n if (hasLocal || hasRemote) {\n if (hasRemote && !hasLocal) {\n branchSource = 'remote';\n result = git([...WORKTREE_ADD, worktreePath, '-b', branchName, '--track', `origin/${branchName}`], repoPath);\n } else {\n branchSource = 'local';\n result = git([...WORKTREE_ADD, worktreePath, branchName], repoPath);\n }\n } else if (baseBranch) {\n // Validate the base branch exists\n const baseLocal = localBranchExists(baseBranch, repoPath);\n const baseRemote = remoteBranchExists(baseBranch, repoPath);\n\n if (!baseLocal && !baseRemote) {\n report('error', ` Base branch '${baseBranch}' does not exist locally or on remote`);\n return false;\n }\n\n // The freshest copy of the base: a local one nothing pulls (not checked out) can be far behind origin's.\n const baseRef = freshestRef(repoPath, baseBranch) ?? (baseLocal ? baseBranch : `origin/${baseBranch}`);\n result = git([...WORKTREE_ADD, worktreePath, '-b', branchName, baseRef], repoPath);\n } else {\n // If pulling the base repo branch failed, use origin/<baseRepoBranch> as the\n // source so the new branch isn't created from a stale local HEAD.\n const fallbackToRemote = baseRepoPullFailed && !!baseRepoBranch && remoteBranchExists(baseRepoBranch, repoPath);\n if (fallbackToRemote) {\n report('step', ` Using origin/${baseRepoBranch} as base (local '${baseRepoBranch}' is stale)`);\n result = git([...WORKTREE_ADD, worktreePath, '-b', branchName, `origin/${baseRepoBranch}`], repoPath);\n } else {\n result = git([...WORKTREE_ADD, worktreePath, '-b', branchName], repoPath);\n }\n }\n\n if (result.exitCode !== 0) {\n debug('git worktree add failed', { exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr });\n report('error', ' Failed to create worktree');\n if (result.stderr) {\n report('error', ` ${result.stderr}`);\n }\n return false;\n }\n\n // Copy configuration files from main repo\n if (config.copyFiles && config.copyFiles.length > 0) {\n copyConfigFiles(repoPath, worktreePath, config.copyFiles);\n }\n\n if (branchSource === 'remote') {\n report('step', ` Tracking remote branch origin/${branchName}`);\n } else if (branchSource === 'local') {\n report('step', ` Using existing local branch ${branchName}`);\n } else if (baseBranch) {\n report('step', ` Created new branch ${branchName} from ${baseBranch}`);\n } else {\n report('step', ` Created new branch ${branchName}${baseRepoBranch ? ` from ${baseRepoBranch}` : ''}`);\n if (created && baseRepoBranch) created.from = baseRepoBranch;\n }\n\n report('success', ` Created worktree: ${worktreePath}`);\n return true;\n}\n\n/**\n * Remove a single git worktree.\n * Returns true on success, false if blocked (uncommitted/unpushed changes).\n */\n/**\n * Would `removeSingleWorktree(…, force)` refuse this worktree? Same checks,\n * no side effects — lets callers stop the session's Claude only when the\n * worktree is really going away (a refused non-forced removal must leave\n * the running agent alone).\n */\nexport function wouldRefuseRemoval(worktreePath: string, force: boolean): boolean {\n if (force || !fs.existsSync(worktreePath)) return false;\n const state = repoState(worktreePath);\n if (state === 'not-a-repo') return false;\n if (state === 'unknown') return true; // git can't read it: can't prove it's safe\n const status = getStatusChecked(worktreePath);\n if (status === null) return true;\n return !!status || !!getUnpushedCommits(worktreePath);\n}\n\n/**\n * git got through its checks and failed while deleting the files (a path too\n * long for Windows, a file another program holds) — as opposed to refusing\n * (\"contains modified or untracked files\", \"is locked\").\n */\nexport function isDeleteFailure(stderr: string): boolean {\n return /failed to delete/i.test(stderr);\n}\n\nexport function removeSingleWorktree(repoPath: string, worktreePath: string, branchName: string, force: boolean): boolean {\n if (!fs.existsSync(worktreePath)) {\n report('warn', ` Worktree does not exist at: ${worktreePath}`);\n return true; // Nothing to remove is success\n }\n\n // A folder that is definitely not a git checkout (a leftover) is just\n // deleted. One git merely failed to read is NOT: without --force it's\n // refused, because every check below would read as \"clean\".\n const state = repoState(worktreePath);\n if (state === 'not-a-repo') {\n fs.rmSync(worktreePath, { recursive: true, force: true });\n git(['worktree', 'prune'], repoPath);\n report('info', ` Removed invalid worktree directory: ${worktreePath}`);\n return true;\n }\n if (state === 'unknown' && !force) {\n report(\n 'warn',\n ` git can't read ${worktreePath} (ownership, a moved main repo, git not on PATH?) — not removing it. Check it, or use --force.`,\n );\n return false;\n }\n\n if (!force) {\n // Check for uncommitted changes\n const status = getStatusChecked(worktreePath);\n if (status === null) {\n report('warn', ` Could not check ${worktreePath} for uncommitted changes — not removing it.`);\n return false;\n }\n if (status) {\n report('warn', ` Uncommitted changes in: ${worktreePath}`);\n report('info', status);\n return false;\n }\n\n // Check for unpushed commits\n const unpushed = getUnpushedCommits(worktreePath);\n if (unpushed) {\n report('warn', ` Unpushed commits in: ${worktreePath}`);\n report('info', unpushed);\n return false;\n }\n }\n\n // core.longpaths: a worktree's node_modules / bin / obj easily pass\n // Windows' 260-character limit, and without it git stops half way with\n // \"Filename too long\" (a no-op elsewhere).\n const args = force\n ? ['-c', 'core.longpaths=true', 'worktree', 'remove', worktreePath, '--force']\n : ['-c', 'core.longpaths=true', 'worktree', 'remove', worktreePath];\n\n const result = git(args, repoPath);\n\n if (result.exitCode === 0) {\n report('success', ` Removed worktree: ${worktreePath}`);\n return true;\n } else if (isDeleteFailure(result.stderr)) {\n // git had passed its own checks (and ours above) and failed while\n // deleting files: finish the delete ourselves — Node handles long paths —\n // then let git forget the registration. A git REFUSAL never gets here.\n try {\n fs.rmSync(worktreePath, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 });\n } catch (err) {\n report('error', ` Failed to remove worktree: ${worktreePath}`);\n report('error', ` ${(err as Error).message}`);\n return false;\n }\n git(['worktree', 'prune'], repoPath);\n const why = result.stderr.split('\\n')[0].replace(/^error:\\s*/, '');\n report('success', ` Removed worktree: ${worktreePath} (finished the delete git could not: ${why})`);\n return true;\n } else if (force && state === 'unknown') {\n // git can't handle it (its main repo moved, say) and the user forced\n // it: delete the folder, then let git forget the registration.\n fs.rmSync(worktreePath, { recursive: true, force: true });\n git(['worktree', 'prune'], repoPath);\n report('success', ` Removed worktree folder git could not read: ${worktreePath}`);\n return true;\n } else {\n report('error', ` Failed to remove worktree: ${worktreePath}`);\n if (result.stderr) {\n report('error', ` ${result.stderr}`);\n }\n return false;\n }\n}\n\n/** Caller-tunable behavior for {@link setupWorktree}. */\nexport interface WorktreeSetupOptions {\n /**\n * Pull latest changes when switching into a worktree that already exists.\n * Default true; `work tree --no-pull` turns it off.\n */\n pull?: boolean;\n /**\n * Per repo alias: the branch to check out instead of the session's — set\n * when restoring an archived session whose worktree was removed while on\n * another branch (archive.json `heads`). The folder keeps the session's name.\n */\n checkoutFor?: Record<string, string>;\n /** Name the session (its title, shown instead of the branch); empty keeps what it has. */\n name?: string;\n /**\n * A NEW session's repos (aliases), instead of its group's config: a fork of\n * a session folder takes the parent's own list, which may hold a repo the\n * group doesn't name. Given, the session is made as a folder. An existing\n * session keeps the repos (and layout) it records.\n */\n repos?: string[];\n /**\n * The Claude account a NEW session runs on (a name from config `claudeAccounts`, or `default`); unset: the configured\n * default. An unknown name is refused before anything is made. An existing session keeps the account it has.\n */\n account?: string;\n}\n\n/**\n * Result of setupWorktree — everything needed to launch an AI session.\n */\nexport interface WorktreeSetupResult {\n /** Directory to launch the AI tool in. */\n launchDir: string;\n /** All worktree paths created/found (for session tracking). */\n paths: string[];\n /** Whether the target is a group. */\n isGroup: boolean;\n /** Stable dev-server port allocated to this worktree, if allocation succeeded. */\n port?: number;\n}\n\n/**\n * Why a new session can't run on `account` (a message), or null: the name must be one of the configured agent's\n * accounts (its adapter's `accounts` part); an agent without accounts takes only the default (a fork of one passes it).\n */\nexport function accountRefusal(account: string | undefined, config: WorkConfig): string | null {\n if (account === undefined) return null;\n const agent = agentFor(config);\n if (!agent.accounts) return account === DEFAULT_ACCOUNT ? null : `${agent.name} has no accounts: “${account}” can't be used`;\n return agent.accounts.has(account) ? null : `Unknown ${agent.name} account: ${account} (see \\`work account list\\`)`;\n}\n\n/**\n * High-level worktree setup: resolve target, create worktree(s), copy group\n * CLAUDE.md, and record the session. Used by both the CLI command and the TUI.\n *\n * Returns the setup result on success, or null on failure.\n */\nexport async function setupWorktree(\n targetName: string,\n branchName: string,\n config: WorkConfig,\n base?: string | BaseSpec,\n jiraKey?: string,\n opts: WorktreeSetupOptions = {},\n): Promise<WorktreeSetupResult | null> {\n const spec = toBaseSpec(base);\n debug('setupWorktree', { targetName, branchName, spec, jiraKey, opts });\n const target = resolveProjectTarget(targetName, config);\n if (!target) {\n debug('setupWorktree: target not found', targetName);\n return null;\n }\n\n // A name that isn't an account is refused first, before any git: a session recorded on it couldn't start.\n const accountRefused = accountRefusal(opts.account, config);\n if (accountRefused) {\n report('error', accountRefused);\n return null;\n }\n\n const workTreeDirName = branchName.replace(/\\//g, '-');\n const sessionTarget = target.isGroup ? target.name : targetName;\n // A repo's session made as a folder (config `sessionFolders`, or one recorded so): set\n // up as a group of its own repos, in its session folder (session-folder.ts: `<root>/<branch>-<id6>/<repo-folder>/`).\n const explicit = explicitRepos(sessionTarget, branchName, opts.repos, config);\n if (explicit && 'error' in explicit) {\n report('error', explicit.error);\n return null;\n }\n const asFolder = target.isGroup || !!explicit || folderSessionFor(targetName, branchName, config);\n // Its repos: coming back to a session that records its own (it may hold a repo its\n // group's config doesn't name, or one the group lost), those; else the ones asked\n // for (a new session's), else the group's config.\n const repoAliases = asFolder\n ? groupReposFor(sessionTarget, branchName, explicit?.repos ?? target.repoAliases, config)\n : target.repoAliases;\n if (asFolder && repoAliases.length === 0) {\n report('error', `none of this session's repos are in your config: add them back (work config add) to open it`);\n return null;\n }\n\n // Coming back to an archived session whose merged branch archiving\n // deleted: put the branch back at the tip it had, so the worktree is that\n // work (branch resolution would otherwise start a new branch from base).\n bestEffort('recreate the archived branch', () => recreateArchivedBranches(sessionTarget, branchName, repoAliases, config));\n // And its worktree comes back on the branch it was on (Claude may have\n // switched from the session's), not a new one of the session's name.\n const checkoutFor = opts.checkoutFor ?? archivedHeads(sessionTarget, branchName);\n if (checkoutFor) opts = { ...opts, checkoutFor };\n\n const result = asFolder\n ? await setupGroupWorktree(sessionTarget, repoAliases, branchName, config, spec, jiraKey, opts)\n : await setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey, opts);\n // Coming back to an archived session: put its conversation back where\n // Claude looks for it (only files that aren't there), so it continues.\n if (result) {\n const session = findSession(loadHistory(), sessionTarget, branchName);\n if (session) bestEffort('restore the archived conversation', () => restoreArchivedTranscripts(session), 0);\n // And the uncommitted work archiving saved when it removed the worktree.\n if (session)\n await restoreArchivedUncommitted(session, config).catch((err: Error) =>\n report('warn', `couldn't put back its uncommitted changes: ${err.message}`),\n );\n // Its git-ignored files (local settings, the editor's state) archiving kept.\n if (session) bestEffort('put back its local settings', () => restoreArchivedIgnored(session, config));\n // And what was left of a half-removed worktree: over the checkout, or — when the\n // archive's save already put its changes back — only the files that aren't there.\n const tips = session ? (readArchive(sessionIdFor(session))?.tips ?? {}) : {};\n for (const p of result.paths) {\n // Its repo: a group's worktrees are named after the repo's folder, a single repo's is the target.\n const alias = asFolder\n ? repoAliases.find((a) => path.basename(config.repos[a] ?? '').toLowerCase() === path.basename(p).toLowerCase())\n : targetName;\n putBackLeftover(p, alias ? tips[alias] : undefined);\n }\n if (opts.name?.trim()) await setSessionTitle(sessionTarget, branchName, opts.name);\n }\n return result;\n}\n\n/**\n * Whether a repo's session (`work tree <alias> <branch>`) is a session folder:\n * an existing session as it was made (a folder session records its repos and\n * `isGroup`; a single one keeps its layout whatever the switch says); a new one\n * when config `sessionFolders` is on — unless a worktree of the branch is there\n * already (made outside a session), which is reused as it always was.\n */\nfunction folderSessionFor(alias: string, branch: string, config: WorkConfig): boolean {\n const known = findSession(loadHistory(), alias, branch);\n if (known) return isFolderSession(known);\n if (config.sessionFolders !== true) return false;\n const repoPath = config.repos[alias];\n // Not there: the single-repo setup says so, as always.\n if (!repoPath || !fs.existsSync(repoPath)) return false;\n return !parseWorktreeList(repoPath).some((wt) => wt.branch === branch && path.resolve(wt.path) !== path.resolve(repoPath));\n}\n\n/**\n * The repos asked for a new session (`opts.repos`), checked against the\n * config; undefined when none were asked for, or the session exists already\n * (it keeps what it records — and its layout).\n */\nfunction explicitRepos(\n sessionTarget: string,\n branch: string,\n repos: string[] | undefined,\n config: WorkConfig,\n): { repos: string[] } | { error: string } | undefined {\n if (!repos?.length || findSession(loadHistory(), sessionTarget, branch)) return undefined;\n const unique = [...new Set(repos)];\n const unknown = unique.filter((a) => !config.repos[a]);\n if (unknown.length) return { error: `not in your config: ${unknown.join(', ')}` };\n const folders = unique.map((a) => path.basename(config.repos[a]).toLowerCase());\n if (new Set(folders).size !== folders.length) return { error: `two of these repos have the same folder name: ${unique.join(', ')}` };\n return { repos: unique };\n}\n\n/**\n * A group session's repos to set up: the ones an existing session records\n * (sessionRepos), else — a new session, or a row from before — the group's\n * config. A recorded repo no longer in the config can't be checked out: said, and skipped.\n */\nfunction groupReposFor(sessionTarget: string, branch: string, configured: string[], config: WorkConfig): string[] {\n const known = findSession(loadHistory(), sessionTarget, branch);\n // A list that is there but damaged is matched by folder name (listedRepos), never replaced by the config.\n const own = known ? listedRepos(known, config) : null;\n if (!own) return configured;\n const gone = own.filter((r) => !config.repos[r.alias]).map((r) => r.alias);\n if (gone.length) report('warn', `not in your config any more, so not set up: ${gone.join(', ')}`);\n return own.map((r) => r.alias).filter((a) => !gone.includes(a));\n}\n\n/** The same aliases, in any order (a new session made with the group's repos, or another list: a fork's). */\nconst sameRepos = (a: string[], b: string[]) => a.length === b.length && a.every((x) => b.includes(x));\n\n/** Copy a leftover set aside for this worktree (createSingleWorktree) back into it, and say how it went. */\nfunction putBackLeftover(worktree: string, tip: string | undefined): void {\n const aside = takeLeftover(worktree);\n if (!aside) return;\n // Over the checkout only when nothing else brought its changes back (clean) and the branch\n // is where it was when the folder was left (the archive's recorded tip): on a branch that\n // moved since, the leftover's copies of tracked files are older, and would undo newer work.\n const head = git(['rev-parse', 'HEAD'], worktree).stdout;\n const clean = git(['status', '--porcelain'], worktree).stdout === '';\n const r = putLeftoverBack(aside, worktree, { overwrite: clean && (!tip || tip === head) });\n if (r.failed.length)\n report(\n 'warn',\n `put back ${r.copied} file(s) left in the old folder; ${r.failed.length} couldn't be copied — they're still in ${aside}`,\n );\n else if (r.copied)\n report(\n 'info',\n `put back ${r.copied} file(s) left in the old folder${r.removed ? '' : ` (it's still at ${aside}: remove it when done)`}`,\n );\n else if (!r.removed) report('info', `nothing to put back from the old folder (still at ${aside}: remove it when done)`);\n}\n\n/**\n * For each repo whose local branch archiving deleted (archive.json\n * `branchesDeleted`): recreate it at the recorded tip when neither a local\n * nor a remote branch of that name exists and the commit is still there.\n * Returns the aliases it recreated the branch in.\n */\nexport function recreateArchivedBranches(sessionTarget: string, branch: string, aliases: string[], config: WorkConfig): string[] {\n const session = findSession(loadHistory(), sessionTarget, branch);\n if (!session) return [];\n const rec = readArchive(sessionIdFor(session));\n if (!rec?.tips || !rec.branchesDeleted?.length) return [];\n const done: string[] = [];\n for (const alias of aliases) {\n const repo = config.repos[alias];\n const tip = rec.tips[alias];\n // The branch it was on: the session's, or the one Claude switched to.\n const name = rec.heads?.[alias] ?? branch;\n if (!repo || !tip || !rec.branchesDeleted.includes(alias)) continue;\n if (localBranchExists(name, repo) || remoteBranchExists(name, repo)) continue;\n if (git(['cat-file', '-e', `${tip}^{commit}`], repo).exitCode !== 0) continue;\n if (git(['branch', name, tip], repo).exitCode === 0) done.push(alias);\n }\n return done;\n}\n\n/**\n * An archived session whose worktree was removed while (some of) its repos\n * were on another branch: alias → that branch, for setupWorktree to check\n * out. Undefined otherwise (the worktree was kept, or on the session's branch).\n */\nexport function archivedHeads(sessionTarget: string, branch: string): Record<string, string> | undefined {\n const session = findSession(loadHistory(), sessionTarget, branch);\n if (!session?.archivedAt) return undefined;\n const rec = readArchive(sessionIdFor(session));\n return rec?.worktreeRemoved && rec.heads && Object.keys(rec.heads).length ? rec.heads : undefined;\n}\n\nasync function setupGroupWorktree(\n groupName: string,\n repoAliases: string[],\n branchName: string,\n config: WorkConfig,\n spec: BaseSpec,\n jiraKey?: string,\n opts: WorktreeSetupOptions = {},\n): Promise<WorktreeSetupResult | null> {\n // `<root>/<branch>-<id6>/` for a new one with `sessionFolders` on, else `<root>/<group>/<branch>/`; an existing one where it is.\n const groupWorktreePath = sessionFolderPath(\n groupName,\n branchName,\n config,\n findSession(loadHistory(), groupName, branchName),\n fs.existsSync,\n );\n\n // Pre-validate --base across all repos before creating anything. Each repo\n // resolves its own base: a per-repo override (`alias=branch`) if present,\n // otherwise the bare default.\n if (!isEmptyBaseSpec(spec)) {\n const unknownAliases = baseSpecOverrideAliases(spec).filter((a) => !repoAliases.includes(a));\n if (unknownAliases.length > 0) {\n report(\n 'error',\n `--base names repo(s) not in group '${groupName}': ${unknownAliases.join(', ')}. Group repos: ${repoAliases.join(', ')}`,\n );\n return null;\n }\n\n const missingBase: string[] = [];\n const branchExists: string[] = [];\n\n for (const alias of repoAliases) {\n const repoPath = config.repos[alias];\n const repoBase = baseForAlias(spec, alias);\n if (!repoBase) continue; // no base applied to this repo → forks HEAD\n if (!localBranchExists(repoBase, repoPath) && !remoteBranchExists(repoBase, repoPath)) {\n missingBase.push(`${alias} (${repoBase})`);\n }\n if (localBranchExists(branchName, repoPath) || remoteBranchExists(branchName, repoPath)) {\n branchExists.push(alias);\n }\n }\n\n if (missingBase.length > 0) {\n report('error', `Base branch not found in: ${missingBase.join(', ')}`);\n return null;\n }\n if (branchExists.length > 0) {\n report('error', `Cannot use --base: branch '${branchName}' already exists in: ${branchExists.join(', ')}`);\n return null;\n }\n }\n\n const isConfiguredGroup = Object.prototype.hasOwnProperty.call(config.groups, groupName);\n report('step', `Creating ${isConfiguredGroup ? 'group worktree' : 'session folder'}: ${groupName}/${branchName}`);\n report('detail', `Directory: ${groupWorktreePath}`);\n report('info', '');\n\n const cantMake = makeFolder(groupWorktreePath);\n if (cantMake) {\n report('error', worktreeFolderMessage(groupWorktreePath, config.worktreesRoot, cantMake));\n return null;\n }\n\n const createdWorktrees: Array<{ repoPath: string; worktreePath: string }> = [];\n // Per-repo fork point, keyed by worktree path (matches the session `paths`).\n const baseBranches: Record<string, string> = {};\n\n // The repos whose worktree is new fetch at once (the network is most of a\n // repo's wait), then each is set up in turn without fetching again. One that\n // exists already isn't fetched here: re-entering pulls it (or, with\n // --no-pull, touches no network). A fetch that fails or times out (30 s)\n // leaves its repo to fetch for itself.\n const toCreate = repoAliases.filter((alias) => !fs.existsSync(path.join(groupWorktreePath, path.basename(config.repos[alias]))));\n const fetched = new Set<string>();\n if (toCreate.length > 1) {\n report('info', `Fetching ${toCreate.length} repos…`);\n await Promise.all(\n toCreate.map((alias) =>\n fetchRemoteAsync(config.repos[alias]).then(\n () => void fetched.add(alias),\n (err: Error) => debug('group fetch failed', { alias, error: err.message }),\n ),\n ),\n );\n }\n\n for (const alias of repoAliases) {\n const repoPath = config.repos[alias];\n const repoName = path.basename(repoPath);\n const subWorktreePath = path.join(groupWorktreePath, repoName);\n const repoBase = baseForAlias(spec, alias);\n const created: { from?: string } = {};\n\n report('step', `[${alias}] (${repoName}):`);\n const success = createSingleWorktree(\n repoPath,\n subWorktreePath,\n opts.checkoutFor?.[alias] ?? branchName,\n config,\n repoBase,\n opts.pull !== false,\n fetched.has(alias),\n created,\n );\n\n if (success) {\n createdWorktrees.push({ repoPath, worktreePath: subWorktreePath });\n // No --base: where its new branch came from (the main checkout's branch), so \"Since branch\" needn't guess.\n const from = repoBase ?? created.from;\n if (from) baseBranches[subWorktreePath] = from;\n } else {\n // Rollback\n report('info', '');\n report('warn', 'Rolling back created worktrees due to failure...');\n for (const wt of createdWorktrees) {\n removeSingleWorktree(wt.repoPath, wt.worktreePath, branchName, true);\n }\n try {\n if (fs.readdirSync(groupWorktreePath).length === 0) {\n fs.rmSync(groupWorktreePath, { recursive: true, force: true });\n }\n } catch {\n /* */\n }\n report('error', 'Failed to create group worktree. Changes have been rolled back.');\n return null;\n }\n }\n\n // Copy the group's instructions file, under the name its agent reads (CLAUDE.md, AGENTS.md…).\n const configDir = getConfigDir();\n const claudeMdSrc = path.join(configDir, `${groupName}.claude.md`);\n const known = findSession(loadHistory(), groupName, branchName);\n const agent = agentFor(config, known);\n const instructionsFile = agent.instructionsFile;\n const claudeMdDest = path.join(groupWorktreePath, instructionsFile);\n // A session folder imports each repo's own file instead, when its agent can import\n // (`instructionsImport`): a session recorded so (`instructions`; one a repo was added to\n // keeps its group's summary above the block), or one whose file has work's block; a new\n // one that is a repo's folder session (no group to copy from), made with config\n // `sessionFolders` on, or with other repos than its group's. A session from before keeps\n // the group's copy, whatever the switch says now.\n const wantsImports = known\n ? !!known.instructions || hasInstructionsBlock(claudeMdDest) || !isConfiguredGroup\n : !isConfiguredGroup || config.sessionFolders === true || !sameRepos(config.groups[groupName], repoAliases);\n const importLine = agent.instructionsImport;\n const byImport = wantsImports && !!importLine;\n\n if (byImport && importLine) {\n // A Restore of a group session a repo was added to: its summary first, as it had it.\n if (known?.instructions === 'summary+imports' && !fs.existsSync(claudeMdDest) && fs.existsSync(claudeMdSrc))\n fs.copyFileSync(claudeMdSrc, claudeMdDest);\n const imports = writeSessionInstructions(\n groupWorktreePath,\n createdWorktrees.map((wt) => path.basename(wt.worktreePath)),\n instructionsFile,\n importLine,\n );\n report('info', '');\n report('success', `${instructionsFile} in the session folder imports ${imports.length} repo file(s)`);\n } else if (wantsImports && !isConfiguredGroup) {\n // No group summary to copy, and an agent that can't import: each repo's file is in its folder.\n report('info', '');\n report('warn', `${agent.name} can't import files into ${instructionsFile}: each repo's own is in its folder`);\n } else if (fs.existsSync(claudeMdSrc)) {\n fs.copyFileSync(claudeMdSrc, claudeMdDest);\n report('info', '');\n report('success', `Copied the group's ${instructionsFile} to the worktree root`);\n } else {\n report('info', '');\n report('warn', `Warning: the group's ${instructionsFile} not found at ${claudeMdSrc}`);\n report('warn', `Run 'work config group regen ${groupName}' to generate it.`);\n }\n\n const allPaths = createdWorktrees.map((wt) => wt.worktreePath);\n // Representative base for the single-line \"vs X\" badge: the explicit\n // default, else a per-repo value only when every repo shares it.\n const distinctBases = [...new Set(Object.values(baseBranches))];\n // One for the whole group only when every repo has it: it is the fallback for a repo with none of its own.\n const everyRepo = Object.keys(baseBranches).length === allPaths.length;\n const representativeBase = spec.default ?? (distinctBases.length === 1 && everyRepo ? distinctBases[0] : undefined);\n // What it owns: a new session records its repos (and how its instructions are made); one\n // that records them keeps them — a repo no longer in the config, not set up, stays listed with\n // its folder rather than forgotten. A row from before is left as it was: it goes on following\n // its group's config, as it always did.\n const own = known ? listedRepos(known, config) : null;\n // (A folder of a damaged list matched to no repo isn't recorded under a made-up alias.)\n const gone = (own ?? []).filter((r) => !config.repos[r.alias] && !r.guessed);\n const owns = !known || !!own;\n const { port } = await upsertSessionWithPort(\n groupName,\n true,\n branchName,\n owns ? [...allPaths, ...gone.map((r) => r.path)] : allPaths,\n config,\n jiraKey,\n representativeBase,\n baseBranches,\n {\n ...(owns\n ? { repos: [...repoAliases, ...gone.map((r) => r.alias)], ...(byImport && !known ? { instructions: 'imports' as const } : {}) }\n : {}),\n account: opts.account,\n },\n );\n\n // The branch each repo is on now joins the session's record (session-branches.ts): a re-entry onto a branch\n // Claude switched to, a Restore that checked its branch out again.\n bestEffort(`record the branches of ${groupName}:${branchName}`, () =>\n recordCheckedOutBranches({ target: groupName, branch: branchName, isGroup: true, paths: allPaths }),\n );\n\n report('info', '');\n report('info', `Branch: ${branchName}`);\n if (port !== undefined) report('detail', `Dev-server port: ${port}`);\n\n return { launchDir: groupWorktreePath, paths: allPaths, isGroup: true, port };\n}\n\nasync function setupSingleWorktree(\n targetName: string,\n branchName: string,\n workTreeDirName: string,\n config: WorkConfig,\n spec: BaseSpec,\n jiraKey?: string,\n opts: WorktreeSetupOptions = {},\n): Promise<WorktreeSetupResult | null> {\n const repoPath = config.repos[targetName];\n const repoName = path.basename(repoPath);\n let workTreePath = path.join(config.worktreesRoot, repoName, workTreeDirName);\n\n // For a single repo, the only valid per-repo override alias is the target.\n const unknownAliases = baseSpecOverrideAliases(spec).filter((a) => a !== targetName);\n if (unknownAliases.length > 0) {\n report('error', `--base names repo(s) other than '${targetName}': ${unknownAliases.join(', ')}`);\n return null;\n }\n const baseBranch = baseForAlias(spec, targetName);\n // No --base: where a new branch came from (the main checkout's branch), recorded so \"Since branch\" needn't guess.\n const created: { from?: string } = {};\n\n if (!fs.existsSync(repoPath)) {\n report('error', `Repository path does not exist: ${repoPath}`);\n return null;\n }\n\n // Check for existing worktree at any path\n const worktrees = parseWorktreeList(repoPath);\n const existing = worktrees.find((wt) => wt.branch === branchName && path.resolve(wt.path) !== path.resolve(repoPath));\n\n if (existing) {\n if (baseBranch) {\n report('error', `Cannot use --base: worktree for '${branchName}' already exists at ${existing.path}`);\n return null;\n }\n report('info', `Worktree already exists at: ${existing.path}`);\n workTreePath = existing.path;\n if (opts.pull !== false) pullLatestForBranch(workTreePath, branchName);\n } else {\n const success = createSingleWorktree(\n repoPath,\n workTreePath,\n opts.checkoutFor?.[targetName] ?? branchName,\n config,\n baseBranch,\n opts.pull !== false,\n false,\n created,\n );\n if (!success) return null;\n }\n\n const base = baseBranch ?? created.from;\n // A new session records its repo; a row from before is left as it was (it reads the same).\n const isNew = !findSession(loadHistory(), targetName, branchName);\n const { port } = await upsertSessionWithPort(\n targetName,\n false,\n branchName,\n [workTreePath],\n config,\n jiraKey,\n base,\n base ? { [workTreePath]: base } : undefined,\n { ...(isNew ? { repos: [targetName] } : {}), account: opts.account },\n );\n\n bestEffort(`record the branches of ${targetName}:${branchName}`, () =>\n recordCheckedOutBranches({ target: targetName, branch: branchName, isGroup: false, paths: [workTreePath] }),\n );\n\n report('info', `Branch: ${branchName}`);\n if (port !== undefined) report('detail', `Dev-server port: ${port}`);\n\n return { launchDir: workTreePath, paths: [workTreePath], isGroup: false, port };\n}\n\n/**\n * Remove all worktrees for a session and clean up.\n * Returns true if all worktrees were successfully removed.\n * When force=false, stops on uncommitted/unpushed changes.\n */\n/** For comparing folders: absolute, long-form (Windows 8.3 names expanded), `/`, case-folded. */\nconst normalizeWorktreePath = (p: string): string => {\n let full = path.resolve(p);\n try {\n full = fs.realpathSync.native(full);\n } catch {\n /* gone: compare as given */\n }\n return full.replace(/\\\\/g, '/').replace(/\\/$/, '').toLowerCase();\n};\n\nexport function teardownWorktree(\n target: string,\n isGroup: boolean,\n branch: string,\n config: WorkConfig,\n force: boolean = true,\n /** The session's folders, when the caller knows them: the worktree is the\n * one AT that folder, whatever branch is checked out there now (you may\n * have switched branches inside it). Without them, found by branch. */\n paths?: string[],\n): boolean {\n // A group session that records its repos is torn down over exactly those (its own\n // list, sessionRepos), at its recorded folders; a row from before over the group's config.\n // A repo's session folder (config `sessionFolders`) is one too, though its target is a repo\n // and a caller that resolved the target (`work remove <alias> <branch>`) says it isn't a group.\n const own = isGroup || recordedFolderSession(target, branch) ? ownGroupRepos(target, branch, paths, config) : null;\n\n if ((isGroup || own) && (own || config.groups[target])) {\n // No row (forgotten, or history lost): the caller's folders say where, else what's on disk.\n const known = findSession(loadHistory(), target, branch) ?? (paths?.length ? { paths } : null);\n const groupWorktreePath = sessionFolderPath(target, branch, config, known, fs.existsSync);\n const repos =\n own ??\n config.groups[target].map((alias) => ({\n alias,\n path: config.repos[alias] ? path.join(groupWorktreePath, path.basename(config.repos[alias])) : '',\n }));\n let allRemoved = true;\n\n for (const { alias, path: subWorktreePath } of repos) {\n const repoPath = config.repos[alias];\n if (!repoPath) {\n // Not in the config any more: git can't be asked to remove its worktree. Kept, and said.\n if (subWorktreePath && fs.existsSync(subWorktreePath)) {\n report('warn', `[${alias}] isn't in your config any more: ${subWorktreePath} is left as it is`);\n allRemoved = false;\n }\n continue;\n }\n const repoName = path.basename(repoPath);\n report('step', `[${alias}] (${repoName}):`);\n if (!removeSingleWorktree(repoPath, subWorktreePath, branch, force)) {\n allRemoved = false;\n }\n }\n\n // Clean up the group's instructions file (its agent's name) and empty parent dir\n const claudeMd = path.join(groupWorktreePath, agentFor(config, findSession(loadHistory(), target, branch)).instructionsFile);\n try {\n if (fs.existsSync(claudeMd)) fs.unlinkSync(claudeMd);\n } catch {\n /* */\n }\n try {\n if (fs.existsSync(groupWorktreePath) && fs.readdirSync(groupWorktreePath).length === 0) {\n fs.rmSync(groupWorktreePath, { recursive: true, force: true });\n report('success', `Cleaned up group directory: ${groupWorktreePath}`);\n }\n } catch {\n /* */\n }\n\n return allRemoved;\n } else {\n const repoPath = config.repos[target];\n if (repoPath) {\n const worktrees = parseWorktreeList(repoPath);\n const at = paths?.[0] ? normalizeWorktreePath(paths[0]) : null;\n const wt =\n (at ? worktrees.find((w) => normalizeWorktreePath(w.path) === at) : undefined) ?? worktrees.find((w) => w.branch === branch);\n if (wt) {\n return removeSingleWorktree(repoPath, wt.path, branch, force);\n }\n }\n report('warn', `No worktree found for branch '${branch}' in '${target}'.`);\n return false;\n }\n}\n\n/** The session for target + branch is recorded as a folder with its own repos (a group, or a repo's session folder). */\nfunction recordedFolderSession(target: string, branch: string): boolean {\n const s = findSession(loadHistory(), target, branch);\n return !!s && isFolderSession(s) && Array.isArray(s.repos);\n}\n\n/**\n * The repos a session lists, at its folders: as recorded; a list that is\n * there but doesn't line up with its paths (a damaged row), each folder\n * matched by name (sessionRepos) — never the group's config in its place.\n * Null for a row from before (no list at all).\n */\nfunction listedRepos(s: WorktreeSession, config: WorkConfig): SessionRepo[] | null {\n const recorded = recordedRepos(s);\n if (recorded) return recorded;\n return Array.isArray(s.repos) && s.isGroup ? sessionRepos(s, config) : null;\n}\n\n/**\n * The repos a group session records (sessionRepos), at its folders — the\n * session found by target and branch; null for a row from before, or none.\n * The caller's folders, when given and the same in number, are the ones torn down.\n */\nfunction ownGroupRepos(\n target: string,\n branch: string,\n paths: string[] | undefined,\n config: WorkConfig,\n): Array<{ alias: string; path: string }> | null {\n const s = findSession(loadHistory(), target, branch);\n const own = s ? listedRepos(s, config) : null;\n if (!own) return null;\n // The caller's folder for each repo: the same folder (by path, never by place in the list), else the recorded one.\n const given = paths ?? [];\n return own.map((r) => ({\n alias: r.alias,\n path: given.find((p) => normalizeWorktreePath(p) === normalizeWorktreePath(r.path)) ?? r.path,\n }));\n}\n\n/** What opening a repo's own checkout gave: the session it is, or why not. */\nexport type BaseCheckoutResult = { ok: true; repoPath: string; branch: string; dropped: string[] } | { ok: false; error: string };\n\n/**\n * Work on a repo's own checkout, on whatever branch it has (`work tree\n * <repo>` with no branch, or the New worktree dialog with the branch left\n * empty): no worktree, the session is the checkout itself. Pulls first\n * (unless `pull: false`), and drops the entries recorded for this checkout\n * when it was on another branch — one session per checkout. A group has no\n * single checkout: it needs a branch.\n */\nexport async function openBaseCheckout(\n targetName: string,\n config: WorkConfig,\n opts: { pull?: boolean; jiraKey?: string; name?: string; account?: string } = {},\n): Promise<BaseCheckoutResult> {\n const accountRefused = accountRefusal(opts.account, config);\n if (accountRefused) return { ok: false, error: accountRefused };\n const target = resolveProjectTarget(targetName, config);\n if (!target) return { ok: false, error: `Project or group not found: ${targetName}` };\n if (target.isGroup) return { ok: false, error: `${targetName} is a group: give it a branch (a group has no one checkout to open)` };\n const repoPath = config.repos[targetName];\n if (!repoPath) return { ok: false, error: `Repository path not configured for: ${targetName}` };\n if (!fs.existsSync(repoPath)) return { ok: false, error: `Repository path does not exist: ${repoPath}` };\n const branch = getCurrentBranch(repoPath) ?? '(detached)';\n // Detached HEAD has no upstream to pull from — skip rather than warn.\n if (opts.pull !== false && branch && branch !== '(detached)') pullLatestForBranch(repoPath, branch);\n await upsertSession(targetName, false, branch, [repoPath], opts.jiraKey, undefined, undefined, undefined, opts.account);\n if (opts.name?.trim()) await setSessionTitle(targetName, branch, opts.name);\n const dropped = await forgetOtherBaseCheckoutEntries(targetName, branch, repoPath);\n return { ok: true, repoPath, branch, dropped };\n}\n","import path from 'node:path';\nimport type { WorkConfig } from '../platform/config.js';\nimport type { WorktreeSession } from '../sessions/history.js';\nimport { archiveDirFor, archiveRoot, readArchive, writeArchiveRecord } from './session-archive.js';\nimport { restoreUncommitted } from './archive-uncommitted.js';\nimport { restoreIgnored } from './archive-ignored.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { report } from '../platform/report.js';\n\n/**\n * Restore of an archived session whose worktree was removed: put back the\n * uncommitted work archiving saved (archive-uncommitted.ts), once. A repo\n * whose save was put back, or couldn't be, isn't tried again — a later\n * `work tree` into it must not bring old changes back over newer work. What\n * couldn't be put back says where it is (its ref and patch stay).\n */\nexport async function restoreArchivedUncommitted(\n s: WorktreeSession,\n config: WorkConfig,\n root = archiveRoot(),\n): Promise<{ restored: string[]; failed: Array<{ repo: string; error: string }> }> {\n const id = sessionIdFor(s);\n const rec = readArchive(id, root);\n const out = { restored: [] as string[], failed: [] as Array<{ repo: string; error: string }> };\n if (!rec?.worktreeRemoved || !rec.uncommitted) return out;\n const dir = archiveDirFor(id, root);\n const now = new Date().toISOString();\n let changed = false;\n for (const [alias, saved] of Object.entries(rec.uncommitted)) {\n if (saved.restoredAt || saved.restoreError) continue;\n const wt = worktreeFor(s, alias, config);\n const r = wt ? await restoreUncommitted(wt, saved, dir) : { ok: false as const, error: `no worktree of ${alias} in the session` };\n if (r.ok) {\n saved.restoredAt = now;\n out.restored.push(alias);\n report('info', `${alias}: put back ${saved.files} uncommitted file${saved.files === 1 ? '' : 's'} saved when it was archived`);\n } else {\n saved.restoreError = r.error;\n out.failed.push({ repo: alias, error: r.error });\n report('warn', `${alias}: its uncommitted changes from the archive weren't put back: ${r.error}`);\n }\n changed = true;\n }\n if (changed) writeArchiveRecord(rec, root);\n return out;\n}\n\n/**\n * And the git-ignored files archiving copied (local settings, the editor's\n * state; archive-ignored.ts), once per repo, over what the new checkout has\n * (`copyFiles` may have put a fresh copy there): they were the worktree's own.\n */\nexport function restoreArchivedIgnored(s: WorktreeSession, config: WorkConfig, root = archiveRoot()): string[] {\n const id = sessionIdFor(s);\n const rec = readArchive(id, root);\n if (!rec?.worktreeRemoved || !rec.ignored) return [];\n const dir = archiveDirFor(id, root);\n const done: string[] = [];\n let changed = false;\n for (const [alias, saved] of Object.entries(rec.ignored)) {\n if (saved.restoredAt || saved.restoreError) continue;\n const wt = worktreeFor(s, alias, config);\n if (!wt) continue;\n // Each repo on its own, and recorded whatever happens: a later re-entry must not copy\n // them again over settings edited since.\n try {\n const n = restoreIgnored(path.join(dir, 'ignored', alias), wt);\n saved.restoredAt = new Date().toISOString();\n done.push(alias);\n if (n) report('info', `${alias}: put back ${n} git-ignored file${n === 1 ? '' : 's'} (local settings, editor state) it had`);\n } catch (err) {\n saved.restoreError = (err as Error).message;\n report('warn', `${alias}: its local settings from the archive weren't all put back: ${saved.restoreError}`);\n }\n changed = true;\n }\n if (changed) writeArchiveRecord(rec, root);\n return done;\n}\n\n/** The session's worktree of a repo: its only path, or (a group) the one named after the repo's folder. */\nexport function worktreeFor(s: WorktreeSession, alias: string, config: WorkConfig): string | null {\n if (!s.isGroup) return s.paths[0] ?? null;\n const repo = config.repos[alias];\n if (!repo) return null;\n const name = path.basename(repo).toLowerCase();\n return s.paths.find((p) => path.basename(p).toLowerCase() === name) ?? null;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { runGitAsync } from '../diff/git-tree-snapshot.js';\nimport { isBuildOutputPath } from '../cleanup/build-folders.js';\nimport type { SavedIgnored } from './session-archive.js';\n\n/**\n * A worktree's git-ignored files that aren't build output — local settings\n * (`appsettings.Development.json`, `.env.local`), the editor's state (`.vs`,\n * `.idea`) — kept when archiving removes the worktree and put back on\n * Restore, so it comes back as it was. The uncommitted save\n * (archive-uncommitted.ts) leaves them out; build output, environments and\n * package caches stay out here too (they're made again). Copied as files\n * into the archive folder (`ignored/<repo>/…`), within caps: a stray dump\n * shouldn't land in ~/.work. They can hold secrets: `work move export`\n * leaves them behind, and archive retention deletes them after\n * `compressAfterDays` (archive-retention.ts).\n */\n\nexport type { SavedIgnored };\n\n/** A bigger file isn't kept (an IDE's index, a database dump). */\nexport const MAX_IGNORED_FILE_BYTES = 5 * 1024 * 1024;\n/** Nor more than this in all, per repo. */\nexport const MAX_IGNORED_TOTAL_BYTES = 50 * 1024 * 1024;\n/** Nor more files than this are looked at: a big ignored tree isn't walked to its end (archiving runs in work web). */\nexport const MAX_IGNORED_FILES = 5000;\n\n/** Ignored folders that are neither settings nor editor state: environments and package caches. */\nconst HEAVY = new Set([\n '.venv',\n 'venv',\n 'packages',\n '.pnpm-store',\n '.yarn',\n '.cache',\n '.terraform',\n '.tox',\n '.mypy_cache',\n '.ruff_cache',\n '.dart_tool',\n]);\nconst leftOut = (rel: string): boolean => isBuildOutputPath(rel) || rel.split(/[\\\\/]/).some((seg) => HEAVY.has(seg));\n\n/**\n * The ignored files under a worktree, relative (folders git lists whole are\n * walked), build output and heavy folders left out; at most `max`, `more`\n * when it stopped there. Off the event loop: git and the walk are async.\n */\nexport async function ignoredFiles(worktree: string, max = MAX_IGNORED_FILES): Promise<{ files: string[]; more: boolean }> {\n const r = await runGitAsync(worktree, { args: ['ls-files', '--others', '--ignored', '--exclude-standard', '--directory', '-z'] });\n if (r.status !== 0) return { files: [], more: false };\n const files: string[] = [];\n let more = false;\n const walk = async (rel: string): Promise<void> => {\n let entries: fs.Dirent[];\n try {\n entries = await fs.promises.readdir(path.join(worktree, rel), { withFileTypes: true });\n } catch {\n return;\n }\n for (const e of entries) {\n if (files.length >= max) {\n more = true;\n return;\n }\n const r2 = path.join(rel, e.name);\n if (leftOut(r2)) continue;\n if (e.isDirectory()) await walk(r2);\n else if (e.isFile()) files.push(r2);\n }\n };\n const entries = r.stdout.split('\\0').filter(Boolean);\n // git lists a folder whole when it's ignored, but also an untracked folder that holds ignored\n // files (and those files again): only the ignored folders are walked.\n const dirs = entries.filter((e) => e.endsWith('/') && !leftOut(e.replace(/\\/$/, '')));\n const ignoredDirs = new Set<string>();\n if (dirs.length) {\n const check = await runGitAsync(worktree, { args: ['check-ignore', '--', ...dirs] });\n for (const d of check.stdout.split(/\\r?\\n/).filter(Boolean)) ignoredDirs.add(d.replace(/\\/$/, ''));\n }\n for (const entry of entries) {\n if (files.length >= max) {\n more = true;\n break;\n }\n const rel = entry.replace(/\\/$/, '');\n if (leftOut(rel)) continue;\n if (!entry.endsWith('/')) files.push(path.normalize(rel));\n else if (ignoredDirs.has(rel)) await walk(path.normalize(rel));\n }\n return { files: [...new Set(files)], more };\n}\n\n/**\n * Copy a worktree's ignored files (not build output, within the caps) into\n * `dest`, the smallest first: settings files are small, an editor's index is\n * not, and it mustn't use up the budget before them.\n */\nexport async function saveIgnored(\n worktree: string,\n dest: string,\n caps = { file: MAX_IGNORED_FILE_BYTES, total: MAX_IGNORED_TOTAL_BYTES, files: MAX_IGNORED_FILES },\n): Promise<SavedIgnored> {\n const saved: SavedIgnored = { files: 0, bytes: 0, skipped: 0 };\n const listed = await ignoredFiles(worktree, caps.files);\n if (listed.more) saved.partial = true;\n const sized: Array<{ rel: string; size: number }> = [];\n for (const rel of listed.files) {\n try {\n sized.push({ rel, size: (await fs.promises.stat(path.join(worktree, rel))).size });\n } catch {\n /* gone meanwhile */\n }\n }\n sized.sort((a, b) => a.size - b.size || a.rel.localeCompare(b.rel));\n for (const { rel, size } of sized) {\n if (size > caps.file || saved.bytes + size > caps.total) {\n saved.skipped++;\n continue;\n }\n try {\n await fs.promises.mkdir(path.dirname(path.join(dest, rel)), { recursive: true });\n await fs.promises.copyFile(path.join(worktree, rel), path.join(dest, rel));\n saved.files++;\n saved.bytes += size;\n } catch {\n saved.skipped++;\n }\n }\n return saved;\n}\n\n/** Put saved ignored files back into a worktree: the archived ones win (they were the worktree's own). Returns how many. */\nexport function restoreIgnored(src: string, worktree: string): number {\n if (!fs.existsSync(src)) return 0;\n let n = 0;\n fs.cpSync(src, worktree, {\n recursive: true,\n force: true,\n filter: (from) => {\n if (fs.statSync(from).isFile()) n++;\n return true;\n },\n });\n return n;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { atomicWriteFile } from '../platform/fs-safe.js';\n\n/**\n * A session folder's instructions file (CLAUDE.md, AGENTS.md…): it imports\n * each repo's own (Claude's `@<repo-folder>/CLAUDE.md`, written in the agent's\n * own syntax: `AgentAdapter.instructionsImport`), so the agent started in the\n * folder reads every repo's instructions — no combined file written by an\n * internal run. The imports live in a block work owns; anything else in the\n * file is the user's and is kept as it is.\n */\n\nexport const BLOCK_START = '<!-- work:repos -->';\nexport const BLOCK_END = '<!-- /work:repos -->';\nconst HEADING = \"This session's repos, each a folder here:\";\n\n/** The work-managed block for these imports (one line each, as the agent writes an import). */\nfunction block(imports: string[]): string {\n return [BLOCK_START, HEADING, '', ...imports, BLOCK_END].join('\\n');\n}\n\n/**\n * The file's text with its block set to these imports: replaced in place when\n * it has one, else appended (after a blank line) — the rest kept as it is.\n * Pure. `imports` are the lines as written (Claude's `@api/CLAUDE.md`).\n */\nexport function renderInstructions(existing: string, imports: string[]): string {\n const next = block(imports);\n const start = existing.indexOf(BLOCK_START);\n const end = start >= 0 ? existing.indexOf(BLOCK_END, start) : -1;\n if (start >= 0 && end >= 0) return existing.slice(0, start) + next + existing.slice(end + BLOCK_END.length);\n if (!existing.trim()) return `${next}\\n`;\n return `${existing.replace(/\\s*$/, '')}\\n\\n${next}\\n`;\n}\n\n/** The file's text; '' when there is none yet. Any other failure (no access, in use) is thrown, never read as empty. */\nfunction readOrEmpty(file: string): string {\n try {\n return fs.readFileSync(file, 'utf8');\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return '';\n throw err;\n }\n}\n\n/** Whether a file has work's block (a session folder's import file, not a copied group summary). */\nexport function hasInstructionsBlock(file: string): boolean {\n return readOrEmpty(file).includes(BLOCK_START);\n}\n\n/**\n * Write or update `<folder>/<fileName>`: one import per repo folder whose\n * worktree has that file, each written by `importLine` (the agent's syntax).\n * Returns the repo folders imported. A file that can't be read (other than\n * not there yet) is thrown, never overwritten.\n */\nexport function writeSessionInstructions(\n folder: string,\n repoFolders: string[],\n fileName: string,\n importLine: (relPath: string) => string,\n): string[] {\n const imported = repoFolders.filter((repo) => fs.existsSync(path.join(folder, repo, fileName)));\n const imports = imported.map((repo) => importLine(`${repo.replace(/\\\\/g, '/')}/${fileName}`));\n const file = path.join(folder, fileName);\n const existing = readOrEmpty(file);\n const next = renderInstructions(existing, imports);\n if (next !== existing) atomicWriteFile(file, next);\n return imported;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { globSync } from 'glob';\nimport { report } from '../platform/report.js';\n\n/** Directories to exclude when copying files. */\nconst EXCLUDED_DIRS = ['bin', 'obj', 'node_modules', '.git', 'cdk.out'];\n\n/**\n * Copy files matching configured patterns from a source repo into a worktree.\n * Handles .claude directory specially (direct path match).\n * Other patterns use recursive glob with exclusion filtering.\n */\nexport function copyConfigFiles(repoPath: string, worktreePath: string, patterns: string[]): void {\n for (const pattern of patterns) {\n // Normalize pattern separators to forward slashes for glob\n const normalized = pattern.replace(/\\\\/g, '/');\n\n // Handle .claude directory specially (direct path match)\n if (normalized.startsWith('.claude/')) {\n const relativePath = normalized;\n const sourcePath = path.join(repoPath, relativePath);\n\n if (fs.existsSync(sourcePath)) {\n const destPath = path.join(worktreePath, relativePath);\n const destDir = path.dirname(destPath);\n fs.mkdirSync(destDir, { recursive: true });\n fs.copyFileSync(sourcePath, destPath);\n report('info', ` Copied: ${relativePath}`);\n }\n continue;\n }\n\n // Use glob for pattern matching (recursive)\n const matches = globSync(`**/${normalized}`, {\n cwd: repoPath,\n nodir: true,\n posix: true,\n dot: true,\n });\n\n for (const match of matches) {\n // Check exclusion directories\n const parts = match.split('/');\n if (parts.some((p) => EXCLUDED_DIRS.includes(p))) {\n continue;\n }\n\n const sourcePath = path.join(repoPath, match);\n const destPath = path.join(worktreePath, match);\n const destDir = path.dirname(destPath);\n\n fs.mkdirSync(destDir, { recursive: true });\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AO,QAAS,QAAO,EAAE,IAAI,OAAO,OAAO,GAAG,UAAU,sEAAsE;AAClI,QAAM,WAAW,OAAO,MAAM,UAAU;AACxC,MAAI,CAAC,SAAU,QAAO,EAAE,IAAI,OAAO,OAAO,uCAAuC,UAAU,GAAG;AAC9F,MAAI,CAACA,IAAG,WAAW,QAAQ,EAAG,QAAO,EAAE,IAAI,OAAO,OAAO,mCAAmC,QAAQ,GAAG;AACvG,QAAM,SAAS,iBAAiB,QAAQ,KAAK;AAE7C,MAAI,KAAK,SAAS,SAAS,UAAU,WAAW,aAAc,qBAAoB,UAAU,MAAM;AAClG,QAAM,cAAc,YAAY,OAAO,QAAQ,CAAC,QAAQ,GAAG,KAAK,SAAS,QAAW,QAAW,QAAW,KAAK,OAAO;AACtH,MAAI,KAAK,MAAM,KAAK,EAAG,OAAM,gBAAgB,YAAY,QAAQ,KAAK,IAAI;AAC1E,QAAM,UAAU,MAAM,+BAA+B,YAAY,QAAQ,QAAQ;AACjF,SAAO,EAAE,IAAI,MAAM,UAAU,QAAQ,QAAQ;AAC/C;","names":["fs","path","entries","path","path","fs","path","fs","path","fs","path","path","fs","path","fs"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/worktree/setup-child.ts"],"sourcesContent":["import path from 'node:path';\nimport crossSpawn from '../platform/spawn.js';\nimport type { BaseSpec } from '../git/base-spec.js';\nimport type { WorkConfig } from '../platform/config.js';\nimport { findSession, loadHistory } from '../sessions/history.js';\nimport { openBaseCheckout, setupWorktree } from './worktree.js';\nimport { ownsBranch } from './own-checkout.js';\nimport { isEmptyBaseSpec } from '../git/base-spec.js';\nimport { collectingReporter, withReporter } from '../platform/report.js';\nimport { resolveProjectTarget } from './resolve.js';\nimport { defaultRunner } from '../pr/ship.js';\nimport { sessionAliases } from '../sessions/session-repos.js';\n\n/**\n * Creating a worktree runs git synchronously (fetch, pull, worktree add):\n * done inside work web, that held up every request — the dashboard, the\n * terminals' relays, the status hooks — for as long as the network took.\n * So work web runs it as `work tree … --setup-only` in a child process and\n * reads the result back from the history it wrote. The CLI and tests use\n * the in-process `createInProcess`; both answer the same way.\n */\n\nexport interface CreateRequest {\n target: string;\n /** Empty: the repo's own checkout, on the branch it has (`work tree <repo>`). */\n branch?: string;\n base?: BaseSpec;\n jiraKey?: string;\n name?: string;\n /** A new session's repos instead of its group's config (a fork of a session folder: the parent's own). */\n repos?: string[];\n /** The Claude account a new session runs on; unset: the configured default. */\n account?: string;\n}\n\nexport type CreateResult =\n { ok: true; branch: string; launchDir: string; paths: string[]; warnings?: string[] } | { ok: false; error: string };\n\n/** The line `work tree --setup-only` ends with on success: what it warned about (the parent reads only this). */\nexport const SETUP_WARNINGS = 'work-setup-warnings ';\n\n/** The warnings a `--setup-only` child printed (its last such line); none when there is none. Pure. */\nexport function setupWarningsOf(stdout: string): string[] {\n const line = stdout\n .split(/\\r?\\n/)\n .reverse()\n .find((l) => l.startsWith(SETUP_WARNINGS));\n if (!line) return [];\n try {\n const v: unknown = JSON.parse(line.slice(SETUP_WARNINGS.length));\n return Array.isArray(v) ? v.filter((x): x is string => typeof x === 'string') : [];\n } catch {\n return [];\n }\n}\nexport type CreateWorktree = (req: CreateRequest, config: WorkConfig) => Promise<CreateResult>;\n\n/**\n * A request the child's command line could misread: a project or branch\n * starting with `-` would be taken for a flag (`--fresh` as a branch opened\n * the base checkout instead). Git refuses such branch names anyway. Pure.\n */\nexport function invalidRequest(req: CreateRequest): string | null {\n if (req.target.startsWith('-')) return `not a project: ${req.target}`;\n if (req.branch?.startsWith('-')) return `${req.branch} is not a valid branch name (it can't start with \"-\")`;\n for (const [alias, b] of Object.entries(req.base?.perRepo ?? {}))\n if (alias.startsWith('-') || b.startsWith('-')) return `not a valid base: ${alias}=${b}`;\n if (req.base?.default?.startsWith('-')) return `not a valid base: ${req.base.default}`;\n if (req.account?.startsWith('-')) return `not a Claude account: ${req.account}`;\n for (const alias of req.repos ?? []) if (!alias || alias.startsWith('-') || alias.includes(',')) return `not a repo: ${alias}`;\n return null;\n}\n\n/** `--base` flags for a base spec (`--base=dev`, `--base=backend=dev`). Pure. */\nexport function baseArgs(spec: BaseSpec | undefined): string[] {\n if (!spec) return [];\n const out: string[] = [];\n if (spec.default) out.push(`--base=${spec.default}`);\n for (const [alias, b] of Object.entries(spec.perRepo)) out.push(`--base=${alias}=${b}`);\n return out;\n}\n\n/**\n * The argv of the child `work tree` run (after node and the bin). Values go\n * as `--flag=value`: a name like `--fresh` given as `--name --fresh` would\n * be read as a flag of its own (and the name lost). Pure.\n */\nexport function childArgs(req: CreateRequest): string[] {\n return [\n 'tree',\n req.target,\n ...(req.branch ? [req.branch] : []),\n '--setup-only',\n ...baseArgs(req.base),\n ...(req.jiraKey ? [`--jira-key=${req.jiraKey}`] : []),\n ...(req.name?.trim() ? [`--name=${req.name.trim()}`] : []),\n ...(req.repos?.length ? [`--repos=${req.repos.join(',')}`] : []),\n ...(req.account ? [`--account=${req.account}`] : []),\n ];\n}\n\n/**\n * One creation at a time per project: they fetch, pull and add worktrees in\n * the same repos (git's own locks would turn two at once into a failure),\n * and a double-clicked create of the same branch gets the first one's answer.\n */\nexport function oneAtATime(create: CreateWorktree, queue: KeyedQueue = keyedQueue()): CreateWorktree {\n const same = new Map<string, Promise<CreateResult>>();\n return (req, config) => {\n const key = `${req.target}\\0${req.branch ?? ''}`;\n const running = same.get(key);\n if (running) return running;\n const job = queue(req.target, () => create(req, config));\n same.set(key, job);\n void job\n .catch(() => undefined)\n .then(() => {\n if (same.get(key) === job) same.delete(key);\n });\n return job;\n };\n}\n\n/** Runs jobs one after another per key (a project, or a repo), any number of keys at once. */\nexport type KeyedQueue = <T>(key: string, job: () => Promise<T>) => Promise<T>;\n\nexport function keyedQueue(): KeyedQueue {\n const queues = new Map<string, Promise<unknown>>();\n return <T>(key: string, job: () => Promise<T>): Promise<T> => {\n const before = queues.get(key) ?? Promise.resolve();\n const run = before.then(job);\n const tail = run.catch(() => undefined);\n queues.set(key, tail);\n void tail.then(() => {\n if (queues.get(key) === tail) queues.delete(key);\n });\n return run;\n };\n}\n\n/** What a child `work` run gave back. */\nexport interface ChildRun {\n stdout: string;\n stderr: string;\n code: number | null;\n /** Killed after its time ran out. */\n timedOut: boolean;\n /** It couldn't be started at all. */\n spawnError?: string;\n}\n\n/**\n * Run `node <work> <args…>` in a child process (no window, no colours),\n * killed after `timeoutMs` (5 min). This process's node flags go with it:\n * under tsx (dev) they are what loads a .ts entry (but not a debugger's,\n * whose port is taken).\n */\nexport function runWorkChild(\n workBin: string,\n args: string[],\n opts: { node?: string; execArgv?: string[]; timeoutMs?: number } = {},\n): Promise<ChildRun> {\n return new Promise((resolve) => {\n const child = crossSpawn(\n opts.node ?? process.execPath,\n [...(opts.execArgv ?? process.execArgv).filter((f) => !/^--inspect/.test(f)), workBin, ...args],\n { windowsHide: true, env: { ...process.env, NO_COLOR: '1', FORCE_COLOR: '0' } },\n );\n let stdout = '';\n let stderr = '';\n child.stdout?.on('data', (d: Buffer) => (stdout += d.toString()));\n child.stderr?.on('data', (d: Buffer) => (stderr += d.toString()));\n let timedOut = false;\n const timer = setTimeout(\n () => {\n timedOut = true;\n child.kill();\n },\n opts.timeoutMs ?? 5 * 60_000,\n );\n let settled = false;\n const done = (r: ChildRun) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(r);\n };\n child.on('error', (err) => done({ stdout, stderr, code: null, timedOut, spawnError: err.message }));\n child.on('close', (code) => done({ stdout, stderr, code, timedOut }));\n });\n}\n\n/** What a child printed, in one line, its colours stripped. Pure. */\nexport function childText(text: string): string {\n return text\n .replace(ANSI, '')\n .split(/\\r?\\n/)\n .map((l) => l.trim())\n .filter(Boolean)\n .join(' ');\n}\n\nconst ANSI = /\\x1b\\[[0-9;]*m/g;\n\nconst norm = (p: string) => path.resolve(p).replace(/\\\\/g, '/').toLowerCase();\n\n/** What the run left in the history: the session it created or opened. */\nfunction resultFromHistory(req: CreateRequest, config: WorkConfig): CreateResult {\n const history = loadHistory();\n if (req.branch) {\n const s = findSession(history, req.target, req.branch);\n if (!s) return { ok: false, error: 'the worktree was set up, but its session is not in the history' };\n return { ok: true, branch: s.branch, launchDir: s.isGroup && s.paths[0] ? path.dirname(s.paths[0]) : s.paths[0], paths: s.paths };\n }\n const repo = config.repos[req.target];\n const s = repo\n ? history\n .filter((x) => !x.archivedAt && x.target === req.target && x.paths.some((p) => norm(p) === norm(repo)))\n .sort((a, b) => b.lastAccessedAt.localeCompare(a.lastAccessedAt))[0]\n : undefined;\n if (!s) return { ok: false, error: `opened ${req.target}, but its session is not in the history` };\n return { ok: true, branch: s.branch, launchDir: repo, paths: [repo] };\n}\n\n/** Out of process (work web): `node <work> tree … --setup-only`, then the history. */\nexport function createInChild(workBin: string, opts: { node?: string; execArgv?: string[]; timeoutMs?: number } = {}): CreateWorktree {\n return async (req, config) => {\n const invalid = invalidRequest(req);\n if (invalid) return { ok: false, error: invalid };\n const r = await runWorkChild(workBin, childArgs(req), opts);\n if (r.spawnError) return { ok: false, error: `could not run work: ${r.spawnError}` };\n if (r.timedOut) {\n // Killed from outside, its own rollback never ran: drop what a\n // half-made `git worktree add` registered, so a retry can make it.\n await pruneWorktrees(req.target, req.branch, config, req.repos);\n return { ok: false, error: 'setting it up took too long (stopped; run it again, or `work tree` it from a terminal to see why)' };\n }\n if (r.code === 0) {\n const made = resultFromHistory(req, config);\n const warnings = setupWarningsOf(r.stdout);\n return made.ok && warnings.length ? { ...made, warnings } : made;\n }\n // Its errors, as the CLI printed them (the reporter sends errors to stderr).\n const why = childText(r.stderr || r.stdout);\n return { ok: false, error: why || (r.code === null ? 'setting it up took too long' : `work tree exited ${r.code}`) };\n };\n}\n\n/**\n * `git worktree prune` in each repo of the session (best effort): its own\n * repos when it has a row (sessionAliases: one added to it, or a fork's list),\n * else the project's.\n */\nexport async function pruneWorktrees(\n target: string,\n branch: string | undefined,\n config: WorkConfig,\n /** The repos the run was asked for (a fork of a session folder: its own), when it has no row yet. */\n repos?: string[],\n): Promise<void> {\n const known = branch ? findSession(loadHistory(), target, branch) : undefined;\n const aliases = known ? sessionAliases(known, config) : repos?.length ? repos : (resolveProjectTarget(target, config)?.repoAliases ?? []);\n for (const alias of aliases) {\n const repo = config.repos[alias];\n if (repo) await defaultRunner('git', ['-C', repo, 'worktree', 'prune'], repo).catch(() => undefined);\n }\n}\n\n/** In process (the CLI, tests): the same core calls `work tree` makes. */\nexport const createInProcess: CreateWorktree = async (req, config) => {\n const invalid = invalidRequest(req);\n if (invalid) return { ok: false, error: invalid };\n // No branch, or the one the repo's own folder is on (it can't be checked out twice): that folder.\n if (!req.branch || ((!req.base || isEmptyBaseSpec(req.base)) && ownsBranch(req.target, req.branch, config))) {\n const opened = await openBaseCheckout(req.target, config, { jiraKey: req.jiraKey, name: req.name, account: req.account });\n return opened.ok\n ? { ok: true, branch: opened.branch, launchDir: opened.repoPath, paths: [opened.repoPath] }\n : { ok: false, error: opened.error };\n }\n // Keep what core reports, so a failure says why.\n const reports = collectingReporter();\n const created = await withReporter(reports, () =>\n setupWorktree(req.target, req.branch!, config, req.base, req.jiraKey, {\n name: req.name,\n ...(req.account ? { account: req.account } : {}),\n ...(req.repos?.length ? { repos: req.repos } : {}),\n }),\n );\n const warnings = reports.entries.filter((e) => e.level === 'warn' && e.text.trim()).map((e) => e.text.trim());\n if (!created)\n return {\n ok: false,\n error:\n reports\n .errors()\n .map((e) => e.trim())\n .join(' ') || 'setup failed (target not found?)',\n };\n return { ok: true, branch: req.branch, launchDir: created.launchDir, paths: created.paths, ...(warnings.length ? { warnings } : {}) };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AAuCV,IAAM,iBAAiB;AAGvB,SAAS,gBAAgB,QAA0B;AACxD,QAAM,OAAO,OACV,MAAM,OAAO,EACb,QAAQ,EACR,KAAK,CAAC,MAAM,EAAE,WAAW,cAAc,CAAC;AAC3C,MAAI,CAAC,KAAM,QAAO,CAAC;AACnB,MAAI;AACF,U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M,IAAI,MAAM,SAAS,IAAI,QAAQ,CAAC;AACxH,WAAO,OAAO,KACV,EAAE,IAAI,MAAM,QAAQ,OAAO,QAAQ,WAAW,OAAO,UAAU,OAAO,CAAC,OAAO,QAAQ,EAAE,IACxF,EAAE,IAAI,OAAO,OAAO,OAAO,MAAM;AAAA,EACvC;AAEA,QAAM,UAAU,mBAAmB;AACnC,QAAM,UAAU,MAAM;AAAA,IAAa;AAAA,IAAS,MAC1C,cAAc,IAAI,QAAQ,IAAI,QAAS,QAAQ,IAAI,MAAM,IAAI,SAAS;AAAA,MACpE,MAAM,IAAI;AAAA,MACV,GAAI,IAAI,UAAU,EAAE,SAAS,IAAI,QAAQ,IAAI,CAAC;AAAA,MAC9C,GAAI,IAAI,OAAO,SAAS,EAAE,OAAO,IAAI,MAAM,IAAI,CAAC;AAAA,IAClD,CAAC;AAAA,EACH;AACA,QAAM,WAAW,QAAQ,QAAQ,OAAO,CAAC,MAAM,EAAE,UAAU,UAAU,EAAE,KAAK,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,KAAK,CAAC;AAC5G,MAAI,CAAC;AACH,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,OACE,QACG,OAAO,EACP,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,KAAK,GAAG,KAAK;AAAA,IACpB;AACF,SAAO,EAAE,IAAI,MAAM,QAAQ,IAAI,QAAQ,WAAW,QAAQ,WAAW,OAAO,QAAQ,OAAO,GAAI,SAAS,SAAS,EAAE,SAAS,IAAI,CAAC,EAAG;AACtI;","names":["s"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../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 { atomicWriteFile } from './fs-safe.js';\nimport { validatePrompts } from '../sessions/saved-prompts.js';\nimport { isIssueKey } from '../time/allocate.js';\nimport { getConfigDir } from './config-dir.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 /** The Jira field holding story points (`customfield_…`, each site its own): read for tasks, they weigh the day's split. */\n storyPointsField?: 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 /** Usage meters: `statusLine: false` leaves Claude's status line alone (work otherwise wraps it to read the rate limits). */\n usage?: { statusLine?: boolean };\n /** Claude Code accounts besides the default `~/.claude`: name → its config folder (`CLAUDE_CONFIG_DIR`), as written; agents/claude/accounts.ts checks them. */\n claudeAccounts?: Record<string, string>;\n /** The account new sessions and work's own Claude runs use: `default` or a key of `claudeAccounts`. */\n claudeAccount?: string;\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 /**\n * PR reviews prepared in the background (#64, core/review/): per project (a repo alias or a group) `all` open PRs\n * (the default), only those `asked` of you, or `off`; the day's cap and the size above which a review waits for a\n * click; and kind-of-change rules before the defaults (change-kinds.ts).\n */\n reviews?: {\n projects?: Record<string, 'all' | 'asked' | 'off'>;\n maxPerDay?: number;\n maxLines?: number;\n rules?: unknown[];\n /** What every review's AI step is told to pay attention to (your words: instructions to it), and per repo alias besides. */\n focus?: string[];\n focusFor?: Record<string, string[]>;\n };\n /**\n * The git host of an origin whose URL no adapter claims (core/hosts/index.ts): its hostname (lower case) → a host\n * id. Only a host that can work with such a server needs it (one registered at run time); GitHub Enterprise needs\n * no entry — an unclaimed origin is asked as GitHub already, and gh finds its server from the repo's folder. The\n * registry reads it from the raw config.\n */\n gitHosts?: Record<string, 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 * Experimental, off by default: NEW sessions are made as a folder with one\n * subfolder per repo — a single repo too (`<root>/<branch>-<id6>/<repo>/`, session-folder.ts) —\n * and the agent runs in the folder, whose instructions file imports each\n * repo's own. Existing sessions keep the layout they were made with.\n */\n sessionFolders?: 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 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 10, at least 5; 0 = never.\n * Only a truly idle one: never working, waiting on you, or with background work still running (idle-sleep.ts).\n */\n sleepIdleAfterMinutes?: number;\n /**\n * Windows: start terminals on the ConPTY node-pty ships (`conpty.dll` + `OpenConsole.exe`, the one Windows Terminal\n * uses) instead of the one built into Windows, whose console start can hang — and with it the PTY host. Read at\n * each terminal start; nothing restarts. Default off (node-pty calls it experimental).\n */\n useBundledConpty?: boolean;\n /**\n * Start each session's agent below normal priority, so the builds and tests it runs take the idle cores and give way\n * to what you look at (the dashboard, your editor). Read at each agent start; a running one keeps what it has.\n * Default off.\n */\n agentsLowPriority?: boolean;\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 /** A PR of the session's that turns conflicting: its Claude is asked to merge the base in and\n * resolve it (DECISION NEEDED when it isn't clear-cut). Default on. */\n fixConflicts?: 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 * The checks that count, per repo (its alias, or the host's `owner/name`), for a repo whose host requires none\n * (GitHub's branch protection or rulesets list no required checks): a failed check not named here doesn't make\n * the PR's checks fail — shown grey as \"not required\", never asked of Claude. The host's own list, when it has\n * one, wins; a repo with neither counts every check.\n */\n requiredChecks?: Record<string, string[]>;\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 { getConfigDir };\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 desk = stringList(t.deskProjects)?.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 ...(desk ? { deskProjects: desk } : {}),\n ...(t.taskMinHours === null || (typeof t.taskMinHours === 'number' && t.taskMinHours >= 0)\n ? { taskMinHours: t.taskMinHours as number | null }\n : {}),\n ...num('pointsWeight', 0),\n ...(typeof t.storyPointsField === 'string' && /^customfield_\\d+$/.test(t.storyPointsField)\n ? { storyPointsField: t.storyPointsField }\n : {}),\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\n/** `default` is the account at `~/.claude` (a session that records no account runs on it); it can't be a configured name. */\nexport const DEFAULT_ACCOUNT = 'default';\n\n/**\n * `claudeAccounts` as written: the entries whose folder is a string. What makes one an account (a name, a folder that\n * can be one) is Claude's to say (agents/claude/accounts.ts), which checks them where they are read.\n */\nfunction stringRecord(raw: unknown): Record<string, string> | undefined {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return undefined;\n const out = Object.fromEntries(\n Object.entries(raw as Record<string, unknown>).filter((e): e is [string, string] => typeof e[1] === 'string'),\n );\n return Object.keys(out).length ? out : 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 sessionFolders: typeof parsed.sessionFolders === 'boolean' ? parsed.sessionFolders : undefined,\n devCommands: validateDevCommands(parsed.devCommands),\n sleepIdleAfterMinutes:\n typeof parsed.sleepIdleAfterMinutes === 'number' && parsed.sleepIdleAfterMinutes >= 0 ? parsed.sleepIdleAfterMinutes : undefined,\n useBundledConpty: typeof parsed.useBundledConpty === 'boolean' ? parsed.useBundledConpty : undefined,\n agentsLowPriority: typeof parsed.agentsLowPriority === 'boolean' ? parsed.agentsLowPriority : 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 usage: parsed.usage && typeof parsed.usage === 'object' ? { statusLine: parsed.usage.statusLine !== false } : undefined,\n claudeAccounts: stringRecord(parsed.claudeAccounts),\n claudeAccount: typeof parsed.claudeAccount === 'string' ? parsed.claudeAccount : undefined,\n internalAgent: isAgentId(parsed.internalAgent) ? parsed.internalAgent : undefined,\n assistantAgent: isAgentId(parsed.assistantAgent) ? parsed.assistantAgent : undefined,\n reviews:\n parsed.reviews && typeof parsed.reviews === 'object' && !Array.isArray(parsed.reviews)\n ? {\n ...(parsed.reviews.projects && typeof parsed.reviews.projects === 'object' && !Array.isArray(parsed.reviews.projects)\n ? {\n projects: Object.fromEntries(\n Object.entries(parsed.reviews.projects as Record<string, unknown>).filter(\n (e): e is [string, 'all' | 'asked' | 'off'] => e[1] === 'all' || e[1] === 'asked' || e[1] === 'off',\n ),\n ),\n }\n : {}),\n ...(typeof parsed.reviews.maxPerDay === 'number' && parsed.reviews.maxPerDay >= 0\n ? { maxPerDay: parsed.reviews.maxPerDay }\n : {}),\n ...(typeof parsed.reviews.maxLines === 'number' && parsed.reviews.maxLines > 0 ? { maxLines: parsed.reviews.maxLines } : {}),\n ...(Array.isArray(parsed.reviews.rules) ? { rules: parsed.reviews.rules as unknown[] } : {}),\n ...(Array.isArray(parsed.reviews.focus)\n ? { focus: (parsed.reviews.focus as unknown[]).filter((x): x is string => typeof x === 'string' && !!x.trim()) }\n : {}),\n ...(parsed.reviews.focusFor && typeof parsed.reviews.focusFor === 'object' && !Array.isArray(parsed.reviews.focusFor)\n ? {\n focusFor: Object.fromEntries(\n Object.entries(parsed.reviews.focusFor as Record<string, unknown>)\n .filter((e): e is [string, unknown[]] => Array.isArray(e[1]))\n .map(([alias, list]) => [alias, list.filter((x): x is string => typeof x === 'string' && !!x.trim())]),\n ),\n }\n : {}),\n }\n : undefined,\n gitHosts:\n parsed.gitHosts && typeof parsed.gitHosts === 'object' && !Array.isArray(parsed.gitHosts)\n ? Object.fromEntries(\n Object.entries(parsed.gitHosts as Record<string, unknown>).filter((e): e is [string, string] => typeof e[1] === 'string'),\n )\n : 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 // The Settings page writes it (reported: it saved and nothing read it).\n jiraWatch:\n parsed.jiraWatch && typeof parsed.jiraWatch === 'object' && typeof parsed.jiraWatch.maxPerDay === 'number'\n ? Number.isInteger(parsed.jiraWatch.maxPerDay) && parsed.jiraWatch.maxPerDay >= 0 && parsed.jiraWatch.maxPerDay <= 100\n ? { maxPerDay: parsed.jiraWatch.maxPerDay }\n : undefined\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 fixConflicts: parsed.prWatch.fixConflicts !== 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 ...(cleanRequiredChecks(parsed.prWatch.requiredChecks)\n ? { requiredChecks: cleanRequiredChecks(parsed.prWatch.requiredChecks)! }\n : {}),\n }\n : undefined,\n };\n } catch {\n return null;\n }\n}\n\n/** `prWatch.requiredChecks` as written: repo → check names (strings only, none empty); null when there's none. */\nexport function cleanRequiredChecks(raw: unknown): Record<string, string[]> | null {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;\n const out: Record<string, string[]> = {};\n for (const [repo, names] of Object.entries(raw as Record<string, unknown>)) {\n if (!repo.trim() || !Array.isArray(names)) continue;\n const list = names.filter((n): n is string => typeof n === 'string' && n.trim().length > 0).map((n) => n.trim());\n if (list.length) out[repo] = list;\n }\n return Object.keys(out).length ? out : null;\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 the CLI of the git host its origin is on. 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 /** Projects whose tickets are service desk (keep `minHours`); any other project's ticket is a task. */\n deskProjects: string[];\n /** A task's row on a day is at least this (null: tasks get `minHours` like any ticket). */\n taskMinHours: number | null;\n /** A task's measured hours × (1 + this × (story points − 1)) before the day is shared out (0: points don't count). */\n pointsWeight: number;\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 deskProjects: [],\n taskMinHours: null,\n pointsWeight: 0.25,\n};\n\n/** A ticket that isn't service desk, the gap ticket or time off: a task (its own minimum, its story points count). */\nexport function isTask(key: string, s: Pick<TimeSettings, 'deskProjects' | 'gapTicket' | 'timeOffTicket'>): boolean {\n return key !== s.gapTicket && key !== s.timeOffTicket && !s.deskProjects.includes(key.split('-')[0]);\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 /** How each row got its hours, in words, by key: \"51 min of Claude × 5 = 4.25 h\". */\n why: Record<string, string>;\n}\n\n/** \"4.25 h\". */\nconst h2 = (h: number) => `${Math.round(h * 100) / 100} h`;\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; points?: Record<string, 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, why: { [s.timeOffTicket]: 'a day off: the whole day' } }\n : { entries: [], unallocated: s.dayHours, why: {} };\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 // A task's own minimum (as measured, none beyond a step).\n const task = (key: string) => !s.effort && s.taskMinHours !== null && isTask(key, s);\n const minFor = (key: string) => (task(key) ? Math.max(min, units(s.taskMinHours!)) : min);\n // Story points weigh a task's share: × (1 + weight × (points − 1)); unknown points, a desk ticket: × 1.\n const factorFor = (key: string) => {\n const p = opts.points?.[key];\n return !s.effort && p !== undefined && p > 0 && isTask(key, s) ? Math.max(0, 1 + s.pointsWeight * (p - 1)) : 1;\n };\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) * factorFor(key);\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 its minimum: the minimum when it's at least a step's worth, else nothing.\n const least = minFor(r.key);\n return { key: r.key, raw: scaled, u: u >= least ? u : scaled >= s.stepHours ? least : 0, first: 0 };\n })\n .filter((r) => r.u > 0);\n for (const r of rows) r.first = r.u;\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 const dropped: string[] = [];\n while (used > room && rows.length) {\n const big = rows.filter((r) => r.u > minFor(r.key)).sort((a, b) => b.u - a.u || a.key.localeCompare(b.key))[0];\n if (big) big.u--;\n else {\n rows = rows.sort((a, b) => a.raw - b.raw);\n dropped.push(rows[0].key);\n rows = rows.slice(1);\n }\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\n // The words: what it measured, how that became hours, and every step after (cut to fit, a minimum, trimmed).\n const why: Record<string, string> = {};\n const roomWhy =\n room === units(s.capHours) && units(s.capHours) <= day - reserve\n ? `the ${h2(s.capHours)} cap for tickets`\n : `the ${h2(s.dayHours)} day less ${h2(hours(reserve))} kept for ${s.gapTicket}${(opts.reserveMinutes ?? 0) > 0 ? ' (meetings no ticket got)' : ''}`;\n for (const r of rows) {\n const m = minutes.get(r.key)!;\n const parts: string[] = [];\n if (m.claude > 0)\n parts.push(s.effort ? `${Math.round(m.claude)} min of Claude, as measured` : `${Math.round(m.claude)} min of Claude × ${multiplier}`);\n if (m.direct > 0) parts.push(`${Math.round(m.direct)} min of meetings`);\n const measured = (m.claude / 60) * multiplier + m.direct / 60;\n const factor = factorFor(r.key);\n const steps: string[] = [\n measured > 0\n ? `${parts.join(' + ')} = ${h2(measured)}`\n : `only touched (a commit, an issue moved, a chat): the ${h2(s.minHours)} minimum`,\n ];\n if (measured > 0 && factor !== 1)\n steps.push(`× ${Math.round(factor * 100) / 100} for ${opts.points![r.key]} story points = ${h2(measured * factor)}`);\n if (scale < 1) steps.push(`all tickets came to ${h2(total)}, over ${roomWhy}: each cut to ${Math.round(scale * 100)}%`);\n const least = minFor(r.key);\n if (r.first === least && units(r.raw) < least && (measured > 0 || least > min))\n steps.push(least > min ? `raised to the ${h2(hours(least))} minimum for a task` : `raised to the ${h2(s.minHours)} minimum`);\n if (r.u < r.first) steps.push(`trimmed ${h2(hours(r.first - r.u))} so the day adds up`);\n why[r.key] = `${steps.join('; ')} → ${h2(hours(r.u))}`;\n }\n\n const left = day - used;\n if (s.gapTicket && left > 0) {\n why[s.gapTicket] =\n (dropped.length ? `no room left for ${dropped.join(', ')} (each under its minimum); ` : '') +\n `the rest of the ${h2(s.dayHours)} day${(opts.reserveMinutes ?? 0) > 0 ? `, ${Math.round(opts.reserveMinutes ?? 0)} min of it meetings no ticket got` : ''} → ${h2(hours(left))}`;\n return { entries: [...entries, { key: s.gapTicket, hours: hours(left) }], unallocated: 0, why };\n }\n return { entries, unallocated: hours(Math.max(0, left)), why };\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;;;ACYV,IAAM,kBAAiC;AAAA,EAC5C;AAAA,IACE,OAAO;AAAA,IACP,QACE;AAAA,EACJ;AAAA,EACA;AAAA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