@moberg_hr/work-tree 2.9.3 → 2.11.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-Q5Y3YKI7.js} +83 -100
- package/dist/account-Q5Y3YKI7.js.map +1 -0
- package/dist/{add-repo-EDU3QEYI.js → add-repo-L4ZTGBLO.js} +35 -31
- package/dist/{add-repo-EDU3QEYI.js.map → add-repo-L4ZTGBLO.js.map} +1 -1
- package/dist/{answer-MHOJ2J6S.js → answer-GNR4ZBWV.js} +18 -15
- package/dist/{answer-MHOJ2J6S.js.map → answer-GNR4ZBWV.js.map} +1 -1
- package/dist/{attach-37JOJ4C3.js → attach-QNSDKRW7.js} +27 -21
- package/dist/{attach-37JOJ4C3.js.map → attach-QNSDKRW7.js.map} +1 -1
- package/dist/bin.js +5 -5
- package/dist/{block-D5CAR53T.js → block-3YUIMA62.js} +23 -15
- package/dist/block-3YUIMA62.js.map +1 -0
- package/dist/{broadcast-LLYHUWXA.js → broadcast-DR3JFINO.js} +13 -11
- package/dist/{broadcast-LLYHUWXA.js.map → broadcast-DR3JFINO.js.map} +1 -1
- package/dist/{catchup-2SL3JGA7.js → catchup-YG2UOZBL.js} +19 -17
- package/dist/{catchup-2SL3JGA7.js.map → catchup-YG2UOZBL.js.map} +1 -1
- package/dist/{chunk-P6BHOAQG.js → chunk-246OTVRR.js} +2 -2
- package/dist/{chunk-KSUOVFO3.js → chunk-26YZYL77.js} +16 -9
- package/dist/chunk-26YZYL77.js.map +1 -0
- package/dist/{chunk-TPSFJSO7.js → chunk-2KN5ECHJ.js} +13 -10
- package/dist/chunk-2KN5ECHJ.js.map +1 -0
- package/dist/chunk-2QLLPZ2L.js +59 -0
- package/dist/chunk-2QLLPZ2L.js.map +1 -0
- package/dist/chunk-2ZQRD73B.js +376 -0
- package/dist/chunk-2ZQRD73B.js.map +1 -0
- package/dist/{chunk-GNGXYXBC.js → chunk-33XSEAHO.js} +2 -2
- package/dist/{chunk-IPGH7TXJ.js → chunk-4CNBSPNL.js} +2 -2
- package/dist/{chunk-J36ULZBO.js → chunk-4K4S53KX.js} +2 -2
- package/dist/chunk-5PAMO6OG.js +9 -0
- package/dist/{chunk-NWIVXGSL.js.map → chunk-5PAMO6OG.js.map} +1 -1
- package/dist/chunk-63ZLPXRL.js +199 -0
- package/dist/chunk-63ZLPXRL.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-5QGCF3PS.js → chunk-7DUGVGUZ.js} +2 -2
- package/dist/chunk-7E5XPDKX.js +22 -0
- package/dist/chunk-7E5XPDKX.js.map +1 -0
- package/dist/{chunk-6FVYSW3E.js → chunk-7NNGYM3G.js} +21 -6
- package/dist/chunk-7NNGYM3G.js.map +1 -0
- package/dist/{chunk-DQCUYCMX.js → chunk-7NNOGTMC.js} +3 -3
- package/dist/{chunk-OMIMK3LB.js → chunk-7OFVXQSM.js} +2 -2
- package/dist/chunk-7QNVFVG6.js +196 -0
- package/dist/chunk-7QNVFVG6.js.map +1 -0
- package/dist/chunk-7RHC5U7X.js +1578 -0
- package/dist/chunk-7RHC5U7X.js.map +1 -0
- package/dist/{chunk-KUCMJHQW.js → chunk-AHYCZUPI.js} +2 -2
- package/dist/chunk-B6MWNZCN.js +415 -0
- package/dist/chunk-B6MWNZCN.js.map +1 -0
- package/dist/{chunk-CCTALU3C.js → chunk-BLGCU4HT.js} +2 -2
- package/dist/{chunk-RCGFHJM7.js → chunk-CBCOVIXZ.js} +2 -2
- package/dist/{chunk-WTQ2QCAG.js → chunk-CDYCZ3PR.js} +4 -5
- package/dist/chunk-CDYCZ3PR.js.map +1 -0
- package/dist/{chunk-HCVONKJI.js → chunk-CR4LUAP4.js} +15 -17
- package/dist/{chunk-HCVONKJI.js.map → chunk-CR4LUAP4.js.map} +1 -1
- package/dist/{chunk-ZXHMC7UO.js → chunk-D2J3AD6L.js} +3 -5
- package/dist/chunk-D2J3AD6L.js.map +1 -0
- 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-S3BAD4IR.js → chunk-DGVCN7HB.js} +2 -2
- package/dist/chunk-DMGNJ73M.js +84 -0
- package/dist/chunk-DMGNJ73M.js.map +1 -0
- package/dist/{chunk-QL36KN7X.js → chunk-DYQQLUSB.js} +3 -3
- package/dist/{chunk-IWJXFNM4.js → chunk-DZ4LX2EK.js} +16 -24
- package/dist/chunk-DZ4LX2EK.js.map +1 -0
- package/dist/{chunk-3C3BKZ3H.js → chunk-EDIHBLZY.js} +51 -29
- package/dist/chunk-EDIHBLZY.js.map +1 -0
- package/dist/chunk-EL3XL2OC.js +150 -0
- package/dist/chunk-EL3XL2OC.js.map +1 -0
- package/dist/{chunk-T7AFYEQ7.js → chunk-F2CDUWZU.js} +5 -5
- package/dist/chunk-F2NOCGMA.js +243 -0
- package/dist/chunk-F2NOCGMA.js.map +1 -0
- package/dist/chunk-FGPXMAYU.js +25 -0
- package/dist/chunk-FGPXMAYU.js.map +1 -0
- package/dist/{chunk-ICJPVSRY.js → chunk-FLHMFRZB.js} +51 -51
- package/dist/chunk-FLHMFRZB.js.map +1 -0
- package/dist/{chunk-CLBQ7ZC4.js → chunk-FR7B7QH6.js} +3 -3
- package/dist/chunk-FZHFD2AY.js +27 -0
- package/dist/chunk-FZHFD2AY.js.map +1 -0
- package/dist/{chunk-7OUIZ2YQ.js → chunk-G4QUJO7W.js} +56 -58
- package/dist/chunk-G4QUJO7W.js.map +1 -0
- package/dist/{chunk-26OVU2AE.js → chunk-G4ZR5YZL.js} +8 -8
- package/dist/{chunk-P4EQWC5W.js → chunk-GG4VKPAX.js} +2 -2
- package/dist/{chunk-INQQGV2G.js → chunk-GZNF6762.js} +4 -4
- package/dist/{chunk-QHTXLCG7.js → chunk-H3LP3Z4U.js} +19 -13
- package/dist/chunk-H3LP3Z4U.js.map +1 -0
- package/dist/{chunk-6E2I2FBJ.js → chunk-HJKYE57I.js} +22 -22
- package/dist/{chunk-CYWI3ZW7.js → chunk-I5FZXDCO.js} +4 -4
- package/dist/{chunk-5WM24P5N.js → chunk-I6MILNM5.js} +2 -2
- package/dist/chunk-I6MILNM5.js.map +1 -0
- package/dist/{chunk-BSP2Z7B7.js → chunk-IQ4MITHC.js} +6 -6
- package/dist/chunk-J3GEINBH.js +307 -0
- package/dist/chunk-J3GEINBH.js.map +1 -0
- package/dist/{chunk-WXE7D44E.js → chunk-JCFCEJ2D.js} +8 -8
- package/dist/chunk-JCFCEJ2D.js.map +1 -0
- package/dist/{chunk-WXMWZRBH.js → chunk-JF25PSYF.js} +24 -8
- package/dist/chunk-JF25PSYF.js.map +1 -0
- package/dist/{chunk-SG5LUMGE.js → chunk-JNBMANFM.js} +6 -3
- package/dist/chunk-JNBMANFM.js.map +1 -0
- package/dist/chunk-JVE2JFLV.js +15 -0
- package/dist/chunk-JVE2JFLV.js.map +1 -0
- package/dist/{chunk-RGUSVBGN.js → chunk-JVHHSKBJ.js} +2 -2
- 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-MG5TTLYZ.js → chunk-LHM3GB5K.js} +3 -3
- package/dist/{chunk-PSUJZUYX.js → chunk-LM2T5OR3.js} +3 -2
- package/dist/{chunk-GRLKPVTP.js → chunk-LQNHIMJM.js} +56 -81
- package/dist/chunk-LQNHIMJM.js.map +1 -0
- package/dist/{chunk-UBOKRHNV.js → chunk-MKJH2D4V.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-MXOHW4U2.js +187 -0
- package/dist/chunk-MXOHW4U2.js.map +1 -0
- package/dist/{chunk-VUAVPBFR.js → chunk-N4W34U3I.js} +78 -60
- package/dist/chunk-N4W34U3I.js.map +1 -0
- package/dist/{chunk-72IBYKIY.js → chunk-NFWSJFYY.js} +16 -5
- package/dist/chunk-NFWSJFYY.js.map +1 -0
- package/dist/{chunk-2JNW2AQ2.js → chunk-O5ZJY5BT.js} +32 -4
- package/dist/chunk-O5ZJY5BT.js.map +1 -0
- package/dist/{chunk-CMO5YUZR.js → chunk-OY46QHLX.js} +4 -4
- package/dist/{chunk-OTAZOIXK.js → chunk-PKQROEFP.js} +2 -2
- package/dist/{chunk-4NITDMDH.js → chunk-PPZP7CA7.js} +9 -186
- package/dist/chunk-PPZP7CA7.js.map +1 -0
- package/dist/chunk-QBI6K23L.js +50 -0
- package/dist/chunk-QBI6K23L.js.map +1 -0
- package/dist/{chunk-AAYWHIIT.js → chunk-QLFJNYBV.js} +9 -56
- package/dist/chunk-QLFJNYBV.js.map +1 -0
- package/dist/{chunk-PRDRRU2B.js → chunk-R5JCCRGD.js} +5 -5
- package/dist/{chunk-X4AXKO3A.js → chunk-RGLIW45S.js} +2 -2
- package/dist/{chunk-YYBXQBW2.js → chunk-RUYTU2WJ.js} +17 -3
- package/dist/chunk-RUYTU2WJ.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-WC534PXU.js → chunk-SPP7MA3D.js} +36 -25
- package/dist/chunk-SPP7MA3D.js.map +1 -0
- package/dist/{chunk-RFINYWID.js → chunk-TEL27NRC.js} +16 -6
- package/dist/chunk-TEL27NRC.js.map +1 -0
- package/dist/{chunk-ATED7SAH.js → chunk-TEVCBUEN.js} +36 -25
- package/dist/chunk-TEVCBUEN.js.map +1 -0
- package/dist/{chunk-QSOEMCWQ.js → chunk-URGHBFB3.js} +18 -11
- package/dist/chunk-URGHBFB3.js.map +1 -0
- package/dist/{chunk-S3FMTEFR.js → chunk-VAMLU5VH.js} +13 -6
- package/dist/chunk-VAMLU5VH.js.map +1 -0
- package/dist/{chunk-ZI2KXTKM.js → chunk-VJ5XMYXE.js} +6 -10
- package/dist/chunk-VJ5XMYXE.js.map +1 -0
- package/dist/{chunk-QEVYCCKD.js → chunk-VRQKIIC2.js} +12 -34
- package/dist/chunk-VRQKIIC2.js.map +1 -0
- package/dist/{chunk-63VY4YJM.js → chunk-W7MGB3Q2.js} +34 -9
- package/dist/chunk-W7MGB3Q2.js.map +1 -0
- package/dist/{chunk-HEPBANFJ.js → chunk-X3RHLYGI.js} +93 -196
- package/dist/chunk-X3RHLYGI.js.map +1 -0
- package/dist/chunk-YKQLHFY4.js +1478 -0
- package/dist/chunk-YKQLHFY4.js.map +1 -0
- package/dist/chunk-YPXFDJ76.js +71 -0
- package/dist/chunk-YPXFDJ76.js.map +1 -0
- package/dist/{chunk-XVNRP7XE.js → chunk-YQBBFX7D.js} +11 -11
- package/dist/{chunk-37XQIG7F.js → chunk-ZG2M4ECW.js} +569 -55
- package/dist/chunk-ZG2M4ECW.js.map +1 -0
- package/dist/{cleanup-5PSLKZLF.js → cleanup-X7G66SPY.js} +49 -37
- package/dist/{cleanup-5PSLKZLF.js.map → cleanup-X7G66SPY.js.map} +1 -1
- package/dist/cli-RJVX6HVT.js +19 -0
- package/dist/{command-hook-installer-7Q7UD7AU.js → command-hook-installer-GMQ4IVDE.js} +3 -3
- 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-ZBU5PHMG.js} +18 -15
- package/dist/{config-6MSITKGB.js.map → config-ZBU5PHMG.js.map} +1 -1
- package/dist/{diff-Q7MV6YGJ.js → diff-ADSD4SNQ.js} +25 -22
- package/dist/{diff-Q7MV6YGJ.js.map → diff-ADSD4SNQ.js.map} +1 -1
- package/dist/{digest-KUMVYXKZ.js → digest-ORN6JFNE.js} +15 -13
- package/dist/{digest-KUMVYXKZ.js.map → digest-ORN6JFNE.js.map} +1 -1
- package/dist/{fork-OFENISEM.js → fork-VWHAU76U.js} +44 -31
- package/dist/{fork-OFENISEM.js.map → fork-VWHAU76U.js.map} +1 -1
- package/dist/{history-5WKRWARZ.js → history-PP7RHA2V.js} +14 -12
- package/dist/{hook-ARS32DG2.js → hook-6AL5LIQO.js} +56 -22
- package/dist/hook-6AL5LIQO.js.map +1 -0
- package/dist/{hydrate-LCT6DVB3.js → hydrate-JW5MIWLZ.js} +16 -14
- package/dist/{hydrate-LCT6DVB3.js.map → hydrate-JW5MIWLZ.js.map} +1 -1
- package/dist/{init-FJKPEY5N.js → init-SIIKJF3K.js} +29 -21
- package/dist/{init-FJKPEY5N.js.map → init-SIIKJF3K.js.map} +1 -1
- package/dist/install-skills-KS6N4U6L.js +22 -0
- package/dist/install-skills-bin.js +10 -8
- package/dist/install-skills-bin.js.map +1 -1
- package/dist/{list-GTKP5FAW.js → list-UTQF7KHP.js} +17 -15
- package/dist/{list-GTKP5FAW.js.map → list-UTQF7KHP.js.map} +1 -1
- package/dist/{move-GOCLEFGZ.js → move-P6WOVUGF.js} +35 -26
- package/dist/{move-GOCLEFGZ.js.map → move-P6WOVUGF.js.map} +1 -1
- package/dist/{note-B7TQBXQF.js → note-GEFCZKMT.js} +16 -14
- package/dist/{note-B7TQBXQF.js.map → note-GEFCZKMT.js.map} +1 -1
- package/dist/{overlaps-UKQHIJMU.js → overlaps-QMI2RJSG.js} +23 -13
- package/dist/{overlaps-UKQHIJMU.js.map → overlaps-QMI2RJSG.js.map} +1 -1
- package/dist/{pin-UZZCDK7M.js → pin-ZALBX2XK.js} +16 -14
- package/dist/{pin-UZZCDK7M.js.map → pin-ZALBX2XK.js.map} +1 -1
- package/dist/{pr-NU2ME2XW.js → pr-D3EZ7C5H.js} +48 -23
- package/dist/pr-D3EZ7C5H.js.map +1 -0
- package/dist/{prune-IZGEYTSB.js → prune-ZCOBL7IB.js} +47 -35
- package/dist/{prune-IZGEYTSB.js.map → prune-ZCOBL7IB.js.map} +1 -1
- package/dist/{pty-host-AWDIKPQN.js → pty-host-UCM6GV42.js} +104 -40
- package/dist/pty-host-UCM6GV42.js.map +1 -0
- package/dist/{read-U6GBGA5E.js → read-NHRSGZI4.js} +15 -13
- package/dist/{read-U6GBGA5E.js.map → read-NHRSGZI4.js.map} +1 -1
- package/dist/{recent-2DUMLUDG.js → recent-V4JVL4Y2.js} +36 -27
- package/dist/recent-V4JVL4Y2.js.map +1 -0
- package/dist/{remove-OXUP4O33.js → remove-YNO2I3HR.js} +51 -39
- package/dist/{remove-OXUP4O33.js.map → remove-YNO2I3HR.js.map} +1 -1
- package/dist/{restart-QEW4DJC3.js → restart-6YKAD7QQ.js} +19 -17
- package/dist/{restart-QEW4DJC3.js.map → restart-6YKAD7QQ.js.map} +1 -1
- package/dist/{resume-K45IT4QO.js → resume-PNZ7BRXJ.js} +36 -21
- package/dist/resume-PNZ7BRXJ.js.map +1 -0
- package/dist/review-now-HHQIBVUS.js +22 -0
- package/dist/review-now-HHQIBVUS.js.map +1 -0
- package/dist/{run-42LORGPS.js → run-3QYP7GBN.js} +23 -17
- package/dist/run-3QYP7GBN.js.map +1 -0
- package/dist/{screen-2TLIUH3G.js → screen-I6N6FKMF.js} +16 -14
- package/dist/{screen-2TLIUH3G.js.map → screen-I6N6FKMF.js.map} +1 -1
- package/dist/{search-7E4B2KX6.js → search-MLLK3ZCW.js} +12 -10
- package/dist/{search-7E4B2KX6.js.map → search-MLLK3ZCW.js.map} +1 -1
- package/dist/{section-OVA5VD7L.js → section-EQOZ36FS.js} +16 -14
- package/dist/{section-OVA5VD7L.js.map → section-EQOZ36FS.js.map} +1 -1
- package/dist/{send-BJY5CYLO.js → send-LET73FB6.js} +21 -18
- package/dist/send-LET73FB6.js.map +1 -0
- package/dist/{sessions-4A24ZORW.js → sessions-MDOJJZCK.js} +60 -25
- package/dist/sessions-MDOJJZCK.js.map +1 -0
- package/dist/{snooze-WIVKB3GH.js → snooze-TNA7QTXS.js} +15 -13
- package/dist/{snooze-WIVKB3GH.js.map → snooze-TNA7QTXS.js.map} +1 -1
- package/dist/{start-G6GR533S.js → start-OV6LZJ2V.js} +16 -14
- package/dist/{start-G6GR533S.js.map → start-OV6LZJ2V.js.map} +1 -1
- package/dist/{state-S3DGLT4J.js → state-BR43ONIH.js} +18 -6
- package/dist/state-BR43ONIH.js.map +1 -0
- package/dist/{status-BTAWY6JQ.js → status-HDDGCX4J.js} +40 -15
- package/dist/status-HDDGCX4J.js.map +1 -0
- package/dist/{statusline-WLXEU5DM.js → statusline-WKKYCH7O.js} +13 -12
- package/dist/{statusline-WLXEU5DM.js.map → statusline-WKKYCH7O.js.map} +1 -1
- package/dist/{statusline-hook-OVWHHFBV.js → statusline-hook-K7KPN2H6.js} +6 -5
- package/dist/{statusline-hook-OVWHHFBV.js.map → statusline-hook-K7KPN2H6.js.map} +1 -1
- package/dist/{stop-FN6EPFJ4.js → stop-3TJWZBJB.js} +16 -14
- package/dist/{stop-FN6EPFJ4.js.map → stop-3TJWZBJB.js.map} +1 -1
- package/dist/{sync-T3BSHX6Q.js → sync-67AOBEYR.js} +47 -35
- package/dist/{sync-T3BSHX6Q.js.map → sync-67AOBEYR.js.map} +1 -1
- package/dist/{time-5CH5O5MZ.js → time-F6SLY6HR.js} +17 -15
- package/dist/{time-5CH5O5MZ.js.map → time-F6SLY6HR.js.map} +1 -1
- package/dist/{time-actions-XEUQ3UF7.js → time-actions-YOXF5WC7.js} +6 -5
- package/dist/{timesheet-FMQKPS5S.js → timesheet-QUEDQSJ2.js} +26 -17
- package/dist/{timesheet-FMQKPS5S.js.map → timesheet-QUEDQSJ2.js.map} +1 -1
- package/dist/{todo-23COLGR2.js → todo-TALKJYK6.js} +5 -5
- package/dist/{tree-T33VU473.js → tree-FOOQBNVW.js} +66 -47
- package/dist/tree-FOOQBNVW.js.map +1 -0
- package/dist/{update-PJRSKQZ2.js → update-5O3I5P4N.js} +26 -16
- package/dist/{update-PJRSKQZ2.js.map → update-5O3I5P4N.js.map} +1 -1
- package/dist/{usage-TL66LWO4.js → usage-DVKHDT5J.js} +15 -13
- package/dist/{usage-TL66LWO4.js.map → usage-DVKHDT5J.js.map} +1 -1
- package/dist/version-TVT6GSRF.js +115 -0
- package/dist/version-TVT6GSRF.js.map +1 -0
- package/dist/{wait-YIEJO6YM.js → wait-5HZZPKNM.js} +18 -15
- package/dist/{wait-YIEJO6YM.js.map → wait-5HZZPKNM.js.map} +1 -1
- package/dist/wd-bin.js +7 -7
- package/dist/web/assets/{PtyView-DnDd6jLI.js → PtyView-DIGlBtjg.js} +2 -2
- package/dist/web/assets/{PtyView-DnDd6jLI.js.map → PtyView-DIGlBtjg.js.map} +1 -1
- package/dist/web/assets/index-CpqiTeqj.css +1 -0
- package/dist/web/assets/index-Cx0PMo6D.js +126 -0
- package/dist/web/assets/index-Cx0PMo6D.js.map +1 -0
- package/dist/web/index.html +2 -2
- package/dist/{web-IYUNJMQD.js → web-T7UPV3QY.js} +5158 -1822
- package/dist/web-T7UPV3QY.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-3C3BKZ3H.js.map +0 -1
- package/dist/chunk-3GIH4WTA.js +0 -314
- 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-RFINYWID.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/chunk-ZXHMC7UO.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-P6BHOAQG.js.map → chunk-246OTVRR.js.map} +0 -0
- /package/dist/{chunk-GNGXYXBC.js.map → chunk-33XSEAHO.js.map} +0 -0
- /package/dist/{chunk-IPGH7TXJ.js.map → chunk-4CNBSPNL.js.map} +0 -0
- /package/dist/{chunk-J36ULZBO.js.map → chunk-4K4S53KX.js.map} +0 -0
- /package/dist/{chunk-5QGCF3PS.js.map → chunk-7DUGVGUZ.js.map} +0 -0
- /package/dist/{chunk-DQCUYCMX.js.map → chunk-7NNOGTMC.js.map} +0 -0
- /package/dist/{chunk-OMIMK3LB.js.map → chunk-7OFVXQSM.js.map} +0 -0
- /package/dist/{chunk-KUCMJHQW.js.map → chunk-AHYCZUPI.js.map} +0 -0
- /package/dist/{chunk-CCTALU3C.js.map → chunk-BLGCU4HT.js.map} +0 -0
- /package/dist/{chunk-RCGFHJM7.js.map → chunk-CBCOVIXZ.js.map} +0 -0
- /package/dist/{chunk-S3BAD4IR.js.map → chunk-DGVCN7HB.js.map} +0 -0
- /package/dist/{chunk-QL36KN7X.js.map → chunk-DYQQLUSB.js.map} +0 -0
- /package/dist/{chunk-T7AFYEQ7.js.map → chunk-F2CDUWZU.js.map} +0 -0
- /package/dist/{chunk-CLBQ7ZC4.js.map → chunk-FR7B7QH6.js.map} +0 -0
- /package/dist/{chunk-26OVU2AE.js.map → chunk-G4ZR5YZL.js.map} +0 -0
- /package/dist/{chunk-P4EQWC5W.js.map → chunk-GG4VKPAX.js.map} +0 -0
- /package/dist/{chunk-INQQGV2G.js.map → chunk-GZNF6762.js.map} +0 -0
- /package/dist/{chunk-6E2I2FBJ.js.map → chunk-HJKYE57I.js.map} +0 -0
- /package/dist/{chunk-CYWI3ZW7.js.map → chunk-I5FZXDCO.js.map} +0 -0
- /package/dist/{chunk-BSP2Z7B7.js.map → chunk-IQ4MITHC.js.map} +0 -0
- /package/dist/{chunk-RGUSVBGN.js.map → chunk-JVHHSKBJ.js.map} +0 -0
- /package/dist/{chunk-MG5TTLYZ.js.map → chunk-LHM3GB5K.js.map} +0 -0
- /package/dist/{chunk-PSUJZUYX.js.map → chunk-LM2T5OR3.js.map} +0 -0
- /package/dist/{chunk-UBOKRHNV.js.map → chunk-MKJH2D4V.js.map} +0 -0
- /package/dist/{chunk-HMK3INUS.js.map → chunk-MQCDFSVF.js.map} +0 -0
- /package/dist/{chunk-CMO5YUZR.js.map → chunk-OY46QHLX.js.map} +0 -0
- /package/dist/{chunk-OTAZOIXK.js.map → chunk-PKQROEFP.js.map} +0 -0
- /package/dist/{chunk-PRDRRU2B.js.map → chunk-R5JCCRGD.js.map} +0 -0
- /package/dist/{chunk-X4AXKO3A.js.map → chunk-RGLIW45S.js.map} +0 -0
- /package/dist/{chunk-XVNRP7XE.js.map → chunk-YQBBFX7D.js.map} +0 -0
- /package/dist/{cli-AF7636FA.js.map → cli-RJVX6HVT.js.map} +0 -0
- /package/dist/{command-hook-installer-7Q7UD7AU.js.map → command-hook-installer-GMQ4IVDE.js.map} +0 -0
- /package/dist/{history-5WKRWARZ.js.map → history-PP7RHA2V.js.map} +0 -0
- /package/dist/{install-skills-UYAFVJBA.js.map → install-skills-KS6N4U6L.js.map} +0 -0
- /package/dist/{time-actions-XEUQ3UF7.js.map → time-actions-YOXF5WC7.js.map} +0 -0
- /package/dist/{todo-23COLGR2.js.map → todo-TALKJYK6.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/stacks/session-update.ts","../src/core/stacks/behind-main.ts","../src/core/stacks/stack-sessions.ts","../src/core/stacks/stack.ts","../src/core/stacks/stack-retarget.ts"],"sourcesContent":["import path from 'node:path';\nimport { updateFromMain, type UpdateResult } from './behind-main.js';\nimport { loadConfig } from '../platform/config.js';\nimport { loadHistory, setSessionBase } from '../sessions/history.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport type { WorktreeSession } from '../sessions/session-types.js';\nimport { sessionStacks } from './stack-sessions.js';\nimport { parentTipFor, retargetOntoMain } from './stack-retarget.js';\nimport type { CommandRunner } from '../pr/ship.js';\nimport { shownState } from '../status/turn-activity.js';\n\n/**\n * Bringing a session's branch up to date — the dashboard's Update from main /\n * Update from <parent> / Move onto main, and `work update` — one\n * implementation for both front-ends. Never while its Claude works or waits\n * on you (the files would move under it), asked again before each repo.\n */\n\nexport type SessionUpdate =\n | { ok: true; results: UpdateResult[]; how: 'main' | 'parent' | 'onto-main'; base?: string }\n | { ok: false; status: 404 | 409; error: string };\n\nfunction busy(s: WorktreeSession): string | null {\n const st = shownState(s);\n return st === 'working' || st === 'needs_input' ? (st === 'working' ? 'working' : 'waiting for your answer') : null;\n}\n\nfunction refuse(s: WorktreeSession): SessionUpdate | null {\n if (s.archivedAt) return { ok: false, status: 409, error: 'it is archived: restore it first' };\n const b = busy(s);\n return b ? { ok: false, status: 409, error: `Not now: its Claude is ${b} (the files would change under it).` } : null;\n}\n\n/** From origin/<main>, or — stacked on a live session — from that session's branch. */\nexport async function updateFromBase(s: WorktreeSession, run?: CommandRunner): Promise<SessionUpdate> {\n const no = refuse(s);\n if (no) return no;\n const parent = sessionStacks(loadHistory(), loadConfig()).parentOf.get(sessionIdFor(s))?.branch;\n const results: UpdateResult[] = [];\n for (const p of s.paths) {\n const b = busy(s);\n if (b) {\n results.push({ ok: false, repo: path.basename(p), reason: `its Claude started ${b}: stopped here` });\n break;\n }\n results.push(await updateFromMain(p, run, parent));\n }\n return { ok: true, results, how: parent ? 'parent' : 'main', ...(parent ? { base: parent } : {}) };\n}\n\n/** Stacked on a session that merged (archived): onto main, only its own commits (stack-retarget.ts). */\nexport async function moveOntoMain(s: WorktreeSession, run?: CommandRunner): Promise<SessionUpdate> {\n const no = refuse(s);\n if (no) return no;\n const config = loadConfig();\n const parent = sessionStacks(loadHistory(), config).mergedParentOf.get(sessionIdFor(s));\n if (!parent) return { ok: false, status: 409, error: 'it is not stacked on a merged session' };\n const r = await retargetOntoMain(\n s,\n async (repo) => ({ branch: parent.branch, tip: await parentTipFor(repo, parent, config, run) }),\n run,\n () => {\n const b = busy(s);\n return b ? `its Claude started ${b}: stopped` : null;\n },\n );\n // On main now: no longer stacked on anything.\n if (r.ok && r.bases) await setSessionBase(s.target, s.branch, r.bases);\n return { ok: true, results: r.results, how: 'onto-main', base: parent.branch };\n}\n\n/** Whichever it needs: onto main when its parent merged, else from its parent or main (`work update`). */\nexport async function updateSession(s: WorktreeSession, run?: CommandRunner): Promise<SessionUpdate> {\n const merged = sessionStacks(loadHistory(), loadConfig()).mergedParentOf.has(sessionIdFor(s));\n return merged ? moveOntoMain(s, run) : updateFromBase(s, run);\n}\n","import path from 'node:path';\nimport { defaultRunner, type CommandRunner } from '../pr/ship.js';\nimport { logSwallowed } from '../platform/best-effort.js';\n\n/**\n * How far a session's branch has fallen behind its main branch, and whether\n * merging main would conflict — so the dashboard can say \"↓ 34 behind\n * origin/main · conflicts\" before it bites at merge time — and \"Update from\n * main\" to catch up. Against the last fetched `origin/HEAD` (nothing here\n * fetches but the update itself). Git through a CommandRunner: argv only.\n */\n\nexport interface Behind {\n /** origin/<main>, as the repo's origin/HEAD says — or, for a stacked\n * session (stack.ts), the branch of the session it is stacked on. */\n base: string;\n /** Measured against the session it is stacked on, not main. */\n stacked?: true;\n commits: number;\n /** Merging base would conflict (git merge-tree, no worktree touched).\n * False also when it couldn't tell (git before 2.38 has no --write-tree):\n * nothing ever claims \"no conflicts\", only says so when they're found. */\n conflicts: boolean;\n}\n\n/**\n * One repo, against origin/HEAD — or against `parent`, a local branch (the\n * session it is stacked on). Null when there is nothing to compare with.\n */\nexport async function behindMain(repo: string, run: CommandRunner = defaultRunner, parent?: string): Promise<Behind | null> {\n let base: string;\n if (parent) {\n const ok = await run('git', ['-C', repo, 'rev-parse', '--verify', '--quiet', `refs/heads/${parent}`], repo);\n if (ok.code !== 0) return null;\n base = parent;\n } else {\n const head = await run('git', ['-C', repo, 'rev-parse', '--abbrev-ref', 'origin/HEAD'], repo);\n base = head.code === 0 ? head.stdout.trim() : '';\n if (!base || base === 'origin/HEAD') return null;\n }\n const stacked = parent ? ({ stacked: true } as const) : {};\n const count = await run('git', ['-C', repo, 'rev-list', '--count', `HEAD..${parent ? `refs/heads/${parent}` : base}`], repo);\n const commits = count.code === 0 ? Number(count.stdout.trim()) || 0 : 0;\n if (commits === 0) return { base, commits: 0, conflicts: false, ...stacked };\n // Exit 1: the merge would conflict; 0: clean. Anything else (an old git's\n // usage error): can't tell, so no warning.\n const merge = await run(\n 'git',\n ['-C', repo, 'merge-tree', '--write-tree', '--quiet', 'HEAD', parent ? `refs/heads/${parent}` : base],\n repo,\n );\n return { base, commits, conflicts: merge.code === 1, ...stacked };\n}\n\n/** Several repos (a group): the furthest behind, and any conflict. */\nexport function combineBehind(list: Array<Behind | null>): Behind | null {\n const known = list.filter((b): b is Behind => b !== null);\n if (known.length === 0) return null;\n const worst = known.reduce((a, b) => (b.commits > a.commits ? b : a));\n return {\n base: worst.base,\n commits: worst.commits,\n conflicts: known.some((b) => b.conflicts),\n ...(worst.stacked ? { stacked: true as const } : {}),\n };\n}\n\n/**\n * Per session, refreshed in the background (slowly: main moves slowly, and\n * merge-tree costs a little), a couple at a time; reads never wait.\n */\nexport class BehindCache {\n private readonly entries = new Map<string, { value: Behind | null; at: number; inFlight: boolean; parent?: string }>();\n private running = 0;\n private readonly queue: Array<{ id: string; paths: string[]; parent?: string }> = [];\n\n constructor(\n private readonly opts: { ttlMs?: number; concurrency?: number; run?: CommandRunner; onChange?: () => void; now?: () => number } = {},\n ) {}\n\n /** `parent`: the branch of the session it is stacked on (stack.ts); compared with that instead of main. */\n get(id: string, paths: string[], parent?: string): Behind | null {\n const now = (this.opts.now ?? Date.now)();\n const e = this.entries.get(id);\n // Stacked or unstacked since the last look: what it said is about another base.\n const moved = !!e && e.parent !== parent;\n if (!e || moved || (!e.inFlight && now - e.at > (this.opts.ttlMs ?? 10 * 60_000))) this.schedule(id, paths, parent);\n return moved ? null : (e?.value ?? null);\n }\n\n /** Look again soon (the branch moved: an update, a pull). */\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, paths: string[], parent?: string): void {\n const e = this.entries.get(id) ?? { value: null, at: 0, inFlight: false };\n if (e.inFlight && e.parent === parent) return;\n if (e.parent !== parent) e.value = null;\n e.inFlight = true;\n e.parent = parent;\n this.entries.set(id, e);\n this.queue.push({ id, paths, parent });\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 Promise.all(job.paths.map((p) => behindMain(p, this.opts.run, job.parent)))\n .then(combineBehind)\n .catch((err) => {\n logSwallowed(`behind main for ${job.id}`, err);\n return null;\n })\n .then((value) => {\n const e = this.entries.get(job.id)!;\n // Rebased onto another base while this looked: that look is the one that counts.\n if (e.parent !== job.parent) return;\n const changed = JSON.stringify(e.value) !== JSON.stringify(value);\n e.value = value;\n e.at = (this.opts.now ?? Date.now)();\n e.inFlight = false;\n if (changed) this.opts.onChange?.();\n })\n .finally(() => {\n this.running--;\n this.pump();\n });\n }\n }\n}\n\n// ---- Update from main ------------------------------------------------------------\n\nexport type UpdateResult =\n | { ok: true; repo: string; how: 'rebase' | 'merge' | 'nothing'; base: string; commits: number }\n | { ok: false; repo: string; reason: string; conflicts?: boolean; base?: string; handOff?: boolean };\n\n/**\n * Bring one repo's branch up to date with origin/<main>: fetch, then rebase\n * a branch that was never pushed, or merge main into a published one (a\n * rebase would need a force push, which Ship doesn't do). Never with\n * uncommitted changes. A conflict is aborted at once — the worktree is left\n * as it was — and reported, for Claude to resolve.\n */\nexport async function updateFromMain(repo: string, run: CommandRunner = defaultRunner, parent?: string): Promise<UpdateResult> {\n const name = path.basename(repo);\n const git = (...args: string[]) => run('git', ['-C', repo, ...args], repo);\n const dirty = await git('status', '--porcelain');\n if (dirty.code !== 0) return { ok: false, repo: name, reason: dirty.stderr.trim() || 'not a git checkout' };\n if (dirty.stdout.trim()) return { ok: false, repo: name, reason: 'it has uncommitted changes: commit or stash them first' };\n const branch = (await git('rev-parse', '--abbrev-ref', 'HEAD')).stdout.trim();\n if (!branch || branch === 'HEAD') return { ok: false, repo: name, reason: 'not on a branch (detached HEAD)' };\n let head: string;\n if (parent) {\n // Stacked: the parent's local branch (its worktree commits to it here; nothing to fetch).\n if ((await git('rev-parse', '--verify', '--quiet', `refs/heads/${parent}`)).code !== 0)\n return { ok: false, repo: name, reason: `${parent} is gone` };\n head = parent;\n } else {\n await git('fetch', '--quiet', 'origin');\n head = (await git('rev-parse', '--abbrev-ref', 'origin/HEAD')).stdout.trim();\n if (!head || head === 'origin/HEAD')\n return { ok: false, repo: name, reason: 'no origin/HEAD to update from (git remote set-head origin -a)' };\n }\n // The parent as a full ref: a tag or a file of the same name can't stand in for it.\n const ref = parent ? `refs/heads/${parent}` : head;\n const commits = Number((await git('rev-list', '--count', `HEAD..${ref}`)).stdout.trim()) || 0;\n if (commits === 0) return { ok: true, repo: name, how: 'nothing', base: head, commits: 0 };\n const published = (await git('rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branch}`)).code === 0;\n const how = published ? 'merge' : 'rebase';\n const r = published ? await git('merge', '--no-edit', ref) : await git('rebase', ref);\n if (r.code === 0) return { ok: true, repo: name, how, base: head, commits };\n // A conflict leaves unmerged paths; anything else (a hook refusing the\n // commit, signing) doesn't, and isn't one for Claude to resolve.\n const unmerged = (await git('diff', '--name-only', '--diff-filter=U')).stdout.trim() !== '';\n await git(how, '--abort');\n const verb = published ? `merging ${head}` : `rebasing on ${head}`;\n if (unmerged) return { ok: false, repo: name, reason: `${verb} conflicts`, conflicts: true, base: head };\n return {\n ok: false,\n repo: name,\n reason: `${verb} failed: ${firstLine(r.stderr) || firstLine(r.stdout) || `git exited ${r.code}`}`,\n base: head,\n };\n}\n\n/** What went wrong, in its first words (a hook's own message comes before git's \"Not committing merge\"). */\nconst firstLine = (text: string) =>\n text\n .split(/\\r?\\n/)\n .map((l) => l.trim())\n .find((l) => l && !l.startsWith('hint:')) ?? '';\n","import path from 'node:path';\nimport type { WorkConfig } from '../platform/config.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport type { WorktreeSession } from '../sessions/session-types.js';\nimport { mergedParent, stackChildCounts, stackParents } from './stack.js';\nimport fs from 'node:fs';\nimport { archiveDirFor, readArchive } from '../archive/session-archive.js';\n\nconst mergedCache = new Map<string, { key: string; merged: boolean }>();\n\n/**\n * Its archive says it merged: a merged PR, or its branch deleted as merged\n * into main. Read once per change of archive.json (a stat, not a parse, on\n * every /api/sessions build).\n */\nfunction archivedAsMerged(id: string): boolean {\n let key: string;\n try {\n const st = fs.statSync(path.join(archiveDirFor(id), 'archive.json'));\n key = `${st.size}:${st.mtimeMs}`;\n } catch {\n return false;\n }\n const hit = mergedCache.get(id);\n if (hit?.key === key) return hit.merged;\n const a = readArchive(id);\n const merged = !!a && (a.summary.prs.some((p) => p.state === 'MERGED') || (a.branchesDeleted?.length ?? 0) > 0);\n mergedCache.set(id, { key, merged });\n while (mergedCache.size > 1000) mergedCache.delete(mergedCache.keys().next().value!);\n return merged;\n}\n\nexport type StackedSession = WorktreeSession & { id: string };\n\nexport interface Stacks {\n /** Session id → the session it is stacked on. */\n parentOf: Map<string, StackedSession>;\n /** Session id → how many are stacked on it. */\n children: Map<string, number>;\n /** Session id → the archived (merged) session it was made from: time to move onto main. */\n mergedParentOf: Map<string, StackedSession>;\n}\n\nconst norm = (p: string) => path.resolve(p).replace(/\\\\/g, '/').toLowerCase();\n\n/**\n * The stacks among these sessions (stack.ts). A repo's own checkout is never\n * a parent: a session opened on the base checkout (`work tree <repo>`) sits\n * on whatever branch that is, and everything made from it isn't stacked.\n */\nexport function sessionStacks(history: readonly WorktreeSession[], config: WorkConfig | null): Stacks {\n const repoRoots = new Set(Object.values(config?.repos ?? {}).map(norm));\n const all: StackedSession[] = history.map((s) => ({ ...s, id: sessionIdFor(s) }));\n const eligible = (p: StackedSession) => !p.paths.some((x) => repoRoots.has(norm(x)));\n const parentOf = stackParents(all, eligible);\n const mergedParentOf = new Map<string, StackedSession>();\n for (const s of all) {\n const m = parentOf.has(s.id) ? null : mergedParent(s, all, eligible, (p) => archivedAsMerged(p.id));\n if (m) mergedParentOf.set(s.id, m);\n }\n return { parentOf, children: stackChildCounts(parentOf), mergedParentOf };\n}\n\n/** The sessions stacked on this one (live ones). */\nexport function stackedOn(parentId: string, stacks: Stacks, history: readonly WorktreeSession[]): WorktreeSession[] {\n return history.filter((s) => stacks.parentOf.get(sessionIdFor(s))?.id === parentId);\n}\n","/**\n * PURE — keep it import-free (it is the policy; stack-sessions.ts applies it\n * to the session history, stack-sync.ts acts on it).\n *\n * Stacked sessions: one whose branch was made from another live session's\n * branch (a fork, or `work tree … --base feat/x`) is stacked on it — its\n * \"main\" is that branch until it merges. Nothing new is stored: the base a\n * session was made from is already recorded (`baseBranch` / `baseBranches`).\n * Behind and Update from (behind-main.ts) then measure against the parent,\n * and the parent's new commits are brought in (stack-sync.ts).\n */\n\nexport interface StackSubject {\n id: string;\n target: string;\n branch: string;\n baseBranch?: string;\n baseBranches?: Record<string, string>;\n archivedAt?: string | null;\n}\n\n/** Branches that are a project's mainline, never a parent to stack on. */\nconst LONG_LIVED = /^(main|master|dev|develop|development|staging|stage|production|prod|release|trunk)$/;\n\n/** The one branch it was made from (a group: the same in every repo), or null. */\nexport function stackBase(s: Pick<StackSubject, 'baseBranch' | 'baseBranches'>): string | null {\n const per = s.baseBranches ? [...new Set(Object.values(s.baseBranches))] : [];\n const base = per.length === 1 ? per[0] : per.length === 0 ? (s.baseBranch ?? null) : null;\n return base && !LONG_LIVED.test(base) && !/^origin\\//.test(base) ? base : null;\n}\n\n/**\n * The live session it is stacked on: same project, on the branch it was made\n * from. `eligible` leaves out what can't be a parent (the server: a repo's\n * own checkout, which a mainline-named base already excludes most of).\n */\nexport function stackParent<T extends StackSubject>(s: T, all: readonly T[], eligible: (p: T) => boolean = () => true): T | null {\n if (s.archivedAt) return null;\n const base = stackBase(s);\n if (!base || base === s.branch) return null;\n return all.find((p) => p.id !== s.id && !p.archivedAt && p.target === s.target && p.branch === base && eligible(p)) ?? null;\n}\n\n/**\n * Each session's parent, for a whole list at once. Sessions made from each\n * other's branches (A from B's, B from A's — possible with `--base`) form a\n * cycle, not a stack: none of them gets a parent, so nothing is brought back\n * and forth between them.\n */\nexport function stackParents<T extends StackSubject>(all: readonly T[], eligible?: (p: T) => boolean): Map<string, T> {\n const out = new Map<string, T>();\n for (const s of all) {\n const p = stackParent(s, all, eligible);\n if (p) out.set(s.id, p);\n }\n for (const id of [...out.keys()]) {\n const seen = new Set<string>([id]);\n for (let at = out.get(id); at; at = out.get(at.id)) {\n if (seen.has(at.id)) {\n for (const c of seen) out.delete(c);\n break;\n }\n seen.add(at.id);\n }\n }\n return out;\n}\n\n/**\n * The ARCHIVED session it was made from — its parent merged and is done, so\n * it should move onto main (stack-retarget.ts). Only one `merged` says merged:\n * an archived parent that never merged still holds work the child builds on,\n * and moving the child onto main would drop it. Null while a live session is\n * its parent, and for anything stackParent wouldn't count. The newest archive\n * when the branch name was used more than once.\n */\nexport function mergedParent<T extends StackSubject>(\n s: T,\n all: readonly T[],\n eligible: (p: T) => boolean = () => true,\n merged: (p: T) => boolean = () => false,\n): T | null {\n if (s.archivedAt || stackParent(s, all, eligible)) return null;\n const base = stackBase(s);\n if (!base || base === s.branch) return null;\n const gone = all.filter((p) => p.id !== s.id && !!p.archivedAt && p.target === s.target && p.branch === base && eligible(p));\n const newest = gone.sort((a, b) => (b.archivedAt ?? '').localeCompare(a.archivedAt ?? ''))[0];\n return newest && merged(newest) ? newest : null;\n}\n\n/** How many live sessions are stacked on each session. */\nexport function stackChildCounts<T extends StackSubject>(parents: ReadonlyMap<string, T>): Map<string, number> {\n const out = new Map<string, number>();\n for (const p of parents.values()) out.set(p.id, (out.get(p.id) ?? 0) + 1);\n return out;\n}\n","import path from 'node:path';\nimport { updateFromMain, type UpdateResult } from './behind-main.js';\nimport type { WorkConfig } from '../platform/config.js';\nimport { readArchive } from '../archive/session-archive.js';\nimport { defaultRunner, type CommandRunner } from '../pr/ship.js';\nimport type { WorktreeSession } from '../sessions/session-types.js';\nimport type { StackedSession } from './stack-sessions.js';\nimport { sessionAliases } from '../sessions/session-repos.js';\n\n/**\n * A stacked session (stack.ts) whose parent merged — its session archived —\n * moves onto main. Its branch still holds the parent's commits, which main\n * now has in another form (a squash merge), so a plain rebase would replay\n * them: `git rebase --onto origin/<main> <fork point>` replays only its own\n * commits, the fork point being where it left the parent (the parent's\n * branch, or the tip its archive recorded). A branch already pushed isn't\n * rewritten: main is merged into it, as Update from main does. Git through\n * a CommandRunner: argv only.\n */\n\n/** The parent's tip in this repo: its branch if it is still there, else what its archive recorded. */\nexport async function parentTipFor(\n repo: string,\n parent: Pick<StackedSession, 'id' | 'branch' | 'target' | 'isGroup'> & Partial<Pick<StackedSession, 'paths' | 'repos'>>,\n config: WorkConfig | null,\n run: CommandRunner = defaultRunner,\n): Promise<string | null> {\n const ref = await run('git', ['-C', repo, 'rev-parse', '--verify', '--quiet', `refs/heads/${parent.branch}`], repo);\n if (ref.code === 0 && ref.stdout.trim()) return ref.stdout.trim();\n const tips = readArchive(parent.id)?.tips ?? {};\n if (!parent.isGroup) return tips[parent.target] ?? Object.values(tips)[0] ?? null;\n // A group's repos: the alias whose checkout folder this is.\n // (Only the session's own — recorded, else the group's config: another project's repo may have the same folder name.)\n const own = sessionAliases({ ...parent, paths: parent.paths ?? [] }, config);\n const alias = own.find((a) => a in tips && !!config?.repos[a] && path.basename(config.repos[a]) === path.basename(repo));\n return alias ? tips[alias] : null;\n}\n\n/** Where to start replaying from, and how. */\nexport interface Fork {\n /** The commit it left the parent at (replay what came after). */\n fork: string;\n /** `plain`: the parent's tip is in main (a real merge), so `git rebase <main>` drops the parent's commits by itself. */\n plain: boolean;\n}\n\ninterface Plan extends Fork {\n repo: string;\n name: string;\n branch: string;\n head: string;\n published: boolean;\n}\n\n/**\n * Where the branch left its parent. Not simply merge-base with the parent's\n * tip: a parent rebased or amended before it merged shares only an older\n * commit with the child, and replaying from there would bring the parent's\n * old commits back. So: a parent whose tip is in main (a real merge) needs no\n * fork point (a plain rebase); otherwise git's --fork-point (the parent\n * branch's reflog remembers where it was, even rewritten); otherwise the tip,\n * when the branch is built on it. Else it can't tell, and says so.\n * (--fork-point is a reflog heuristic: git documents that an unrelated\n * reflog entry can mislead it. A fork point from it is still one the child\n * is built on, so at worst a commit too few or too many of the parent's\n * comes along — and a conflict is aborted, never left.)\n */\nexport async function forkPoint(\n repo: string,\n parent: { branch: string; tip: string },\n main: string,\n run: CommandRunner = defaultRunner,\n): Promise<Fork | { error: string; handOff?: boolean }> {\n const git = (...args: string[]) => run('git', ['-C', repo, ...args], repo);\n if ((await git('merge-base', '--is-ancestor', parent.tip, main)).code === 0) {\n const base = (await git('merge-base', 'HEAD', main)).stdout.trim();\n return base ? { fork: base, plain: true } : { error: 'it has nothing in common with main' };\n }\n if ((await git('rev-parse', '--verify', '--quiet', `refs/heads/${parent.branch}`)).code === 0) {\n const fp = await git('merge-base', '--fork-point', `refs/heads/${parent.branch}`, 'HEAD');\n if (fp.code === 0 && fp.stdout.trim()) return { fork: fp.stdout.trim(), plain: false };\n }\n if ((await git('merge-base', '--is-ancestor', parent.tip, 'HEAD')).code === 0) return { fork: parent.tip, plain: false };\n return {\n error: `${parent.branch} was rewritten (rebased or amended) after this branched off, and git can't tell which commits are this branch's own: ask its Claude to move it onto main`,\n handOff: true,\n };\n}\n\nasync function plan(\n repo: string,\n parent: { branch: string; tip: string },\n run: CommandRunner,\n fetch: boolean,\n): Promise<Plan | { error: string; handOff?: boolean; base?: string }> {\n const git = (...args: string[]) => run('git', ['-C', repo, ...args], repo);\n const name = path.basename(repo);\n const st = await git('status', '--porcelain');\n if (st.code !== 0) return { error: st.stderr.trim() || 'not a git checkout' };\n if (st.stdout.trim()) return { error: 'it has uncommitted changes: commit or stash them first' };\n const branch = (await git('rev-parse', '--abbrev-ref', 'HEAD')).stdout.trim();\n if (!branch || branch === 'HEAD') return { error: 'not on a branch (detached HEAD)' };\n if (fetch) await git('fetch', '--quiet', 'origin');\n const head = (await git('rev-parse', '--abbrev-ref', 'origin/HEAD')).stdout.trim();\n if (!head || head === 'origin/HEAD') return { error: 'no origin/HEAD to move onto (git remote set-head origin -a)' };\n const f = await forkPoint(repo, parent, head, run);\n if ('error' in f) return { ...f, base: head };\n const published = (await git('rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branch}`)).code === 0;\n return { repo, name, branch, head, published, ...f };\n}\n\n/** Why it can't be moved by git alone, if so: the parent was rewritten and the fork point is unknown (hand it to Claude). */\nexport async function retargetBlocker(\n repo: string,\n parent: { branch: string; tip: string },\n run: CommandRunner = defaultRunner,\n): Promise<{ reason: string; handOff: boolean } | null> {\n const p = await plan(repo, parent, run, false);\n return 'error' in p ? { reason: p.error, handOff: !!p.handOff } : null;\n}\n\n/**\n * Would it move cleanly? (git merge-tree, nothing touched.) False when git\n * can't tell — `--merge-base` needs git 2.40 — so the automatic move never\n * runs on an older git; the button still works.\n */\nexport async function retargetIsClean(\n repo: string,\n parent: { branch: string; tip: string },\n run: CommandRunner = defaultRunner,\n): Promise<boolean> {\n const p = await plan(repo, parent, run, false);\n if ('error' in p) return false;\n const args =\n p.published || p.plain\n ? ['merge-tree', '--write-tree', '--quiet', 'HEAD', p.head]\n : ['merge-tree', '--write-tree', '--quiet', `--merge-base=${p.fork}`, p.head, 'HEAD'];\n return (await run('git', ['-C', repo, ...args], repo)).code === 0;\n}\n\nexport interface RetargetResult {\n ok: boolean;\n results: UpdateResult[];\n /** Each repo's main now (path → `main`), when it moved. */\n bases?: Record<string, string>;\n}\n\n/**\n * Move every repo of the session onto main, all or nothing: a repo that\n * fails puts back the ones already moved (they were clean). Refuses a dirty\n * repo, a detached HEAD, a repo it can't find the parent in, and stops when\n * `stillOk` says no right before a repo is changed (a turn started).\n */\nexport async function retargetOntoMain(\n child: WorktreeSession,\n parentOf: (repo: string) => Promise<{ branch: string; tip: string | null }>,\n run: CommandRunner = defaultRunner,\n stillOk: () => string | null = () => null,\n): Promise<RetargetResult> {\n const plans: Plan[] = [];\n for (const repo of child.paths) {\n const parent = await parentOf(repo);\n if (!parent.tip)\n return {\n ok: false,\n results: [{ ok: false, repo: path.basename(repo), reason: `${parent.branch} is gone and its archive has no tip for this repo` }],\n };\n const p = await plan(repo, { branch: parent.branch, tip: parent.tip }, run, true);\n if ('error' in p)\n return {\n ok: false,\n results: [\n { ok: false, repo: path.basename(repo), reason: p.error, ...(p.handOff ? { handOff: true, base: p.base ?? 'origin/main' } : {}) },\n ],\n };\n plans.push(p);\n }\n const before = new Map<string, string>();\n for (const p of plans) before.set(p.repo, (await run('git', ['-C', p.repo, 'rev-parse', 'HEAD'], p.repo)).stdout.trim());\n const results: UpdateResult[] = [];\n const moved: string[] = [];\n const putBack = async () => {\n for (const repo of moved) await run('git', ['-C', repo, 'reset', '--hard', '--quiet', before.get(repo)!], repo);\n };\n const fail = async (r: UpdateResult): Promise<RetargetResult> => {\n await putBack();\n return {\n ok: false,\n results: [\n ...results.map((x): UpdateResult => ({ ok: false, repo: x.repo, reason: 'put back as it was', base: x.ok ? x.base : undefined })),\n r,\n ],\n };\n };\n for (const p of plans) {\n const busy = stillOk();\n if (busy) return fail({ ok: false, repo: p.name, reason: busy });\n const git = (...args: string[]) => run('git', ['-C', p.repo, ...args], p.repo);\n const commits = Number((await git('rev-list', '--count', `${p.fork}..${p.head}`)).stdout.trim()) || 0;\n let r: UpdateResult;\n if (p.published) {\n // Pushed: not rewritten (no force push) — main merged in, as Update from main does.\n r = await updateFromMain(p.repo, run);\n } else {\n const rb = p.plain ? await git('rebase', p.head) : await git('rebase', '--onto', p.head, p.fork);\n if (rb.code === 0) r = { ok: true, repo: p.name, how: 'rebase', base: p.head, commits };\n else {\n const unmerged = (await git('diff', '--name-only', '--diff-filter=U')).stdout.trim() !== '';\n await git('rebase', '--abort');\n r = unmerged\n ? { ok: false, repo: p.name, reason: `moving onto ${p.head} conflicts`, conflicts: true, base: p.head }\n : {\n ok: false,\n repo: p.name,\n reason: `moving onto ${p.head} failed: ${rb.stderr.trim().split(/\\r?\\n/)[0] || `git exited ${rb.code}`}`,\n base: p.head,\n };\n }\n }\n if (!r.ok) return fail(r);\n results.push(r);\n moved.push(p.repo);\n }\n return { ok: true, results, bases: Object.fromEntries(plans.map((p) => [p.repo, p.head.replace(/^origin\\//, '')])) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,WAAU;;;ACAjB,OAAO,UAAU;AA6BjB,eAAsB,WAAW,MAAc,MAAqB,eAAe,QAAyC;AAC1H,MAAI;AACJ,MAAI,QAAQ;AACV,UAAM,KAAK,MAAM,IAAI,OAAO,CAAC,MAAM,MAAM,aAAa,YAAY,WAAW,cAAc,MAAM,EAAE,GAAG,IAAI;AAC1G,QAAI,GAA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EAAE,MAAO,OAAM,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK;AACrE,SAAO,EAAE,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,aAAa,MAAM,OAAO,OAAO;AAC/E;AAGA,eAAsB,cAAc,GAAoB,KAA6C;AACnG,QAAM,SAAS,cAAc,YAAY,GAAG,WAAW,CAAC,EAAE,eAAe,IAAI,aAAa,CAAC,CAAC;AAC5F,SAAO,SAAS,aAAa,GAAG,GAAG,IAAI,eAAe,GAAG,GAAG;AAC9D;","names":["path","path","path","path","path","busy","path"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/platform/running-from.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { execFile } from 'node:child_process';\nimport { isPidAlive, killTreeAsync } from './process.js';\nimport { packageRoot } from './package-root.js';\nimport { getConfigDir } from './config.js';\n\n/**\n * Processes running from a folder — a dev server, a watcher, a built app\n * Claude started in a worktree — and what keeps a folder in use on Windows.\n * Archiving stops Claude, but not what it started in the background (`vite`\n * with `run_in_background`): that held a file in `node_modules`, so git\n * removed the worktree only in part, and Restore couldn't move what was left.\n *\n * Two kinds, kept apart on purpose:\n * - runs from it: its program is in the folder — the executable, or an\n * interpreter's script (`node <dir>/node_modules/vite/bin/vite.js`,\n * `dotnet <dir>/bin/App.dll`). Work's to stop, with the session's work.\n * - mentions it: anything else naming the folder (an editor opened on it,\n * a terminal). Named in a message, never stopped: it's the user's.\n */\n\nexport interface RunningProcess {\n pid: number;\n ppid: number;\n /** Its executable's file name (\"node.exe\"). */\n name: string;\n /** Its executable's full path, when the system says. */\n exe: string | null;\n /** Its command line ('' when it can't be read). */\n command: string;\n /** Its working folder, where the system says (Linux): a relative script (`node dist/server.js`) is under it. */\n cwd?: string | null;\n}\n\n/** Interpreters whose script is the program: the first argument that isn't an option. */\nconst INTERPRETERS = new Set(['node', 'bun', 'deno', 'python', 'python3', 'pythonw', 'py', 'dotnet', 'java', 'javaw', 'ruby', 'php']);\n\nconst win = process.platform === 'win32';\n\n/** A path as compared: absolute, normalised, `\\` and case-blind on Windows. */\nexport function normDir(p: string, windows = win): string {\n if (windows) return path.win32.normalize(p.replace(/\\//g, '\\\\')).replace(/\\\\+$/, '').toLowerCase();\n return path.posix.normalize(p).replace(/\\/+$/, '');\n}\n\nfunction under(p: string, dir: string, windows: boolean): boolean {\n const a = normDir(p, windows);\n const sep = windows ? '\\\\' : '/';\n return a === dir || a.startsWith(dir + sep);\n}\n\n/** A command line's words: quotes group, and are dropped (Windows' rules, roughly; enough to find a path). */\nexport function commandWords(command: string): string[] {\n const out: string[] = [];\n for (const m of command.matchAll(/\"([^\"]*)\"|(\\S+)/g)) out.push(m[1] ?? m[2]);\n return out;\n}\n\nconst bare = (file: string) =>\n file\n .split(/[\\\\/]/)\n .pop()!\n .toLowerCase()\n .replace(/\\.exe$/, '');\n\n/** Its program is in one of `dirs` (normalised with normDir): the executable, or an interpreter's script. */\nexport function runsFrom(p: RunningProcess, dirs: string[], windows = win): boolean {\n const words = commandWords(p.command);\n const exe = p.exe ?? words[0] ?? '';\n if (exe && dirs.some((d) => under(exe, d, windows))) return true;\n // Its version gone: python3.12, node22 (Linux names the binary itself).\n if (!INTERPRETERS.has(bare(exe || p.name).replace(/[\\d.]+$/, ''))) return false;\n // Its script: the first argument that isn't an option, or the first that names a program file (an option's value\n // comes first in `node -r ts-node/register <dir>/src/index.ts`). Not any later one: `node C:\\tools\\fmt.js <dir>\\a.ts`\n // runs a tool of yours on a file there, its program elsewhere.\n const args = words.slice(1);\n const first = args.find((w) => !w.startsWith('-'));\n const relative = (w: string) => !(windows ? path.win32.isAbsolute(w) : w.startsWith('/'));\n const scripts = [first, args.find((w) => SCRIPT_FILE.test(w))]\n .filter((w): w is string => !!w && (/[\\\\/]/.test(w) || (!!p.cwd && SCRIPT_FILE.test(w))))\n // A relative one is where the process works (`node dist/server.js`, `python manage.py`), when that's known.\n .map((w) => (relative(w) && p.cwd ? (windows ? path.win32.resolve(p.cwd, w) : path.posix.resolve(p.cwd, w)) : w));\n return scripts.some((w) => dirs.some((d) => under(w, d, windows)));\n}\n\nconst SCRIPT_FILE = /\\.(c|m)?(js|ts)$|\\.(py|dll|jar|rb|php)$/i;\n\n/** node-pty's own processes (the console it gives a terminal): work's, when it runs from a checkout. */\nexport function isPtyHelper(p: RunningProcess): boolean {\n return /[\\\\/]node-pty[\\\\/]/i.test(`${p.exe ?? ''} ${p.command}`) || /^(conpty|openconsole|winpty-agent)(\\.exe)?$/i.test(p.name);\n}\n\n/**\n * An editor's helper — a language server, the TypeScript server — even one running the worktree's own copy\n * (`node <wt>/node_modules/typescript/lib/tsserver.js`, VS Code's \"use the workspace version\"): the editor's, which\n * the user closes; stopping it only makes the editor report a crash. Known by what editors start them with.\n */\nexport function isEditorHelper(p: RunningProcess): boolean {\n const words = commandWords(p.command);\n if (words.some((w) => /^--(useNodeIpc|node-ipc|clientProcessId(=.*)?|cancellationPipeName)$/i.test(w))) return true;\n return words.slice(1).some((w) => /[\\\\/](tsserver|typingsInstaller)\\.js$|language-?server|langserver/i.test(w));\n}\n\n/** Where this work runs from: its `dist/bin.js` (an npm install, a linked checkout, the desktop app's copy). */\nexport function workBinPaths(): string[] {\n const root = packageRoot();\n return root ? [normDir(path.join(root, 'dist', 'bin.js'))] : [];\n}\n\n/**\n * One of work's own (the PTY host, a work web, a hook): this work's own `bin.js` running one of those — never\n * stopped, wherever it's installed (stopping the PTY host stops every session's Claude). Not any `bin.js web`:\n * a project's own would be spared, and keep its worktree in use.\n */\nexport function isWorkProcess(p: RunningProcess, bins: string[] = workBinPaths(), windows = win): boolean {\n if (bins.length === 0) return false;\n const raw = commandWords(p.command);\n return raw.some((w, i) => /^(pty-host|web|hook)$/.test(raw[i + 1] ?? '') && bins.includes(normDir(w, windows)));\n}\n\n/** It names one of `dirs` somewhere in its command line or executable path. */\nexport function mentions(p: RunningProcess, dirs: string[], windows = win): boolean {\n const norm = (s: string) => (windows ? s.replace(/\\//g, '\\\\').toLowerCase() : s);\n const text = `${norm(p.exe ?? '')} ${norm(p.command)}`;\n // The folder itself, or inside it: anything but more of a name may follow (a separator, a quote, `&`, `;`, the\n // end) — not feat-x2 or feat-x-old, which are other folders.\n return dirs.some((d) => {\n for (let at = text.indexOf(d); at >= 0; at = text.indexOf(d, at + 1)) {\n const next = text[at + d.length];\n if (next === undefined || !/[\\w.-]/.test(next)) return true;\n }\n return false;\n });\n}\n\nexport interface Holders {\n /** Run from the folders: stop these (each the top of its tree — its children go with it on Windows). */\n stoppable: RunningProcess[];\n /** Every one that runs from them, children too: POSIX kills one process at a time. */\n running?: RunningProcess[];\n /** Name the folders but run from elsewhere (an editor, a shell): the user's to close. */\n others: RunningProcess[];\n}\n\n/**\n * What runs from or names `dirs`, in `procs`. Never this process or one it runs under, never one in `spare` (the\n * PTY host and work web by their recorded pids) or under it, and never one of work's own by its command line\n * (isWorkProcess) — whatever folder they run from.\n */\nexport function holdersOf(\n procs: RunningProcess[],\n dirs: string[],\n self = process.pid,\n windows = win,\n spare: ReadonlySet<number> = new Set(),\n bins: string[] = workBinPaths(),\n): Holders {\n const norm = dirs.map((d) => normDir(d, windows));\n const byPid = new Map(procs.map((p) => [p.pid, p]));\n const mine = new Set<number>();\n for (let pid: number | undefined = self; pid && !mine.has(pid); pid = byPid.get(pid)?.ppid) mine.add(pid);\n // work's own (by pid or command line), and the terminal helpers they run (node-pty's, from where work is\n // installed — a checkout's node_modules). Not everything under them: a dev server a Claude started is a\n // descendant of the PTY host until that Claude is gone, and stopping it is the point.\n const ownWork = (q: RunningProcess) => spare.has(q.pid) || isWorkProcess(q, bins, windows);\n const spared = (p: RunningProcess): boolean => {\n if (ownWork(p)) return true;\n if (!isPtyHelper(p)) return false;\n const seen = new Set<number>();\n for (let q = byPid.get(p.ppid); q && !seen.has(q.pid); q = byPid.get(q.ppid)) {\n if (ownWork(q)) return true;\n seen.add(q.pid);\n }\n return false;\n };\n const candidates = procs.filter((p) => !mine.has(p.pid) && !spared(p));\n // An editor's helper is the user's, like the editor: named, never stopped.\n const running = candidates.filter((p) => runsFrom(p, norm, windows) && !isEditorHelper(p));\n const runningPids = new Set(running.map((p) => p.pid));\n return {\n stoppable: running.filter((p) => !runningPids.has(p.ppid)),\n running,\n others: candidates.filter((p) => !runningPids.has(p.pid) && mentions(p, norm, windows)),\n };\n}\n\n/** The pids work recorded for its PTY host and work web (and the dev server's): spared by every stop. */\nexport function workPids(dir = getConfigDir()): Set<number> {\n const out = new Set<number>();\n for (const file of ['pty-host.json', 'web.pid', 'web-dev.pid']) {\n try {\n const raw = fs.readFileSync(path.join(dir, file), 'utf-8').trim();\n const pid = raw.startsWith('{') ? (JSON.parse(raw) as { pid?: unknown }).pid : Number(raw.split(/\\s/)[0]);\n if (typeof pid === 'number' && Number.isInteger(pid) && pid > 0) out.add(pid);\n } catch {\n /* not running, or not recorded */\n }\n }\n return out;\n}\n\n/** \"node …\\vite\\bin\\vite.js --mode demo (PID 35464)\": its name and command, the folder shortened to \"…\". */\nexport function describeProcess(p: RunningProcess, dirs: string[], windows = win): string {\n const words = commandWords(p.command).slice(1);\n let args = words.join(' ');\n // The folder (normalised as normDir: `\\`, lower case on Windows) wherever it appears, as typed.\n for (const d of dirs) {\n // Char by char, and only where lower case keeps the length (an İ doesn't): the positions stay those of `args`.\n const fold = (s: string) =>\n windows\n ? [...s]\n .map((c) => {\n const l = (c === '/' ? '\\\\' : c).toLowerCase();\n return l.length === c.length ? l : c;\n })\n .join('')\n : s;\n for (let at = fold(args).indexOf(d); at >= 0; at = fold(args).indexOf(d)) args = args.slice(0, at) + '…' + args.slice(at + d.length);\n }\n if (args.length > 90) args = `${args.slice(0, 89)}…`;\n const name = bare(p.name || p.exe || '?');\n return `${name}${args ? ` ${args}` : ''} (PID ${p.pid})`;\n}\n\n/** Windows: `Get-CimInstance Win32_Process` as JSON (one object, or a list). */\nexport function parseCimProcesses(json: string): RunningProcess[] {\n let data: unknown;\n try {\n data = JSON.parse(json);\n } catch {\n return [];\n }\n const rows = Array.isArray(data) ? data : data ? [data] : [];\n const out: RunningProcess[] = [];\n for (const r of rows) {\n if (!r || typeof r !== 'object') continue;\n const o = r as Record<string, unknown>;\n if (typeof o.ProcessId !== 'number') continue;\n out.push({\n pid: o.ProcessId,\n ppid: typeof o.ParentProcessId === 'number' ? o.ParentProcessId : 0,\n name: typeof o.Name === 'string' ? o.Name : '',\n exe: typeof o.ExecutablePath === 'string' ? o.ExecutablePath : null,\n command: typeof o.CommandLine === 'string' ? o.CommandLine : '',\n });\n }\n return out;\n}\n\n/** macOS: `ps -A -o pid=,ppid=,args=`. */\nexport function parsePsProcesses(stdout: string): RunningProcess[] {\n const out: RunningProcess[] = [];\n for (const line of stdout.split(/\\r?\\n/)) {\n const m = /^\\s*(\\d+)\\s+(\\d+)\\s+(.*)$/.exec(line);\n if (!m) continue;\n const command = m[3].trim();\n const first = commandWords(command)[0] ?? '';\n out.push({\n pid: Number(m[1]),\n ppid: Number(m[2]),\n name: path.posix.basename(first),\n exe: first.startsWith('/') ? first : null,\n command,\n });\n }\n return out;\n}\n\n/** Read asynchronously: work web's requests wait behind a synchronous walk of /proc. */\nasync function linuxProcesses(): Promise<RunningProcess[]> {\n const out: RunningProcess[] = [];\n let pids: string[];\n try {\n pids = (await fs.promises.readdir('/proc')).filter((d) => /^\\d+$/.test(d));\n } catch {\n return out;\n }\n for (const d of pids) {\n try {\n const stat = await fs.promises.readFile(`/proc/${d}/stat`, 'utf-8');\n const ppid = Number(stat.slice(stat.lastIndexOf(')') + 2).split(' ')[1]);\n const command = (await fs.promises.readFile(`/proc/${d}/cmdline`, 'utf-8'))\n .split('\\0')\n .filter(Boolean)\n .map((w) => (/\\s/.test(w) ? `\"${w}\"` : w))\n .join(' ');\n let exe: string | null = null;\n let cwd: string | null = null;\n try {\n exe = await fs.promises.readlink(`/proc/${d}/exe`);\n cwd = await fs.promises.readlink(`/proc/${d}/cwd`);\n } catch {\n /* another user's */\n }\n out.push({ pid: Number(d), ppid, name: exe ? path.posix.basename(exe) : '', exe, command, cwd });\n } catch {\n /* gone meanwhile */\n }\n }\n return out;\n}\n\nconst run = (cmd: string, args: string[]): Promise<string> =>\n new Promise((resolve) =>\n execFile(cmd, args, { encoding: 'utf-8', windowsHide: true, timeout: 20_000, maxBuffer: 64 * 1024 * 1024 }, (_err, stdout) =>\n resolve(stdout ?? ''),\n ),\n );\n\n/** Every process with its parent, executable and command line. Empty when they can't be read. */\nexport async function listProcesses(): Promise<RunningProcess[]> {\n if (process.platform === 'linux') return linuxProcesses();\n if (process.platform === 'win32') {\n return parseCimProcesses(\n await run('powershell', [\n '-NoProfile',\n '-NonInteractive',\n '-Command',\n // UTF-8 out: the console's code page would turn a path with Š or č into ?.\n '[Console]::OutputEncoding = [Text.Encoding]::UTF8; Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,ExecutablePath,CommandLine | ConvertTo-Json -Compress',\n ]),\n );\n }\n return parsePsProcesses(await run('ps', ['-A', '-o', 'pid=,ppid=,args=']));\n}\n\n/** Look up what runs from or names `dirs` now. */\nexport async function findHolders(\n dirs: string[],\n list: () => Promise<RunningProcess[]> = listProcesses,\n spare: ReadonlySet<number> = workPids(),\n): Promise<Holders> {\n const existing = dirs.filter((d) => fs.existsSync(d));\n if (existing.length === 0) return { stoppable: [], running: [], others: [] };\n return holdersOf(await list(), existing, process.pid, win, spare);\n}\n\n/**\n * What runs from `dirs`, by name, stopping nothing. Throws when the processes can't be read (none listed: there are\n * always some), so \"nothing runs there\" is never a guess.\n */\nexport async function runningFromNames(dirs: string[], list: () => Promise<RunningProcess[]> = listProcesses): Promise<string[]> {\n const procs = await list();\n if (procs.length === 0) throw new Error(\"couldn't read the running processes\");\n const h = await findHolders(dirs, async () => procs);\n const norm = dirs.map((d) => normDir(d));\n return h.stoppable.map((p) => describeProcess(p, norm));\n}\n\n/** How long a stop waits for what it stopped to be gone (its files let go) before going on. */\nconst EXIT_WAIT_MS = 3000;\n\n/**\n * Stop what runs from `dirs`, and say what: [\"node …\\vite\\bin\\vite.js --mode demo (PID 35464)\"]. Only processes\n * whose program is in the folders — never an editor open on them, never one of work's own. Windows stops each\n * tree; POSIX each process (a kill there is one process). Waits a moment for them to be gone, so the folder is\n * free when it returns.\n */\nexport async function stopRunningFrom(\n dirs: string[],\n io: {\n list?: () => Promise<RunningProcess[]>;\n kill?: (pid: number) => Promise<boolean> | boolean;\n alive?: (pid: number) => boolean;\n spare?: ReadonlySet<number>;\n waitMs?: number;\n } = {},\n): Promise<string[]> {\n const h = await findHolders(dirs, io.list, io.spare);\n const kill = io.kill ?? killTreeAsync;\n const alive = io.alive ?? isPidAlive;\n const targets = win ? h.stoppable : (h.running ?? h.stoppable);\n // All at once, and off the event loop (taskkill takes a few hundred ms each; work web answers meanwhile).\n const killed = await Promise.all(targets.map((p) => Promise.resolve(kill(p.pid)).catch(() => false)));\n const stopped = targets.filter((_, i) => killed[i]);\n for (const until = Date.now() + (io.waitMs ?? EXIT_WAIT_MS); stopped.some((p) => alive(p.pid)) && Date.now() < until;) {\n await new Promise((r) => setTimeout(r, 100));\n }\n const norm = dirs.map((d) => normDir(d));\n const named = new Set(h.stoppable.map((p) => p.pid));\n return stopped.filter((p) => named.has(p.pid)).map((p) => describeProcess(p, norm));\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;AAkCzB,IAAM,eAAe,oBAAI,IAAI,CAAC,QAAQ,OAAO,QAAQ,UAAU,WAAW,WAAW,MAAM,UAAU,QAAQ,SAAS,QAAQ,KAAK,CAAC;AAEpI,IAAM,MAAM,QAAQ,aAAa;AAG1B,SAAS,QAAQ,GAAW,UAAU,KAAa;AACxD,MAAI,QAAS,QAAO,KAAK,MAAM,UAAU,EAAE,QAAQ,OAAO,IAAI,CAAC,EAAE,QAAQ,QAAQ,EAAE,EAAE,YAAY;AACjG,SAAO,KAAK,MAAM,UAAU,CAAC,EAAE,QAA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M,eAAe;AAQrB,eAAsB,gBACpB,MACA,KAMI,CAAC,GACc;AACnB,QAAM,IAAI,MAAM,YAAY,MAAM,GAAG,MAAM,GAAG,KAAK;AACnD,QAAM,OAAO,GAAG,QAAQ;AACxB,QAAM,QAAQ,GAAG,SAAS;AAC1B,QAAM,UAAU,MAAM,EAAE,YAAa,EAAE,WAAW,EAAE;AAEpD,QAAM,SAAS,MAAM,QAAQ,IAAI,QAAQ,IAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,EAAE,GAAG,CAAC,EAAE,MAAM,MAAM,KAAK,CAAC,CAAC;AACpG,QAAM,UAAU,QAAQ,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,CAAC;AAClD,aAAW,QAAQ,KAAK,IAAI,KAAK,GAAG,UAAU,eAAe,QAAQ,KAAK,CAAC,MAAM,MAAM,EAAE,GAAG,CAAC,KAAK,KAAK,IAAI,IAAI,SAAQ;AACrH,UAAM,IAAI,QAAQ,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAAA,EAC7C;AACA,QAAM,OAAO,KAAK,IAAI,CAAC,MAAM,QAAQ,CAAC,CAAC;AACvC,QAAM,QAAQ,IAAI,IAAI,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;AACnD,SAAO,QAAQ,OAAO,CAAC,MAAM,MAAM,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AACpF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/pty/host-control.ts","../src/core/platform/shell-path.ts","../src/core/agents/agent-path.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { execFile } from 'node:child_process';\nimport { ensureHost, probeHostDetailed } from './pty-host-client.js';\nimport { hostInfoPath, readHostInfo } from './pty-host-protocol.js';\nimport { isPidAlive, killTree } from '../platform/process.js';\n\n/**\n * Stopping and restarting the PTY host — the CLI's `work pty-host\n * --stop/--restart` and the dashboard's Restart share it. The persisted\n * session list stays, so the next host restores them with --continue.\n */\n\nexport type StopOutcome = 'stopped' | 'not-running' | 'stale-file' | 'unresponsive' | 'failed';\n\n/** A process's command line, or null when it isn't running or can't be read (Windows: CIM; elsewhere: ps). */\nexport function commandLineOf(pid: number): Promise<string | null> {\n return new Promise((resolve) => {\n const done = (err: Error | null, out: string) => resolve(err ? null : out.trim() || null);\n if (process.platform === 'win32')\n execFile(\n 'powershell',\n ['-NoProfile', '-Command', `(Get-CimInstance Win32_Process -Filter 'ProcessId=${Math.trunc(pid)}').CommandLine`],\n { windowsHide: true, timeout: 15_000 },\n (err, out) => done(err, String(out)),\n );\n else\n execFile('ps', ['-o', 'args=', '-p', String(Math.trunc(pid))], { windowsHide: true, timeout: 5000 }, (err, out) =>\n done(err, String(out)),\n );\n });\n}\n\n/**\n * The recorded pid really is a running PTY host of work's: alive, and its command line runs `pty-host` (not a\n * `--stop`/`--restart`/`--status` call). Pids get reused — on Windows fast — so a host that doesn't answer is only\n * force-stopped after this: blind, it could take down any process that took its number. Pure over its inputs.\n */\nexport function looksLikeHost(commandLine: string | null): boolean {\n return (\n !!commandLine && /(^|\\s|[\"'\\\\/])pty-host(\\s|$|[\"'])/.test(commandLine) && !/\\bpty-host\\b.*--(stop|restart|status)\\b/.test(commandLine)\n );\n}\n\n/**\n * Kill the running host and its PTYs. Only a PID that proves it's our host gets killed: it answers /health with the\n * discovery file's token and that same PID — or, with `force`, it doesn't answer at all (hung: a ConPTY start that\n * blocked its event loop) but its process is alive and runs `work pty-host` (`looksLikeHost`). The file survives\n * crashes and reboots (TerminateProcess skips cleanup), and Windows reuses PIDs. A stale file is just removed.\n */\nexport async function stopHost(\n kill: (pid: number) => boolean = killTree,\n probeTimeoutMs = 5000,\n opts: { force?: boolean; isOurHost?: (pid: number) => Promise<boolean> } = {},\n): Promise<StopOutcome> {\n const hostInfo = readHostInfo();\n if (!hostInfo) return 'not-running';\n // A busy host (restoring many sessions) can miss a short probe; give it\n // longer before concluding anything.\n const probe = await probeHostDetailed(hostInfo, probeTimeoutMs);\n if (probe.kind === 'timeout') {\n // Alive-but-slow must NOT be treated as stale: deleting the file would\n // orphan a live host, and --restart would then start a second one that\n // restores every session again. Keep the file, kill nothing — unless\n // asked to stop a hung one, and it proves to be ours.\n const ours = opts.isOurHost ?? (async (pid: number) => isPidAlive(pid) && looksLikeHost(await commandLineOf(pid)));\n if (!opts.force || !(await ours(hostInfo.pid))) return 'unresponsive';\n return killAndForget(kill, hostInfo.pid);\n }\n if (probe.kind !== 'host' || probe.pid !== hostInfo.pid) {\n // Nothing listening, or someone else on that port: the file is stale\n // (reboot, crash, PID/port reused). Remove it; kill nothing.\n removeInfo();\n return 'stale-file';\n }\n return killAndForget(kill, hostInfo.pid);\n}\n\nfunction killAndForget(kill: (pid: number) => boolean, pid: number): StopOutcome {\n const ok = kill(pid);\n // TerminateProcess means the host never runs its own cleanup.\n removeInfo();\n return ok ? 'stopped' : 'failed';\n}\n\nfunction removeInfo(): void {\n try {\n fs.unlinkSync(hostInfoPath());\n } catch {\n /* */\n }\n}\n\n/**\n * Stop the host and start a new one, which restores every saved session with --continue. `force`: a host that\n * doesn't answer is stopped too (see stopHost). Never starts a second host beside one it couldn't stop.\n */\nexport async function restartHost(\n workBin: string,\n opts: { force?: boolean } = {},\n steps: { stop?: (force: boolean) => Promise<StopOutcome>; start?: (workBin: string) => Promise<{ pid: number }>; pauseMs?: number } = {},\n): Promise<{ outcome: StopOutcome; pid: number | null }> {\n const outcome = await (steps.stop ?? ((force) => stopHost(killTree, 5000, { force })))(!!opts.force);\n if (outcome === 'failed' || outcome === 'unresponsive') return { outcome, pid: null };\n // The old one's port and lock let go before the new one takes them.\n await new Promise((r) => setTimeout(r, steps.pauseMs ?? 500));\n const host = await (steps.start ?? ensureHost)(workBin);\n return { outcome, pid: host.pid };\n}\n","import { spawnSync, type SpawnSyncOptionsWithStringEncoding } from 'node:child_process';\nimport path from 'node:path';\nimport { findOnPath } from './find-on-path.js';\nimport { report } from './report.js';\nimport { debugLog } from './logger.js';\nimport { detachHere } from './process.js';\n\n/**\n * The PATH of the user's login shell, for a work started without one.\n *\n * Reported from a Mac: every session ended at once with \"session exited with code 1\", and Enter\n * gave the same. The desktop app started from the Dock or Finder gets the system's minimal PATH\n * (/usr/bin:/bin:/usr/sbin:/sbin), not the one the user's shell sets up, and passes it on to work\n * web, the PTY host and every Claude: `claude` (in ~/.local/bin, /opt/homebrew/bin, an nvm folder…)\n * isn't found, and node-pty's child exits with 1 when its exec fails. So when work web or the PTY\n * host starts on macOS or Linux and the agent's command isn't on its PATH, it asks the login shell\n * for its PATH (`$SHELL -ilc`, as a terminal would set it up) and puts it first. Started from a\n * terminal, the command is found and nothing is asked.\n */\n\nconst MARK = '__WORK_SHELL_PATH__';\n\n/** The shell's PATH first, then what we had that it lacks (e.g. the app's ~/.work/bin). */\nexport function mergePath(current: string | undefined, shellPath: string, sep = path.delimiter): string {\n const out: string[] = [];\n for (const d of [...shellPath.split(sep), ...(current ?? '').split(sep)]) if (d && !out.includes(d)) out.push(d);\n return out.join(sep);\n}\n\n/** The PATH between the markers of the shell's output (an interactive shell may print a greeting around it). */\nexport function parseShellPath(stdout: string): string | null {\n const m = new RegExp(`${MARK}(.*?)${MARK}`, 's').exec(stdout);\n const p = m?.[1].trim();\n return p ? p : null;\n}\n\n/** How long the login shell may take to say its PATH. */\nexport const SHELL_PATH_TIMEOUT_MS = 5_000;\n\n/** The shell's arguments: a login, interactive shell (what a terminal runs) printing its PATH between markers. */\nexport const shellPathArgs = (): string[] => ['-ilc', `printf '%s%s%s' '${MARK}' \"$PATH\" '${MARK}'`];\n\n/**\n * How it's started. `killSignal: SIGKILL`: an interactive bash or zsh ignores SIGTERM (spawnSync's\n * default at the timeout), and Node then waits for it — a stuck profile held work web up for as long as\n * it hung (reproduced: a 2 s timeout returned after 8 s). `detached` (POSIX): its own session, so it\n * never takes this terminal's foreground group — killed while holding it, it left `work web` in the\n * background, where Ctrl+C no longer reached it (reproduced).\n */\nexport const shellPathSpawnOptions = (timeoutMs = SHELL_PATH_TIMEOUT_MS): SpawnSyncOptionsWithStringEncoding =>\n // `detached` isn't in @types/node's spawnSync options, but spawnSync honors it (spawn_sync reads it).\n ({\n encoding: 'utf8',\n timeout: timeoutMs,\n killSignal: 'SIGKILL',\n detached: detachHere(),\n stdio: ['ignore', 'pipe', 'ignore'],\n windowsHide: true,\n }) as SpawnSyncOptionsWithStringEncoding;\n\ntype ShellRun = (cmd: string, args: string[]) => { stdout?: string | null; status?: number | null; signal?: string | null; error?: Error };\n\n/** Ask the login shell for its PATH: its PATH, or why it couldn't say (a timeout, no such shell, no markers). */\nexport function readShellPath(\n shell = process.env.SHELL || '/bin/zsh',\n run: ShellRun = (cmd, args) => spawnSync(cmd, args, shellPathSpawnOptions()),\n): { path: string } | { why: string } {\n try {\n const r = run(shell, shellPathArgs());\n const p = parseShellPath(r.stdout ?? '');\n if (p) return { path: p };\n const how = r.error\n ? r.error.message\n : r.signal\n ? `stopped by ${r.signal} (over ${SHELL_PATH_TIMEOUT_MS / 1000} s?)`\n : `exit ${r.status ?? '?'}, no PATH printed`;\n return { why: `${shell} -ilc: ${how}` };\n } catch (err) {\n return { why: `${shell} -ilc: ${(err as Error).message}` };\n }\n}\n\n/**\n * Make sure the commands in `need` (the agent's binary) can be found: on macOS and Linux, when one\n * isn't on PATH, the login shell's PATH is merged into this process's (which everything it starts\n * inherits). Says what it did; never throws.\n */\nexport function ensureShellPath(\n need: string[],\n opts: {\n platform?: NodeJS.Platform;\n env?: NodeJS.ProcessEnv;\n readPath?: () => { path: string } | { why: string };\n find?: (cmd: string, env: NodeJS.ProcessEnv) => string | null;\n } = {},\n): 'found' | 'added' | 'unavailable' {\n const platform = opts.platform ?? process.platform;\n const env = opts.env ?? process.env;\n if (platform === 'win32') return 'found';\n const find = opts.find ?? ((c: string, e: NodeJS.ProcessEnv) => findOnPath(c, e, platform));\n const missing = need.filter((c) => !find(c, env));\n if (!missing.length) return 'found';\n // Said in the debug log too: started by the desktop app, nothing shows what a reporter prints.\n const say = (level: 'info' | 'warn', text: string) => {\n report(level, text);\n debugLog(level === 'warn' ? 'WARN' : 'INFO', text);\n };\n const read = (opts.readPath ?? (() => readShellPath(env.SHELL)))();\n if ('why' in read) {\n say('warn', `${missing.join(', ')} isn't on PATH (${env.PATH ?? ''}), and the login shell's PATH couldn't be read: ${read.why}`);\n return 'unavailable';\n }\n env.PATH = mergePath(env.PATH, read.path);\n const still = missing.filter((c) => !find(c, env));\n say(\n still.length ? 'warn' : 'info',\n still.length\n ? `${still.join(', ')} isn't on PATH, even with the login shell's (${env.PATH})`\n : `${missing.join(', ')} found with the login shell's PATH: using it (${env.PATH})`,\n );\n return 'added';\n}\n","import { agentFor, agentSettings, assistantAgent, internalAgent } from './index.js';\nimport type { AgentSettings } from './index.js';\nimport { ensureShellPath } from '../platform/shell-path.js';\nimport { debugLog } from '../platform/logger.js';\n\n/**\n * The agents' commands, found on PATH before work web or the PTY host starts any of them\n * (`core/platform/shell-path.ts` says why: the Mac app from the Dock gets the system's PATH).\n */\n\n/** The commands work starts agents with, from the registry: new sessions', the Ctrl+K assistant's, the summaries'. */\nexport function agentCommands(settings: AgentSettings = agentSettings()): string[] {\n return [...new Set([agentFor(settings), assistantAgent(settings), internalAgent(settings)].map((a) => a.launch.tool(settings).cmd))];\n}\n\n/** For `work web` and the PTY host as they start (not wd's lean server: it starts no agent). Never throws. */\nexport function ensureAgentPath(\n deps: { commands?: () => string[]; ensure?: (need: string[]) => ReturnType<typeof ensureShellPath> } = {},\n): ReturnType<typeof ensureShellPath> | 'failed' {\n try {\n return (deps.ensure ?? ensureShellPath)((deps.commands ?? agentCommands)());\n } catch (err) {\n debugLog('WARN', 'finding the agents on PATH failed:', err);\n return 'failed';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,SAAS,gBAAgB;AAclB,SAAS,cAAc,KAAqC;AACjE,SAAO,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AAc,IAAI,KAAK,IAAI;AACjE,MAAI,SAAS,MAAM;AACjB,QAAI,QAAQ,GAAG,QAAQ,KAAK,IAAI,CAAC,mBAAmB,IAAI,QAAQ,EAAE,mDAAmD,KAAK,GAAG,EAAE;AAC/H,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,IAAI,MAAM,KAAK,IAAI;AACxC,QAAM,QAAQ,QAAQ,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;AACjD;AAAA,IACE,MAAM,SAAS,SAAS;AAAA,IACxB,MAAM,SACF,GAAG,MAAM,KAAK,IAAI,CAAC,gDAAgD,IAAI,IAAI,MAC3E,GAAG,QAAQ,KAAK,IAAI,CAAC,iDAAiD,IAAI,IAAI;AAAA,EACpF;AACA,SAAO;AACT;;;AC9GO,SAAS,cAAc,WAA0B,cAAc,GAAa;AACjF,SAAO,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,QAAQ,GAAG,eAAe,QAAQ,GAAG,cAAc,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,EAAE,GAAG,CAAC,CAAC;AACrI;AAGO,SAAS,gBACd,OAAuG,CAAC,GACzD;AAC/C,MAAI;AACF,YAAQ,KAAK,UAAU,kBAAkB,KAAK,YAAY,eAAe,CAAC;AAAA,EAC5E,SAAS,KAAK;AACZ,aAAS,QAAQ,sCAAsC,GAAG;AAC1D,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/shared/setup-completions.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\nimport chalk from 'chalk';\nimport spawn from 'cross-spawn';\n\nexport interface ShellProfile {\n shell: string;\n profilePath: string;\n completionLine: string;\n}\n\nexport type InstallResult = 'installed' | 'created-file' | 'already-exists' | 'error';\n\nexport interface CompletionResult {\n profile: ShellProfile;\n status: InstallResult;\n error?: string;\n}\n\nconst PS_COMPLETION_LINE = 'work completion --shell powershell | Out-String | Invoke-Expression';\nconst BASH_COMPLETION_LINE = 'eval \"$(work completion)\"';\nconst ZSH_COMPLETION_LINE = 'eval \"$(work completion --shell zsh)\"';\nconst FISH_COMPLETION_SCRIPT = `# work tab completions\nfunction __work_complete\n set -l cmd (commandline -opc)\n set -l cur (commandline -ct)\n work --get-yargs-completions $cmd $cur 2>/dev/null\nend\n\ncomplete -c work -f -a '(__work_complete)'`;\nconst MARKER = '# work tab completions';\nconst LEGACY_MARKER = '# work2 tab completions';\n\n/** Get the Windows Documents folder, handling OneDrive redirection. */\nfunction getWindowsDocumentsFolder(): string | null {\n // Try pwsh first, fall back to powershell.exe\n for (const exe of ['pwsh', 'powershell']) {\n const result = spawn.sync(exe, ['-NoProfile', '-Command', \"[Environment]::GetFolderPath('MyDocuments')\"], {\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n windowsHide: true,\n });\n if (result.status === 0 && result.stdout) {\n const dir = result.stdout.toString().trim();\n if (dir) return dir;\n }\n }\n return null;\n}\n\n/** Check if an executable exists on PATH. */\nfunction executableExists(name: string): boolean {\n const cmd = process.platform === 'win32' ? 'where' : 'which';\n const result = spawn.sync(cmd, [name], {\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n windowsHide: true,\n });\n return result.status === 0;\n}\n\n/** Detect available shell profiles for completion installation. */\nexport function detectShellProfiles(): ShellProfile[] {\n const profiles: ShellProfile[] = [];\n\n if (process.platform === 'win32') {\n const docs = getWindowsDocumentsFolder();\n if (!docs) return profiles;\n\n if (executableExists('pwsh')) {\n profiles.push({\n shell: 'PowerShell 7',\n profilePath: path.join(docs, 'PowerShell', 'Microsoft.PowerShell_profile.ps1'),\n completionLine: PS_COMPLETION_LINE,\n });\n }\n\n if (executableExists('powershell')) {\n profiles.push({\n shell: 'PowerShell 5.1',\n profilePath: path.join(docs, 'WindowsPowerShell', 'Microsoft.PowerShell_profile.ps1'),\n completionLine: PS_COMPLETION_LINE,\n });\n }\n } else {\n const shell = process.env.SHELL ?? '';\n const home = os.homedir();\n\n if (shell.includes('fish')) {\n // Fish uses a dedicated completions directory\n const fishConfigDir = process.env.XDG_CONFIG_HOME\n ? path.join(process.env.XDG_CONFIG_HOME, 'fish')\n : path.join(home, '.config', 'fish');\n profiles.push({\n shell: 'Fish',\n profilePath: path.join(fishConfigDir, 'completions', 'work.fish'),\n completionLine: FISH_COMPLETION_SCRIPT,\n });\n } else if (shell.includes('zsh')) {\n profiles.push({\n shell: 'Zsh',\n profilePath: path.join(home, '.zshrc'),\n completionLine: ZSH_COMPLETION_LINE,\n });\n } else if (shell.includes('bash')) {\n profiles.push({\n shell: 'Bash',\n profilePath: path.join(home, '.bashrc'),\n completionLine: BASH_COMPLETION_LINE,\n });\n }\n }\n\n return profiles;\n}\n\n/**\n * Strip a legacy `work2` completion block from a non-fish profile. Matches the\n * marker line and the next line (the install command). Returns content unchanged\n * if no legacy block is present.\n */\nfunction stripLegacyBlock(content: string): string {\n if (!content.includes(LEGACY_MARKER)) return content;\n const lines = content.split(/\\r?\\n/);\n const out: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n if (lines[i].trim() === LEGACY_MARKER) {\n // Skip marker line and the following install line (if present)\n if (i + 1 < lines.length && /work2\\b/.test(lines[i + 1])) i++;\n continue;\n }\n out.push(lines[i]);\n }\n return out.join('\\n').replace(/\\n{3,}/g, '\\n\\n');\n}\n\n/** Idempotently install the completion line into a shell profile. */\nexport function installCompletionLine(profile: ShellProfile): CompletionResult {\n try {\n let createdFile = false;\n const isFish = profile.shell === 'Fish';\n\n let existingContent = '';\n if (fs.existsSync(profile.profilePath)) {\n existingContent = fs.readFileSync(profile.profilePath, 'utf-8');\n if (existingContent.includes(MARKER)) {\n return { profile, status: 'already-exists' };\n }\n } else {\n createdFile = true;\n }\n\n // Ensure parent directory exists\n fs.mkdirSync(path.dirname(profile.profilePath), { recursive: true });\n\n if (isFish) {\n // Fish: write the complete completion script to its own file\n fs.writeFileSync(profile.profilePath, profile.completionLine + '\\n');\n } else {\n // Bash/Zsh/PowerShell: strip any legacy `work2` block, then append new one.\n const cleaned = stripLegacyBlock(existingContent);\n const snippet = `\\n${MARKER}\\n${profile.completionLine}\\n`;\n fs.writeFileSync(profile.profilePath, cleaned + snippet);\n }\n\n return { profile, status: createdFile ? 'created-file' : 'installed' };\n } catch (err) {\n return {\n profile,\n status: 'error',\n error: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\n/** Detect shells and install completions into each profile. */\nexport function setupCompletions(): CompletionResult[] {\n const profiles = detectShellProfiles();\n return profiles.map((p) => installCompletionLine(p));\n}\n\n/** Print colored results for each completion installation. */\nexport function printCompletionResults(results: CompletionResult[]): void {\n for (const r of results) {\n const label = `${r.profile.shell} (${r.profile.profilePath})`;\n\n switch (r.status) {\n case 'installed':\n console.log(chalk.green(` ✓ ${label} — completions added`));\n break;\n case 'created-file':\n console.log(chalk.green(` ✓ ${label} — profile created with completions`));\n break;\n case 'already-exists':\n console.log(chalk.gray(` · ${label} — already has completions`));\n break;\n case 'error':\n console.log(chalk.red(` ✗ ${label} — ${r.error}`));\n break;\n }\n }\n}\n\n/** Print manual instructions when no shells are detected. */\nexport function printManualInstructions(): void {\n console.log(chalk.yellow(' Could not detect shell profiles. Add completions manually:'));\n console.log('');\n console.log(chalk.gray(' PowerShell — add to $PROFILE:'));\n console.log(` ${PS_COMPLETION_LINE}`);\n console.log('');\n console.log(chalk.gray(' Bash/Zsh — add to ~/.bashrc or ~/.zshrc:'));\n console.log(` ${BASH_COMPLETION_LINE}`);\n console.log('');\n console.log(chalk.gray(' Fish — run:'));\n console.log(` work completion --shell fish > ~/.config/fish/completions/work.fish`);\n}\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,WAAW;AAClB,OAAO,WAAW;AAgBlB,IAAM,qBAAqB;AAC3B,IAAM,uBAAuB;AAC7B,IAAM,sB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M,KAAK,UAAO,KAAK,iCAA4B,CAAC;AAChE;AAAA,MACF,KAAK;AACH,gBAAQ,IAAI,MAAM,IAAI,YAAO,KAAK,WAAM,EAAE,KAAK,EAAE,CAAC;AAClD;AAAA,IACJ;AAAA,EACF;AACF;AAGO,SAAS,0BAAgC;AAC9C,UAAQ,IAAI,MAAM,OAAO,8DAA8D,CAAC;AACxF,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,MAAM,KAAK,sCAAiC,CAAC;AACzD,UAAQ,IAAI,OAAO,kBAAkB,EAAE;AACvC,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,MAAM,KAAK,iDAA4C,CAAC;AACpE,UAAQ,IAAI,OAAO,oBAAoB,EAAE;AACzC,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,MAAM,KAAK,oBAAe,CAAC;AACvC,UAAQ,IAAI,yEAAyE;AACvF;","names":[]}
|
package/dist/chunk-VTLDYH3C.js
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
originUrl,
|
|
4
|
-
ownerRepo,
|
|
5
|
-
readGitConfig
|
|
6
|
-
} from "./chunk-HMK3INUS.js";
|
|
7
|
-
|
|
8
|
-
// src/core/pr/pr.ts
|
|
9
|
-
import { execFile } from "child_process";
|
|
10
|
-
function execAsync(cmd, args, cwd, timeout) {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
execFile(cmd, args, { cwd, encoding: "utf-8", timeout, windowsHide: true }, (err, stdout) => {
|
|
13
|
-
if (err) reject(err);
|
|
14
|
-
else resolve(stdout ?? "");
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
function parsePrJson(stdout, repoAlias, currentUser) {
|
|
19
|
-
const parsed = JSON.parse(stdout);
|
|
20
|
-
const prs = Array.isArray(parsed) ? parsed : [];
|
|
21
|
-
return prs.map((pr) => toPrInfo(pr, repoAlias, currentUser));
|
|
22
|
-
}
|
|
23
|
-
function toPrInfo(pr, repoAlias, currentUser) {
|
|
24
|
-
{
|
|
25
|
-
let checksStatus = "NONE";
|
|
26
|
-
const checks = pr.statusCheckRollup ?? [];
|
|
27
|
-
if (checks.length > 0) {
|
|
28
|
-
const hasFailure = checks.some((c) => c.conclusion === "FAILURE" || c.conclusion === "TIMED_OUT" || c.conclusion === "CANCELLED");
|
|
29
|
-
const hasPending = checks.some((c) => c.status === "IN_PROGRESS" || c.status === "QUEUED" || c.status === "PENDING");
|
|
30
|
-
if (hasFailure) checksStatus = "FAILURE";
|
|
31
|
-
else if (hasPending) checksStatus = "PENDING";
|
|
32
|
-
else checksStatus = "SUCCESS";
|
|
33
|
-
}
|
|
34
|
-
let reviewDecision = "NONE";
|
|
35
|
-
if (pr.reviewDecision === "APPROVED") reviewDecision = "APPROVED";
|
|
36
|
-
else if (pr.reviewDecision === "CHANGES_REQUESTED") reviewDecision = "CHANGES_REQUESTED";
|
|
37
|
-
else if (pr.reviewDecision === "REVIEW_REQUIRED") reviewDecision = "REVIEW_REQUIRED";
|
|
38
|
-
let myReview = "NONE";
|
|
39
|
-
if (currentUser) {
|
|
40
|
-
const reviews = pr.reviews ?? [];
|
|
41
|
-
for (let i = reviews.length - 1; i >= 0; i--) {
|
|
42
|
-
if (reviews[i].author?.login?.toLowerCase() === currentUser.toLowerCase()) {
|
|
43
|
-
const state = reviews[i].state;
|
|
44
|
-
if (state === "APPROVED") myReview = "APPROVED";
|
|
45
|
-
else if (state === "CHANGES_REQUESTED") myReview = "CHANGES_REQUESTED";
|
|
46
|
-
else if (state === "COMMENTED") myReview = "COMMENTED";
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
number: pr.number ?? 0,
|
|
53
|
-
title: pr.title ?? "",
|
|
54
|
-
branch: pr.headRefName ?? "",
|
|
55
|
-
url: pr.url ?? "",
|
|
56
|
-
isDraft: pr.isDraft ?? false,
|
|
57
|
-
checksStatus,
|
|
58
|
-
reviewDecision,
|
|
59
|
-
myReview,
|
|
60
|
-
isMine: currentUser ? pr.author?.login?.toLowerCase() === currentUser.toLowerCase() : false,
|
|
61
|
-
conflicting: pr.mergeable === "CONFLICTING",
|
|
62
|
-
reviewRequested: !!currentUser && (pr.reviewRequests ?? []).some((r) => r?.login?.toLowerCase() === currentUser.toLowerCase()),
|
|
63
|
-
repoAlias,
|
|
64
|
-
// Only when who you are is known: isMine is false for all of them otherwise, and your own would read "by @you".
|
|
65
|
-
...currentUser && pr.author?.login ? { author: pr.author.login } : {},
|
|
66
|
-
fork: pr.isCrossRepository === true
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
var PR_SEARCH_QUERY = `query($mine: String!, $asked: String!) {
|
|
71
|
-
viewer { login }
|
|
72
|
-
mine: search(query: $mine, type: ISSUE, first: 100) { issueCount nodes { ...pr } }
|
|
73
|
-
asked: search(query: $asked, type: ISSUE, first: 100) { issueCount nodes { ...pr } }
|
|
74
|
-
}
|
|
75
|
-
fragment pr on PullRequest {
|
|
76
|
-
number title url isDraft headRefName mergeable reviewDecision isCrossRepository
|
|
77
|
-
author { login }
|
|
78
|
-
repository { nameWithOwner }
|
|
79
|
-
commits(last: 1) { nodes { commit { statusCheckRollup { state } } } }
|
|
80
|
-
reviewRequests(first: 20) { nodes { requestedReviewer { ... on User { login } } } }
|
|
81
|
-
latestReviews(first: 20) { nodes { author { login } state } }
|
|
82
|
-
}`;
|
|
83
|
-
var PR_SEARCH_VARS = {
|
|
84
|
-
mine: "is:pr is:open archived:false author:@me",
|
|
85
|
-
asked: "is:pr is:open archived:false review-requested:@me"
|
|
86
|
-
};
|
|
87
|
-
function rollupAsChecks(state) {
|
|
88
|
-
if (state === "FAILURE" || state === "ERROR") return [{ conclusion: "FAILURE", status: "COMPLETED" }];
|
|
89
|
-
if (state === "PENDING" || state === "EXPECTED") return [{ conclusion: null, status: "PENDING" }];
|
|
90
|
-
if (state === "SUCCESS") return [{ conclusion: "SUCCESS", status: "COMPLETED" }];
|
|
91
|
-
return [];
|
|
92
|
-
}
|
|
93
|
-
function parsePrSearch(stdout, aliasesOf) {
|
|
94
|
-
const data = JSON.parse(stdout)?.data ?? {};
|
|
95
|
-
const user = (data.viewer?.login ?? "").trim();
|
|
96
|
-
const seen = /* @__PURE__ */ new Set();
|
|
97
|
-
const prs = [];
|
|
98
|
-
let incomplete = false;
|
|
99
|
-
for (const key of ["mine", "asked"]) {
|
|
100
|
-
const result = data[key];
|
|
101
|
-
const nodes = (result?.nodes ?? []).filter((n) => !!n && typeof n.number === "number");
|
|
102
|
-
if ((result?.issueCount ?? 0) > nodes.length) incomplete = true;
|
|
103
|
-
for (const n of nodes) {
|
|
104
|
-
const pr = {
|
|
105
|
-
...n,
|
|
106
|
-
statusCheckRollup: rollupAsChecks(n.commits?.nodes?.[0]?.commit?.statusCheckRollup?.state),
|
|
107
|
-
reviews: (n.latestReviews?.nodes ?? []).filter((r) => !!r),
|
|
108
|
-
reviewRequests: (n.reviewRequests?.nodes ?? []).map((r) => r?.requestedReviewer ?? null)
|
|
109
|
-
};
|
|
110
|
-
for (const alias of aliasesOf(n.repository?.nameWithOwner ?? "")) {
|
|
111
|
-
const id = `${alias}#${n.number}`;
|
|
112
|
-
if (seen.has(id)) continue;
|
|
113
|
-
seen.add(id);
|
|
114
|
-
prs.push(toPrInfo(pr, alias, user));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return { prs, incomplete };
|
|
119
|
-
}
|
|
120
|
-
function readSearch(stdout, aliasesOf) {
|
|
121
|
-
try {
|
|
122
|
-
return parsePrSearch(stdout, aliasesOf);
|
|
123
|
-
} catch {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function githubRepoOf(configText) {
|
|
128
|
-
const url = originUrl(configText);
|
|
129
|
-
if (!url || !/(^|[@/.])github\.com[:/]/i.test(url)) return null;
|
|
130
|
-
return ownerRepo(url)?.toLowerCase() ?? null;
|
|
131
|
-
}
|
|
132
|
-
var PR_LIST_LIMIT = 100;
|
|
133
|
-
async function fetchPullRequests(repoPath, repoAlias, currentUser) {
|
|
134
|
-
try {
|
|
135
|
-
const stdout = await execAsync(
|
|
136
|
-
"gh",
|
|
137
|
-
[
|
|
138
|
-
"pr",
|
|
139
|
-
"list",
|
|
140
|
-
"--state",
|
|
141
|
-
"open",
|
|
142
|
-
"--json",
|
|
143
|
-
"number,title,headRefName,url,isDraft,statusCheckRollup,reviewDecision,reviews,reviewRequests,mergeable,author,isCrossRepository",
|
|
144
|
-
"--limit",
|
|
145
|
-
String(PR_LIST_LIMIT)
|
|
146
|
-
],
|
|
147
|
-
repoPath,
|
|
148
|
-
15e3
|
|
149
|
-
);
|
|
150
|
-
if (!stdout) return [];
|
|
151
|
-
return parsePrJson(stdout, repoAlias, currentUser);
|
|
152
|
-
} catch {
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
async function getCurrentUser() {
|
|
157
|
-
try {
|
|
158
|
-
const stdout = await execAsync("gh", ["api", "user", "--jq", ".login"], process.cwd(), 5e3);
|
|
159
|
-
return stdout.trim();
|
|
160
|
-
} catch {
|
|
161
|
-
return "";
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function defaultPrListDeps() {
|
|
165
|
-
let user = null;
|
|
166
|
-
return {
|
|
167
|
-
search: async () => {
|
|
168
|
-
try {
|
|
169
|
-
return await execAsync(
|
|
170
|
-
"gh",
|
|
171
|
-
["api", "graphql", "-f", `query=${PR_SEARCH_QUERY}`, "-f", `mine=${PR_SEARCH_VARS.mine}`, "-f", `asked=${PR_SEARCH_VARS.asked}`],
|
|
172
|
-
process.cwd(),
|
|
173
|
-
2e4
|
|
174
|
-
);
|
|
175
|
-
} catch {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
listRepo: async (repoPath, alias) => fetchPullRequests(repoPath, alias, await (user ??= getCurrentUser())),
|
|
180
|
-
gitConfig: readGitConfig
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
async function fetchAllPullRequests(repos, deps = defaultPrListDeps()) {
|
|
184
|
-
const entries = Object.entries(repos);
|
|
185
|
-
const onGithub = /* @__PURE__ */ new Map();
|
|
186
|
-
const elsewhere = [];
|
|
187
|
-
for (const [alias, repoPath] of entries) {
|
|
188
|
-
const text = deps.gitConfig(repoPath);
|
|
189
|
-
const gh = text ? githubRepoOf(text) : null;
|
|
190
|
-
if (gh) onGithub.set(gh, [...onGithub.get(gh) ?? [], alias]);
|
|
191
|
-
else elsewhere.push([alias, repoPath]);
|
|
192
|
-
}
|
|
193
|
-
const results = [];
|
|
194
|
-
const incomplete = [];
|
|
195
|
-
if (onGithub.size) {
|
|
196
|
-
const out = await deps.search();
|
|
197
|
-
const parsed = out ? readSearch(out, (repo) => onGithub.get(repo.toLowerCase()) ?? []) : null;
|
|
198
|
-
if (parsed) {
|
|
199
|
-
results.push(parsed.prs);
|
|
200
|
-
if (parsed.incomplete) incomplete.push(...[...onGithub.values()].flat());
|
|
201
|
-
} else {
|
|
202
|
-
const asked = new Set(elsewhere.map(([a]) => a));
|
|
203
|
-
for (const [alias, repoPath] of entries) if (!asked.has(alias)) elsewhere.push([alias, repoPath]);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
const listed = await Promise.all(elsewhere.map(([alias, repoPath]) => deps.listRepo(repoPath, alias)));
|
|
207
|
-
results.push(...listed);
|
|
208
|
-
incomplete.push(...elsewhere.filter((_, i) => listed[i] === null || listed[i].length >= PR_LIST_LIMIT).map(([alias]) => alias));
|
|
209
|
-
const map = /* @__PURE__ */ new Map();
|
|
210
|
-
for (const prList of results) {
|
|
211
|
-
for (const pr of prList ?? []) {
|
|
212
|
-
const existing = map.get(pr.branch);
|
|
213
|
-
if (existing) {
|
|
214
|
-
existing.push(pr);
|
|
215
|
-
} else {
|
|
216
|
-
map.set(pr.branch, [pr]);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return { map, incomplete };
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export {
|
|
224
|
-
githubRepoOf,
|
|
225
|
-
fetchAllPullRequests
|
|
226
|
-
};
|
|
227
|
-
//# sourceMappingURL=chunk-VTLDYH3C.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/pr/pr.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { originUrl, ownerRepo, readGitConfig } from '../worktree/repo-scan.js';\n\nexport interface PullRequestInfo {\n number: number;\n title: string;\n branch: string;\n url: string;\n isDraft: boolean;\n checksStatus: 'SUCCESS' | 'FAILURE' | 'PENDING' | 'NONE';\n reviewDecision: 'APPROVED' | 'CHANGES_REQUESTED' | 'REVIEW_REQUIRED' | 'NONE';\n /** Current user's latest review state on this PR. */\n myReview: 'APPROVED' | 'CHANGES_REQUESTED' | 'COMMENTED' | 'NONE';\n /** Whether the current user is the PR author. */\n isMine: boolean;\n /** It can't merge as it is: a conflict with its base (checks say nothing about that). */\n conflicting: boolean;\n /** Your review was asked for, by name (a team's request isn't known here). */\n reviewRequested: boolean;\n /** Repo alias this PR belongs to (for distinguishing group PRs). */\n repoAlias: string;\n /** Its author's login (absent from a server before this). */\n author?: string;\n /** It comes from a fork: its branch isn't on origin (absent from a server before this). */\n fork?: boolean;\n}\n\n/**\n * Map from branch name to array of PRs (one per repo that has a PR for that branch).\n * Single-repo sessions will have at most 1 entry; groups can have multiple.\n */\nexport type BranchPrMap = Map<string, PullRequestInfo[]>;\n\nfunction execAsync(cmd: string, args: string[], cwd: string, timeout: number): Promise<string> {\n return new Promise((resolve, reject) => {\n // `windowsHide: true` prevents a console window from flashing on\n // Windows whenever the PRs pane refreshes. Without it, opening\n // the PRs pane in `work web` triggers a visible terminal popup\n // for every configured repo's `gh pr list` invocation.\n execFile(cmd, args, { cwd, encoding: 'utf-8', timeout, windowsHide: true }, (err, stdout) => {\n if (err) reject(err);\n else resolve(stdout ?? '');\n });\n });\n}\n\n/** The fields of `gh pr list --json …` this reads; all optional — it is someone else's output. */\ninterface GhPr {\n number?: number;\n title?: string;\n headRefName?: string;\n url?: string;\n isDraft?: boolean;\n mergeable?: string;\n reviewDecision?: string;\n author?: { login?: string } | null;\n isCrossRepository?: boolean;\n statusCheckRollup?: Array<{ conclusion?: string | null; status?: string | null }> | null;\n reviews?: Array<{ author?: { login?: string } | null; state?: string }> | null;\n reviewRequests?: Array<{ login?: string } | null> | null;\n}\n\n/** `gh pr list --json …` output as work's PR rows: checks, review, yours or not, conflicts, review asked of you. Pure. */\nexport function parsePrJson(stdout: string, repoAlias: string, currentUser: string): PullRequestInfo[] {\n const parsed = JSON.parse(stdout) as unknown;\n const prs: GhPr[] = Array.isArray(parsed) ? (parsed as GhPr[]) : [];\n return prs.map((pr) => toPrInfo(pr, repoAlias, currentUser));\n}\n\n/** One PR as work's row. */\nfunction toPrInfo(pr: GhPr, repoAlias: string, currentUser: string): PullRequestInfo {\n {\n let checksStatus: PullRequestInfo['checksStatus'] = 'NONE';\n const checks = pr.statusCheckRollup ?? [];\n if (checks.length > 0) {\n const hasFailure = checks.some((c) => c.conclusion === 'FAILURE' || c.conclusion === 'TIMED_OUT' || c.conclusion === 'CANCELLED');\n const hasPending = checks.some((c) => c.status === 'IN_PROGRESS' || c.status === 'QUEUED' || c.status === 'PENDING');\n if (hasFailure) checksStatus = 'FAILURE';\n else if (hasPending) checksStatus = 'PENDING';\n else checksStatus = 'SUCCESS';\n }\n\n let reviewDecision: PullRequestInfo['reviewDecision'] = 'NONE';\n if (pr.reviewDecision === 'APPROVED') reviewDecision = 'APPROVED';\n else if (pr.reviewDecision === 'CHANGES_REQUESTED') reviewDecision = 'CHANGES_REQUESTED';\n else if (pr.reviewDecision === 'REVIEW_REQUIRED') reviewDecision = 'REVIEW_REQUIRED';\n\n // Check current user's latest review state\n let myReview: PullRequestInfo['myReview'] = 'NONE';\n if (currentUser) {\n const reviews = pr.reviews ?? [];\n for (let i = reviews.length - 1; i >= 0; i--) {\n if (reviews[i].author?.login?.toLowerCase() === currentUser.toLowerCase()) {\n const state = reviews[i].state;\n if (state === 'APPROVED') myReview = 'APPROVED';\n else if (state === 'CHANGES_REQUESTED') myReview = 'CHANGES_REQUESTED';\n else if (state === 'COMMENTED') myReview = 'COMMENTED';\n break;\n }\n }\n }\n\n return {\n number: pr.number ?? 0,\n title: pr.title ?? '',\n branch: pr.headRefName ?? '',\n url: pr.url ?? '',\n isDraft: pr.isDraft ?? false,\n checksStatus,\n reviewDecision,\n myReview,\n isMine: currentUser ? pr.author?.login?.toLowerCase() === currentUser.toLowerCase() : false,\n conflicting: pr.mergeable === 'CONFLICTING',\n reviewRequested: !!currentUser && (pr.reviewRequests ?? []).some((r) => r?.login?.toLowerCase() === currentUser.toLowerCase()),\n repoAlias,\n // Only when who you are is known: isMine is false for all of them otherwise, and your own would read \"by @you\".\n ...(currentUser && pr.author?.login ? { author: pr.author.login } : {}),\n fork: pr.isCrossRepository === true,\n };\n }\n}\n\n/**\n * Your open PRs and the ones asking for your review, across every GitHub\n * repo, in ONE GraphQL call (about one API point). The list used to be a\n * `gh pr list` per enrolled repo every two minutes: 27 calls for 27 repos.\n * Start shows only these two kinds anyway.\n */\nexport const PR_SEARCH_QUERY = `query($mine: String!, $asked: String!) {\n viewer { login }\n mine: search(query: $mine, type: ISSUE, first: 100) { issueCount nodes { ...pr } }\n asked: search(query: $asked, type: ISSUE, first: 100) { issueCount nodes { ...pr } }\n}\nfragment pr on PullRequest {\n number title url isDraft headRefName mergeable reviewDecision isCrossRepository\n author { login }\n repository { nameWithOwner }\n commits(last: 1) { nodes { commit { statusCheckRollup { state } } } }\n reviewRequests(first: 20) { nodes { requestedReviewer { ... on User { login } } } }\n latestReviews(first: 20) { nodes { author { login } state } }\n}`;\n\n/** The search's two queries: open PRs by you, and open PRs asking you by name. */\nexport const PR_SEARCH_VARS = {\n mine: 'is:pr is:open archived:false author:@me',\n asked: 'is:pr is:open archived:false review-requested:@me',\n};\n\ninterface SearchNode extends Omit<GhPr, 'statusCheckRollup' | 'reviews' | 'reviewRequests'> {\n repository?: { nameWithOwner?: string } | null;\n commits?: { nodes?: Array<{ commit?: { statusCheckRollup?: { state?: string } | null } | null } | null> | null } | null;\n reviewRequests?: { nodes?: Array<{ requestedReviewer?: { login?: string } | null } | null> | null } | null;\n latestReviews?: { nodes?: Array<{ author?: { login?: string } | null; state?: string } | null> | null } | null;\n}\n\n/** A check rollup's one word, in the shape `gh pr list` gives (so one conversion reads both). */\nfunction rollupAsChecks(state: string | undefined): GhPr['statusCheckRollup'] {\n if (state === 'FAILURE' || state === 'ERROR') return [{ conclusion: 'FAILURE', status: 'COMPLETED' }];\n if (state === 'PENDING' || state === 'EXPECTED') return [{ conclusion: null, status: 'PENDING' }];\n if (state === 'SUCCESS') return [{ conclusion: 'SUCCESS', status: 'COMPLETED' }];\n return [];\n}\n\n/**\n * The search's answer as work's PR rows, each under the alias (or aliases)\n * enrolled for its repository; PRs of repos you haven't enrolled are left\n * out, as before. `incomplete` when a search found more than it returned. Pure.\n */\nexport function parsePrSearch(\n stdout: string,\n aliasesOf: (nameWithOwner: string) => string[],\n): { prs: PullRequestInfo[]; incomplete: boolean } {\n const data = (JSON.parse(stdout) as { data?: Record<string, unknown> } | null)?.data ?? {};\n const user = ((data.viewer as { login?: string } | undefined)?.login ?? '').trim();\n const seen = new Set<string>();\n const prs: PullRequestInfo[] = [];\n let incomplete = false;\n for (const key of ['mine', 'asked']) {\n const result = data[key] as { issueCount?: number; nodes?: Array<SearchNode | null> } | undefined;\n const nodes = (result?.nodes ?? []).filter((n): n is SearchNode => !!n && typeof n.number === 'number');\n if ((result?.issueCount ?? 0) > nodes.length) incomplete = true;\n for (const n of nodes) {\n const pr: GhPr = {\n ...n,\n statusCheckRollup: rollupAsChecks(n.commits?.nodes?.[0]?.commit?.statusCheckRollup?.state),\n reviews: (n.latestReviews?.nodes ?? []).filter((r) => !!r),\n reviewRequests: (n.reviewRequests?.nodes ?? []).map((r) => r?.requestedReviewer ?? null),\n };\n for (const alias of aliasesOf(n.repository?.nameWithOwner ?? '')) {\n const id = `${alias}#${n.number}`;\n if (seen.has(id)) continue;\n seen.add(id);\n prs.push(toPrInfo(pr, alias, user));\n }\n }\n }\n return { prs, incomplete };\n}\n\n/** parsePrSearch, or null for an answer that isn't JSON. */\nfunction readSearch(stdout: string, aliasesOf: (nameWithOwner: string) => string[]): ReturnType<typeof parsePrSearch> | null {\n try {\n return parsePrSearch(stdout, aliasesOf);\n } catch {\n return null;\n }\n}\n\n/** `owner/name` (lowercase) of a repo's origin on github.com, from its `.git/config` text; null for another host or no origin. Pure. */\nexport function githubRepoOf(configText: string): string | null {\n const url = originUrl(configText);\n if (!url || !/(^|[@/.])github\\.com[:/]/i.test(url)) return null;\n return ownerRepo(url)?.toLowerCase() ?? null;\n}\n\n/**\n * Fetch open PRs for a repo using `gh` CLI (async, non-blocking).\n */\nconst PR_LIST_LIMIT = 100;\n\n/** Open PRs for a repo; null when gh couldn't say (missing, offline, not a GitHub repo). */\nasync function fetchPullRequests(repoPath: string, repoAlias: string, currentUser: string): Promise<PullRequestInfo[] | null> {\n try {\n const stdout = await execAsync(\n 'gh',\n [\n 'pr',\n 'list',\n '--state',\n 'open',\n '--json',\n 'number,title,headRefName,url,isDraft,statusCheckRollup,reviewDecision,reviews,reviewRequests,mergeable,author,isCrossRepository',\n '--limit',\n String(PR_LIST_LIMIT),\n ],\n repoPath,\n 15000,\n );\n if (!stdout) return [];\n return parsePrJson(stdout, repoAlias, currentUser);\n } catch {\n return null;\n }\n}\n\n/**\n * Fetch PRs for all configured repos (async, non-blocking).\n * Runs all repo fetches in parallel.\n * Returns a map from branch name → array of PRs across repos.\n */\nasync function getCurrentUser(): Promise<string> {\n try {\n const stdout = await execAsync('gh', ['api', 'user', '--jq', '.login'], process.cwd(), 5000);\n return stdout.trim();\n } catch {\n return '';\n }\n}\n\n/** What fetchAllPullRequests reaches outside (tests pass fakes). */\nexport interface PrListDeps {\n /** `gh api graphql` with the search: its stdout, or null when gh couldn't. */\n search: () => Promise<string | null>;\n /** One repo the old way (`gh pr list` there): not on github.com, or the search failed. */\n listRepo: (repoPath: string, alias: string) => Promise<PullRequestInfo[] | null>;\n /** A repo's `.git/config` text, or null. */\n gitConfig: (repoPath: string) => string | null;\n}\n\nfunction defaultPrListDeps(): PrListDeps {\n let user: Promise<string> | null = null;\n return {\n search: async () => {\n try {\n return await execAsync(\n 'gh',\n ['api', 'graphql', '-f', `query=${PR_SEARCH_QUERY}`, '-f', `mine=${PR_SEARCH_VARS.mine}`, '-f', `asked=${PR_SEARCH_VARS.asked}`],\n process.cwd(),\n 20000,\n );\n } catch {\n return null;\n }\n },\n listRepo: async (repoPath, alias) => fetchPullRequests(repoPath, alias, await (user ??= getCurrentUser())),\n gitConfig: readGitConfig,\n };\n}\n\n/**\n * The PRs for the dashboard: one search for every repo on github.com (yours,\n * and those asking your review), and the old per-repo list only for repos\n * elsewhere (GitHub Enterprise, no origin) — or for all of them when the\n * search fails. Returns a map from branch name → PRs across repos.\n */\nexport async function fetchAllPullRequests(\n repos: Record<string, string>,\n deps: PrListDeps = defaultPrListDeps(),\n): Promise<{ map: BranchPrMap; incomplete: string[] }> {\n const entries = Object.entries(repos);\n const onGithub = new Map<string, string[]>(); // owner/name → its aliases\n const elsewhere: Array<[string, string]> = [];\n for (const [alias, repoPath] of entries) {\n const text = deps.gitConfig(repoPath);\n const gh = text ? githubRepoOf(text) : null;\n if (gh) onGithub.set(gh, [...(onGithub.get(gh) ?? []), alias]);\n else elsewhere.push([alias, repoPath]);\n }\n\n const results: Array<PullRequestInfo[] | null> = [];\n const incomplete: string[] = [];\n if (onGithub.size) {\n const out = await deps.search();\n const parsed = out ? readSearch(out, (repo) => onGithub.get(repo.toLowerCase()) ?? []) : null;\n if (parsed) {\n results.push(parsed.prs);\n if (parsed.incomplete) incomplete.push(...[...onGithub.values()].flat());\n } else {\n // gh can't search (an old gh, no network): the old way, repo by repo.\n const asked = new Set(elsewhere.map(([a]) => a));\n for (const [alias, repoPath] of entries) if (!asked.has(alias)) elsewhere.push([alias, repoPath]);\n }\n }\n const listed = await Promise.all(elsewhere.map(([alias, repoPath]) => deps.listRepo(repoPath, alias)));\n results.push(...listed);\n // Repos whose list may be missing PRs: gh failed, or it hit the limit.\n incomplete.push(...elsewhere.filter((_, i) => listed[i] === null || listed[i]!.length >= PR_LIST_LIMIT).map(([alias]) => alias));\n\n const map: BranchPrMap = new Map();\n for (const prList of results) {\n for (const pr of prList ?? []) {\n const existing = map.get(pr.branch);\n if (existing) {\n existing.push(pr);\n } else {\n map.set(pr.branch, [pr]);\n }\n }\n }\n\n return { map, incomplete };\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,gBAAgB;AAiCzB,SAAS,UAAU,KAAa,MAAgB,KAAa,SAAkC;AAC7F,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AAKtC,aAAS,KAAK,MAAM,EAAE,KAAK,UAAU,SAAS,SAAS,aAAa,KAAK,GAAG,CAAC,KAAK,WAAW;AAC3F,UAAI,IAAK,QAAO,GAAG;AAAA,UACd,SAAQ,UAAU,EAAE;AAAA,IAC3B,CAAC;AAAA,EACH,CAAC;AACH;AAmBO,SAAS,YAAY,QAAgB,WAAmB,aAAwC;AACrG,QAAM,SAAS,KAAK,MAAM,MAAM;AAChC,QAAM,MAAc,MAAM,QAAQ,MAAM,IAAK,SAAoB,CAAC;AAClE,SAAO,IAAI,IAAI,CAAC,OAAO,SAAS,IAAI,WAAW,WAAW,CAAC;AAC7D;AAGA,SAAS,SAAS,IAAU,WAAmB,aAAsC;AACnF;AACE,QAAI,eAAgD;AACpD,UAAM,SAAS,GAAG,qBAAqB,CAAC;AACxC,QAAI,OAAO,SAAS,GAAG;AACrB,YAAM,aAAa,OAAO,KAAK,CAAC,MAAM,EAAE,eAAe,aAAa,EAAE,eAAe,eAAe,EAAE,eA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