@moberg_hr/work-tree 2.9.3 → 2.10.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-NG75VLRU.js → account-QSNXX5YV.js} +81 -98
- package/dist/account-QSNXX5YV.js.map +1 -0
- package/dist/{add-repo-EDU3QEYI.js → add-repo-YZ32MLZG.js} +32 -28
- package/dist/{add-repo-EDU3QEYI.js.map → add-repo-YZ32MLZG.js.map} +1 -1
- package/dist/{answer-MHOJ2J6S.js → answer-Y4T5X446.js} +16 -13
- package/dist/{answer-MHOJ2J6S.js.map → answer-Y4T5X446.js.map} +1 -1
- package/dist/{attach-37JOJ4C3.js → attach-XPYWYHDP.js} +25 -19
- package/dist/{attach-37JOJ4C3.js.map → attach-XPYWYHDP.js.map} +1 -1
- package/dist/bin.js +4 -4
- package/dist/{block-D5CAR53T.js → block-JVAGG5QA.js} +22 -13
- package/dist/block-JVAGG5QA.js.map +1 -0
- package/dist/{broadcast-LLYHUWXA.js → broadcast-FATIANHX.js} +11 -9
- package/dist/{broadcast-LLYHUWXA.js.map → broadcast-FATIANHX.js.map} +1 -1
- package/dist/{catchup-2SL3JGA7.js → catchup-OTI2KZG5.js} +17 -15
- package/dist/{catchup-2SL3JGA7.js.map → catchup-OTI2KZG5.js.map} +1 -1
- package/dist/{chunk-37XQIG7F.js → chunk-27LWL6QE.js} +111 -49
- package/dist/chunk-27LWL6QE.js.map +1 -0
- package/dist/chunk-2HHIDWHH.js +50 -0
- package/dist/chunk-2HHIDWHH.js.map +1 -0
- package/dist/{chunk-T7AFYEQ7.js → chunk-2K5TDJ7M.js} +5 -5
- package/dist/{chunk-2JNW2AQ2.js → chunk-2MAZV5KS.js} +17 -2
- package/dist/chunk-2MAZV5KS.js.map +1 -0
- package/dist/{chunk-S3FMTEFR.js → chunk-2VRZVUM7.js} +13 -6
- package/dist/chunk-2VRZVUM7.js.map +1 -0
- package/dist/{chunk-63VY4YJM.js → chunk-34E2LA3M.js} +34 -9
- package/dist/chunk-34E2LA3M.js.map +1 -0
- package/dist/{chunk-QL36KN7X.js → chunk-353ZINJ2.js} +3 -3
- package/dist/{chunk-5QGCF3PS.js → chunk-3BSFVKMK.js} +2 -2
- package/dist/{chunk-WTQ2QCAG.js → chunk-3S6L437Q.js} +4 -5
- package/dist/chunk-3S6L437Q.js.map +1 -0
- package/dist/{chunk-AAYWHIIT.js → chunk-3XG23PLG.js} +8 -55
- package/dist/chunk-3XG23PLG.js.map +1 -0
- package/dist/{chunk-RFINYWID.js → chunk-46XSWHCQ.js} +14 -5
- package/dist/{chunk-RFINYWID.js.map → chunk-46XSWHCQ.js.map} +1 -1
- package/dist/{chunk-J36ULZBO.js → chunk-4K4S53KX.js} +2 -2
- package/dist/{chunk-ZI2KXTKM.js → chunk-4O4VQQEA.js} +6 -10
- package/dist/chunk-4O4VQQEA.js.map +1 -0
- package/dist/chunk-4TTYEMOY.js +180 -0
- package/dist/chunk-4TTYEMOY.js.map +1 -0
- package/dist/{chunk-GRLKPVTP.js → chunk-5R5JEQW7.js} +55 -80
- package/dist/chunk-5R5JEQW7.js.map +1 -0
- package/dist/chunk-63ZLPXRL.js +199 -0
- package/dist/chunk-63ZLPXRL.js.map +1 -0
- package/dist/{chunk-QHTXLCG7.js → chunk-66VPQOVZ.js} +17 -14
- package/dist/chunk-66VPQOVZ.js.map +1 -0
- package/dist/{chunk-6FVYSW3E.js → chunk-6J6U7JXN.js} +20 -5
- package/dist/chunk-6J6U7JXN.js.map +1 -0
- package/dist/{chunk-P2HOLCBF.js → chunk-6UTH3A76.js} +18 -2
- package/dist/{chunk-P2HOLCBF.js.map → chunk-6UTH3A76.js.map} +1 -1
- package/dist/{chunk-HCVONKJI.js → chunk-6YMLYU5G.js} +15 -17
- package/dist/{chunk-HCVONKJI.js.map → chunk-6YMLYU5G.js.map} +1 -1
- package/dist/chunk-7E5XPDKX.js +22 -0
- package/dist/chunk-7E5XPDKX.js.map +1 -0
- package/dist/chunk-7QNVFVG6.js +196 -0
- package/dist/chunk-7QNVFVG6.js.map +1 -0
- package/dist/chunk-7S2NQRWL.js +9 -0
- package/dist/{chunk-NWIVXGSL.js.map → chunk-7S2NQRWL.js.map} +1 -1
- package/dist/{chunk-P4EQWC5W.js → chunk-ADIN3DTD.js} +2 -2
- package/dist/{chunk-IWJXFNM4.js → chunk-AHI2WVWP.js} +16 -24
- package/dist/chunk-AHI2WVWP.js.map +1 -0
- package/dist/{chunk-KUCMJHQW.js → chunk-AHYCZUPI.js} +2 -2
- package/dist/chunk-AQP6SCCJ.js +66 -0
- package/dist/chunk-AQP6SCCJ.js.map +1 -0
- package/dist/chunk-B5WDN63X.js +84 -0
- package/dist/chunk-B5WDN63X.js.map +1 -0
- package/dist/{chunk-26OVU2AE.js → chunk-BNKVENDF.js} +8 -8
- package/dist/chunk-DAKJTB6N.js +76 -0
- package/dist/chunk-DAKJTB6N.js.map +1 -0
- package/dist/{chunk-3N3UQEC4.js → chunk-DCCC7LEP.js} +4 -3
- package/dist/chunk-DCCC7LEP.js.map +1 -0
- package/dist/chunk-E67DOUVU.js +289 -0
- package/dist/chunk-E67DOUVU.js.map +1 -0
- package/dist/{chunk-6E2I2FBJ.js → chunk-E7WPTSHQ.js} +22 -22
- package/dist/chunk-EL3XL2OC.js +150 -0
- package/dist/chunk-EL3XL2OC.js.map +1 -0
- package/dist/{chunk-CLBQ7ZC4.js → chunk-F3PEUOTP.js} +3 -3
- package/dist/{chunk-ICJPVSRY.js → chunk-FKM67CZZ.js} +53 -51
- package/dist/chunk-FKM67CZZ.js.map +1 -0
- package/dist/{chunk-CCTALU3C.js → chunk-FMLE2WSN.js} +2 -2
- package/dist/{chunk-QSOEMCWQ.js → chunk-FSQJOZS4.js} +17 -10
- package/dist/chunk-FSQJOZS4.js.map +1 -0
- package/dist/chunk-FZHFD2AY.js +27 -0
- package/dist/chunk-FZHFD2AY.js.map +1 -0
- package/dist/{chunk-OTAZOIXK.js → chunk-GZGJQKQT.js} +2 -2
- package/dist/{chunk-5WM24P5N.js → chunk-I6MILNM5.js} +2 -2
- package/dist/chunk-I6MILNM5.js.map +1 -0
- package/dist/{chunk-S3BAD4IR.js → chunk-ICXUTMGH.js} +2 -2
- package/dist/{chunk-PRDRRU2B.js → chunk-IDQVTWLX.js} +5 -5
- package/dist/{chunk-3C3BKZ3H.js → chunk-IFQOOCT7.js} +8 -8
- package/dist/{chunk-TPSFJSO7.js → chunk-IKX3B26P.js} +13 -10
- package/dist/chunk-IKX3B26P.js.map +1 -0
- package/dist/{chunk-OMIMK3LB.js → chunk-IOHK45WE.js} +2 -2
- package/dist/{chunk-SG5LUMGE.js → chunk-JNBMANFM.js} +6 -3
- package/dist/chunk-JNBMANFM.js.map +1 -0
- package/dist/{chunk-QEVYCCKD.js → chunk-JNCKZ3OF.js} +12 -34
- package/dist/chunk-JNCKZ3OF.js.map +1 -0
- package/dist/{chunk-CMO5YUZR.js → chunk-JVBIWU7S.js} +4 -4
- package/dist/chunk-JVE2JFLV.js +15 -0
- package/dist/chunk-JVE2JFLV.js.map +1 -0
- package/dist/{chunk-MG5TTLYZ.js → chunk-KDO7D46L.js} +3 -3
- package/dist/{chunk-CYWI3ZW7.js → chunk-KL4YYV37.js} +4 -4
- package/dist/chunk-KSVYR4G2.js +47 -0
- package/dist/chunk-KSVYR4G2.js.map +1 -0
- package/dist/{chunk-RYNBBSLY.js → chunk-KWHHB737.js} +6 -8
- package/dist/chunk-KWHHB737.js.map +1 -0
- package/dist/chunk-L22AWXWA.js +29 -0
- package/dist/chunk-L22AWXWA.js.map +1 -0
- package/dist/{chunk-WXE7D44E.js → chunk-LJKF73JB.js} +8 -8
- package/dist/chunk-LJKF73JB.js.map +1 -0
- package/dist/{chunk-BSP2Z7B7.js → chunk-LKESANVD.js} +6 -6
- package/dist/{chunk-XVNRP7XE.js → chunk-LZZCJAJQ.js} +11 -11
- package/dist/{chunk-IPGH7TXJ.js → chunk-MM7344RC.js} +2 -2
- package/dist/{chunk-HMK3INUS.js → chunk-MQCDFSVF.js} +2 -2
- package/dist/{chunk-VJ7SVDED.js → chunk-MSJWQC7H.js} +6 -4
- package/dist/chunk-MSJWQC7H.js.map +1 -0
- package/dist/chunk-NWOCQVSL.js +307 -0
- package/dist/chunk-NWOCQVSL.js.map +1 -0
- package/dist/{chunk-RGUSVBGN.js → chunk-OCMNBOPX.js} +2 -2
- package/dist/{chunk-72IBYKIY.js → chunk-PCNNW63Z.js} +16 -5
- package/dist/chunk-PCNNW63Z.js.map +1 -0
- package/dist/chunk-PHGVVFTF.js +1603 -0
- package/dist/chunk-PHGVVFTF.js.map +1 -0
- package/dist/{chunk-4NITDMDH.js → chunk-PPZP7CA7.js} +9 -186
- package/dist/chunk-PPZP7CA7.js.map +1 -0
- package/dist/{chunk-X4AXKO3A.js → chunk-RGLIW45S.js} +2 -2
- package/dist/{chunk-P6BHOAQG.js → chunk-RHDZPV6C.js} +2 -2
- package/dist/{chunk-3GIH4WTA.js → chunk-RJUMLWXP.js} +109 -104
- package/dist/chunk-RJUMLWXP.js.map +1 -0
- package/dist/chunk-RQFHA5BM.js +1443 -0
- package/dist/chunk-RQFHA5BM.js.map +1 -0
- package/dist/chunk-S3CTXKSN.js +17 -0
- package/dist/chunk-S3CTXKSN.js.map +1 -0
- package/dist/chunk-SJBEIYLK.js +16 -0
- package/dist/chunk-SJBEIYLK.js.map +1 -0
- package/dist/chunk-TIG7NHVO.js +231 -0
- package/dist/chunk-TIG7NHVO.js.map +1 -0
- package/dist/{chunk-ATED7SAH.js → chunk-TKWUSJNQ.js} +36 -23
- package/dist/chunk-TKWUSJNQ.js.map +1 -0
- package/dist/{chunk-DQCUYCMX.js → chunk-UP2JTDBI.js} +3 -3
- package/dist/chunk-V4U5RGEG.js +59 -0
- package/dist/chunk-V4U5RGEG.js.map +1 -0
- package/dist/{chunk-HEPBANFJ.js → chunk-V7GCYL6A.js} +93 -196
- package/dist/chunk-V7GCYL6A.js.map +1 -0
- package/dist/{chunk-WC534PXU.js → chunk-VFH4SU3M.js} +34 -23
- package/dist/chunk-VFH4SU3M.js.map +1 -0
- package/dist/{chunk-KSUOVFO3.js → chunk-VV3NFLLP.js} +16 -9
- package/dist/chunk-VV3NFLLP.js.map +1 -0
- package/dist/{chunk-INQQGV2G.js → chunk-WKOJ7NXD.js} +4 -4
- package/dist/{chunk-7OUIZ2YQ.js → chunk-WVV54JP3.js} +56 -58
- package/dist/chunk-WVV54JP3.js.map +1 -0
- package/dist/chunk-WY7QZ2P7.js +71 -0
- package/dist/chunk-WY7QZ2P7.js.map +1 -0
- package/dist/{chunk-YYBXQBW2.js → chunk-Y7T73SAP.js} +13 -3
- package/dist/chunk-Y7T73SAP.js.map +1 -0
- package/dist/{chunk-WXMWZRBH.js → chunk-Z6ZMWFNV.js} +25 -7
- package/dist/chunk-Z6ZMWFNV.js.map +1 -0
- package/dist/{chunk-VUAVPBFR.js → chunk-Z7I6DQAR.js} +42 -57
- package/dist/chunk-Z7I6DQAR.js.map +1 -0
- package/dist/{chunk-GNGXYXBC.js → chunk-ZRATYLBB.js} +2 -2
- package/dist/{cleanup-5PSLKZLF.js → cleanup-M5TY4FQS.js} +46 -34
- package/dist/{cleanup-5PSLKZLF.js.map → cleanup-M5TY4FQS.js.map} +1 -1
- package/dist/cli-446A536X.js +19 -0
- package/dist/{completion-MXX5TRIV.js → completion-IAH7WRKJ.js} +3 -2
- package/dist/{completion-MXX5TRIV.js.map → completion-IAH7WRKJ.js.map} +1 -1
- package/dist/{config-6MSITKGB.js → config-JLORGUXN.js} +16 -13
- package/dist/{config-6MSITKGB.js.map → config-JLORGUXN.js.map} +1 -1
- package/dist/{diff-Q7MV6YGJ.js → diff-4O5HXNZ7.js} +23 -20
- package/dist/{diff-Q7MV6YGJ.js.map → diff-4O5HXNZ7.js.map} +1 -1
- package/dist/{digest-KUMVYXKZ.js → digest-IAAZXJCC.js} +13 -11
- package/dist/{digest-KUMVYXKZ.js.map → digest-IAAZXJCC.js.map} +1 -1
- package/dist/{fork-OFENISEM.js → fork-ULJYPEKY.js} +41 -28
- package/dist/{fork-OFENISEM.js.map → fork-ULJYPEKY.js.map} +1 -1
- package/dist/{history-5WKRWARZ.js → history-JFZF22M7.js} +12 -10
- package/dist/{hook-ARS32DG2.js → hook-UYOIQVJ7.js} +54 -20
- package/dist/hook-UYOIQVJ7.js.map +1 -0
- package/dist/{hydrate-LCT6DVB3.js → hydrate-DROI4RJ7.js} +14 -12
- package/dist/{hydrate-LCT6DVB3.js.map → hydrate-DROI4RJ7.js.map} +1 -1
- package/dist/{init-FJKPEY5N.js → init-FF75CQM7.js} +27 -19
- package/dist/{init-FJKPEY5N.js.map → init-FF75CQM7.js.map} +1 -1
- package/dist/install-skills-XSAHNBYD.js +22 -0
- package/dist/install-skills-bin.js +8 -6
- package/dist/install-skills-bin.js.map +1 -1
- package/dist/{list-GTKP5FAW.js → list-5FEHBP6N.js} +15 -13
- package/dist/{list-GTKP5FAW.js.map → list-5FEHBP6N.js.map} +1 -1
- package/dist/{move-GOCLEFGZ.js → move-422L6PPI.js} +33 -24
- package/dist/{move-GOCLEFGZ.js.map → move-422L6PPI.js.map} +1 -1
- package/dist/{note-B7TQBXQF.js → note-AAXPD5VA.js} +14 -12
- package/dist/{note-B7TQBXQF.js.map → note-AAXPD5VA.js.map} +1 -1
- package/dist/{overlaps-UKQHIJMU.js → overlaps-WPNUYOFF.js} +21 -11
- package/dist/{overlaps-UKQHIJMU.js.map → overlaps-WPNUYOFF.js.map} +1 -1
- package/dist/{pin-UZZCDK7M.js → pin-QXPF23BB.js} +14 -12
- package/dist/{pin-UZZCDK7M.js.map → pin-QXPF23BB.js.map} +1 -1
- package/dist/{pr-NU2ME2XW.js → pr-QLGXPKPQ.js} +46 -21
- package/dist/pr-QLGXPKPQ.js.map +1 -0
- package/dist/{prune-IZGEYTSB.js → prune-GRHKRRVT.js} +44 -32
- package/dist/{prune-IZGEYTSB.js.map → prune-GRHKRRVT.js.map} +1 -1
- package/dist/{pty-host-AWDIKPQN.js → pty-host-XDDXA4SL.js} +103 -39
- package/dist/pty-host-XDDXA4SL.js.map +1 -0
- package/dist/{read-U6GBGA5E.js → read-YWKD2DGP.js} +13 -11
- package/dist/{read-U6GBGA5E.js.map → read-YWKD2DGP.js.map} +1 -1
- package/dist/{recent-2DUMLUDG.js → recent-SI5BDVVH.js} +35 -26
- package/dist/recent-SI5BDVVH.js.map +1 -0
- package/dist/{remove-OXUP4O33.js → remove-RXXCHY44.js} +48 -36
- package/dist/{remove-OXUP4O33.js.map → remove-RXXCHY44.js.map} +1 -1
- package/dist/{restart-QEW4DJC3.js → restart-CPNDEXU6.js} +17 -15
- package/dist/{restart-QEW4DJC3.js.map → restart-CPNDEXU6.js.map} +1 -1
- package/dist/{resume-K45IT4QO.js → resume-BLP4TTJK.js} +35 -20
- package/dist/resume-BLP4TTJK.js.map +1 -0
- package/dist/review-now-ADWZPELT.js +22 -0
- package/dist/review-now-ADWZPELT.js.map +1 -0
- package/dist/{run-42LORGPS.js → run-JFCDJ3EV.js} +21 -15
- package/dist/run-JFCDJ3EV.js.map +1 -0
- package/dist/{screen-2TLIUH3G.js → screen-LBOPAUXV.js} +14 -12
- package/dist/{screen-2TLIUH3G.js.map → screen-LBOPAUXV.js.map} +1 -1
- package/dist/{search-7E4B2KX6.js → search-AMEGRH24.js} +10 -8
- package/dist/{search-7E4B2KX6.js.map → search-AMEGRH24.js.map} +1 -1
- package/dist/{section-OVA5VD7L.js → section-73Z34PVE.js} +14 -12
- package/dist/{section-OVA5VD7L.js.map → section-73Z34PVE.js.map} +1 -1
- package/dist/{send-BJY5CYLO.js → send-IZBSEET5.js} +19 -16
- package/dist/send-IZBSEET5.js.map +1 -0
- package/dist/{sessions-4A24ZORW.js → sessions-WVQ2U2W4.js} +58 -23
- package/dist/sessions-WVQ2U2W4.js.map +1 -0
- package/dist/{snooze-WIVKB3GH.js → snooze-7IBHY5MY.js} +13 -11
- package/dist/{snooze-WIVKB3GH.js.map → snooze-7IBHY5MY.js.map} +1 -1
- package/dist/{start-G6GR533S.js → start-AU62TW6M.js} +14 -12
- package/dist/{start-G6GR533S.js.map → start-AU62TW6M.js.map} +1 -1
- package/dist/{state-S3DGLT4J.js → state-IZV7DAPL.js} +8 -5
- package/dist/state-IZV7DAPL.js.map +1 -0
- package/dist/{status-BTAWY6JQ.js → status-Z7OMNYZX.js} +38 -13
- package/dist/status-Z7OMNYZX.js.map +1 -0
- package/dist/{statusline-WLXEU5DM.js → statusline-VJFY7ZAB.js} +12 -11
- package/dist/{statusline-WLXEU5DM.js.map → statusline-VJFY7ZAB.js.map} +1 -1
- package/dist/{statusline-hook-OVWHHFBV.js → statusline-hook-JA7MNE5H.js} +4 -3
- package/dist/{statusline-hook-OVWHHFBV.js.map → statusline-hook-JA7MNE5H.js.map} +1 -1
- package/dist/{stop-FN6EPFJ4.js → stop-PWNXSFBD.js} +14 -12
- package/dist/{stop-FN6EPFJ4.js.map → stop-PWNXSFBD.js.map} +1 -1
- package/dist/{sync-T3BSHX6Q.js → sync-2BTZVDDG.js} +44 -32
- package/dist/{sync-T3BSHX6Q.js.map → sync-2BTZVDDG.js.map} +1 -1
- package/dist/{time-5CH5O5MZ.js → time-CTCIAXIY.js} +15 -13
- package/dist/{time-5CH5O5MZ.js.map → time-CTCIAXIY.js.map} +1 -1
- package/dist/{time-actions-XEUQ3UF7.js → time-actions-UYBOXET6.js} +5 -4
- package/dist/{timesheet-FMQKPS5S.js → timesheet-BUFQ34FC.js} +24 -15
- package/dist/{timesheet-FMQKPS5S.js.map → timesheet-BUFQ34FC.js.map} +1 -1
- package/dist/{todo-23COLGR2.js → todo-2R7VID57.js} +4 -4
- package/dist/{tree-T33VU473.js → tree-LQDPAXQA.js} +65 -45
- package/dist/tree-LQDPAXQA.js.map +1 -0
- package/dist/{update-PJRSKQZ2.js → update-2IYJHY7H.js} +24 -14
- package/dist/{update-PJRSKQZ2.js.map → update-2IYJHY7H.js.map} +1 -1
- package/dist/{usage-TL66LWO4.js → usage-IR5GNF4R.js} +13 -11
- package/dist/{usage-TL66LWO4.js.map → usage-IR5GNF4R.js.map} +1 -1
- package/dist/version-ONEI52TI.js +115 -0
- package/dist/version-ONEI52TI.js.map +1 -0
- package/dist/{wait-YIEJO6YM.js → wait-6DH34L53.js} +16 -13
- package/dist/{wait-YIEJO6YM.js.map → wait-6DH34L53.js.map} +1 -1
- package/dist/wd-bin.js +6 -6
- package/dist/web/assets/{PtyView-DnDd6jLI.js → PtyView-kBcAOwHr.js} +2 -2
- package/dist/web/assets/{PtyView-DnDd6jLI.js.map → PtyView-kBcAOwHr.js.map} +1 -1
- package/dist/web/assets/index-BgfR3N99.js +124 -0
- package/dist/web/assets/index-BgfR3N99.js.map +1 -0
- package/dist/web/assets/index-CKpHjII8.css +1 -0
- package/dist/web/index.html +2 -2
- package/dist/{web-IYUNJMQD.js → web-RIHGV7YY.js} +2786 -451
- package/dist/web-RIHGV7YY.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/work-tree/skills/wd-review/SKILL.md +1 -1
- package/plugins/work-tree/skills/work-sessions/SKILL.md +2 -2
- package/dist/account-NG75VLRU.js.map +0 -1
- package/dist/block-D5CAR53T.js.map +0 -1
- package/dist/chunk-2JNW2AQ2.js.map +0 -1
- package/dist/chunk-37XQIG7F.js.map +0 -1
- package/dist/chunk-3GIH4WTA.js.map +0 -1
- package/dist/chunk-3N3UQEC4.js.map +0 -1
- package/dist/chunk-4NITDMDH.js.map +0 -1
- package/dist/chunk-5WM24P5N.js.map +0 -1
- package/dist/chunk-63VY4YJM.js.map +0 -1
- package/dist/chunk-6FVYSW3E.js.map +0 -1
- package/dist/chunk-72IBYKIY.js.map +0 -1
- package/dist/chunk-7OUIZ2YQ.js.map +0 -1
- package/dist/chunk-AAYWHIIT.js.map +0 -1
- package/dist/chunk-ATED7SAH.js.map +0 -1
- package/dist/chunk-GRLKPVTP.js.map +0 -1
- package/dist/chunk-HEPBANFJ.js.map +0 -1
- package/dist/chunk-ICJPVSRY.js.map +0 -1
- package/dist/chunk-IWJXFNM4.js.map +0 -1
- package/dist/chunk-KSUOVFO3.js.map +0 -1
- package/dist/chunk-NWIVXGSL.js +0 -9
- package/dist/chunk-PTWVOT7A.js +0 -551
- package/dist/chunk-PTWVOT7A.js.map +0 -1
- package/dist/chunk-QEVYCCKD.js.map +0 -1
- package/dist/chunk-QHTXLCG7.js.map +0 -1
- package/dist/chunk-QSOEMCWQ.js.map +0 -1
- package/dist/chunk-RCYI7SRA.js +0 -15
- package/dist/chunk-RCYI7SRA.js.map +0 -1
- package/dist/chunk-RYNBBSLY.js.map +0 -1
- package/dist/chunk-S3FMTEFR.js.map +0 -1
- package/dist/chunk-SG5LUMGE.js.map +0 -1
- package/dist/chunk-TPSFJSO7.js.map +0 -1
- package/dist/chunk-VJ7SVDED.js.map +0 -1
- package/dist/chunk-VTLDYH3C.js +0 -227
- package/dist/chunk-VTLDYH3C.js.map +0 -1
- package/dist/chunk-VUAVPBFR.js.map +0 -1
- package/dist/chunk-WC534PXU.js.map +0 -1
- package/dist/chunk-WTQ2QCAG.js.map +0 -1
- package/dist/chunk-WXE7D44E.js.map +0 -1
- package/dist/chunk-WXMWZRBH.js.map +0 -1
- package/dist/chunk-YYBXQBW2.js.map +0 -1
- package/dist/chunk-ZDMJPEBO.js +0 -31
- package/dist/chunk-ZDMJPEBO.js.map +0 -1
- package/dist/chunk-ZI2KXTKM.js.map +0 -1
- package/dist/cli-AF7636FA.js +0 -19
- package/dist/hook-ARS32DG2.js.map +0 -1
- package/dist/install-skills-UYAFVJBA.js +0 -20
- package/dist/pr-NU2ME2XW.js.map +0 -1
- package/dist/pty-host-AWDIKPQN.js.map +0 -1
- package/dist/recent-2DUMLUDG.js.map +0 -1
- package/dist/resume-K45IT4QO.js.map +0 -1
- package/dist/run-42LORGPS.js.map +0 -1
- package/dist/send-BJY5CYLO.js.map +0 -1
- package/dist/sessions-4A24ZORW.js.map +0 -1
- package/dist/state-S3DGLT4J.js.map +0 -1
- package/dist/status-BTAWY6JQ.js.map +0 -1
- package/dist/tree-T33VU473.js.map +0 -1
- package/dist/web/assets/index-DxozAoUO.css +0 -1
- package/dist/web/assets/index-InmdAx6g.js +0 -120
- package/dist/web/assets/index-InmdAx6g.js.map +0 -1
- package/dist/web-IYUNJMQD.js.map +0 -1
- /package/dist/{chunk-T7AFYEQ7.js.map → chunk-2K5TDJ7M.js.map} +0 -0
- /package/dist/{chunk-QL36KN7X.js.map → chunk-353ZINJ2.js.map} +0 -0
- /package/dist/{chunk-5QGCF3PS.js.map → chunk-3BSFVKMK.js.map} +0 -0
- /package/dist/{chunk-J36ULZBO.js.map → chunk-4K4S53KX.js.map} +0 -0
- /package/dist/{chunk-P4EQWC5W.js.map → chunk-ADIN3DTD.js.map} +0 -0
- /package/dist/{chunk-KUCMJHQW.js.map → chunk-AHYCZUPI.js.map} +0 -0
- /package/dist/{chunk-26OVU2AE.js.map → chunk-BNKVENDF.js.map} +0 -0
- /package/dist/{chunk-6E2I2FBJ.js.map → chunk-E7WPTSHQ.js.map} +0 -0
- /package/dist/{chunk-CLBQ7ZC4.js.map → chunk-F3PEUOTP.js.map} +0 -0
- /package/dist/{chunk-CCTALU3C.js.map → chunk-FMLE2WSN.js.map} +0 -0
- /package/dist/{chunk-OTAZOIXK.js.map → chunk-GZGJQKQT.js.map} +0 -0
- /package/dist/{chunk-S3BAD4IR.js.map → chunk-ICXUTMGH.js.map} +0 -0
- /package/dist/{chunk-PRDRRU2B.js.map → chunk-IDQVTWLX.js.map} +0 -0
- /package/dist/{chunk-3C3BKZ3H.js.map → chunk-IFQOOCT7.js.map} +0 -0
- /package/dist/{chunk-OMIMK3LB.js.map → chunk-IOHK45WE.js.map} +0 -0
- /package/dist/{chunk-CMO5YUZR.js.map → chunk-JVBIWU7S.js.map} +0 -0
- /package/dist/{chunk-MG5TTLYZ.js.map → chunk-KDO7D46L.js.map} +0 -0
- /package/dist/{chunk-CYWI3ZW7.js.map → chunk-KL4YYV37.js.map} +0 -0
- /package/dist/{chunk-BSP2Z7B7.js.map → chunk-LKESANVD.js.map} +0 -0
- /package/dist/{chunk-XVNRP7XE.js.map → chunk-LZZCJAJQ.js.map} +0 -0
- /package/dist/{chunk-IPGH7TXJ.js.map → chunk-MM7344RC.js.map} +0 -0
- /package/dist/{chunk-HMK3INUS.js.map → chunk-MQCDFSVF.js.map} +0 -0
- /package/dist/{chunk-RGUSVBGN.js.map → chunk-OCMNBOPX.js.map} +0 -0
- /package/dist/{chunk-X4AXKO3A.js.map → chunk-RGLIW45S.js.map} +0 -0
- /package/dist/{chunk-P6BHOAQG.js.map → chunk-RHDZPV6C.js.map} +0 -0
- /package/dist/{chunk-DQCUYCMX.js.map → chunk-UP2JTDBI.js.map} +0 -0
- /package/dist/{chunk-INQQGV2G.js.map → chunk-WKOJ7NXD.js.map} +0 -0
- /package/dist/{chunk-GNGXYXBC.js.map → chunk-ZRATYLBB.js.map} +0 -0
- /package/dist/{cli-AF7636FA.js.map → cli-446A536X.js.map} +0 -0
- /package/dist/{history-5WKRWARZ.js.map → history-JFZF22M7.js.map} +0 -0
- /package/dist/{install-skills-UYAFVJBA.js.map → install-skills-XSAHNBYD.js.map} +0 -0
- /package/dist/{time-actions-XEUQ3UF7.js.map → time-actions-UYBOXET6.js.map} +0 -0
- /package/dist/{todo-23COLGR2.js.map → todo-2R7VID57.js.map} +0 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
MAX_WATCHED_BRANCHES,
|
|
4
|
+
backfillSessionBranches,
|
|
5
|
+
branchHidden,
|
|
6
|
+
noteBranchFacts,
|
|
7
|
+
readSessionBranches,
|
|
8
|
+
repoNameOf
|
|
9
|
+
} from "./chunk-E67DOUVU.js";
|
|
10
|
+
import {
|
|
11
|
+
defaultRunner
|
|
12
|
+
} from "./chunk-KSVYR4G2.js";
|
|
13
|
+
import {
|
|
14
|
+
bestEffort,
|
|
15
|
+
checkedOutBranch,
|
|
16
|
+
logSwallowed,
|
|
17
|
+
stageOfPr
|
|
18
|
+
} from "./chunk-27LWL6QE.js";
|
|
19
|
+
import {
|
|
20
|
+
sessionIdFor
|
|
21
|
+
} from "./chunk-Y7T73SAP.js";
|
|
22
|
+
|
|
23
|
+
// src/core/stacks/branch-facts.ts
|
|
24
|
+
async function repoBase(repo, run = defaultRunner) {
|
|
25
|
+
const head = await run("git", ["-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], repo);
|
|
26
|
+
const base = head.code === 0 ? head.stdout.trim() : "";
|
|
27
|
+
return base && base !== "origin/HEAD" ? base : null;
|
|
28
|
+
}
|
|
29
|
+
var count = (out) => out.code === 0 && /^\d+$/.test(out.stdout.trim()) ? Number(out.stdout.trim()) : null;
|
|
30
|
+
async function branchFacts(repo, name, run = defaultRunner, base) {
|
|
31
|
+
const git = (...args) => run("git", ["-C", repo, ...args], repo);
|
|
32
|
+
const local = `refs/heads/${name}`;
|
|
33
|
+
const remote = `refs/remotes/origin/${name}`;
|
|
34
|
+
const tip = await git("rev-parse", "--verify", "--quiet", local);
|
|
35
|
+
const exists = tip.code === 0;
|
|
36
|
+
const pushed = (await git("rev-parse", "--verify", "--quiet", remote)).code === 0;
|
|
37
|
+
if (!exists) return { exists, sha: null, pushed, commits: null, unpushed: null, merged: false };
|
|
38
|
+
const main = base === void 0 ? await repoBase(repo, run) : base;
|
|
39
|
+
const commits = main ? count(await git("rev-list", "--count", `${main}..${local}`)) : null;
|
|
40
|
+
const unpushed = pushed ? count(await git("rev-list", "--count", `${remote}..${local}`)) : commits;
|
|
41
|
+
return { exists, sha: tip.stdout.trim() || null, pushed, commits, unpushed, merged: pushed && commits === 0 };
|
|
42
|
+
}
|
|
43
|
+
var factsKey = (repo, name) => `${repo}\0${name}`;
|
|
44
|
+
var BranchFactsCache = class {
|
|
45
|
+
constructor(opts = {}) {
|
|
46
|
+
this.opts = opts;
|
|
47
|
+
}
|
|
48
|
+
entries = /* @__PURE__ */ new Map();
|
|
49
|
+
running = 0;
|
|
50
|
+
queue = [];
|
|
51
|
+
/** What the last look found (an empty map before the first); schedules one when stale or the branches changed. */
|
|
52
|
+
get(id, jobs) {
|
|
53
|
+
const now = (this.opts.now ?? Date.now)();
|
|
54
|
+
const key = jobs.map((j) => factsKey(j.repo, j.name)).join("|");
|
|
55
|
+
const e = this.entries.get(id);
|
|
56
|
+
const moved = !!e && e.key !== key;
|
|
57
|
+
if (!e || moved || !e.inFlight && now - e.at > (this.opts.ttlMs ?? 5 * 6e4)) this.schedule(id, jobs, key);
|
|
58
|
+
return this.entries.get(id)?.value ?? /* @__PURE__ */ new Map();
|
|
59
|
+
}
|
|
60
|
+
/** Look again soon (a turn ended, a push). */
|
|
61
|
+
invalidate(id) {
|
|
62
|
+
const e = this.entries.get(id);
|
|
63
|
+
if (e) e.at = 0;
|
|
64
|
+
}
|
|
65
|
+
async idle() {
|
|
66
|
+
while (this.running > 0 || this.queue.length > 0) await new Promise((r) => setTimeout(r, 5));
|
|
67
|
+
}
|
|
68
|
+
schedule(id, jobs, key) {
|
|
69
|
+
const e = this.entries.get(id) ?? { value: /* @__PURE__ */ new Map(), at: 0, inFlight: false, key };
|
|
70
|
+
if (e.inFlight && e.key === key) return;
|
|
71
|
+
e.inFlight = true;
|
|
72
|
+
e.key = key;
|
|
73
|
+
this.entries.set(id, e);
|
|
74
|
+
this.queue.push({ id, jobs });
|
|
75
|
+
this.pump();
|
|
76
|
+
}
|
|
77
|
+
pump() {
|
|
78
|
+
while (this.running < (this.opts.concurrency ?? 2) && this.queue.length > 0) {
|
|
79
|
+
const job = this.queue.shift();
|
|
80
|
+
this.running++;
|
|
81
|
+
void lookAt(job.jobs, this.opts.run).catch((err) => {
|
|
82
|
+
logSwallowed(`branch facts for ${job.id}`, err);
|
|
83
|
+
return null;
|
|
84
|
+
}).then((found) => {
|
|
85
|
+
const e = this.entries.get(job.id);
|
|
86
|
+
e.inFlight = false;
|
|
87
|
+
e.at = (this.opts.now ?? Date.now)();
|
|
88
|
+
if (!found) return;
|
|
89
|
+
const value = new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)]));
|
|
90
|
+
const changed = JSON.stringify([...e.value]) !== JSON.stringify([...value]);
|
|
91
|
+
e.value = value;
|
|
92
|
+
this.opts.onFacts?.(job.id, found);
|
|
93
|
+
if (changed) this.opts.onChange?.();
|
|
94
|
+
}).finally(() => {
|
|
95
|
+
this.running--;
|
|
96
|
+
this.pump();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var strip = (f) => ({
|
|
102
|
+
exists: f.exists,
|
|
103
|
+
sha: f.sha,
|
|
104
|
+
pushed: f.pushed,
|
|
105
|
+
commits: f.commits,
|
|
106
|
+
unpushed: f.unpushed,
|
|
107
|
+
merged: f.merged
|
|
108
|
+
});
|
|
109
|
+
async function lookAt(jobs, run) {
|
|
110
|
+
const bases = /* @__PURE__ */ new Map();
|
|
111
|
+
const out = [];
|
|
112
|
+
for (const j of jobs) {
|
|
113
|
+
if (!bases.has(j.path)) bases.set(j.path, await repoBase(j.path, run));
|
|
114
|
+
out.push({ ...j, ...await branchFacts(j.path, j.name, run, bases.get(j.path)) });
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
function prOfBranch(ci, repo, name) {
|
|
119
|
+
const r = ci?.repos.find((x) => x.name === repo);
|
|
120
|
+
if (!r) return null;
|
|
121
|
+
if (r.branch === name && r.pr) return r.pr;
|
|
122
|
+
return r.otherPrs?.find((o) => o.branch === name)?.pr ?? null;
|
|
123
|
+
}
|
|
124
|
+
function branchesWire(rec, current, facts, ci, now) {
|
|
125
|
+
if (!rec?.branches.length) return null;
|
|
126
|
+
const rows = [];
|
|
127
|
+
for (const b of rec.branches) {
|
|
128
|
+
const pr = prOfBranch(ci, b.repo, b.name);
|
|
129
|
+
if (branchHidden(b, now, pr?.state === "MERGED")) continue;
|
|
130
|
+
const f = facts.get(factsKey(b.repo, b.name));
|
|
131
|
+
rows.push({
|
|
132
|
+
repo: b.repo,
|
|
133
|
+
name: b.name,
|
|
134
|
+
current: current(b.repo) === b.name,
|
|
135
|
+
firstSeen: b.firstSeen,
|
|
136
|
+
lastSeen: b.lastSeen,
|
|
137
|
+
...b.from ? { from: b.from } : {},
|
|
138
|
+
...f ? {
|
|
139
|
+
exists: f.exists,
|
|
140
|
+
pushed: f.pushed,
|
|
141
|
+
commits: f.commits,
|
|
142
|
+
unpushed: f.unpushed,
|
|
143
|
+
merged: f.merged || !!b.merged || pr?.state === "MERGED"
|
|
144
|
+
} : b.merged || pr?.state === "MERGED" ? { merged: true } : {},
|
|
145
|
+
...pr ? { pr: { number: pr.number, url: pr.url, state: pr.state, kind: stageOfPr(pr) } } : {}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const repos = new Set(rows.map((r) => r.repo));
|
|
149
|
+
if (![...repos].some((repo) => rows.filter((r) => r.repo === repo).length > 1)) return null;
|
|
150
|
+
return rows.sort(
|
|
151
|
+
(a, b) => Number(b.current) - Number(a.current) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen) || a.repo.localeCompare(b.repo)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
function createSessionBranches(opts = {}) {
|
|
155
|
+
const now = opts.now ?? Date.now;
|
|
156
|
+
const facts = new BranchFactsCache({
|
|
157
|
+
...opts.run ? { run: opts.run } : {},
|
|
158
|
+
now,
|
|
159
|
+
onChange: opts.onChange,
|
|
160
|
+
onFacts: (id, found) => bestEffort(`keep the branch facts of ${id}`, () => (opts.keepFacts ?? ((sid, f) => noteBranchFacts(sid, f)))(id, found))
|
|
161
|
+
});
|
|
162
|
+
const backfill = opts.backfill ?? ((s) => backfillSessionBranches(s));
|
|
163
|
+
const asked = /* @__PURE__ */ new Set();
|
|
164
|
+
const waiting = [];
|
|
165
|
+
let busy = false;
|
|
166
|
+
const pump = () => {
|
|
167
|
+
if (busy) return;
|
|
168
|
+
const s = waiting.shift();
|
|
169
|
+
if (!s) return;
|
|
170
|
+
busy = true;
|
|
171
|
+
setImmediate(() => {
|
|
172
|
+
const rec = bestEffort(`read the branches of ${s.target}:${s.branch} from its reflog`, () => backfill(s));
|
|
173
|
+
busy = false;
|
|
174
|
+
if (rec && branchJobs(s, rec, now())) opts.onChange?.();
|
|
175
|
+
pump();
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
/** The row's branches (branchesWire), from what was recorded and last looked at. */
|
|
180
|
+
wire(s, rec, ci) {
|
|
181
|
+
if (s.archivedAt) return null;
|
|
182
|
+
const id = sessionIdFor(s);
|
|
183
|
+
if (!rec?.backfilled && !asked.has(id)) {
|
|
184
|
+
asked.add(id);
|
|
185
|
+
waiting.push(s);
|
|
186
|
+
pump();
|
|
187
|
+
}
|
|
188
|
+
const plan = branchJobs(s, rec, now());
|
|
189
|
+
return plan ? branchesWire(rec, plan.current, facts.get(id, plan.jobs), ci, now()) : null;
|
|
190
|
+
},
|
|
191
|
+
invalidate: (id) => facts.invalidate(id),
|
|
192
|
+
async idle() {
|
|
193
|
+
await facts.idle();
|
|
194
|
+
while (busy || waiting.length) await new Promise((r) => setTimeout(r, 5));
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function branchJobs(s, rec, now) {
|
|
199
|
+
if (!rec?.branches.length) return null;
|
|
200
|
+
const currentOf = new Map(s.paths.map((p) => [repoNameOf(s, p), checkedOutBranch(p)]));
|
|
201
|
+
const visible = rec.branches.filter((b) => !branchHidden(b, now));
|
|
202
|
+
const repos = new Set(visible.map((b) => b.repo));
|
|
203
|
+
if (![...repos].some((r) => visible.filter((b) => b.repo === r).length > 1)) return null;
|
|
204
|
+
const pathOf = new Map(s.paths.map((p) => [repoNameOf(s, p), p]));
|
|
205
|
+
const jobs = [];
|
|
206
|
+
for (const repo of repos) {
|
|
207
|
+
const p = pathOf.get(repo);
|
|
208
|
+
if (!p) continue;
|
|
209
|
+
const isCurrent = (name) => Number(name === currentOf.get(repo));
|
|
210
|
+
const mine = visible.filter((b) => b.repo === repo).sort((a, b) => isCurrent(b.name) - isCurrent(a.name) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen)).slice(0, MAX_WATCHED_BRANCHES + 1);
|
|
211
|
+
for (const b of mine) jobs.push({ repo, path: p, name: b.name });
|
|
212
|
+
}
|
|
213
|
+
return { jobs, current: (repo) => currentOf.get(repo) ?? null };
|
|
214
|
+
}
|
|
215
|
+
async function sessionBranchesNow(s, ci, run = defaultRunner, now = Date.now()) {
|
|
216
|
+
if (s.archivedAt) return null;
|
|
217
|
+
let rec = readSessionBranches(sessionIdFor(s));
|
|
218
|
+
if (!rec?.backfilled) rec = bestEffort(`read the branches of ${s.target}:${s.branch}`, () => backfillSessionBranches(s), rec) ?? rec;
|
|
219
|
+
const plan = branchJobs(s, rec, now);
|
|
220
|
+
if (!plan) return null;
|
|
221
|
+
const found = await lookAt(plan.jobs, run);
|
|
222
|
+
return branchesWire(rec, plan.current, new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)])), ci, now);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export {
|
|
226
|
+
repoBase,
|
|
227
|
+
branchFacts,
|
|
228
|
+
createSessionBranches,
|
|
229
|
+
sessionBranchesNow
|
|
230
|
+
};
|
|
231
|
+
//# sourceMappingURL=chunk-TIG7NHVO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/stacks/branch-facts.ts"],"sourcesContent":["import { defaultRunner, type CommandRunner } from '../platform/command-runner.js';\nimport { bestEffort, logSwallowed } from '../platform/best-effort.js';\nimport type { SessionBranchWire, SessionCi, ShipPr } from '../api-types.js';\nimport { stageOfPr } from '../pr/pr-stage.js';\nimport {\n backfillSessionBranches,\n branchHidden,\n MAX_WATCHED_BRANCHES,\n noteBranchFacts,\n readSessionBranches,\n repoNameOf,\n type SessionBranches,\n} from '../sessions/session-branches.js';\nimport { checkedOutBranch } from '../git/git-head.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport type { WorktreeSession } from '../sessions/session-types.js';\n\n/**\n * What a session's other branches hold (session-branches.ts records them):\n * still there, pushed, how many commits its base lacks, how many origin\n * lacks, merged. Git through a CommandRunner (argv only), a few runs per\n * branch — so read in the background (BranchFactsCache, beside behind-main's)\n * and by the PR watch's preflight, never on a request's path.\n */\n\nexport interface BranchFacts {\n exists: boolean;\n /** Its tip, when it exists. */\n sha: string | null;\n /** `origin/<name>` exists. */\n pushed: boolean;\n /** Commits on it that its base (origin/HEAD) doesn't have; null: unknown. */\n commits: number | null;\n /** Commits on it that origin doesn't have (all of `commits` when never pushed); null: unknown. */\n unpushed: number | null;\n /** Its commits are all in its base, and it was pushed (a branch merged the usual way). */\n merged: boolean;\n}\n\n/** The repo's main line (`origin/main`), as origin/HEAD names it; null when it doesn't. */\nexport async function repoBase(repo: string, run: CommandRunner = defaultRunner): Promise<string | null> {\n const head = await run('git', ['-C', repo, 'rev-parse', '--abbrev-ref', 'origin/HEAD'], repo);\n const base = head.code === 0 ? head.stdout.trim() : '';\n return base && base !== 'origin/HEAD' ? base : null;\n}\n\nconst count = (out: { code: number; stdout: string }) =>\n out.code === 0 && /^\\d+$/.test(out.stdout.trim()) ? Number(out.stdout.trim()) : null;\n\n/** One branch of one repo. `base`: the repo's main line (repoBase), passed so a repo's branches ask it once. */\nexport async function branchFacts(\n repo: string,\n name: string,\n run: CommandRunner = defaultRunner,\n base?: string | null,\n): Promise<BranchFacts> {\n const git = (...args: string[]) => run('git', ['-C', repo, ...args], repo);\n const local = `refs/heads/${name}`;\n const remote = `refs/remotes/origin/${name}`;\n const tip = await git('rev-parse', '--verify', '--quiet', local);\n const exists = tip.code === 0;\n const pushed = (await git('rev-parse', '--verify', '--quiet', remote)).code === 0;\n if (!exists) return { exists, sha: null, pushed, commits: null, unpushed: null, merged: false };\n const main = base === undefined ? await repoBase(repo, run) : base;\n const commits = main ? count(await git('rev-list', '--count', `${main}..${local}`)) : null;\n const unpushed = pushed ? count(await git('rev-list', '--count', `${remote}..${local}`)) : commits;\n return { exists, sha: tip.stdout.trim() || null, pushed, commits, unpushed, merged: pushed && commits === 0 };\n}\n\n/** A repo's other branches to look at: by name, in its checkout. */\nexport interface BranchJob {\n repo: string;\n path: string;\n name: string;\n}\n\nexport const factsKey = (repo: string, name: string) => `${repo}\\u0000${name}`;\n\n/**\n * Per session, refreshed in the background a couple of sessions at a time;\n * reads never wait (BehindCache's way). `onFacts`: what a look found, to keep\n * (a branch seen deleted, or merged: session-branches.ts `noteBranchFacts`).\n */\nexport class BranchFactsCache {\n private readonly entries = new Map<string, { value: Map<string, BranchFacts>; at: number; inFlight: boolean; key: string }>();\n private running = 0;\n private readonly queue: Array<{ id: string; jobs: BranchJob[] }> = [];\n\n constructor(\n private readonly opts: {\n ttlMs?: number;\n concurrency?: number;\n run?: CommandRunner;\n onChange?: () => void;\n onFacts?: (id: string, facts: Array<BranchJob & BranchFacts>) => void;\n now?: () => number;\n } = {},\n ) {}\n\n /** What the last look found (an empty map before the first); schedules one when stale or the branches changed. */\n get(id: string, jobs: BranchJob[]): Map<string, BranchFacts> {\n const now = (this.opts.now ?? Date.now)();\n const key = jobs.map((j) => factsKey(j.repo, j.name)).join('|');\n const e = this.entries.get(id);\n const moved = !!e && e.key !== key;\n if (!e || moved || (!e.inFlight && now - e.at > (this.opts.ttlMs ?? 5 * 60_000))) this.schedule(id, jobs, key);\n return this.entries.get(id)?.value ?? new Map();\n }\n\n /** Look again soon (a turn ended, a push). */\n invalidate(id: string): void {\n const e = this.entries.get(id);\n if (e) e.at = 0;\n }\n\n async idle(): Promise<void> {\n while (this.running > 0 || this.queue.length > 0) await new Promise((r) => setTimeout(r, 5));\n }\n\n private schedule(id: string, jobs: BranchJob[], key: string): void {\n const e = this.entries.get(id) ?? { value: new Map<string, BranchFacts>(), at: 0, inFlight: false, key };\n if (e.inFlight && e.key === key) return;\n e.inFlight = true;\n e.key = key;\n this.entries.set(id, e);\n this.queue.push({ id, jobs });\n this.pump();\n }\n\n private pump(): void {\n while (this.running < (this.opts.concurrency ?? 2) && this.queue.length > 0) {\n const job = this.queue.shift()!;\n this.running++;\n void lookAt(job.jobs, this.opts.run)\n .catch((err) => {\n logSwallowed(`branch facts for ${job.id}`, err);\n return null;\n })\n .then((found) => {\n const e = this.entries.get(job.id)!;\n e.inFlight = false;\n e.at = (this.opts.now ?? Date.now)();\n if (!found) return;\n const value = new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)]));\n const changed = JSON.stringify([...e.value]) !== JSON.stringify([...value]);\n e.value = value;\n this.opts.onFacts?.(job.id, found);\n if (changed) this.opts.onChange?.();\n })\n .finally(() => {\n this.running--;\n this.pump();\n });\n }\n }\n}\n\nconst strip = (f: BranchJob & BranchFacts): BranchFacts => ({\n exists: f.exists,\n sha: f.sha,\n pushed: f.pushed,\n commits: f.commits,\n unpushed: f.unpushed,\n merged: f.merged,\n});\n\nasync function lookAt(jobs: BranchJob[], run?: CommandRunner): Promise<Array<BranchJob & BranchFacts>> {\n const bases = new Map<string, string | null>();\n const out: Array<BranchJob & BranchFacts> = [];\n for (const j of jobs) {\n if (!bases.has(j.path)) bases.set(j.path, await repoBase(j.path, run));\n out.push({ ...j, ...(await branchFacts(j.path, j.name, run, bases.get(j.path))) });\n }\n return out;\n}\n\n/** The PR of a repo's branch, from the PR watch's last check: the checked-out one's, or another's. */\nexport function prOfBranch(ci: SessionCi | null | undefined, repo: string, name: string): ShipPr | null {\n const r = ci?.repos.find((x) => x.name === repo);\n if (!r) return null;\n if (r.branch === name && r.pr) return r.pr;\n return r.otherPrs?.find((o) => o.branch === name)?.pr ?? null;\n}\n\n/**\n * The branches a session's row shows: every recorded one not hidden (merged\n * and deleted a while ago), each with its facts and PR, the checked-out ones\n * first, the rest newest first. Null unless some repo has been on more than\n * one: a session that stayed on its branch shows nothing new. Pure.\n */\nexport function branchesWire(\n rec: SessionBranches | null | undefined,\n current: (repo: string) => string | null,\n facts: Map<string, BranchFacts>,\n ci: SessionCi | null | undefined,\n now: number,\n): SessionBranchWire[] | null {\n if (!rec?.branches.length) return null;\n const rows: SessionBranchWire[] = [];\n for (const b of rec.branches) {\n const pr = prOfBranch(ci, b.repo, b.name);\n if (branchHidden(b, now, pr?.state === 'MERGED')) continue;\n const f = facts.get(factsKey(b.repo, b.name));\n rows.push({\n repo: b.repo,\n name: b.name,\n current: current(b.repo) === b.name,\n firstSeen: b.firstSeen,\n lastSeen: b.lastSeen,\n ...(b.from ? { from: b.from } : {}),\n ...(f\n ? {\n exists: f.exists,\n pushed: f.pushed,\n commits: f.commits,\n unpushed: f.unpushed,\n merged: f.merged || !!b.merged || pr?.state === 'MERGED',\n }\n : b.merged || pr?.state === 'MERGED'\n ? { merged: true }\n : {}),\n ...(pr ? { pr: { number: pr.number, url: pr.url, state: pr.state, kind: stageOfPr(pr) } } : {}),\n });\n }\n const repos = new Set(rows.map((r) => r.repo));\n if (![...repos].some((repo) => rows.filter((r) => r.repo === repo).length > 1)) return null;\n return rows.sort(\n (a, b) => Number(b.current) - Number(a.current) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen) || a.repo.localeCompare(b.repo),\n );\n}\n\n/**\n * The sessions list's branches (work web): each row's recorded branches with\n * their facts — read in the background (BranchFactsCache), what it finds kept\n * (deleted, merged, pushed once) — and, once per session recorded before the\n * list began, its reflog read into the record (backfillSessionBranches), one\n * session at a time, off the request's path. `wire` never runs git.\n */\nexport function createSessionBranches(\n opts: {\n onChange?: () => void;\n run?: CommandRunner;\n now?: () => number;\n /** Tests: the reflog read and the fact keeping (default: session-branches.ts). */\n backfill?: (s: WorktreeSession) => SessionBranches | void;\n keepFacts?: (id: string, facts: Array<BranchJob & BranchFacts>) => void;\n } = {},\n) {\n const now = opts.now ?? Date.now;\n const facts = new BranchFactsCache({\n ...(opts.run ? { run: opts.run } : {}),\n now,\n onChange: opts.onChange,\n onFacts: (id, found) =>\n bestEffort(`keep the branch facts of ${id}`, () => (opts.keepFacts ?? ((sid, f) => noteBranchFacts(sid, f)))(id, found)),\n });\n const backfill = opts.backfill ?? ((s: WorktreeSession) => backfillSessionBranches(s));\n const asked = new Set<string>();\n const waiting: WorktreeSession[] = [];\n let busy = false;\n const pump = () => {\n if (busy) return;\n const s = waiting.shift();\n if (!s) return;\n busy = true;\n setImmediate(() => {\n const rec = bestEffort(`read the branches of ${s.target}:${s.branch} from its reflog`, () => backfill(s));\n busy = false;\n // Only a session that turns out to have worked on more than one branch looks any different.\n if (rec && branchJobs(s, rec, now())) opts.onChange?.();\n pump();\n });\n };\n return {\n /** The row's branches (branchesWire), from what was recorded and last looked at. */\n wire(s: WorktreeSession, rec: SessionBranches | null | undefined, ci: SessionCi | null | undefined): SessionBranchWire[] | null {\n if (s.archivedAt) return null;\n const id = sessionIdFor(s);\n if (!rec?.backfilled && !asked.has(id)) {\n asked.add(id);\n waiting.push(s);\n pump();\n }\n const plan = branchJobs(s, rec, now());\n return plan ? branchesWire(rec, plan.current, facts.get(id, plan.jobs), ci, now()) : null;\n },\n invalidate: (id: string) => facts.invalidate(id),\n async idle(): Promise<void> {\n await facts.idle();\n while (busy || waiting.length) await new Promise((r) => setTimeout(r, 5));\n },\n };\n}\n\n/**\n * What to look at for a session's row: each repo's visible recorded branches (the checked-out one first, then\n * the most recent, at most MAX_WATCHED_BRANCHES others), and what each repo has checked out (HEAD files). Null\n * when no repo has been on more than one branch. No git.\n */\nexport function branchJobs(\n s: Pick<WorktreeSession, 'target' | 'isGroup' | 'paths'>,\n rec: SessionBranches | null | undefined,\n now: number,\n): { jobs: BranchJob[]; current: (repo: string) => string | null } | null {\n if (!rec?.branches.length) return null;\n const currentOf = new Map(s.paths.map((p) => [repoNameOf(s, p), checkedOutBranch(p)]));\n const visible = rec.branches.filter((b) => !branchHidden(b, now));\n const repos = new Set(visible.map((b) => b.repo));\n if (![...repos].some((r) => visible.filter((b) => b.repo === r).length > 1)) return null;\n const pathOf = new Map(s.paths.map((p) => [repoNameOf(s, p), p]));\n const jobs: BranchJob[] = [];\n for (const repo of repos) {\n const p = pathOf.get(repo);\n if (!p) continue;\n const isCurrent = (name: string) => Number(name === currentOf.get(repo));\n const mine = visible\n .filter((b) => b.repo === repo)\n .sort((a, b) => isCurrent(b.name) - isCurrent(a.name) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen))\n .slice(0, MAX_WATCHED_BRANCHES + 1);\n for (const b of mine) jobs.push({ repo, path: p, name: b.name });\n }\n return { jobs, current: (repo) => currentOf.get(repo) ?? null };\n}\n\n/**\n * The same now, for the CLI (`work sessions --json`, `work status`): the record (read from the reflog first\n * when it never was), each branch looked at with git, the PR from the PR watch's last check. Null when it stayed\n * on one branch.\n */\nexport async function sessionBranchesNow(\n s: WorktreeSession,\n ci: SessionCi | null | undefined,\n run: CommandRunner = defaultRunner,\n now = Date.now(),\n): Promise<SessionBranchWire[] | null> {\n if (s.archivedAt) return null;\n let rec = readSessionBranches(sessionIdFor(s));\n if (!rec?.backfilled) rec = bestEffort(`read the branches of ${s.target}:${s.branch}`, () => backfillSessionBranches(s), rec) ?? rec;\n const plan = branchJobs(s, rec, now);\n if (!plan) return null;\n const found = await lookAt(plan.jobs, run);\n return branchesWire(rec, plan.current, new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)])), ci, now);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwCA,eAAsB,SAAS,MAAc,MAAqB,eAAuC;AACvG,QAAM,OAAO,MAAM,IAAI,OAAO,CAAC,MAAM,MAAM,aAAa,gBAAgB,aAAa,GAAG,IAAI;AAC5F,QAAM,OAAO,KAAK,SAAS,IAAI,KAAK,OAAO,KAAK,IAAI;AACpD,SAAO,QAAQ,SAAS,gBAAgB,OAAO;AACjD;AAEA,IAAM,QAAQ,CAAC,QACb,IAAI,SAAS,KAAK,QAAQ,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,OAAO,IAAI,OAAO,KAAK,CAAC,IAAI;AAGlF,eAAsB,YACpB,MACA,MACA,MAAqB,eACrB,MACsB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EFAULT_HOST
|
|
11
|
+
} from "./chunk-AQP6SCCJ.js";
|
|
5
12
|
import {
|
|
6
13
|
defaultRunner
|
|
7
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-KSVYR4G2.js";
|
|
8
15
|
import {
|
|
9
16
|
loadHistory
|
|
10
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-27LWL6QE.js";
|
|
11
18
|
import {
|
|
12
19
|
getConfigPath,
|
|
13
20
|
loadConfig
|
|
14
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2MAZV5KS.js";
|
|
15
22
|
import {
|
|
16
23
|
atomicWriteFile,
|
|
17
24
|
withFileLock
|
|
@@ -71,15 +78,6 @@ var TOOLS = [
|
|
|
71
78
|
args: ["--version"],
|
|
72
79
|
missing: "Install Claude Code (npm install -g @anthropic-ai/claude-code) and sign in once in a terminal."
|
|
73
80
|
},
|
|
74
|
-
{
|
|
75
|
-
id: "gh",
|
|
76
|
-
label: "GitHub CLI",
|
|
77
|
-
needed: false,
|
|
78
|
-
cmd: "gh",
|
|
79
|
-
args: ["auth", "status"],
|
|
80
|
-
missing: "Optional: install gh to see your pull requests, CI and review comments.",
|
|
81
|
-
failing: "Optional: run `gh auth login` so work can see your pull requests."
|
|
82
|
-
},
|
|
83
81
|
{
|
|
84
82
|
id: "acli",
|
|
85
83
|
label: "Atlassian CLI",
|
|
@@ -89,19 +87,34 @@ var TOOLS = [
|
|
|
89
87
|
missing: "Optional: install acli to start sessions from your Jira issues."
|
|
90
88
|
}
|
|
91
89
|
];
|
|
90
|
+
function toolsNow() {
|
|
91
|
+
const repos = Object.values(loadConfig()?.repos ?? {});
|
|
92
|
+
const used = new Set(repos.map((p) => hostForRepo(p).host.id));
|
|
93
|
+
const hosts = knownHosts().filter((h) => h.id === DEFAULT_HOST || used.has(h.id)).map((h) => ({
|
|
94
|
+
id: h.cli.cmd,
|
|
95
|
+
label: h.cli.label,
|
|
96
|
+
needed: false,
|
|
97
|
+
cmd: h.cli.cmd,
|
|
98
|
+
args: h.cli.checkArgs,
|
|
99
|
+
missing: h.cli.missing,
|
|
100
|
+
failing: h.cli.failing,
|
|
101
|
+
...h.cli.requires ? { requires: h.cli.requires } : {}
|
|
102
|
+
}));
|
|
103
|
+
return [TOOLS[0], TOOLS[1], ...hosts, ...TOOLS.slice(2)];
|
|
104
|
+
}
|
|
92
105
|
async function checkTools(run = defaultRunner) {
|
|
93
106
|
return Promise.all(
|
|
94
|
-
|
|
95
|
-
const
|
|
107
|
+
toolsNow().map(async (t) => {
|
|
108
|
+
const ask = (args) => run(t.cmd, args, os.tmpdir()).catch(() => ({ code: 127, stdout: "", stderr: "" }));
|
|
109
|
+
const notFound = (r2) => r2.code === 127 || /not (found|recognized)|ENOENT/i.test(r2.stderr);
|
|
110
|
+
const result = (ok2, detail) => ({ id: t.id, label: t.label, needed: t.needed, ok: ok2, detail });
|
|
111
|
+
for (const pre of t.requires ?? []) {
|
|
112
|
+
const r2 = await ask(pre.args);
|
|
113
|
+
if (r2.code !== 0) return result(false, notFound(r2) ? t.missing : pre.failing);
|
|
114
|
+
}
|
|
115
|
+
const r = await ask(t.args);
|
|
96
116
|
const ok = r.code === 0;
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
id: t.id,
|
|
100
|
-
label: t.label,
|
|
101
|
-
needed: t.needed,
|
|
102
|
-
ok,
|
|
103
|
-
detail: ok ? (r.stdout || r.stderr).split("\n")[0].trim() : notFound ? t.missing : t.failing ?? t.missing
|
|
104
|
-
};
|
|
117
|
+
return result(ok, ok ? (r.stdout || r.stderr).split("\n")[0].trim() : notFound(r) ? t.missing : t.failing ?? t.missing);
|
|
105
118
|
})
|
|
106
119
|
);
|
|
107
120
|
}
|
|
@@ -127,4 +140,4 @@ export {
|
|
|
127
140
|
checkTools,
|
|
128
141
|
setupState
|
|
129
142
|
};
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
143
|
+
//# sourceMappingURL=chunk-TKWUSJNQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/setup/first-run.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { DEFAULT_HOST, hostForRepo, knownHosts } from '../hosts/index.js';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { getConfigDir, getConfigPath, loadConfig } from '../platform/config.js';\nimport { atomicWriteFile, withFileLock } from '../platform/fs-safe.js';\nimport { loadHistory } from '../sessions/history.js';\nimport { defaultRunner, type CommandRunner } from '../pr/ship.js';\nimport type { SetupWire, ToolCheck } from '../api-types.js';\nimport { makeFolder } from '../worktree/worktrees-root.js';\n\n/**\n * First run (the dashboard's Welcome page, `work init`): where your repos\n * are, where worktrees go, and whether the tools work leans on are there.\n * Nothing here is needed again once the folders are set and a repo is in.\n */\n\n/** Files new worktrees get copied from the repo (local settings git ignores): `work init`'s defaults. */\nexport const DEFAULT_COPY_FILES = ['*.Development.json', '*.Local.json', '.claude/settings.local.json'];\n\n/** Where repos usually live, most likely first. */\nconst REPO_FOLDERS = [['source', 'repos'], ['repos'], ['src'], ['code'], ['projects'], ['dev'], ['git'], ['work']];\n\n/**\n * The folders to suggest: the first usual repos folder that exists under\n * home, and worktrees beside it (`…/source/repos` → `…/source/worktrees`).\n * With none, worktrees go under home and the repos folder is yours to name.\n */\nexport function suggestFolders(\n home: string,\n exists: (p: string) => boolean = fs.existsSync,\n): { reposFolder: string | null; worktreesRoot: string } {\n for (const parts of REPO_FOLDERS) {\n const p = path.join(home, ...parts);\n if (exists(p)) return { reposFolder: p, worktreesRoot: path.join(path.dirname(p), 'worktrees') };\n }\n return { reposFolder: null, worktreesRoot: path.join(home, 'worktrees') };\n}\n\n/** What a folder entered for setup is wrong with, or null. */\nexport function folderProblem(p: unknown, mustExist: boolean): string | null {\n if (typeof p !== 'string' || !p.trim()) return 'give a folder';\n if (!path.isAbsolute(p.trim())) return `${p} isn't a full path (start it from the drive or /)`;\n if (mustExist && !fs.existsSync(p.trim())) return `${p} doesn't exist`;\n return null;\n}\n\n/**\n * Set the folders: config.json made when there is none (with `work init`'s\n * defaults), else its worktrees root and scanned folder changed in place,\n * every other key as it was.\n */\nexport async function saveFolders(req: { worktreesRoot: string; reposFolder: string }): Promise<void> {\n const wt = folderProblem(req.worktreesRoot, false);\n if (wt) throw new Error(`Worktrees folder: ${wt}`);\n const rf = folderProblem(req.reposFolder, true);\n if (rf) throw new Error(`Repos folder: ${rf}`);\n const worktreesRoot = path.resolve(req.worktreesRoot.trim());\n const reposFolder = path.resolve(req.reposFolder.trim());\n const cantMake = makeFolder(worktreesRoot);\n if (cantMake) throw new Error(`Worktrees folder: ${cantMake} — pick a folder you own, e.g. under ${os.homedir()}`);\n getConfigDir();\n const file = getConfigPath();\n if (!fs.existsSync(file)) fs.writeFileSync(file, '{}', { flag: 'wx' });\n await withFileLock(file, () => {\n const raw = JSON.parse(fs.readFileSync(file, 'utf-8') || '{}') as Record<string, unknown>;\n raw.worktreesRoot = worktreesRoot;\n raw.scanRoots = [reposFolder];\n raw.repos ??= {};\n raw.groups ??= {};\n raw.copyFiles ??= DEFAULT_COPY_FILES;\n atomicWriteFile(file, JSON.stringify(raw, null, 2));\n });\n}\n\n/** One tool's check: its command, and what it means when it's missing. */\ninterface ToolSpec {\n id: ToolCheck['id'];\n label: string;\n needed: boolean;\n args: string[];\n cmd: string;\n missing: string;\n /** A failure that isn't \"not installed\" (gh logged out). */\n failing?: string;\n /** Checked first, each with its own line when it fails (az's azure-devops extension). */\n requires?: Array<{ args: string[]; failing: string }>;\n}\n\nconst TOOLS: ToolSpec[] = [\n { id: 'git', label: 'git', needed: true, cmd: 'git', args: ['--version'], missing: 'Install git: worktrees are git’s.' },\n {\n id: 'claude',\n label: 'Claude Code',\n needed: true,\n cmd: 'claude',\n args: ['--version'],\n missing: 'Install Claude Code (npm install -g @anthropic-ai/claude-code) and sign in once in a terminal.',\n },\n {\n id: 'acli',\n label: 'Atlassian CLI',\n needed: false,\n cmd: 'acli',\n args: ['--version'],\n missing: 'Optional: install acli to start sessions from your Jira issues.',\n },\n];\n\n/** Each git host's CLI, after git and Claude Code: optional, it adds that host's pull requests. */\nfunction toolsNow(): ToolSpec[] {\n const repos = Object.values(loadConfig()?.repos ?? {});\n const used = new Set(repos.map((p) => hostForRepo(p).host.id));\n const hosts = knownHosts()\n .filter((h) => h.id === DEFAULT_HOST || used.has(h.id))\n .map((h): ToolSpec => ({\n id: h.cli.cmd,\n label: h.cli.label,\n needed: false,\n cmd: h.cli.cmd,\n args: h.cli.checkArgs,\n missing: h.cli.missing,\n failing: h.cli.failing,\n ...(h.cli.requires ? { requires: h.cli.requires } : {}),\n }));\n return [TOOLS[0], TOOLS[1], ...hosts, ...TOOLS.slice(2)];\n}\n\n/** Whether each tool answers. A command not found is \"missing\"; one that runs and fails says why. */\nexport async function checkTools(run: CommandRunner = defaultRunner): Promise<ToolCheck[]> {\n return Promise.all(\n toolsNow().map(async (t): Promise<ToolCheck> => {\n const ask = (args: string[]) => run(t.cmd, args, os.tmpdir()).catch(() => ({ code: 127, stdout: '', stderr: '' }));\n const notFound = (r: { code: number; stderr: string }) => r.code === 127 || /not (found|recognized)|ENOENT/i.test(r.stderr);\n const result = (ok: boolean, detail: string): ToolCheck => ({ id: t.id, label: t.label, needed: t.needed, ok, detail });\n // What it needs beyond itself first (az's azure-devops extension): `az account show` passes without it.\n for (const pre of t.requires ?? []) {\n const r = await ask(pre.args);\n if (r.code !== 0) return result(false, notFound(r) ? t.missing : pre.failing);\n }\n const r = await ask(t.args);\n const ok = r.code === 0;\n return result(ok, ok ? (r.stdout || r.stderr).split('\\n')[0].trim() : notFound(r) ? t.missing : (t.failing ?? t.missing));\n }),\n );\n}\n\n/** Where setup stands: the folders, how many repos and sessions, the tools. */\nexport async function setupState(tools: () => Promise<ToolCheck[]> = () => checkTools()): Promise<SetupWire> {\n const config = loadConfig();\n const suggested = suggestFolders(os.homedir());\n const sessions = config ? loadHistory().filter((s) => !s.archivedAt).length : 0;\n return {\n configured: !!config && !!config.worktreesRoot,\n worktreesRoot: config?.worktreesRoot || null,\n reposFolder: config?.scanRoots?.[0] ?? (config?.worktreesRoot ? path.dirname(config.worktreesRoot) : null),\n repos: config ? Object.keys(config.repos).length : 0,\n sessions,\n suggested,\n tools: await tools(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AAEf,OAAO,QAAQ;AACf,OAAO,UAAU;AAeV,IAAM,qBAAqB,CAAC,sBAAsB,gBAAgB,6BAA6B;AAGtG,IAAM,eAAe,CAAC,CAAC,UAAU,OAAO,GAAG,CAAC,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC,UAAU,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC;AAO1G,SAAS,eACd,MACA,SAAiC,GAAG,YACmB;AACvD,aAAW,SAAS,cAAc;AAChC,UAAM,IAAI,KAAK,KAAK,MAAM,GAAG,KAAK;AAClC,QAAI,OAAO,CAAC,EAAG,QAAO,EAAE,aAAa,GAAG,eAAe,KAAK,KAAK,KAAK,QAAQ,CAAC,GAAG,WAAW,EAAE;AAAA,EACjG;AACA,SAAO,EAAE,aAAa,MAAM,eAAe,KAAK,KAAK,MAAM,WAAW,EAAE;AAC1E;AAGO,SAAS,cAAc,GAAY,WAAmC;AAC3E,MAAI,OAAO,MAAM,YAAY,CAAC,EAAE,KAAK,EAAG,QAAO;AAC/C,MAAI,CAAC,KAAK,WAAW,EAAE,KAAK,CAAC,EAAG,QAAO,GAAG,CAAC;AAC3C,MAAI,aAAa,CAAC,GAAG,WAAW,EAAE,KAAK,CAAC,EAAG,QAAO,GAAG,CAAC;AACtD,SAAO;AACT;AAOA,eAAsB,YAAY,KAAoE;AACpG,QAAM,KAAK,cAAc,IAAI,eAAe,KAAK;AACjD,MAAI,GAAI,OAAM,IAAI,MAAM,qBAAqB,EAAE,EAAE;AACjD,QAAM,KAAK,cAAc,IAAI,aAAa,IAAI;AAC9C,MAAI,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;AAC1B,YAAM,KAAK,EAAE,SAAS;AACtB,aAAO,OAAO,IAAI,MAAM,EAAE,UAAU,EAAE,QAAQ,MAAM,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,SAAS,CAAC,IAAI,EAAE,UAAW,EAAE,WAAW,EAAE,OAAQ;AAAA,IAC1H,CAAC;AAAA,EACH;AACF;AAGA,eAAsB,WAAW,QAAoC,MAAM,WAAW,GAAuB;AAC3G,QAAM,SAAS,WAAW;AAC1B,QAAM,YAAY,eAAe,GAAG,QAAQ,CAAC;AAC7C,QAAM,WAAW,SAAS,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,SAAS;AAC9E,SAAO;AAAA,IACL,YAAY,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO;AAAA,IACjC,eAAe,QAAQ,iBAAiB;AAAA,IACxC,aAAa,QAAQ,YAAY,CAAC,MAAM,QAAQ,gBAAgB,KAAK,QAAQ,OAAO,aAAa,IAAI;AAAA,IACrG,OAAO,SAAS,OAAO,KAAK,OAAO,KAAK,EAAE,SAAS;AAAA,IACnD;AAAA,IACA;AAAA,IACA,OAAO,MAAM,MAAM;AAAA,EACrB;AACF;","names":["r","ok"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
findSessionForCwd
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JNCKZ3OF.js";
|
|
5
5
|
import {
|
|
6
6
|
sessionIdFor
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Y7T73SAP.js";
|
|
8
8
|
|
|
9
9
|
// src/core/sessions/live-agents.ts
|
|
10
10
|
function agentsBySession(list, sessions) {
|
|
@@ -40,4 +40,4 @@ export {
|
|
|
40
40
|
agentsBySession,
|
|
41
41
|
summarizeAgents
|
|
42
42
|
};
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-UP2JTDBI.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
isEnvDelta
|
|
4
|
+
} from "./chunk-B5WDN63X.js";
|
|
5
|
+
import {
|
|
6
|
+
getConfigDir
|
|
7
|
+
} from "./chunk-6THUVP6T.js";
|
|
8
|
+
|
|
9
|
+
// src/core/pty/pty-host-protocol.ts
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
import path from "path";
|
|
12
|
+
var PROTOCOL_VERSION = 2;
|
|
13
|
+
var HOST_FEATURES = ["agentEnv", "halt"];
|
|
14
|
+
var SECRET_NAME = /TOKEN|SECRET|PASS|PWD|CREDENTIAL|PRIVATE|KEY|AUTH|BEARER|COOKIE|SESSION|CERT|SIGN|SALT|(^|_)PAT($|_)|DSN|CONN|DATABASE_URL|_URI$|_URL$/i;
|
|
15
|
+
var SECRET_VALUE = /:\/\/[^/\s:@]+:[^/\s@]+@/;
|
|
16
|
+
var ALWAYS_KEPT_ENV = ["CLAUDE_CONFIG_DIR"];
|
|
17
|
+
function keepEnv(env, names) {
|
|
18
|
+
if (!env) return void 0;
|
|
19
|
+
const kept = Object.fromEntries(
|
|
20
|
+
[.../* @__PURE__ */ new Set([...names, ...ALWAYS_KEPT_ENV])].filter((n) => !SECRET_NAME.test(n) && typeof env[n] === "string" && !SECRET_VALUE.test(env[n])).map((n) => [n, env[n]])
|
|
21
|
+
);
|
|
22
|
+
return Object.keys(kept).length ? kept : void 0;
|
|
23
|
+
}
|
|
24
|
+
function isPersistedPty(x) {
|
|
25
|
+
const e = x;
|
|
26
|
+
return !!e && typeof e === "object" && typeof e.cwd === "string" && !!e.tool && typeof e.tool === "object" && (e.agentEnv === void 0 || isEnvDelta(e.agentEnv)) && (e.keptEnv === void 0 || !!e.keptEnv && typeof e.keptEnv === "object" && Object.values(e.keptEnv).every((v) => typeof v === "string"));
|
|
27
|
+
}
|
|
28
|
+
function hostInfoPath() {
|
|
29
|
+
return path.join(getConfigDir(), "pty-host.json");
|
|
30
|
+
}
|
|
31
|
+
function hostStartLockPath() {
|
|
32
|
+
return path.join(getConfigDir(), "pty-host.start.lock");
|
|
33
|
+
}
|
|
34
|
+
function ptySessionsPath() {
|
|
35
|
+
return path.join(getConfigDir(), "pty-sessions.json");
|
|
36
|
+
}
|
|
37
|
+
function readHostInfo() {
|
|
38
|
+
try {
|
|
39
|
+
const raw = JSON.parse(fs.readFileSync(hostInfoPath(), "utf-8"));
|
|
40
|
+
if (typeof raw.port === "number" && typeof raw.token === "string" && typeof raw.pid === "number") {
|
|
41
|
+
return raw;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
PROTOCOL_VERSION,
|
|
51
|
+
HOST_FEATURES,
|
|
52
|
+
keepEnv,
|
|
53
|
+
isPersistedPty,
|
|
54
|
+
hostInfoPath,
|
|
55
|
+
hostStartLockPath,
|
|
56
|
+
ptySessionsPath,
|
|
57
|
+
readHostInfo
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=chunk-V4U5RGEG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/pty/pty-host-protocol.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { getConfigDir } from '../platform/config.js';\nimport type { AiToolSpec } from '../platform/ai-launcher.js';\nimport { isEnvDelta, type EnvDelta } from '../platform/env-delta.js';\n\n/**\n * Wire contract between the PTY host (`work pty-host`, the long-lived\n * process that owns every Claude PTY) and its clients (`work web`,\n * `work attach`). Bump PROTOCOL_VERSION on any incompatible change: a\n * client that finds an older host running tells the user to restart it\n * (`work pty-host --restart`) instead of silently misbehaving — the host\n * outlives rebuilds by design.\n *\n * 2: the restore list moved from pty-sessions.json into state.db. A v1 host\n * still writes the file, which a v2 host adopts on start\n * (adoptLegacyRestoreList).\n */\nexport const PROTOCOL_VERSION = 2;\n\n/**\n * What this host can do beyond PROTOCOL_VERSION, answered by `/health` (additive: a host from before answers none).\n * `agentEnv`: it applies a spawn's / restart's / resume's `agentEnv` (a session's Claude account); `halt`: halt / resume.\n * A client asks before sending something an older host would silently drop (pty-pool.ts).\n */\nexport const HOST_FEATURES = ['agentEnv', 'halt'] as const;\nexport type HostFeature = (typeof HOST_FEATURES)[number];\n\n/** Discovery file: where the running host listens and its auth token. */\nexport interface HostInfo {\n pid: number;\n port: number;\n token: string;\n version: number;\n}\n\n/** What a client asks the host to spawn. The host decides `--continue`\n * itself (see `hasClaudeConversation`) so restores after a reboot make\n * the same call a fresh spawn would. */\nexport interface SpawnSpec {\n cwd: string;\n tool: AiToolSpec;\n port?: number;\n cols?: number;\n rows?: number;\n // No `unsafe` any more: every agent starts in its own permission mode. An older client may still send\n // `unsafe: true`, and a restore list written by an older host may hold it (and its tool an `unsafeFlag`): extra\n // fields, so no PROTOCOL_VERSION bump. A current host starts nothing from them and drops both when it restores or\n // restarts a session (pty-registry.ts); for one release legacy-unsafe.ts reads an entry's `unsafe: true` as \"an\n // older host still runs this agent without permission prompts\" and keeps its guards (REMOVE IN THE NEXT RELEASE).\n /** `--fresh`: start a new conversation even if one exists. First spawn\n * only — a restore always continues. */\n fresh?: boolean;\n /** `--prompt` / `--prompt-file` contents. First spawn only. */\n initialPrompt?: string;\n /** The launching shell's environment. First spawn only and never\n * persisted — it can hold secrets; a restore after reboot uses the\n * host's own environment. */\n env?: Record<string, string>;\n /**\n * What the agent's environment differs by for this session (its account's `CLAUDE_CONFIG_DIR`: set, or `null` = taken\n * out), applied over whatever environment the process starts with — the shell's, or the host's own. Persisted (a\n * folder path is no secret), so a restore keeps it. Additive, no PROTOCOL_VERSION bump: a host from before ignores\n * it and starts the agent on the environment it inherits (`work pty-host --restart` after upgrading).\n */\n agentEnv?: EnvDelta;\n}\n\n/** One entry of the host's restore list: how to respawn a session. The\n * spec as launched, minus `env` (never persisted: it can hold secrets) —\n * except the variables config `hostEnv` names (`keptEnv`), which a restore\n * after a reboot puts back over the host's own environment. */\nexport interface PersistedPty extends SpawnSpec {\n startedAt: string;\n keptEnv?: Record<string, string>;\n}\n\n/** Names that look like secrets (or carry them, as a connection string does): never kept on disk, whatever `hostEnv` says. */\nconst SECRET_NAME =\n /TOKEN|SECRET|PASS|PWD|CREDENTIAL|PRIVATE|KEY|AUTH|BEARER|COOKIE|SESSION|CERT|SIGN|SALT|(^|_)PAT($|_)|DSN|CONN|DATABASE_URL|_URI$|_URL$/i;\n/** Values that carry a password whatever their name: `scheme://user:pass@host`. */\nconst SECRET_VALUE = /:\\/\\/[^/\\s:@]+:[^/\\s@]+@/;\n\n/** Always kept for a restore, whatever `hostEnv` says: the agent's account folder (a path, not a secret — SECRET_VALUE still applies). */\nexport const ALWAYS_KEPT_ENV = ['CLAUDE_CONFIG_DIR'] as const;\n\n/** The variables of `env` to keep for a restore: the ones named (and `ALWAYS_KEPT_ENV`), that exist, and look like neither a secret nor a URL with a password in it. Pure. */\nexport function keepEnv(env: Record<string, string> | undefined, names: readonly string[]): Record<string, string> | undefined {\n if (!env) return undefined;\n const kept = Object.fromEntries(\n [...new Set([...names, ...ALWAYS_KEPT_ENV])]\n .filter((n) => !SECRET_NAME.test(n) && typeof env[n] === 'string' && !SECRET_VALUE.test(env[n]))\n .map((n) => [n, env[n]]),\n );\n return Object.keys(kept).length ? kept : undefined;\n}\nexport type PersistedPtys = Record<string, PersistedPty>;\n\n/** Shape check for a restore-list entry read back from storage. */\nexport function isPersistedPty(x: unknown): x is PersistedPty {\n const e = x as PersistedPty | null;\n return (\n !!e &&\n typeof e === 'object' &&\n typeof e.cwd === 'string' &&\n !!e.tool &&\n typeof e.tool === 'object' &&\n (e.agentEnv === undefined || isEnvDelta(e.agentEnv)) &&\n (e.keptEnv === undefined ||\n (!!e.keptEnv && typeof e.keptEnv === 'object' && Object.values(e.keptEnv).every((v) => typeof v === 'string')))\n );\n}\n\nexport interface PtyInfo {\n id: string;\n cwd: string;\n pid: number;\n exited: boolean;\n cols: number;\n rows: number;\n startedAt: string;\n /** Respawned by the host on startup from the persisted session list\n * (after a crash, `--restart` or reboot), not by a client. */\n restored: boolean;\n /** Clients attached right now (dashboard Terminal tabs, `work attach`).\n * Additive: a host from before it sends none. */\n clients?: number;\n /** When the PTY last printed anything (ISO). Additive, like clients. */\n lastOutputAt?: string;\n /** The tool's binary (`claude`, `opencode`…). Additive, like clients. */\n tool?: string;\n}\n\n/** Client → host frames on the attach WebSocket (text, JSON). Host →\n * client PTY output is sent as binary frames; control frames as text. */\nexport type ClientFrame = { type: 'input'; data: string } | { type: 'resize'; cols: number; rows: number };\n\nexport type HostControlFrame =\n /** Sent once, first, on attach: the serialized screen and the grid it was\n * drawn for. Clients draw it at exactly cols×rows, then resize to their\n * own size (which makes Claude redraw), and only then send input. */\n { type: 'replay'; data: string; cols: number; rows: number } | { type: 'exit'; code: number } | { type: 'error'; message: string };\n\nexport function hostInfoPath(): string {\n return path.join(getConfigDir(), 'pty-host.json');\n}\n\n/** Held by a starting host from \"is one running?\" through writing its\n * discovery file AND restoring the saved sessions — so two hosts can't\n * both start, and a `work remove` racing a start waits for the restore\n * instead of slipping between it (see stopSessionPty). */\nexport function hostStartLockPath(): string {\n return path.join(getConfigDir(), 'pty-host.start.lock');\n}\n\n/** The pre-SQLite restore list. Only the one-time import reads it now. */\nexport function ptySessionsPath(): string {\n return path.join(getConfigDir(), 'pty-sessions.json');\n}\n\nexport function readHostInfo(): HostInfo | null {\n try {\n const raw = JSON.parse(fs.readFileSync(hostInfoPath(), 'utf-8')) as HostInfo;\n if (typeof raw.port === 'number' && typeof raw.token === 'string' && typeof raw.pid === 'number') {\n return raw;\n }\n return null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAiBV,IAAM,mBAAmB;AAOzB,IAAM,gBAAgB,CAAC,YAAY,MAAM;AAqDhD,IAAM,c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