@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
|
@@ -0,0 +1,1578 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
threadCode
|
|
4
|
+
} from "./chunk-FGPXMAYU.js";
|
|
5
|
+
import {
|
|
6
|
+
originUrl,
|
|
7
|
+
ownerRepo,
|
|
8
|
+
readGitConfig
|
|
9
|
+
} from "./chunk-MQCDFSVF.js";
|
|
10
|
+
import {
|
|
11
|
+
RUN_TIMED_OUT,
|
|
12
|
+
defaultRunner
|
|
13
|
+
} from "./chunk-KSVYR4G2.js";
|
|
14
|
+
import {
|
|
15
|
+
AZURE_THREAD_ID,
|
|
16
|
+
DEFAULT_HOST,
|
|
17
|
+
GITHUB_THREAD_ID,
|
|
18
|
+
azureCommands,
|
|
19
|
+
azureRepoId,
|
|
20
|
+
azureThreadId,
|
|
21
|
+
azureThreadRepoId,
|
|
22
|
+
azureWebUrl,
|
|
23
|
+
githubCommands,
|
|
24
|
+
githubRepoId,
|
|
25
|
+
onAzure,
|
|
26
|
+
onGithub,
|
|
27
|
+
parseAzureOrigin,
|
|
28
|
+
parseAzurePrUrl,
|
|
29
|
+
parseAzureThreadId,
|
|
30
|
+
parseGithubPrUrl
|
|
31
|
+
} from "./chunk-ZG2M4ECW.js";
|
|
32
|
+
import {
|
|
33
|
+
json
|
|
34
|
+
} from "./chunk-RUYTU2WJ.js";
|
|
35
|
+
import {
|
|
36
|
+
configView
|
|
37
|
+
} from "./chunk-NFWSJFYY.js";
|
|
38
|
+
import {
|
|
39
|
+
explainNotOnPath,
|
|
40
|
+
programPath
|
|
41
|
+
} from "./chunk-EL3XL2OC.js";
|
|
42
|
+
|
|
43
|
+
// src/core/hosts/origin-hostname.ts
|
|
44
|
+
function originHostname(origin) {
|
|
45
|
+
const s = origin.trim();
|
|
46
|
+
const url = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]*@)?([^/:]+)/i.exec(s);
|
|
47
|
+
if (url) return url[1].toLowerCase();
|
|
48
|
+
const scp = /^(?:[^@/]+@)?([^/:]+):(?!\/\/)/.exec(s);
|
|
49
|
+
return scp ? scp[1].toLowerCase() : null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/core/hosts/github/adapter.ts
|
|
53
|
+
import os2 from "os";
|
|
54
|
+
|
|
55
|
+
// src/core/hosts/github/pr-list.ts
|
|
56
|
+
import { execFile } from "child_process";
|
|
57
|
+
|
|
58
|
+
// src/core/hosts/github/server.ts
|
|
59
|
+
var FAILED_LOOKUP_MS = 5 * 6e4;
|
|
60
|
+
var HOSTNAME = /^[a-z0-9][a-z0-9.-]*$/;
|
|
61
|
+
var known = /* @__PURE__ */ new Map();
|
|
62
|
+
var asking = /* @__PURE__ */ new Map();
|
|
63
|
+
async function githubServerArgs(run, cwd, deps = {}) {
|
|
64
|
+
const text = (deps.readConfig ?? readGitConfig)(cwd);
|
|
65
|
+
const origin = text ? originUrl(text) : null;
|
|
66
|
+
if (!origin || onGithub(origin)) return { ok: true, args: [] };
|
|
67
|
+
const now = deps.now ?? Date.now;
|
|
68
|
+
const key = `${cwd}
|
|
69
|
+
${origin}`;
|
|
70
|
+
const was = known.get(key);
|
|
71
|
+
if (was && now() < was.until) return was.value;
|
|
72
|
+
const inflight = asking.get(key);
|
|
73
|
+
if (inflight) return inflight;
|
|
74
|
+
const p = lookUp(run, cwd, origin).then((value) => {
|
|
75
|
+
known.set(key, { value, until: value.ok ? Infinity : now() + FAILED_LOOKUP_MS });
|
|
76
|
+
return value;
|
|
77
|
+
}).finally(() => asking.delete(key));
|
|
78
|
+
asking.set(key, p);
|
|
79
|
+
return p;
|
|
80
|
+
}
|
|
81
|
+
async function lookUp(run, cwd, origin) {
|
|
82
|
+
const r = await run("gh", ["repo", "view", "--json", "url", "--jq", ".url"], cwd).catch(() => null);
|
|
83
|
+
const url = r?.code === 0 ? r.stdout.trim() : "";
|
|
84
|
+
const server = url ? originHostname(url) : null;
|
|
85
|
+
if (!server || !HOSTNAME.test(server)) {
|
|
86
|
+
const why = r?.stderr.trim().split("\n")[0] || "gh gave no answer";
|
|
87
|
+
return { ok: false, error: `couldn't tell which GitHub server ${originHostname(origin) ?? origin} is (${why})` };
|
|
88
|
+
}
|
|
89
|
+
return { ok: true, args: server === "github.com" ? [] : ["--hostname", server] };
|
|
90
|
+
}
|
|
91
|
+
async function ghApi(run, cwd, args, deps) {
|
|
92
|
+
const server = await githubServerArgs(run, cwd, deps);
|
|
93
|
+
if (!server.ok) return { code: 1, stdout: "", stderr: server.error, serverUnknown: true };
|
|
94
|
+
return run("gh", ["api", ...args, ...server.args], cwd);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/core/hosts/github/pr-list.ts
|
|
98
|
+
function execAsync(cmd, args, cwd, timeout) {
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
execFile(programPath(cmd), args, { cwd, encoding: "utf-8", timeout, windowsHide: true }, (err, stdout) => {
|
|
101
|
+
if (err) reject(explainNotOnPath(err));
|
|
102
|
+
else resolve(stdout ?? "");
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function parsePrJson(stdout, repoAlias, currentUser) {
|
|
107
|
+
const parsed = JSON.parse(stdout);
|
|
108
|
+
const prs = Array.isArray(parsed) ? parsed : [];
|
|
109
|
+
return prs.map((pr) => toPrInfo(pr, repoAlias, currentUser));
|
|
110
|
+
}
|
|
111
|
+
function toPrInfo(pr, repoAlias, currentUser) {
|
|
112
|
+
{
|
|
113
|
+
let checksStatus = "NONE";
|
|
114
|
+
const checks = pr.statusCheckRollup ?? [];
|
|
115
|
+
if (checks.length > 0) {
|
|
116
|
+
const hasFailure = checks.some((c) => c.conclusion === "FAILURE" || c.conclusion === "TIMED_OUT" || c.conclusion === "CANCELLED");
|
|
117
|
+
const hasPending = checks.some((c) => c.status === "IN_PROGRESS" || c.status === "QUEUED" || c.status === "PENDING");
|
|
118
|
+
if (hasFailure) checksStatus = "FAILURE";
|
|
119
|
+
else if (hasPending) checksStatus = "PENDING";
|
|
120
|
+
else checksStatus = "SUCCESS";
|
|
121
|
+
}
|
|
122
|
+
let reviewDecision2 = "NONE";
|
|
123
|
+
if (pr.reviewDecision === "APPROVED") reviewDecision2 = "APPROVED";
|
|
124
|
+
else if (pr.reviewDecision === "CHANGES_REQUESTED") reviewDecision2 = "CHANGES_REQUESTED";
|
|
125
|
+
else if (pr.reviewDecision === "REVIEW_REQUIRED") reviewDecision2 = "REVIEW_REQUIRED";
|
|
126
|
+
let myReview = "NONE";
|
|
127
|
+
if (currentUser) {
|
|
128
|
+
const reviews = pr.reviews ?? [];
|
|
129
|
+
for (let i = reviews.length - 1; i >= 0; i--) {
|
|
130
|
+
if (reviews[i].author?.login?.toLowerCase() === currentUser.toLowerCase()) {
|
|
131
|
+
const state = reviews[i].state;
|
|
132
|
+
if (state === "APPROVED") myReview = "APPROVED";
|
|
133
|
+
else if (state === "CHANGES_REQUESTED") myReview = "CHANGES_REQUESTED";
|
|
134
|
+
else if (state === "COMMENTED") myReview = "COMMENTED";
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
number: pr.number ?? 0,
|
|
141
|
+
title: pr.title ?? "",
|
|
142
|
+
branch: pr.headRefName ?? "",
|
|
143
|
+
url: pr.url ?? "",
|
|
144
|
+
isDraft: pr.isDraft ?? false,
|
|
145
|
+
checksStatus,
|
|
146
|
+
reviewDecision: reviewDecision2,
|
|
147
|
+
myReview,
|
|
148
|
+
isMine: currentUser ? pr.author?.login?.toLowerCase() === currentUser.toLowerCase() : false,
|
|
149
|
+
conflicting: pr.mergeable === "CONFLICTING",
|
|
150
|
+
reviewRequested: !!currentUser && (pr.reviewRequests ?? []).some((r) => r?.login?.toLowerCase() === currentUser.toLowerCase()),
|
|
151
|
+
repoAlias,
|
|
152
|
+
// Only when who you are is known: isMine is false for all of them otherwise, and your own would read "by @you".
|
|
153
|
+
...currentUser && pr.author?.login ? { author: pr.author.login } : {},
|
|
154
|
+
fork: pr.isCrossRepository === true
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
var PR_SEARCH_QUERY = `query($mine: String!, $asked: String!) {
|
|
159
|
+
viewer { login }
|
|
160
|
+
mine: search(query: $mine, type: ISSUE, first: 100) { issueCount nodes { ...pr } }
|
|
161
|
+
asked: search(query: $asked, type: ISSUE, first: 100) { issueCount nodes { ...pr } }
|
|
162
|
+
}
|
|
163
|
+
fragment pr on PullRequest {
|
|
164
|
+
number title url isDraft headRefName mergeable reviewDecision isCrossRepository
|
|
165
|
+
author { login }
|
|
166
|
+
repository { nameWithOwner }
|
|
167
|
+
commits(last: 1) { nodes { commit { statusCheckRollup { state } } } }
|
|
168
|
+
reviewRequests(first: 20) { nodes { requestedReviewer { ... on User { login } } } }
|
|
169
|
+
latestReviews(first: 20) { nodes { author { login } state } }
|
|
170
|
+
}`;
|
|
171
|
+
var PR_SEARCH_VARS = {
|
|
172
|
+
mine: "is:pr is:open archived:false author:@me",
|
|
173
|
+
asked: "is:pr is:open archived:false review-requested:@me"
|
|
174
|
+
};
|
|
175
|
+
function rollupAsChecks(state) {
|
|
176
|
+
if (state === "FAILURE" || state === "ERROR") return [{ conclusion: "FAILURE", status: "COMPLETED" }];
|
|
177
|
+
if (state === "PENDING" || state === "EXPECTED") return [{ conclusion: null, status: "PENDING" }];
|
|
178
|
+
if (state === "SUCCESS") return [{ conclusion: "SUCCESS", status: "COMPLETED" }];
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
function parsePrSearch(stdout, aliasesOf) {
|
|
182
|
+
const data = JSON.parse(stdout)?.data ?? {};
|
|
183
|
+
const user = (data.viewer?.login ?? "").trim();
|
|
184
|
+
const seen = /* @__PURE__ */ new Set();
|
|
185
|
+
const prs = [];
|
|
186
|
+
let incomplete = false;
|
|
187
|
+
for (const key of ["mine", "asked"]) {
|
|
188
|
+
const result = data[key];
|
|
189
|
+
const nodes = (result?.nodes ?? []).filter((n) => !!n && typeof n.number === "number");
|
|
190
|
+
if ((result?.issueCount ?? 0) > nodes.length) incomplete = true;
|
|
191
|
+
for (const n of nodes) {
|
|
192
|
+
const pr = {
|
|
193
|
+
...n,
|
|
194
|
+
statusCheckRollup: rollupAsChecks(n.commits?.nodes?.[0]?.commit?.statusCheckRollup?.state),
|
|
195
|
+
reviews: (n.latestReviews?.nodes ?? []).filter((r) => !!r),
|
|
196
|
+
reviewRequests: (n.reviewRequests?.nodes ?? []).map((r) => r?.requestedReviewer ?? null)
|
|
197
|
+
};
|
|
198
|
+
for (const alias of aliasesOf(n.repository?.nameWithOwner ?? "")) {
|
|
199
|
+
const id = `${alias}#${n.number}`;
|
|
200
|
+
if (seen.has(id)) continue;
|
|
201
|
+
seen.add(id);
|
|
202
|
+
prs.push(toPrInfo(pr, alias, user));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return { prs, incomplete };
|
|
207
|
+
}
|
|
208
|
+
function readSearch(stdout, aliasesOf) {
|
|
209
|
+
try {
|
|
210
|
+
return parsePrSearch(stdout, aliasesOf);
|
|
211
|
+
} catch {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function githubRepoOf(configText) {
|
|
216
|
+
const url = originUrl(configText);
|
|
217
|
+
if (!url || !/(^|[@/.])github\.com[:/]/i.test(url)) return null;
|
|
218
|
+
return ownerRepo(url)?.toLowerCase() ?? null;
|
|
219
|
+
}
|
|
220
|
+
var PR_LIST_LIMIT = 100;
|
|
221
|
+
async function fetchPullRequests(exec, repoPath, repoAlias, currentUser) {
|
|
222
|
+
try {
|
|
223
|
+
const stdout = await exec(
|
|
224
|
+
"gh",
|
|
225
|
+
[
|
|
226
|
+
"pr",
|
|
227
|
+
"list",
|
|
228
|
+
"--state",
|
|
229
|
+
"open",
|
|
230
|
+
"--json",
|
|
231
|
+
"number,title,headRefName,url,isDraft,statusCheckRollup,reviewDecision,reviews,reviewRequests,mergeable,author,isCrossRepository",
|
|
232
|
+
"--limit",
|
|
233
|
+
String(PR_LIST_LIMIT)
|
|
234
|
+
],
|
|
235
|
+
repoPath,
|
|
236
|
+
15e3
|
|
237
|
+
);
|
|
238
|
+
if (!stdout) return [];
|
|
239
|
+
return parsePrJson(stdout, repoAlias, currentUser);
|
|
240
|
+
} catch {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
async function getCurrentUser(exec, cwd, server) {
|
|
245
|
+
try {
|
|
246
|
+
const stdout = await exec("gh", ["api", "user", "--jq", ".login", ...server], cwd, 5e3);
|
|
247
|
+
return stdout.trim();
|
|
248
|
+
} catch {
|
|
249
|
+
return "";
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function defaultPrListDeps(run = defaultRunner) {
|
|
253
|
+
const exec = run === defaultRunner ? execAsync : async (cmd, args, cwd) => {
|
|
254
|
+
const r = await run(cmd, args, cwd);
|
|
255
|
+
if (r.code !== 0) throw new Error(r.stderr || `${cmd} failed`);
|
|
256
|
+
return r.stdout;
|
|
257
|
+
};
|
|
258
|
+
const users = /* @__PURE__ */ new Map();
|
|
259
|
+
const userFor = async (repoPath) => {
|
|
260
|
+
const server = await githubServerArgs(run, repoPath);
|
|
261
|
+
if (!server.ok) return "";
|
|
262
|
+
const key = server.args.join(" ");
|
|
263
|
+
let p = users.get(key);
|
|
264
|
+
if (!p) users.set(key, p = getCurrentUser(exec, repoPath, server.args));
|
|
265
|
+
return p;
|
|
266
|
+
};
|
|
267
|
+
return {
|
|
268
|
+
search: async () => {
|
|
269
|
+
try {
|
|
270
|
+
return await exec(
|
|
271
|
+
"gh",
|
|
272
|
+
["api", "graphql", "-f", `query=${PR_SEARCH_QUERY}`, "-f", `mine=${PR_SEARCH_VARS.mine}`, "-f", `asked=${PR_SEARCH_VARS.asked}`],
|
|
273
|
+
process.cwd(),
|
|
274
|
+
2e4
|
|
275
|
+
);
|
|
276
|
+
} catch {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
listRepo: async (repoPath, alias) => fetchPullRequests(exec, repoPath, alias, await userFor(repoPath)),
|
|
281
|
+
gitConfig: readGitConfig
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
async function githubPrList(repos, deps = defaultPrListDeps()) {
|
|
285
|
+
const entries = Object.entries(repos);
|
|
286
|
+
const onGithub2 = /* @__PURE__ */ new Map();
|
|
287
|
+
const elsewhere = [];
|
|
288
|
+
for (const [alias, repoPath] of entries) {
|
|
289
|
+
const text = deps.gitConfig(repoPath);
|
|
290
|
+
const gh = text ? githubRepoOf(text) : null;
|
|
291
|
+
if (gh) onGithub2.set(gh, [...onGithub2.get(gh) ?? [], alias]);
|
|
292
|
+
else elsewhere.push([alias, repoPath]);
|
|
293
|
+
}
|
|
294
|
+
const results = [];
|
|
295
|
+
const incomplete = [];
|
|
296
|
+
if (onGithub2.size) {
|
|
297
|
+
const out = await deps.search();
|
|
298
|
+
const parsed = out ? readSearch(out, (repo) => onGithub2.get(repo.toLowerCase()) ?? []) : null;
|
|
299
|
+
if (parsed) {
|
|
300
|
+
results.push(parsed.prs);
|
|
301
|
+
if (parsed.incomplete) incomplete.push(...[...onGithub2.values()].flat());
|
|
302
|
+
} else {
|
|
303
|
+
const asked = new Set(elsewhere.map(([a]) => a));
|
|
304
|
+
for (const [alias, repoPath] of entries) if (!asked.has(alias)) elsewhere.push([alias, repoPath]);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const listed = await Promise.all(elsewhere.map(([alias, repoPath]) => deps.listRepo(repoPath, alias)));
|
|
308
|
+
results.push(...listed);
|
|
309
|
+
incomplete.push(...elsewhere.filter((_, i) => listed[i] === null || listed[i].length >= PR_LIST_LIMIT).map(([alias]) => alias));
|
|
310
|
+
return { prs: results.flatMap((r) => r ?? []), incomplete };
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// src/core/hosts/github/pr-ops.ts
|
|
314
|
+
import fs from "fs";
|
|
315
|
+
import os from "os";
|
|
316
|
+
import path from "path";
|
|
317
|
+
|
|
318
|
+
// src/core/hosts/submit-doubt.ts
|
|
319
|
+
var CLIENT_ERROR = /\bHTTP[ /:]*4\d\d\b|\bstatus(?: code)?:? 4\d\d\b|\(4\d\d\)|\b(?:Bad Request|Unauthorized|Forbidden|Not Found|Conflict|Unprocessable Entity|Validation Failed|Too Many Requests)\b/i;
|
|
320
|
+
var NOT_STARTED = /^refused: |: refused: /;
|
|
321
|
+
function refusedClearly(code, stderr, refusal) {
|
|
322
|
+
if (code === 0 || code === RUN_TIMED_OUT) return false;
|
|
323
|
+
if (code === 127) return true;
|
|
324
|
+
if (NOT_STARTED.test(stderr.trim())) return true;
|
|
325
|
+
if (CLIENT_ERROR.test(stderr)) return true;
|
|
326
|
+
return !!refusal && refusal.test(stderr);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// src/core/hosts/github/pr-ops.ts
|
|
330
|
+
var FAILED = ["FAILURE", "ERROR", "CANCELLED", "TIMED_OUT", "ACTION_REQUIRED", "STARTUP_FAILURE"];
|
|
331
|
+
function failingFromRollup(rollup) {
|
|
332
|
+
return (rollup ?? []).filter((c) => FAILED.includes((c.conclusion ?? c.state ?? "").toUpperCase())).map((c) => {
|
|
333
|
+
const url = c.detailsUrl ?? c.targetUrl ?? void 0;
|
|
334
|
+
return { name: c.name ?? c.context ?? "check", ...url ? { url } : {} };
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function rollupRunning(rollup) {
|
|
338
|
+
return (rollup ?? []).some((c) => {
|
|
339
|
+
const v = (c.conclusion ?? c.state ?? "").toUpperCase();
|
|
340
|
+
if (FAILED.includes(v)) return false;
|
|
341
|
+
const status = (c.status ?? "").toUpperCase();
|
|
342
|
+
return !v || v === "PENDING" || v === "EXPECTED" || !!status && status !== "COMPLETED";
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
function checksFromRollup(rollup) {
|
|
346
|
+
if (!rollup || rollup.length === 0) return "none";
|
|
347
|
+
let pending = false;
|
|
348
|
+
for (const c of rollup) {
|
|
349
|
+
const v = (c.conclusion ?? c.state ?? "").toUpperCase();
|
|
350
|
+
if (FAILED.includes(v)) {
|
|
351
|
+
return "fail";
|
|
352
|
+
}
|
|
353
|
+
const status = (c.status ?? "").toUpperCase();
|
|
354
|
+
if (!v || v === "PENDING" || v === "EXPECTED" || status && status !== "COMPLETED") pending = true;
|
|
355
|
+
}
|
|
356
|
+
return pending ? "pending" : "pass";
|
|
357
|
+
}
|
|
358
|
+
function blockingChecks(rollup, required) {
|
|
359
|
+
const nameOf = (c) => c.name ?? c.context ?? "check";
|
|
360
|
+
const failed = (c) => FAILED.includes((c.conclusion ?? c.state ?? "").toUpperCase());
|
|
361
|
+
const all = rollup ?? [];
|
|
362
|
+
const optional = all.filter((c) => failed(c) && !required.has(nameOf(c)));
|
|
363
|
+
const counted = all.filter((c) => !optional.includes(c));
|
|
364
|
+
const checks = checksFromRollup(counted);
|
|
365
|
+
return {
|
|
366
|
+
checks: checks === "none" && all.length ? "pass" : checks,
|
|
367
|
+
failing: failingFromRollup(counted),
|
|
368
|
+
optional: failingFromRollup(optional)
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
async function requiredChecks(run, cwd, which) {
|
|
372
|
+
const r = await run("gh", ["pr", "checks", which, "--required", "--json", "name"], cwd);
|
|
373
|
+
try {
|
|
374
|
+
const list = JSON.parse(r.stdout);
|
|
375
|
+
if (Array.isArray(list))
|
|
376
|
+
return new Set(list.map((c) => c?.name).filter((n) => typeof n === "string"));
|
|
377
|
+
} catch {
|
|
378
|
+
}
|
|
379
|
+
return /no required checks reported/i.test(`${r.stderr}
|
|
380
|
+
${r.stdout}`) ? /* @__PURE__ */ new Set() : null;
|
|
381
|
+
}
|
|
382
|
+
var oneLineErr = (s) => s.trim().split("\n")[0] ?? "";
|
|
383
|
+
var reasonLine = (s) => s.split("\n").map((l) => l.trim()).find((l) => /rate limit/i.test(l)) ?? oneLineErr(s);
|
|
384
|
+
function githubPrForBranch(run, cwd, branch2) {
|
|
385
|
+
return githubPrView(run, cwd, branch2);
|
|
386
|
+
}
|
|
387
|
+
function githubPrForRef(run, cwd, ref) {
|
|
388
|
+
return githubPrView(run, cwd, ref.url);
|
|
389
|
+
}
|
|
390
|
+
async function githubPrView(run, cwd, which) {
|
|
391
|
+
const view = await run(
|
|
392
|
+
"gh",
|
|
393
|
+
[
|
|
394
|
+
"pr",
|
|
395
|
+
"view",
|
|
396
|
+
which,
|
|
397
|
+
"--json",
|
|
398
|
+
"number,url,state,isDraft,mergeStateStatus,headRefOid,headRefName,mergedAt,updatedAt,statusCheckRollup,reviewDecision,author,baseRefName"
|
|
399
|
+
],
|
|
400
|
+
cwd
|
|
401
|
+
);
|
|
402
|
+
if (view.code === 0) {
|
|
403
|
+
try {
|
|
404
|
+
const j = JSON.parse(view.stdout);
|
|
405
|
+
let failed = {
|
|
406
|
+
checks: checksFromRollup(j.statusCheckRollup),
|
|
407
|
+
failing: failingFromRollup(j.statusCheckRollup),
|
|
408
|
+
optional: [],
|
|
409
|
+
byHost: false
|
|
410
|
+
};
|
|
411
|
+
if (failed.checks === "fail") {
|
|
412
|
+
const required = await requiredChecks(run, cwd, which);
|
|
413
|
+
if (required?.size) failed = { ...blockingChecks(j.statusCheckRollup, required), byHost: true };
|
|
414
|
+
}
|
|
415
|
+
const pr = {
|
|
416
|
+
number: j.number,
|
|
417
|
+
url: j.url,
|
|
418
|
+
state: j.state,
|
|
419
|
+
isDraft: j.isDraft,
|
|
420
|
+
mergeStateStatus: j.mergeStateStatus ?? "UNKNOWN",
|
|
421
|
+
checks: failed.checks,
|
|
422
|
+
headSha: j.headRefOid,
|
|
423
|
+
...j.mergedAt ? { mergedAt: j.mergedAt } : {},
|
|
424
|
+
...j.updatedAt ? { updatedAt: j.updatedAt } : {},
|
|
425
|
+
...typeof j.reviewDecision === "string" ? { reviewDecision: j.reviewDecision } : {},
|
|
426
|
+
// gh pr view names an app `app/dependabot`; the search API, `dependabot`.
|
|
427
|
+
...j.author?.login ? { author: j.author.login.replace(/^app\//, "") } : {},
|
|
428
|
+
...j.baseRefName ? { baseBranch: j.baseRefName } : {},
|
|
429
|
+
...j.headRefName ? { headBranch: j.headRefName } : {},
|
|
430
|
+
...failed.checks === "fail" ? { failing: failed.failing } : {},
|
|
431
|
+
...failed.optional.length ? { optionalFailing: failed.optional } : {},
|
|
432
|
+
...failed.byHost ? { checksRequiredByHost: true } : {},
|
|
433
|
+
...failed.checks === "fail" && !failed.byHost && rollupRunning(j.statusCheckRollup) ? { checksRunning: true } : {}
|
|
434
|
+
};
|
|
435
|
+
return { kind: "pr", pr };
|
|
436
|
+
} catch {
|
|
437
|
+
return { kind: "error", error: "could not read `gh pr view` output" };
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (view.code === 127) return { kind: "error", error: "GitHub CLI (gh) not found \u2014 install it to open and merge PRs" };
|
|
441
|
+
if (/no pull requests found/i.test(view.stderr)) return { kind: "none" };
|
|
442
|
+
return { kind: "error", error: reasonLine(view.stderr) || "gh pr view failed" };
|
|
443
|
+
}
|
|
444
|
+
async function githubCreatePr(run, cwd, branch2, opts) {
|
|
445
|
+
const args = ["pr", "create", "--fill", "--head", branch2];
|
|
446
|
+
if (opts.draft) args.push("--draft");
|
|
447
|
+
const res = await run("gh", args, cwd);
|
|
448
|
+
if (res.code !== 0) return { ok: false, error: oneLineErr(res.stderr) || "gh pr create failed" };
|
|
449
|
+
const url = res.stdout.trim().split(/\s+/).find((t) => t.startsWith("http"));
|
|
450
|
+
return { ok: true, ...url ? { url } : {} };
|
|
451
|
+
}
|
|
452
|
+
async function githubMergePr(run, cwd, number, method, headSha) {
|
|
453
|
+
const res = await run("gh", ["pr", "merge", String(number), `--${method}`, "--match-head-commit", headSha], cwd);
|
|
454
|
+
return res.code === 0 ? { ok: true } : { ok: false, error: oneLineErr(res.stderr) || "gh pr merge failed" };
|
|
455
|
+
}
|
|
456
|
+
async function githubPrByNumber(run, cwd, repoId, number) {
|
|
457
|
+
const view = await run(
|
|
458
|
+
"gh",
|
|
459
|
+
[
|
|
460
|
+
"pr",
|
|
461
|
+
"view",
|
|
462
|
+
String(number),
|
|
463
|
+
"--repo",
|
|
464
|
+
repoId,
|
|
465
|
+
"--json",
|
|
466
|
+
"number,title,url,headRefName,headRefOid,baseRefName,state,isCrossRepository,author,headRepositoryOwner"
|
|
467
|
+
],
|
|
468
|
+
cwd
|
|
469
|
+
);
|
|
470
|
+
if (view.code === 127) return { ok: false, error: "GitHub CLI (gh) not found: install it to start from a PR." };
|
|
471
|
+
if (view.code !== 0) return { ok: false, error: `PR #${number} in ${repoId}: ${oneLineErr(view.stderr) || "gh pr view failed"}` };
|
|
472
|
+
let pr;
|
|
473
|
+
try {
|
|
474
|
+
pr = JSON.parse(view.stdout);
|
|
475
|
+
} catch {
|
|
476
|
+
return { ok: false, error: "Couldn't read what gh said about the PR." };
|
|
477
|
+
}
|
|
478
|
+
return {
|
|
479
|
+
ok: true,
|
|
480
|
+
pr: {
|
|
481
|
+
number: pr.number ?? number,
|
|
482
|
+
title: pr.title ?? "",
|
|
483
|
+
url: pr.url ?? "",
|
|
484
|
+
branch: pr.headRefName ?? "",
|
|
485
|
+
...pr.headRefOid ? { headSha: pr.headRefOid } : {},
|
|
486
|
+
base: pr.baseRefName ?? "",
|
|
487
|
+
author: (pr.author?.login ?? "").replace(/^app\//, ""),
|
|
488
|
+
state: pr.state ?? "OPEN",
|
|
489
|
+
...pr.isCrossRepository ? { fork: { owner: pr.headRepositoryOwner?.login ?? "a fork" } } : {}
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
async function githubPrState(run, url, cwd) {
|
|
494
|
+
const r = await run("gh", ["pr", "view", url, "--json", "state", "-q", ".state"], cwd);
|
|
495
|
+
if (r.code !== 0) return { ok: false, error: reasonLine(r.stderr) || "gh pr view failed" };
|
|
496
|
+
const st = r.stdout.trim();
|
|
497
|
+
return st === "OPEN" || st === "MERGED" || st === "CLOSED" ? { ok: true, state: st } : { ok: false, error: `gh said ${st || "nothing"}` };
|
|
498
|
+
}
|
|
499
|
+
async function githubMergedPr(run, cwd, branch2, tip) {
|
|
500
|
+
const pr = await run("gh", ["pr", "list", "--state", "merged", "--head", branch2, "--json", "number,headRefOid", "--limit", "5"], cwd);
|
|
501
|
+
if (pr.code !== 0) return void 0;
|
|
502
|
+
try {
|
|
503
|
+
const list = JSON.parse(pr.stdout);
|
|
504
|
+
return list.find((p) => p.headRefOid === tip)?.number ?? null;
|
|
505
|
+
} catch {
|
|
506
|
+
return void 0;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
var OPEN_PR_LIMIT = 100;
|
|
510
|
+
async function githubOpenPrs(run, cwd) {
|
|
511
|
+
const r = await run(
|
|
512
|
+
"gh",
|
|
513
|
+
[
|
|
514
|
+
"pr",
|
|
515
|
+
"list",
|
|
516
|
+
"--state",
|
|
517
|
+
"open",
|
|
518
|
+
"--limit",
|
|
519
|
+
String(OPEN_PR_LIMIT),
|
|
520
|
+
"--json",
|
|
521
|
+
"number,title,url,headRefName,headRefOid,baseRefName,author,isDraft,additions,deletions,reviewRequests,isCrossRepository,updatedAt"
|
|
522
|
+
],
|
|
523
|
+
cwd
|
|
524
|
+
);
|
|
525
|
+
if (r.code === 127) return { ok: false, error: "GitHub CLI (gh) not found" };
|
|
526
|
+
if (r.code !== 0) return { ok: false, error: oneLineErr(r.stderr) || "gh pr list failed" };
|
|
527
|
+
let list;
|
|
528
|
+
try {
|
|
529
|
+
list = JSON.parse(r.stdout);
|
|
530
|
+
} catch {
|
|
531
|
+
return { ok: false, error: "couldn't read what gh said" };
|
|
532
|
+
}
|
|
533
|
+
if (!Array.isArray(list)) return { ok: false, error: "couldn't read what gh said" };
|
|
534
|
+
const prs = list.flatMap((x) => {
|
|
535
|
+
const o = x ?? {};
|
|
536
|
+
if (typeof o.number !== "number" || typeof o.headRefOid !== "string") return [];
|
|
537
|
+
const login = (v) => v && typeof v === "object" && typeof v.login === "string" ? v.login : "";
|
|
538
|
+
return [
|
|
539
|
+
{
|
|
540
|
+
number: o.number,
|
|
541
|
+
title: typeof o.title === "string" ? o.title : "",
|
|
542
|
+
url: typeof o.url === "string" ? o.url : "",
|
|
543
|
+
branch: typeof o.headRefName === "string" ? o.headRefName : "",
|
|
544
|
+
headSha: o.headRefOid,
|
|
545
|
+
base: typeof o.baseRefName === "string" ? o.baseRefName : "",
|
|
546
|
+
author: login(o.author).replace(/^app\//, ""),
|
|
547
|
+
isDraft: o.isDraft === true,
|
|
548
|
+
additions: typeof o.additions === "number" ? o.additions : 0,
|
|
549
|
+
deletions: typeof o.deletions === "number" ? o.deletions : 0,
|
|
550
|
+
requested: Array.isArray(o.reviewRequests) ? o.reviewRequests.map(login).filter(Boolean) : [],
|
|
551
|
+
...o.isCrossRepository === true ? { fork: true } : {},
|
|
552
|
+
...typeof o.updatedAt === "string" && o.updatedAt ? { updatedAt: o.updatedAt } : {}
|
|
553
|
+
}
|
|
554
|
+
];
|
|
555
|
+
});
|
|
556
|
+
return { ok: true, prs, ...list.length >= OPEN_PR_LIMIT ? { more: true } : {} };
|
|
557
|
+
}
|
|
558
|
+
var GITHUB_EVENT = { comment: "COMMENT", approve: "APPROVE", "request-changes": "REQUEST_CHANGES" };
|
|
559
|
+
async function githubSubmitReview(run, cwd, number, review) {
|
|
560
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "work-gh-"));
|
|
561
|
+
try {
|
|
562
|
+
const file = path.join(dir, "review.json");
|
|
563
|
+
fs.writeFileSync(
|
|
564
|
+
file,
|
|
565
|
+
JSON.stringify({
|
|
566
|
+
commit_id: review.commitId,
|
|
567
|
+
event: GITHUB_EVENT[review.event],
|
|
568
|
+
body: review.body,
|
|
569
|
+
comments: review.comments.map((c) => ({ path: c.path, line: c.line, side: "RIGHT", body: c.body }))
|
|
570
|
+
})
|
|
571
|
+
);
|
|
572
|
+
const r = await ghApi(run, cwd, ["--method", "POST", `repos/{owner}/{repo}/pulls/${number}/reviews`, "--input", file]);
|
|
573
|
+
if ("serverUnknown" in r) return { ok: false, error: r.stderr };
|
|
574
|
+
if (r.code !== 0) {
|
|
575
|
+
const error = oneLineErr(r.stderr) || (r.code === RUN_TIMED_OUT ? "gh timed out" : "gh could not submit the review");
|
|
576
|
+
return refusedClearly(r.code, r.stderr, GH_REFUSAL) ? { ok: false, error } : { ok: false, error, inDoubt: { comments: review.comments.map((_, i) => i), summary: !!review.body.trim() } };
|
|
577
|
+
}
|
|
578
|
+
try {
|
|
579
|
+
const url = JSON.parse(r.stdout).html_url;
|
|
580
|
+
return { ok: true, ...typeof url === "string" ? { url } : {} };
|
|
581
|
+
} catch {
|
|
582
|
+
return { ok: true };
|
|
583
|
+
}
|
|
584
|
+
} finally {
|
|
585
|
+
try {
|
|
586
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
587
|
+
} catch {
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
var GH_REFUSAL = /gh auth login|not logged in|authentication required|Could not resolve to a Repository/i;
|
|
592
|
+
|
|
593
|
+
// src/core/hosts/discussion.ts
|
|
594
|
+
var MAX_DISCUSSION_BODY = 4e3;
|
|
595
|
+
var MAX_THREAD_COMMENTS = 50;
|
|
596
|
+
function discussionBody(body) {
|
|
597
|
+
const text = typeof body === "string" ? body : "";
|
|
598
|
+
return text.length > MAX_DISCUSSION_BODY ? `${text.slice(0, MAX_DISCUSSION_BODY)}
|
|
599
|
+
|
|
600
|
+
\u2026 (cut: the rest is on the host)` : text;
|
|
601
|
+
}
|
|
602
|
+
function reviewStateOf(state) {
|
|
603
|
+
switch (typeof state === "string" ? state.toUpperCase() : "") {
|
|
604
|
+
case "APPROVED":
|
|
605
|
+
return "approved";
|
|
606
|
+
case "CHANGES_REQUESTED":
|
|
607
|
+
return "changes-requested";
|
|
608
|
+
case "COMMENTED":
|
|
609
|
+
return "commented";
|
|
610
|
+
case "DISMISSED":
|
|
611
|
+
return "dismissed";
|
|
612
|
+
default:
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// src/core/hosts/github/review.ts
|
|
618
|
+
var QUERY = `query($owner: String!, $name: String!, $number: Int!) {
|
|
619
|
+
viewer { login }
|
|
620
|
+
repository(owner: $owner, name: $name) {
|
|
621
|
+
pullRequest(number: $number) {
|
|
622
|
+
reviewThreads(first: 100) {
|
|
623
|
+
nodes {
|
|
624
|
+
id isResolved isOutdated path line originalStartLine originalLine
|
|
625
|
+
head: comments(first: 1) { nodes { diffHunk } }
|
|
626
|
+
comments(last: 20) { nodes { id author { login } authorAssociation body url createdAt } }
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
reviews(last: 30) { nodes { id state author { login } authorAssociation body url submittedAt } }
|
|
630
|
+
comments(last: 50) { nodes { id author { login } authorAssociation body url createdAt } }
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}`;
|
|
634
|
+
var comment = (n) => ({
|
|
635
|
+
id: n.id,
|
|
636
|
+
author: n.author?.login ?? "ghost",
|
|
637
|
+
association: n.authorAssociation ?? "NONE",
|
|
638
|
+
body: n.body ?? "",
|
|
639
|
+
url: n.url ?? "",
|
|
640
|
+
createdAt: n.createdAt ?? n.submittedAt ?? ""
|
|
641
|
+
});
|
|
642
|
+
function parseReviewFeedback(stdout) {
|
|
643
|
+
try {
|
|
644
|
+
const j = JSON.parse(stdout);
|
|
645
|
+
const pr = j.data?.repository?.pullRequest;
|
|
646
|
+
if (!pr || !j.data?.viewer?.login) return null;
|
|
647
|
+
return {
|
|
648
|
+
viewer: j.data.viewer.login,
|
|
649
|
+
threads: (pr.reviewThreads?.nodes ?? []).map((t) => ({
|
|
650
|
+
id: t.id,
|
|
651
|
+
isResolved: !!t.isResolved,
|
|
652
|
+
isOutdated: !!t.isOutdated,
|
|
653
|
+
path: t.path ?? null,
|
|
654
|
+
line: t.line ?? null,
|
|
655
|
+
code: threadCode(t.head?.nodes?.[0]?.diffHunk, t.originalStartLine, t.originalLine, !!t.isOutdated),
|
|
656
|
+
comments: (t.comments?.nodes ?? []).map(comment)
|
|
657
|
+
})),
|
|
658
|
+
reviews: (pr.reviews?.nodes ?? []).map((r) => ({ ...comment(r), state: r.state ?? "COMMENTED" })),
|
|
659
|
+
comments: (pr.comments?.nodes ?? []).map(comment)
|
|
660
|
+
};
|
|
661
|
+
} catch {
|
|
662
|
+
return null;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
async function githubViewer(run, cwd, deps) {
|
|
666
|
+
const r = await ghApi(run, cwd, ["user", "--jq", ".login"], deps).catch(() => null);
|
|
667
|
+
const login = r?.code === 0 ? r.stdout.trim() : "";
|
|
668
|
+
return login || null;
|
|
669
|
+
}
|
|
670
|
+
async function githubReviewFeedback(run, repoPath, prNumber, deps) {
|
|
671
|
+
const res = await ghApi(
|
|
672
|
+
run,
|
|
673
|
+
repoPath,
|
|
674
|
+
["graphql", "-F", "owner={owner}", "-F", "name={repo}", "-F", `number=${prNumber}`, "-f", `query=${QUERY}`],
|
|
675
|
+
deps
|
|
676
|
+
);
|
|
677
|
+
return res.code === 0 ? parseReviewFeedback(res.stdout) : null;
|
|
678
|
+
}
|
|
679
|
+
var DISCUSSION_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
|
|
680
|
+
repository(owner: $owner, name: $name) {
|
|
681
|
+
pullRequest(number: $number) {
|
|
682
|
+
updatedAt
|
|
683
|
+
reviewThreads(first: 100) {
|
|
684
|
+
pageInfo { hasNextPage }
|
|
685
|
+
nodes {
|
|
686
|
+
id isResolved isOutdated path line originalLine diffSide
|
|
687
|
+
comments(first: ${MAX_THREAD_COMMENTS}) { totalCount nodes { author { login } authorAssociation body url createdAt } }
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
reviews(last: 50) { pageInfo { hasPreviousPage } nodes { state author { login } authorAssociation body url submittedAt } }
|
|
691
|
+
comments(last: 100) { pageInfo { hasPreviousPage } nodes { author { login } authorAssociation body url createdAt } }
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}`;
|
|
695
|
+
var dstr = (v) => typeof v === "string" ? v : "";
|
|
696
|
+
var dcomment = (n) => {
|
|
697
|
+
const association = dstr(n.authorAssociation);
|
|
698
|
+
const url = dstr(n.url);
|
|
699
|
+
return {
|
|
700
|
+
// gh names an app `app/dependabot` in some answers; a deleted account is GitHub's "ghost".
|
|
701
|
+
author: dstr(n.author?.login).replace(/^app\//, "") || "ghost",
|
|
702
|
+
...association ? { association } : {},
|
|
703
|
+
body: discussionBody(n.body),
|
|
704
|
+
at: dstr(n.createdAt) || dstr(n.submittedAt),
|
|
705
|
+
...url ? { url } : {}
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
function parseGithubDiscussion(stdout) {
|
|
709
|
+
let j;
|
|
710
|
+
try {
|
|
711
|
+
j = JSON.parse(stdout);
|
|
712
|
+
} catch {
|
|
713
|
+
return null;
|
|
714
|
+
}
|
|
715
|
+
const pr = j?.data?.repository?.pullRequest;
|
|
716
|
+
if (!pr || typeof pr !== "object") return null;
|
|
717
|
+
const num = (v) => typeof v === "number" && Number.isSafeInteger(v) ? v : null;
|
|
718
|
+
const threads = (pr.reviewThreads?.nodes ?? []).flatMap((t) => {
|
|
719
|
+
if (!t || typeof t.id !== "string") return [];
|
|
720
|
+
const comments2 = (t.comments?.nodes ?? []).flatMap((c) => c ? [dcomment(c)] : []);
|
|
721
|
+
if (!comments2.length) return [];
|
|
722
|
+
const original = num(t.originalLine);
|
|
723
|
+
return [
|
|
724
|
+
{
|
|
725
|
+
id: t.id,
|
|
726
|
+
path: dstr(t.path) || null,
|
|
727
|
+
line: num(t.line),
|
|
728
|
+
...original !== null ? { originalLine: original } : {},
|
|
729
|
+
side: t.diffSide === "LEFT" ? "left" : "right",
|
|
730
|
+
outdated: t.isOutdated === true,
|
|
731
|
+
resolved: t.isResolved === true,
|
|
732
|
+
...comments2[0].url ? { url: comments2[0].url } : {},
|
|
733
|
+
comments: comments2
|
|
734
|
+
}
|
|
735
|
+
];
|
|
736
|
+
});
|
|
737
|
+
const reviews = (pr.reviews?.nodes ?? []).flatMap((r) => {
|
|
738
|
+
const state = r ? reviewStateOf(r.state) : null;
|
|
739
|
+
return r && state ? [{ ...dcomment(r), state }] : [];
|
|
740
|
+
});
|
|
741
|
+
const comments = (pr.comments?.nodes ?? []).flatMap((c) => c ? [dcomment(c)] : []);
|
|
742
|
+
const more = pr.reviewThreads?.pageInfo?.hasNextPage === true || pr.reviews?.pageInfo?.hasPreviousPage === true || pr.comments?.pageInfo?.hasPreviousPage === true || (pr.reviewThreads?.nodes ?? []).some((t) => typeof t?.comments?.totalCount === "number" && t.comments.totalCount > MAX_THREAD_COMMENTS);
|
|
743
|
+
const updatedAt = dstr(pr.updatedAt);
|
|
744
|
+
return { ...updatedAt ? { updatedAt } : {}, threads, reviews, comments, ...more ? { more: true } : {} };
|
|
745
|
+
}
|
|
746
|
+
async function githubDiscussion(run, repoPath, prNumber, deps) {
|
|
747
|
+
const res = await ghApi(
|
|
748
|
+
run,
|
|
749
|
+
repoPath,
|
|
750
|
+
["graphql", "-F", "owner={owner}", "-F", "name={repo}", "-F", `number=${prNumber}`, "-f", `query=${DISCUSSION_QUERY}`],
|
|
751
|
+
deps
|
|
752
|
+
);
|
|
753
|
+
if (res.code === 127) return { ok: false, error: "GitHub CLI (gh) not found" };
|
|
754
|
+
if (res.code !== 0) return { ok: false, error: reasonLine(res.stderr) || "gh couldn't read the PR's discussion" };
|
|
755
|
+
const discussion = parseGithubDiscussion(res.stdout);
|
|
756
|
+
return discussion ? { ok: true, discussion } : { ok: false, error: "couldn't read what gh said about the PR's discussion" };
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// src/core/hosts/github/threads.ts
|
|
760
|
+
var ADD_REPLY = `mutation($threadId: ID!, $body: String!) {
|
|
761
|
+
addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: $threadId, body: $body }) { comment { url } }
|
|
762
|
+
}`;
|
|
763
|
+
var RESOLVE = `mutation($threadId: ID!) { resolveReviewThread(input: { threadId: $threadId }) { thread { isResolved } } }`;
|
|
764
|
+
var THREAD_NOW = `query($threadId: ID!) {
|
|
765
|
+
viewer { login }
|
|
766
|
+
node(id: $threadId) { ... on PullRequestReviewThread { isResolved comments(last: 1) { nodes { author { login } } } } }
|
|
767
|
+
}`;
|
|
768
|
+
var THREAD_LIVE = `query($threadId: ID!) {
|
|
769
|
+
viewer { login }
|
|
770
|
+
node(id: $threadId) { ... on PullRequestReviewThread {
|
|
771
|
+
isResolved isOutdated path line originalStartLine originalLine
|
|
772
|
+
first: comments(first: 1) { nodes { author { login } body url diffHunk } }
|
|
773
|
+
last: comments(last: 1) { nodes { author { login } url } }
|
|
774
|
+
pullRequest { number url headRefName repository { nameWithOwner } }
|
|
775
|
+
} }
|
|
776
|
+
}`;
|
|
777
|
+
var THREAD_RESOLVED = `query($threadId: ID!) { node(id: $threadId) { ... on PullRequestReviewThread { isResolved } } }`;
|
|
778
|
+
var graphql = (run, cwd, query, vars) => ghApi(run, cwd, ["graphql", "-f", `query=${query}`, ...Object.entries(vars).flatMap(([k, v]) => ["-f", `${k}=${v}`])]);
|
|
779
|
+
async function githubThreadNow(run, cwd, id) {
|
|
780
|
+
const r = await graphql(run, cwd, THREAD_NOW, { threadId: id });
|
|
781
|
+
if (r.code !== 0) return { ok: false, error: `couldn't read the thread on GitHub first: ${r.stderr.trim() || "gh failed"}` };
|
|
782
|
+
const j = json.parse(r.stdout);
|
|
783
|
+
const me = j?.data?.viewer?.login;
|
|
784
|
+
const node = j?.data?.node;
|
|
785
|
+
if (typeof me !== "string" || !me || !node) return { ok: false, error: "couldn't read the thread on GitHub first" };
|
|
786
|
+
const last = node.comments?.nodes?.at(-1)?.author?.login;
|
|
787
|
+
return { ok: true, thread: { viewer: me, resolved: node.isResolved === true, lastAuthor: typeof last === "string" ? last : null } };
|
|
788
|
+
}
|
|
789
|
+
async function githubThreadLive(run, cwd, id) {
|
|
790
|
+
const r = await graphql(run, cwd, THREAD_LIVE, { threadId: id });
|
|
791
|
+
if (r.code !== 0) return { ok: false, error: `couldn't read the thread on GitHub: ${r.stderr.trim() || "gh failed"}` };
|
|
792
|
+
const j = json.parse(r.stdout);
|
|
793
|
+
const me = j?.data?.viewer?.login;
|
|
794
|
+
const t = j?.data?.node;
|
|
795
|
+
const pr = t?.pullRequest;
|
|
796
|
+
if (typeof me !== "string" || !me || !t || !pr || typeof pr.number !== "number")
|
|
797
|
+
return { ok: false, error: `${id} isn't a review thread GitHub knows` };
|
|
798
|
+
const str = (v) => typeof v === "string" ? v : "";
|
|
799
|
+
const num = (v) => typeof v === "number" ? v : null;
|
|
800
|
+
const first = t.first?.nodes?.[0];
|
|
801
|
+
const last = t.last?.nodes?.at(-1);
|
|
802
|
+
return {
|
|
803
|
+
ok: true,
|
|
804
|
+
thread: {
|
|
805
|
+
viewer: me,
|
|
806
|
+
resolved: t.isResolved === true,
|
|
807
|
+
outdated: t.isOutdated === true,
|
|
808
|
+
path: str(t.path) || null,
|
|
809
|
+
line: num(t.line),
|
|
810
|
+
originalStartLine: num(t.originalStartLine),
|
|
811
|
+
originalLine: num(t.originalLine),
|
|
812
|
+
first: first ? { author: str(first.author?.login), body: str(first.body), url: str(first.url), diffHunk: str(first.diffHunk) || null } : null,
|
|
813
|
+
last: last ? { author: str(last.author?.login), url: str(last.url) } : null,
|
|
814
|
+
pr: {
|
|
815
|
+
number: pr.number,
|
|
816
|
+
url: str(pr.url),
|
|
817
|
+
headBranch: str(pr.headRefName),
|
|
818
|
+
repoId: str(pr.repository?.nameWithOwner).toLowerCase()
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
async function githubThreadResolved(run, cwd, id) {
|
|
824
|
+
const res = await graphql(run, cwd, THREAD_RESOLVED, { threadId: id });
|
|
825
|
+
if (res.code !== 0) return null;
|
|
826
|
+
const j = json.parse(res.stdout);
|
|
827
|
+
const v = j?.data?.node?.isResolved;
|
|
828
|
+
return typeof v === "boolean" ? v : null;
|
|
829
|
+
}
|
|
830
|
+
async function githubThreadReply(run, cwd, id, body) {
|
|
831
|
+
const add = await graphql(run, cwd, ADD_REPLY, { threadId: id, body });
|
|
832
|
+
if (add.code !== 0) return { ok: false, error: add.stderr.trim() || "gh could not post the reply" };
|
|
833
|
+
const parsed = json.parse(add.stdout);
|
|
834
|
+
const got = parsed?.data?.addPullRequestReviewThreadReply?.comment?.url;
|
|
835
|
+
return { ok: true, ...typeof got === "string" ? { url: got } : {} };
|
|
836
|
+
}
|
|
837
|
+
async function githubThreadResolve(run, cwd, id) {
|
|
838
|
+
const r = await graphql(run, cwd, RESOLVE, { threadId: id });
|
|
839
|
+
return r.code === 0;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// src/core/hosts/github/adapter.ts
|
|
843
|
+
var github = {
|
|
844
|
+
id: "github",
|
|
845
|
+
name: "GitHub",
|
|
846
|
+
cli: {
|
|
847
|
+
cmd: "gh",
|
|
848
|
+
label: "GitHub CLI",
|
|
849
|
+
checkArgs: ["auth", "status"],
|
|
850
|
+
missing: "Optional: install gh to see your pull requests, CI and review comments.",
|
|
851
|
+
failing: "Optional: run `gh auth login` so work can see your pull requests."
|
|
852
|
+
},
|
|
853
|
+
matches: onGithub,
|
|
854
|
+
repoId: githubRepoId,
|
|
855
|
+
parsePrUrl: parseGithubPrUrl,
|
|
856
|
+
prRef: (n) => `refs/pull/${n}/head`,
|
|
857
|
+
// One search for every repo, then gh pr list per repo elsewhere; the real runner is its own execFile with timeouts.
|
|
858
|
+
list: async (repos, run) => githubPrList(Object.fromEntries(repos.map((r) => [r.alias, r.path])), defaultPrListDeps(run)),
|
|
859
|
+
viewer: githubViewer,
|
|
860
|
+
prForBranch: githubPrForBranch,
|
|
861
|
+
prForRef: githubPrForRef,
|
|
862
|
+
prByNumber: githubPrByNumber,
|
|
863
|
+
prState: (run, url) => githubPrState(run, url, os2.tmpdir()),
|
|
864
|
+
createPr: githubCreatePr,
|
|
865
|
+
mergePr: githubMergePr,
|
|
866
|
+
mergedPr: githubMergedPr,
|
|
867
|
+
openPrs: githubOpenPrs,
|
|
868
|
+
submitReview: githubSubmitReview,
|
|
869
|
+
reviewFeedback: (run, cwd, n) => githubReviewFeedback(run, cwd, n),
|
|
870
|
+
discussion: (run, cwd, n) => githubDiscussion(run, cwd, n),
|
|
871
|
+
threads: {
|
|
872
|
+
isId: (id) => GITHUB_THREAD_ID.test(id),
|
|
873
|
+
now: githubThreadNow,
|
|
874
|
+
live: githubThreadLive,
|
|
875
|
+
isResolved: githubThreadResolved,
|
|
876
|
+
reply: githubThreadReply,
|
|
877
|
+
resolve: githubThreadResolve
|
|
878
|
+
},
|
|
879
|
+
// gh's words when GitHub's API limit is spent ("API rate limit already exceeded", "secondary rate limit").
|
|
880
|
+
rateLimited: (text) => /rate limit/i.test(text),
|
|
881
|
+
// A squash or merge commit GitHub wrote itself, not your work of that day.
|
|
882
|
+
hostCommit: (email) => email.toLowerCase() === "noreply@github.com",
|
|
883
|
+
commands: githubCommands
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
// src/core/hosts/azure/adapter.ts
|
|
887
|
+
import fs2 from "fs";
|
|
888
|
+
import os3 from "os";
|
|
889
|
+
import path2 from "path";
|
|
890
|
+
|
|
891
|
+
// src/core/hosts/azure/map.ts
|
|
892
|
+
var branch = (ref) => (ref ?? "").replace(/^refs\/heads\//, "");
|
|
893
|
+
var lower = (s) => (s ?? "").toLowerCase();
|
|
894
|
+
function prState(status) {
|
|
895
|
+
return status === "completed" ? "MERGED" : status === "abandoned" ? "CLOSED" : "OPEN";
|
|
896
|
+
}
|
|
897
|
+
function reviewDecision(pr) {
|
|
898
|
+
const votes = (pr.reviewers ?? []).filter((r) => !!r).map((r) => r.vote ?? 0);
|
|
899
|
+
if (!votes.length) return "";
|
|
900
|
+
if (votes.some((v) => v < 0)) return "CHANGES_REQUESTED";
|
|
901
|
+
const required = (pr.reviewers ?? []).filter((r) => r?.isRequired);
|
|
902
|
+
if (required.length ? required.every((r) => (r.vote ?? 0) > 0) : votes.some((v) => v > 0)) return "APPROVED";
|
|
903
|
+
return "REVIEW_REQUIRED";
|
|
904
|
+
}
|
|
905
|
+
var isBuild = (p) => /build/i.test(p.configuration?.type?.displayName ?? "");
|
|
906
|
+
function checksOf(policies2) {
|
|
907
|
+
const builds = policies2.filter((p) => p.configuration?.isEnabled !== false && isBuild(p) && p.status !== "notApplicable");
|
|
908
|
+
const failed = builds.filter((p) => p.status === "rejected" || p.status === "broken");
|
|
909
|
+
const nameOf = (p) => ({ name: p.configuration?.settings?.displayName || p.configuration?.type?.displayName || "build" });
|
|
910
|
+
const failing = failed.filter((p) => p.configuration?.isBlocking !== false).map(nameOf);
|
|
911
|
+
const optional = failed.filter((p) => p.configuration?.isBlocking === false).map(nameOf);
|
|
912
|
+
if (!builds.length) return { checks: "none", failing: [], optional: [] };
|
|
913
|
+
if (failing.length) return { checks: "fail", failing, optional };
|
|
914
|
+
if (builds.some((p) => p.status === "queued" || p.status === "running")) return { checks: "pending", failing: [], optional };
|
|
915
|
+
return { checks: "pass", failing: [], optional };
|
|
916
|
+
}
|
|
917
|
+
function mergeState(pr, policies2) {
|
|
918
|
+
if (pr.mergeStatus === "conflicts") return "DIRTY";
|
|
919
|
+
if (pr.isDraft) return "DRAFT";
|
|
920
|
+
const blocking = policies2.filter(
|
|
921
|
+
(p) => p.configuration?.isBlocking && p.configuration?.isEnabled !== false && p.status !== "notApplicable"
|
|
922
|
+
);
|
|
923
|
+
if (blocking.some((p) => p.status === "rejected" || p.status === "broken")) return "BLOCKED";
|
|
924
|
+
if (blocking.some((p) => p.status !== "approved")) return "BLOCKED";
|
|
925
|
+
if (pr.mergeStatus === "failure" || pr.mergeStatus === "rejectedByPolicy") return "BLOCKED";
|
|
926
|
+
if (pr.mergeStatus === "queued" || pr.mergeStatus === "notSet") return "UNKNOWN";
|
|
927
|
+
return "CLEAN";
|
|
928
|
+
}
|
|
929
|
+
var prWebUrl = (repo, id) => `${azureWebUrl(repo)}/pullrequest/${id}`;
|
|
930
|
+
function shipPrOf(repo, pr, policies2) {
|
|
931
|
+
const n = pr.pullRequestId;
|
|
932
|
+
const head = pr.lastMergeSourceCommit?.commitId;
|
|
933
|
+
if (typeof n !== "number" || !head) return null;
|
|
934
|
+
const { checks, failing, optional } = checksOf(policies2);
|
|
935
|
+
const state = prState(pr.status);
|
|
936
|
+
return {
|
|
937
|
+
number: n,
|
|
938
|
+
url: prWebUrl(repo, n),
|
|
939
|
+
state,
|
|
940
|
+
isDraft: pr.isDraft === true,
|
|
941
|
+
mergeStateStatus: mergeState(pr, policies2),
|
|
942
|
+
checks,
|
|
943
|
+
headSha: head,
|
|
944
|
+
...state === "MERGED" && pr.closedDate ? { mergedAt: pr.closedDate } : {},
|
|
945
|
+
// Only a closed PR's date says it hasn't changed since: an open one's creationDate never moves, and the PR
|
|
946
|
+
// watch would believe its review threads unchanged for good. Without it they're read every check.
|
|
947
|
+
...state !== "OPEN" && pr.closedDate ? { updatedAt: pr.closedDate } : {},
|
|
948
|
+
reviewDecision: reviewDecision(pr),
|
|
949
|
+
...pr.createdBy?.uniqueName ? { author: pr.createdBy.uniqueName } : {},
|
|
950
|
+
...pr.targetRefName ? { baseBranch: branch(pr.targetRefName) } : {},
|
|
951
|
+
...failing.length ? { failing } : {},
|
|
952
|
+
...optional.length ? { optionalFailing: optional } : {},
|
|
953
|
+
// A build policy is blocking or not: Azure DevOps always says which checks count.
|
|
954
|
+
...checks !== "none" ? { checksRequiredByHost: true } : {},
|
|
955
|
+
...pr.sourceRefName ? { headBranch: branch(pr.sourceRefName) } : {}
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function pickPr(list) {
|
|
959
|
+
const valid = list.filter((p) => typeof p.pullRequestId === "number");
|
|
960
|
+
return valid.find((p) => p.status === "active") ?? [...valid].sort((a, b) => (b.creationDate ?? "").localeCompare(a.creationDate ?? ""))[0] ?? null;
|
|
961
|
+
}
|
|
962
|
+
var myVote = (pr, me) => (pr.reviewers ?? []).find((r) => lower(r?.uniqueName) === lower(me))?.vote;
|
|
963
|
+
function prInfoOf(repo, alias, pr, me) {
|
|
964
|
+
const n = pr.pullRequestId;
|
|
965
|
+
if (typeof n !== "number") return null;
|
|
966
|
+
const vote = me ? myVote(pr, me) : void 0;
|
|
967
|
+
const decision = reviewDecision(pr);
|
|
968
|
+
return {
|
|
969
|
+
number: n,
|
|
970
|
+
title: pr.title ?? "",
|
|
971
|
+
branch: branch(pr.sourceRefName),
|
|
972
|
+
url: prWebUrl(repo, n),
|
|
973
|
+
isDraft: pr.isDraft === true,
|
|
974
|
+
checksStatus: "NONE",
|
|
975
|
+
// policies are asked per PR by the PR watch, not for the whole list
|
|
976
|
+
reviewDecision: decision === "APPROVED" || decision === "CHANGES_REQUESTED" || decision === "REVIEW_REQUIRED" ? decision : "NONE",
|
|
977
|
+
myReview: vote === void 0 || vote === 0 ? "NONE" : vote > 0 ? "APPROVED" : "CHANGES_REQUESTED",
|
|
978
|
+
isMine: !!me && lower(pr.createdBy?.uniqueName) === lower(me),
|
|
979
|
+
conflicting: pr.mergeStatus === "conflicts",
|
|
980
|
+
reviewRequested: vote === 0,
|
|
981
|
+
repoAlias: alias,
|
|
982
|
+
...me && pr.createdBy?.uniqueName ? { author: pr.createdBy.uniqueName } : {},
|
|
983
|
+
fork: !!pr.forkSource
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
function openPrOf(repo, pr) {
|
|
987
|
+
const n = pr.pullRequestId;
|
|
988
|
+
const head = pr.lastMergeSourceCommit?.commitId;
|
|
989
|
+
if (typeof n !== "number" || !head || pr.status !== "active") return null;
|
|
990
|
+
return {
|
|
991
|
+
number: n,
|
|
992
|
+
title: pr.title ?? "",
|
|
993
|
+
url: prWebUrl(repo, n),
|
|
994
|
+
branch: branch(pr.sourceRefName),
|
|
995
|
+
headSha: head,
|
|
996
|
+
base: branch(pr.targetRefName),
|
|
997
|
+
author: pr.createdBy?.uniqueName ?? "",
|
|
998
|
+
isDraft: pr.isDraft === true,
|
|
999
|
+
// Azure DevOps' PR list says nothing of size: the review queue's size limit can't apply before it's fetched.
|
|
1000
|
+
additions: 0,
|
|
1001
|
+
deletions: 0,
|
|
1002
|
+
requested: (pr.reviewers ?? []).filter((r) => r && (r.vote ?? 0) === 0 && r.uniqueName).map((r) => r.uniqueName),
|
|
1003
|
+
...pr.forkSource ? { fork: true } : {}
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
function prForStartOf(repo, pr) {
|
|
1007
|
+
const n = pr.pullRequestId;
|
|
1008
|
+
if (typeof n !== "number") return null;
|
|
1009
|
+
return {
|
|
1010
|
+
number: n,
|
|
1011
|
+
title: pr.title ?? "",
|
|
1012
|
+
url: prWebUrl(repo, n),
|
|
1013
|
+
branch: branch(pr.sourceRefName),
|
|
1014
|
+
...pr.lastMergeSourceCommit?.commitId ? { headSha: pr.lastMergeSourceCommit.commitId } : {},
|
|
1015
|
+
base: branch(pr.targetRefName),
|
|
1016
|
+
author: pr.createdBy?.uniqueName ?? "",
|
|
1017
|
+
state: prState(pr.status),
|
|
1018
|
+
...pr.forkSource ? { fork: { owner: pr.forkSource.repository?.project?.name ?? "a fork" } } : {}
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
var RESOLVED_THREAD = /* @__PURE__ */ new Set(["fixed", "closed", "wontFix", "byDesign"]);
|
|
1022
|
+
function feedbackOf(repo, prNumber, threads, viewer2) {
|
|
1023
|
+
const out = [];
|
|
1024
|
+
for (const t of threads) {
|
|
1025
|
+
if (typeof t.id !== "number" || t.isDeleted) continue;
|
|
1026
|
+
const comments = (t.comments ?? []).filter((c) => !!c && !c.isDeleted && c.commentType !== "system");
|
|
1027
|
+
if (!comments.length) continue;
|
|
1028
|
+
const url = `${prWebUrl(repo, prNumber)}?discussionId=${t.id}`;
|
|
1029
|
+
out.push({
|
|
1030
|
+
id: azureThreadId(repo, prNumber, t.id),
|
|
1031
|
+
isResolved: RESOLVED_THREAD.has(t.status ?? ""),
|
|
1032
|
+
isOutdated: false,
|
|
1033
|
+
path: t.threadContext?.filePath ? t.threadContext.filePath.replace(/^\//, "") : null,
|
|
1034
|
+
line: t.threadContext?.rightFileEnd?.line ?? t.threadContext?.rightFileStart?.line ?? null,
|
|
1035
|
+
code: null,
|
|
1036
|
+
comments: comments.map((c) => ({
|
|
1037
|
+
id: `${t.id}-${c.id ?? 0}`,
|
|
1038
|
+
author: c.author?.uniqueName ?? c.author?.displayName ?? "unknown",
|
|
1039
|
+
// Azure DevOps has no "association": a commenter on a PR is in the organisation (its members are who can).
|
|
1040
|
+
association: "MEMBER",
|
|
1041
|
+
body: c.content ?? "",
|
|
1042
|
+
url,
|
|
1043
|
+
createdAt: c.publishedDate ?? ""
|
|
1044
|
+
}))
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
return { viewer: viewer2, threads: out, reviews: [], comments: [] };
|
|
1048
|
+
}
|
|
1049
|
+
function discussionOf(repo, prNumber, threads, pr) {
|
|
1050
|
+
const web = prWebUrl(repo, prNumber);
|
|
1051
|
+
const out = [];
|
|
1052
|
+
const comments = [];
|
|
1053
|
+
let more = false;
|
|
1054
|
+
for (const t of threads) {
|
|
1055
|
+
if (typeof t.id !== "number" || t.isDeleted) continue;
|
|
1056
|
+
const people = (t.comments ?? []).filter((c) => !!c && !c.isDeleted && c.commentType !== "system");
|
|
1057
|
+
if (!people.length) continue;
|
|
1058
|
+
const url = `${web}?discussionId=${t.id}`;
|
|
1059
|
+
const said = people.map((c) => ({
|
|
1060
|
+
author: c.author?.uniqueName ?? c.author?.displayName ?? "unknown",
|
|
1061
|
+
body: discussionBody(c.content),
|
|
1062
|
+
at: c.publishedDate ?? "",
|
|
1063
|
+
url
|
|
1064
|
+
}));
|
|
1065
|
+
const ctx = t.threadContext;
|
|
1066
|
+
if (!ctx?.filePath) {
|
|
1067
|
+
comments.push(...said);
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
const right = ctx.rightFileEnd?.line ?? ctx.rightFileStart?.line ?? null;
|
|
1071
|
+
const left = ctx.leftFileEnd?.line ?? ctx.leftFileStart?.line ?? null;
|
|
1072
|
+
if (said.length > MAX_THREAD_COMMENTS) more = true;
|
|
1073
|
+
out.push({
|
|
1074
|
+
id: azureThreadId(repo, prNumber, t.id),
|
|
1075
|
+
path: ctx.filePath.replace(/^\//, ""),
|
|
1076
|
+
line: right ?? left,
|
|
1077
|
+
side: right === null && left !== null ? "left" : "right",
|
|
1078
|
+
outdated: false,
|
|
1079
|
+
resolved: RESOLVED_THREAD.has(t.status ?? ""),
|
|
1080
|
+
url,
|
|
1081
|
+
comments: said.slice(0, MAX_THREAD_COMMENTS)
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
const reviews = (pr?.reviewers ?? []).flatMap((r) => {
|
|
1085
|
+
const vote = r?.vote ?? 0;
|
|
1086
|
+
if (!r || !vote) return [];
|
|
1087
|
+
return [
|
|
1088
|
+
{
|
|
1089
|
+
author: r.uniqueName ?? r.displayName ?? "unknown",
|
|
1090
|
+
state: vote > 0 ? "approved" : "changes-requested",
|
|
1091
|
+
body: "",
|
|
1092
|
+
at: "",
|
|
1093
|
+
url: web
|
|
1094
|
+
}
|
|
1095
|
+
];
|
|
1096
|
+
});
|
|
1097
|
+
return { threads: out, reviews, comments, ...more ? { more: true } : {} };
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
// src/core/hosts/azure/adapter.ts
|
|
1101
|
+
var lower2 = (s) => (s ?? "").toLowerCase();
|
|
1102
|
+
var API = "7.1";
|
|
1103
|
+
var THROTTLED = /TF400733|\b429\b|Too Many Requests|rate limit/i;
|
|
1104
|
+
function azReason(stderr) {
|
|
1105
|
+
const lines = stderr.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
1106
|
+
return lines.find((l) => THROTTLED.test(l)) ?? lines.find((l) => !/^WARNING:/i.test(l)) ?? lines[0] ?? "";
|
|
1107
|
+
}
|
|
1108
|
+
var AZ_REFUSAL = /az login|az devops login|Before you can run Azure DevOps commands|TF400813|TF40102[78]|TF401019|TF401181|VS403\d{3}/i;
|
|
1109
|
+
async function az(run, cwd, args) {
|
|
1110
|
+
const r = await run("az", [...args, "--output", "json"], cwd);
|
|
1111
|
+
if (r.code === 127) return { ok: false, error: "Azure CLI (az) not found \u2014 install it and the azure-devops extension" };
|
|
1112
|
+
if (r.code === RUN_TIMED_OUT) return { ok: false, error: azReason(r.stderr) || "az timed out", uncertain: true };
|
|
1113
|
+
if (r.code !== 0)
|
|
1114
|
+
return {
|
|
1115
|
+
ok: false,
|
|
1116
|
+
error: azReason(r.stderr) || `az ${args.slice(0, 3).join(" ")} failed`,
|
|
1117
|
+
...refusedClearly(r.code, r.stderr, AZ_REFUSAL) ? {} : { uncertain: true }
|
|
1118
|
+
};
|
|
1119
|
+
try {
|
|
1120
|
+
return { ok: true, value: JSON.parse(r.stdout || "null") };
|
|
1121
|
+
} catch {
|
|
1122
|
+
return { ok: false, error: "couldn't read what az said", uncertain: true };
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
function repoAt(cwd) {
|
|
1126
|
+
const text = readGitConfig(cwd);
|
|
1127
|
+
const origin = text ? originUrl(text) : null;
|
|
1128
|
+
return origin ? parseAzureOrigin(origin) : null;
|
|
1129
|
+
}
|
|
1130
|
+
var where = (r) => ["--org", r.orgUrl, "--project", r.project, "--repository", r.repo];
|
|
1131
|
+
var routeValueOk = (v) => typeof v === "number" ? Number.isSafeInteger(v) && v >= 0 : /^[^/\\?#%=&\x00-\x1f\x7f]{1,128}$/.test(v) && v.trim() === v;
|
|
1132
|
+
async function invoke(run, cwd, r, resource, route, method = "GET", body) {
|
|
1133
|
+
const values = Object.entries({ project: r.project, repositoryId: r.repo, ...route });
|
|
1134
|
+
const bad = values.find(([, v]) => !routeValueOk(v));
|
|
1135
|
+
if (bad) return { ok: false, error: `refused: ${bad[0]} isn't a name Azure DevOps has` };
|
|
1136
|
+
const params = values.map(([k, v]) => `${k}=${v}`);
|
|
1137
|
+
let dir = null;
|
|
1138
|
+
const args = [
|
|
1139
|
+
"devops",
|
|
1140
|
+
"invoke",
|
|
1141
|
+
"--org",
|
|
1142
|
+
r.orgUrl,
|
|
1143
|
+
"--area",
|
|
1144
|
+
"git",
|
|
1145
|
+
"--resource",
|
|
1146
|
+
resource,
|
|
1147
|
+
"--route-parameters",
|
|
1148
|
+
...params,
|
|
1149
|
+
"--http-method",
|
|
1150
|
+
method,
|
|
1151
|
+
"--api-version",
|
|
1152
|
+
API
|
|
1153
|
+
];
|
|
1154
|
+
try {
|
|
1155
|
+
if (body !== void 0) {
|
|
1156
|
+
dir = fs2.mkdtempSync(path2.join(os3.tmpdir(), "work-az-"));
|
|
1157
|
+
const file = path2.join(dir, "body.json");
|
|
1158
|
+
fs2.writeFileSync(file, JSON.stringify(body));
|
|
1159
|
+
args.push("--in-file", file);
|
|
1160
|
+
}
|
|
1161
|
+
return await az(run, cwd, args);
|
|
1162
|
+
} finally {
|
|
1163
|
+
if (dir)
|
|
1164
|
+
try {
|
|
1165
|
+
fs2.rmSync(dir, { recursive: true, force: true });
|
|
1166
|
+
} catch {
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
async function viewer(run, cwd) {
|
|
1171
|
+
const r = await az(run, cwd, ["account", "show"]);
|
|
1172
|
+
return r.ok && r.value?.user?.name ? r.value.user.name : null;
|
|
1173
|
+
}
|
|
1174
|
+
async function policies(run, cwd, r, id) {
|
|
1175
|
+
const p = await az(run, cwd, ["repos", "pr", "policy", "list", "--id", String(id), "--org", r.orgUrl]);
|
|
1176
|
+
if (!p.ok) return p;
|
|
1177
|
+
return Array.isArray(p.value) ? { ok: true, value: p.value } : { ok: false, error: "couldn't read what az said about the PR's policies" };
|
|
1178
|
+
}
|
|
1179
|
+
async function iterationAt(run, cwd, r, number, commitId) {
|
|
1180
|
+
const got = await invoke(run, cwd, r, "pullRequestIterations", { pullRequestId: number });
|
|
1181
|
+
if (!got.ok) return got;
|
|
1182
|
+
const its = (got.value?.value ?? []).filter((i) => typeof i?.id === "number" && i.sourceRefCommit?.commitId === commitId);
|
|
1183
|
+
const id = its.at(-1)?.id;
|
|
1184
|
+
return typeof id === "number" ? { ok: true, value: id } : { ok: false, error: `the PR has no push at ${commitId.slice(0, 8)} (it moved since the review was prepared)` };
|
|
1185
|
+
}
|
|
1186
|
+
var OPEN_PR_LIMIT2 = 100;
|
|
1187
|
+
async function postThread(run, cwd, r, number, c, iteration) {
|
|
1188
|
+
return invoke(run, cwd, r, "pullRequestThreads", { pullRequestId: number }, "POST", {
|
|
1189
|
+
comments: [{ parentCommentId: 0, content: c.body, commentType: 1 }],
|
|
1190
|
+
status: "active",
|
|
1191
|
+
threadContext: { filePath: `/${c.path}`, rightFileStart: { line: c.line, offset: 1 }, rightFileEnd: { line: c.line, offset: 1 } },
|
|
1192
|
+
// At the push the review read (its lines are that commit's), not whatever the PR is at now.
|
|
1193
|
+
pullRequestThreadContext: { iterationContext: { firstComparingIteration: iteration, secondComparingIteration: iteration } }
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
var MERGE_STRATEGY = { squash: "squash", merge: "noFastForward", rebase: "rebase" };
|
|
1197
|
+
var azure = {
|
|
1198
|
+
id: "azure",
|
|
1199
|
+
name: "Azure DevOps",
|
|
1200
|
+
cli: {
|
|
1201
|
+
cmd: "az",
|
|
1202
|
+
label: "Azure CLI (azure-devops)",
|
|
1203
|
+
checkArgs: ["account", "show"],
|
|
1204
|
+
requires: [
|
|
1205
|
+
{
|
|
1206
|
+
args: ["extension", "show", "--name", "azure-devops"],
|
|
1207
|
+
failing: "Optional: add the Azure CLI's azure-devops extension (az extension add --name azure-devops) to see the pull requests of your Azure DevOps repos."
|
|
1208
|
+
}
|
|
1209
|
+
],
|
|
1210
|
+
missing: "Optional: install the Azure CLI and its azure-devops extension (az extension add --name azure-devops) to see the pull requests of your Azure DevOps repos.",
|
|
1211
|
+
failing: "Optional: run `az login` so work can see your Azure DevOps pull requests."
|
|
1212
|
+
},
|
|
1213
|
+
matches: onAzure,
|
|
1214
|
+
repoId: azureRepoId,
|
|
1215
|
+
parsePrUrl: (t) => {
|
|
1216
|
+
const l = parseAzurePrUrl(t);
|
|
1217
|
+
return l ? { repoId: l.repoId, number: l.number, url: l.url, label: l.label } : null;
|
|
1218
|
+
},
|
|
1219
|
+
// The PR merged into its target (its first parent); its second parent is the PR's head, where a review reads and comments.
|
|
1220
|
+
prRef: (n) => `refs/pull/${n}/merge`,
|
|
1221
|
+
prRefIsMerge: true,
|
|
1222
|
+
async list(repos, run) {
|
|
1223
|
+
const prs = [];
|
|
1224
|
+
const incomplete = [];
|
|
1225
|
+
let me;
|
|
1226
|
+
for (const repo of repos) {
|
|
1227
|
+
const r = repo.origin ? parseAzureOrigin(repo.origin) : null;
|
|
1228
|
+
if (!r) {
|
|
1229
|
+
incomplete.push(repo.alias);
|
|
1230
|
+
continue;
|
|
1231
|
+
}
|
|
1232
|
+
me ??= await viewer(run, repo.path);
|
|
1233
|
+
if (!me) {
|
|
1234
|
+
me = void 0;
|
|
1235
|
+
incomplete.push(repo.alias);
|
|
1236
|
+
continue;
|
|
1237
|
+
}
|
|
1238
|
+
const list = await az(run, repo.path, ["repos", "pr", "list", ...where(r), "--status", "active", "--top", "100"]);
|
|
1239
|
+
if (!list.ok || !Array.isArray(list.value)) {
|
|
1240
|
+
incomplete.push(repo.alias);
|
|
1241
|
+
continue;
|
|
1242
|
+
}
|
|
1243
|
+
for (const pr of list.value) {
|
|
1244
|
+
const row = prInfoOf(r, repo.alias, pr, me);
|
|
1245
|
+
if (row && (row.isMine || row.reviewRequested)) prs.push(row);
|
|
1246
|
+
}
|
|
1247
|
+
if (list.value.length >= 100) incomplete.push(repo.alias);
|
|
1248
|
+
}
|
|
1249
|
+
return { prs, incomplete };
|
|
1250
|
+
},
|
|
1251
|
+
viewer,
|
|
1252
|
+
async prForBranch(run, cwd, branch2) {
|
|
1253
|
+
const r = repoAt(cwd);
|
|
1254
|
+
if (!r) return { kind: "error", error: "this repo's origin isn't an Azure DevOps one" };
|
|
1255
|
+
const list = await az(run, cwd, [
|
|
1256
|
+
"repos",
|
|
1257
|
+
"pr",
|
|
1258
|
+
"list",
|
|
1259
|
+
...where(r),
|
|
1260
|
+
"--source-branch",
|
|
1261
|
+
branch2,
|
|
1262
|
+
"--status",
|
|
1263
|
+
"all",
|
|
1264
|
+
"--top",
|
|
1265
|
+
"10"
|
|
1266
|
+
]);
|
|
1267
|
+
if (!list.ok) return { kind: "error", error: list.error };
|
|
1268
|
+
const pr = pickPr(Array.isArray(list.value) ? list.value : []);
|
|
1269
|
+
if (!pr) return { kind: "none" };
|
|
1270
|
+
const pol = pr.status === "active" ? await policies(run, cwd, r, pr.pullRequestId) : { ok: true, value: [] };
|
|
1271
|
+
if (!pol.ok) return { kind: "error", error: pol.error };
|
|
1272
|
+
const ship = shipPrOf(r, pr, pol.value);
|
|
1273
|
+
return ship ? { kind: "pr", pr: ship } : { kind: "error", error: "couldn't read what az said about the PR" };
|
|
1274
|
+
},
|
|
1275
|
+
async prForRef(run, cwd, ref) {
|
|
1276
|
+
const l = parseAzurePrUrl(ref.url);
|
|
1277
|
+
if (!l || l.number !== ref.number) return { kind: "error", error: "not an Azure DevOps pull request link" };
|
|
1278
|
+
const r = l.repo;
|
|
1279
|
+
const shown = await az(run, cwd, ["repos", "pr", "show", "--id", String(ref.number), "--org", r.orgUrl]);
|
|
1280
|
+
if (!shown.ok) return { kind: "error", error: shown.error };
|
|
1281
|
+
const pr = shown.value ?? {};
|
|
1282
|
+
if (lower2(pr.repository?.name) !== lower2(r.repo) || lower2(pr.repository?.project?.name) !== lower2(r.project))
|
|
1283
|
+
return { kind: "error", error: `PR #${ref.number} isn't in ${r.project}/${r.repo}` };
|
|
1284
|
+
const pol = pr.status === "active" ? await policies(run, cwd, r, ref.number) : { ok: true, value: [] };
|
|
1285
|
+
if (!pol.ok) return { kind: "error", error: pol.error };
|
|
1286
|
+
const ship = shipPrOf(r, pr, pol.value);
|
|
1287
|
+
return ship ? { kind: "pr", pr: ship } : { kind: "error", error: "couldn't read what az said about the PR" };
|
|
1288
|
+
},
|
|
1289
|
+
async prByNumber(run, cwd, repoId, number) {
|
|
1290
|
+
const r = repoAt(cwd);
|
|
1291
|
+
if (!r || `${r.org}/${r.project}/${r.repo}`.toLowerCase() !== repoId)
|
|
1292
|
+
return { ok: false, error: `PR #${number}: its repo isn't this folder's` };
|
|
1293
|
+
const shown = await az(run, cwd, ["repos", "pr", "show", "--id", String(number), "--org", r.orgUrl]);
|
|
1294
|
+
if (!shown.ok) return { ok: false, error: `PR #${number} in ${r.repo}: ${shown.error}` };
|
|
1295
|
+
const on = shown.value?.repository;
|
|
1296
|
+
if (lower2(on?.name) !== lower2(r.repo) || lower2(on?.project?.name) !== lower2(r.project))
|
|
1297
|
+
return { ok: false, error: `PR #${number} is in ${on?.project?.name ?? "?"}/${on?.name ?? "?"}, not ${r.project}/${r.repo}` };
|
|
1298
|
+
const pr = prForStartOf(r, shown.value ?? {});
|
|
1299
|
+
return pr ? { ok: true, pr } : { ok: false, error: "couldn't read what az said about the PR" };
|
|
1300
|
+
},
|
|
1301
|
+
async prState(run, url) {
|
|
1302
|
+
const l = parseAzurePrUrl(url);
|
|
1303
|
+
if (!l) return { ok: false, error: "not an Azure DevOps pull request link" };
|
|
1304
|
+
const shown = await az(run, os3.tmpdir(), ["repos", "pr", "show", "--id", String(l.number), "--org", l.repo.orgUrl]);
|
|
1305
|
+
return shown.ok ? { ok: true, state: prState(shown.value?.status) } : { ok: false, error: shown.error };
|
|
1306
|
+
},
|
|
1307
|
+
async createPr(run, cwd, branch2, opts) {
|
|
1308
|
+
const r = repoAt(cwd);
|
|
1309
|
+
if (!r) return { ok: false, error: "this repo's origin isn't an Azure DevOps one" };
|
|
1310
|
+
const subject = (await run("git", ["log", "-1", "--format=%s"], cwd)).stdout.trim() || branch2;
|
|
1311
|
+
const body = (await run("git", ["log", "-1", "--format=%b"], cwd)).stdout.trim();
|
|
1312
|
+
const repo = await invoke(run, cwd, r, "repositories", {});
|
|
1313
|
+
if (!repo.ok) return { ok: false, error: repo.error };
|
|
1314
|
+
const target = repo.value?.defaultBranch;
|
|
1315
|
+
if (!target) return { ok: false, error: `couldn't tell ${r.repo}'s default branch` };
|
|
1316
|
+
const made = await invoke(run, cwd, r, "pullRequests", {}, "POST", {
|
|
1317
|
+
sourceRefName: `refs/heads/${branch2}`,
|
|
1318
|
+
targetRefName: target,
|
|
1319
|
+
title: subject,
|
|
1320
|
+
description: body,
|
|
1321
|
+
isDraft: opts.draft
|
|
1322
|
+
});
|
|
1323
|
+
if (!made.ok) return { ok: false, error: made.error };
|
|
1324
|
+
const n = made.value?.pullRequestId;
|
|
1325
|
+
return { ok: true, ...typeof n === "number" ? { url: prWebUrl(r, n) } : {} };
|
|
1326
|
+
},
|
|
1327
|
+
async mergePr(run, cwd, number, method, headSha) {
|
|
1328
|
+
const r = repoAt(cwd);
|
|
1329
|
+
if (!r) return { ok: false, error: "this repo's origin isn't an Azure DevOps one" };
|
|
1330
|
+
const done = await invoke(run, cwd, r, "pullRequests", { pullRequestId: number }, "PATCH", {
|
|
1331
|
+
status: "completed",
|
|
1332
|
+
lastMergeSourceCommit: { commitId: headSha },
|
|
1333
|
+
completionOptions: { mergeStrategy: MERGE_STRATEGY[method], deleteSourceBranch: false }
|
|
1334
|
+
});
|
|
1335
|
+
if (!done.ok) return { ok: false, error: done.error };
|
|
1336
|
+
const status = done.value?.status;
|
|
1337
|
+
if (status === "completed") return { ok: true };
|
|
1338
|
+
const why = done.value?.mergeStatus && done.value.mergeStatus !== "succeeded" ? ` (merge: ${done.value.mergeStatus})` : "";
|
|
1339
|
+
const queued = status === "active" ? ": its completion may be queued until its policies pass" : "";
|
|
1340
|
+
return { ok: false, error: `Azure DevOps didn't complete PR #${number}, it is ${status ?? "in an unknown state"}${why}${queued}` };
|
|
1341
|
+
},
|
|
1342
|
+
async mergedPr(run, cwd, branch2, tip) {
|
|
1343
|
+
const r = repoAt(cwd);
|
|
1344
|
+
if (!r) return void 0;
|
|
1345
|
+
const list = await az(run, cwd, [
|
|
1346
|
+
"repos",
|
|
1347
|
+
"pr",
|
|
1348
|
+
"list",
|
|
1349
|
+
...where(r),
|
|
1350
|
+
"--source-branch",
|
|
1351
|
+
branch2,
|
|
1352
|
+
"--status",
|
|
1353
|
+
"completed",
|
|
1354
|
+
"--top",
|
|
1355
|
+
"10"
|
|
1356
|
+
]);
|
|
1357
|
+
if (!list.ok || !Array.isArray(list.value)) return void 0;
|
|
1358
|
+
return list.value.find((p) => p.lastMergeSourceCommit?.commitId === tip)?.pullRequestId ?? null;
|
|
1359
|
+
},
|
|
1360
|
+
async openPrs(run, cwd) {
|
|
1361
|
+
const r = repoAt(cwd);
|
|
1362
|
+
if (!r) return { ok: false, error: "this repo's origin isn't an Azure DevOps one" };
|
|
1363
|
+
const list = await az(run, cwd, ["repos", "pr", "list", ...where(r), "--status", "active", "--top", String(OPEN_PR_LIMIT2)]);
|
|
1364
|
+
if (!list.ok) return { ok: false, error: list.error };
|
|
1365
|
+
if (!Array.isArray(list.value)) return { ok: false, error: "couldn't read what az said" };
|
|
1366
|
+
return {
|
|
1367
|
+
ok: true,
|
|
1368
|
+
prs: list.value.flatMap((p) => openPrOf(r, p) ?? []),
|
|
1369
|
+
...list.value.length >= OPEN_PR_LIMIT2 ? { more: true } : {}
|
|
1370
|
+
};
|
|
1371
|
+
},
|
|
1372
|
+
// Each comment its own thread, then the summary, then the vote: what went out before a failure is said, so a retry
|
|
1373
|
+
// sends none of it again; a call that failed without a clear refusal may have gone through (`inDoubt`), and the
|
|
1374
|
+
// steps after it weren't tried (`rest`: if it went, the review went only in part).
|
|
1375
|
+
async submitReview(run, cwd, number, review) {
|
|
1376
|
+
const r = repoAt(cwd);
|
|
1377
|
+
if (!r) return { ok: false, error: "this repo's origin isn't an Azure DevOps one" };
|
|
1378
|
+
const iteration = review.comments.length ? await iterationAt(run, cwd, r, number, review.commitId) : null;
|
|
1379
|
+
if (iteration && !iteration.ok) return { ok: false, error: iteration.error, posted: 0 };
|
|
1380
|
+
const summary = !!review.body.trim();
|
|
1381
|
+
const vote = review.event !== "comment";
|
|
1382
|
+
for (const [i, c] of review.comments.entries()) {
|
|
1383
|
+
const made = await postThread(run, cwd, r, number, c, iteration?.ok ? iteration.value : 0);
|
|
1384
|
+
if (!made.ok)
|
|
1385
|
+
return {
|
|
1386
|
+
ok: false,
|
|
1387
|
+
error: `${c.path}:${c.line}: ${made.error}`,
|
|
1388
|
+
posted: i,
|
|
1389
|
+
...made.uncertain ? { inDoubt: { comments: [i], summary: false, rest: i < review.comments.length - 1 || summary || vote } } : {}
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
if (summary) {
|
|
1393
|
+
const general = await invoke(run, cwd, r, "pullRequestThreads", { pullRequestId: number }, "POST", {
|
|
1394
|
+
comments: [{ parentCommentId: 0, content: review.body, commentType: 1 }],
|
|
1395
|
+
status: "active"
|
|
1396
|
+
});
|
|
1397
|
+
if (!general.ok)
|
|
1398
|
+
return {
|
|
1399
|
+
ok: false,
|
|
1400
|
+
error: `the summary: ${general.error}`,
|
|
1401
|
+
posted: review.comments.length,
|
|
1402
|
+
...general.uncertain ? { inDoubt: { comments: [], summary: true, rest: vote } } : {}
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
if (review.event !== "comment") {
|
|
1406
|
+
const vote2 = review.event === "approve" ? "approve" : "wait-for-author";
|
|
1407
|
+
const v = await az(run, cwd, ["repos", "pr", "set-vote", "--id", String(number), "--vote", vote2, "--org", r.orgUrl]);
|
|
1408
|
+
if (!v.ok)
|
|
1409
|
+
return {
|
|
1410
|
+
ok: false,
|
|
1411
|
+
error: `the comments went out, the vote didn't: ${v.error}`,
|
|
1412
|
+
posted: review.comments.length,
|
|
1413
|
+
summaryPosted: summary
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
return { ok: true, url: prWebUrl(r, number) };
|
|
1417
|
+
},
|
|
1418
|
+
// Read only: the PR's threads and its reviewers' votes (two GETs through `az devops invoke`).
|
|
1419
|
+
async discussion(run, cwd, number) {
|
|
1420
|
+
const r = repoAt(cwd);
|
|
1421
|
+
if (!r) return { ok: false, error: "this repo's origin isn't an Azure DevOps one" };
|
|
1422
|
+
const threads = await invoke(run, cwd, r, "pullRequestThreads", { pullRequestId: number });
|
|
1423
|
+
if (!threads.ok) return { ok: false, error: threads.error };
|
|
1424
|
+
const pr = await invoke(run, cwd, r, "pullRequests", { pullRequestId: number });
|
|
1425
|
+
if (!pr.ok) return { ok: false, error: pr.error };
|
|
1426
|
+
return { ok: true, discussion: discussionOf(r, number, threads.value?.value ?? [], pr.value ?? null) };
|
|
1427
|
+
},
|
|
1428
|
+
async reviewFeedback(run, cwd, number) {
|
|
1429
|
+
const r = repoAt(cwd);
|
|
1430
|
+
if (!r) return null;
|
|
1431
|
+
const me = await viewer(run, cwd);
|
|
1432
|
+
if (!me) return null;
|
|
1433
|
+
const threads = await invoke(run, cwd, r, "pullRequestThreads", { pullRequestId: number });
|
|
1434
|
+
if (!threads.ok) return null;
|
|
1435
|
+
return feedbackOf(r, number, threads.value?.value ?? [], me);
|
|
1436
|
+
},
|
|
1437
|
+
threads: {
|
|
1438
|
+
isId: (id) => AZURE_THREAD_ID.test(id),
|
|
1439
|
+
repoOf: azureThreadRepoId,
|
|
1440
|
+
async now(run, cwd, id) {
|
|
1441
|
+
const t = parseAzureThreadId(id);
|
|
1442
|
+
if (!t) return { ok: false, error: "not an Azure DevOps thread id" };
|
|
1443
|
+
const me = await viewer(run, cwd);
|
|
1444
|
+
const got = await invoke(run, cwd, t.repo, "pullRequestThreads", { pullRequestId: t.pr, threadId: t.thread });
|
|
1445
|
+
if (!me || !got.ok || !got.value)
|
|
1446
|
+
return { ok: false, error: `couldn't read the thread on Azure DevOps first${got.ok ? "" : `: ${got.error}`}` };
|
|
1447
|
+
const people = (got.value.comments ?? []).filter((c) => c && !c.isDeleted && c.commentType !== "system");
|
|
1448
|
+
return {
|
|
1449
|
+
ok: true,
|
|
1450
|
+
thread: {
|
|
1451
|
+
viewer: me,
|
|
1452
|
+
resolved: RESOLVED_THREAD.has(got.value.status ?? ""),
|
|
1453
|
+
lastAuthor: people.at(-1)?.author?.uniqueName ?? null
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
},
|
|
1457
|
+
async live(run, cwd, id) {
|
|
1458
|
+
const t = parseAzureThreadId(id);
|
|
1459
|
+
if (!t) return { ok: false, error: "not an Azure DevOps thread id" };
|
|
1460
|
+
const me = await viewer(run, cwd);
|
|
1461
|
+
const got = await invoke(run, cwd, t.repo, "pullRequestThreads", { pullRequestId: t.pr, threadId: t.thread });
|
|
1462
|
+
const pr = await az(run, cwd, ["repos", "pr", "show", "--id", String(t.pr), "--org", t.repo.orgUrl]);
|
|
1463
|
+
if (!me || !got.ok || !got.value || !pr.ok) return { ok: false, error: `${id} isn't a review thread Azure DevOps knows` };
|
|
1464
|
+
const people = (got.value.comments ?? []).filter((c) => c && !c.isDeleted && c.commentType !== "system");
|
|
1465
|
+
const first = people[0];
|
|
1466
|
+
const last = people.at(-1);
|
|
1467
|
+
const url = `${prWebUrl(t.repo, t.pr)}?discussionId=${t.thread}`;
|
|
1468
|
+
const ctx = got.value.threadContext;
|
|
1469
|
+
const repo = parseAzureOrigin(`${t.repo.orgUrl}/${encodeURIComponent(t.repo.project)}/_git/${encodeURIComponent(t.repo.repo)}`);
|
|
1470
|
+
return {
|
|
1471
|
+
ok: true,
|
|
1472
|
+
thread: {
|
|
1473
|
+
viewer: me,
|
|
1474
|
+
resolved: RESOLVED_THREAD.has(got.value.status ?? ""),
|
|
1475
|
+
outdated: false,
|
|
1476
|
+
path: ctx?.filePath ? ctx.filePath.replace(/^\//, "") : null,
|
|
1477
|
+
line: ctx?.rightFileEnd?.line ?? null,
|
|
1478
|
+
originalStartLine: null,
|
|
1479
|
+
originalLine: null,
|
|
1480
|
+
first: first ? { author: first.author?.uniqueName ?? "", body: first.content ?? "", url, diffHunk: null } : null,
|
|
1481
|
+
last: last ? { author: last.author?.uniqueName ?? "", url } : null,
|
|
1482
|
+
pr: {
|
|
1483
|
+
number: t.pr,
|
|
1484
|
+
url: prWebUrl(t.repo, t.pr),
|
|
1485
|
+
headBranch: (pr.value?.sourceRefName ?? "").replace(/^refs\/heads\//, ""),
|
|
1486
|
+
repoId: repo ? `${repo.org}/${repo.project}/${repo.repo}`.toLowerCase() : ""
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
},
|
|
1491
|
+
async isResolved(run, cwd, id) {
|
|
1492
|
+
const t = parseAzureThreadId(id);
|
|
1493
|
+
if (!t) return null;
|
|
1494
|
+
const got = await invoke(run, cwd, t.repo, "pullRequestThreads", { pullRequestId: t.pr, threadId: t.thread });
|
|
1495
|
+
return got.ok && got.value?.status ? RESOLVED_THREAD.has(got.value.status) : null;
|
|
1496
|
+
},
|
|
1497
|
+
async reply(run, cwd, id, body) {
|
|
1498
|
+
const t = parseAzureThreadId(id);
|
|
1499
|
+
if (!t) return { ok: false, error: "not an Azure DevOps thread id" };
|
|
1500
|
+
const made = await invoke(run, cwd, t.repo, "pullRequestThreadComments", { pullRequestId: t.pr, threadId: t.thread }, "POST", {
|
|
1501
|
+
content: body,
|
|
1502
|
+
parentCommentId: 1,
|
|
1503
|
+
commentType: 1
|
|
1504
|
+
});
|
|
1505
|
+
return made.ok ? { ok: true, url: `${prWebUrl(t.repo, t.pr)}?discussionId=${t.thread}` } : { ok: false, error: made.error };
|
|
1506
|
+
},
|
|
1507
|
+
async resolve(run, cwd, id) {
|
|
1508
|
+
const t = parseAzureThreadId(id);
|
|
1509
|
+
if (!t) return false;
|
|
1510
|
+
const done = await invoke(run, cwd, t.repo, "pullRequestThreads", { pullRequestId: t.pr, threadId: t.thread }, "PATCH", {
|
|
1511
|
+
status: "fixed"
|
|
1512
|
+
});
|
|
1513
|
+
return done.ok;
|
|
1514
|
+
}
|
|
1515
|
+
},
|
|
1516
|
+
rateLimited: (text) => THROTTLED.test(text),
|
|
1517
|
+
// A completed PR's merge commit is the user's own (Azure DevOps commits as the person completing it).
|
|
1518
|
+
hostCommit: () => false,
|
|
1519
|
+
commands: azureCommands
|
|
1520
|
+
};
|
|
1521
|
+
|
|
1522
|
+
// src/core/hosts/index.ts
|
|
1523
|
+
var builtIn = [github, azure];
|
|
1524
|
+
var registered = [];
|
|
1525
|
+
function knownHosts() {
|
|
1526
|
+
return [...registered, ...builtIn];
|
|
1527
|
+
}
|
|
1528
|
+
function hostById(id) {
|
|
1529
|
+
return knownHosts().find((h) => h.id === id) ?? null;
|
|
1530
|
+
}
|
|
1531
|
+
function defaultHost() {
|
|
1532
|
+
return hostById(DEFAULT_HOST) ?? github;
|
|
1533
|
+
}
|
|
1534
|
+
var overrides = configView((raw) => {
|
|
1535
|
+
const out = /* @__PURE__ */ new Map();
|
|
1536
|
+
const v = raw?.gitHosts;
|
|
1537
|
+
if (v && typeof v === "object" && !Array.isArray(v)) {
|
|
1538
|
+
for (const [k, id] of Object.entries(v)) if (typeof id === "string") out.set(k.toLowerCase(), id);
|
|
1539
|
+
}
|
|
1540
|
+
return out;
|
|
1541
|
+
});
|
|
1542
|
+
function hostForOrigin(origin, deps = {}) {
|
|
1543
|
+
if (origin) {
|
|
1544
|
+
const name = originHostname(origin);
|
|
1545
|
+
const named = name ? hostById((deps.overrides ?? overrides)().get(name)) : null;
|
|
1546
|
+
if (named) return named;
|
|
1547
|
+
const claimed = knownHosts().find((h) => h.matches(origin));
|
|
1548
|
+
if (claimed) return claimed;
|
|
1549
|
+
}
|
|
1550
|
+
return defaultHost();
|
|
1551
|
+
}
|
|
1552
|
+
function hostForRepo(repoPath, deps = {}) {
|
|
1553
|
+
const text = (deps.gitConfig ?? readGitConfig)(repoPath);
|
|
1554
|
+
const origin = text ? originUrl(text) : null;
|
|
1555
|
+
return { host: hostForOrigin(origin, deps), origin };
|
|
1556
|
+
}
|
|
1557
|
+
function hostOfThread(id) {
|
|
1558
|
+
return knownHosts().find((h) => h.threads.isId(id)) ?? null;
|
|
1559
|
+
}
|
|
1560
|
+
function hostOfPrUrl(text) {
|
|
1561
|
+
for (const host of knownHosts()) {
|
|
1562
|
+
const link = host.parsePrUrl(text);
|
|
1563
|
+
if (link) return { host, link };
|
|
1564
|
+
}
|
|
1565
|
+
return null;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
export {
|
|
1569
|
+
originHostname,
|
|
1570
|
+
knownHosts,
|
|
1571
|
+
hostById,
|
|
1572
|
+
defaultHost,
|
|
1573
|
+
hostForOrigin,
|
|
1574
|
+
hostForRepo,
|
|
1575
|
+
hostOfThread,
|
|
1576
|
+
hostOfPrUrl
|
|
1577
|
+
};
|
|
1578
|
+
//# sourceMappingURL=chunk-7RHC5U7X.js.map
|