@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,243 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
MAX_WATCHED_BRANCHES,
|
|
4
|
+
backfillSessionBranches,
|
|
5
|
+
branchHidden,
|
|
6
|
+
noteBranchFacts,
|
|
7
|
+
readSessionBranches,
|
|
8
|
+
repoNameOf
|
|
9
|
+
} from "./chunk-2ZQRD73B.js";
|
|
10
|
+
import {
|
|
11
|
+
defaultRunner
|
|
12
|
+
} from "./chunk-KSVYR4G2.js";
|
|
13
|
+
import {
|
|
14
|
+
bestEffort,
|
|
15
|
+
checkedOutBranch,
|
|
16
|
+
logSwallowed,
|
|
17
|
+
stageOfPr
|
|
18
|
+
} from "./chunk-ZG2M4ECW.js";
|
|
19
|
+
import {
|
|
20
|
+
sessionIdFor
|
|
21
|
+
} from "./chunk-RUYTU2WJ.js";
|
|
22
|
+
|
|
23
|
+
// src/core/stacks/branch-facts.ts
|
|
24
|
+
async function repoBase(repo, run = defaultRunner) {
|
|
25
|
+
const head = await run("git", ["-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], repo);
|
|
26
|
+
const base = head.code === 0 ? head.stdout.trim() : "";
|
|
27
|
+
return base && base !== "origin/HEAD" ? base : null;
|
|
28
|
+
}
|
|
29
|
+
var count = (out) => out.code === 0 && /^\d+$/.test(out.stdout.trim()) ? Number(out.stdout.trim()) : null;
|
|
30
|
+
async function branchFacts(repo, name, run = defaultRunner, base) {
|
|
31
|
+
const git = (...args) => run("git", ["-C", repo, ...args], repo);
|
|
32
|
+
const local = `refs/heads/${name}`;
|
|
33
|
+
const remote = `refs/remotes/origin/${name}`;
|
|
34
|
+
const tip = await git("rev-parse", "--verify", "--quiet", local);
|
|
35
|
+
const exists = tip.code === 0;
|
|
36
|
+
const pushed = (await git("rev-parse", "--verify", "--quiet", remote)).code === 0;
|
|
37
|
+
if (!exists) return { exists, sha: null, pushed, commits: null, unpushed: null, merged: false };
|
|
38
|
+
const main = base === void 0 ? await repoBase(repo, run) : base;
|
|
39
|
+
const commits = main ? count(await git("rev-list", "--count", `${main}..${local}`)) : null;
|
|
40
|
+
const unpushed = pushed ? count(await git("rev-list", "--count", `${remote}..${local}`)) : commits;
|
|
41
|
+
const isBase = !!main && main === `origin/${name}`;
|
|
42
|
+
return {
|
|
43
|
+
exists,
|
|
44
|
+
sha: tip.stdout.trim() || null,
|
|
45
|
+
pushed,
|
|
46
|
+
commits,
|
|
47
|
+
unpushed,
|
|
48
|
+
merged: !isBase && pushed && commits === 0,
|
|
49
|
+
...isBase ? { base: true } : {}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var factsKey = (repo, name) => `${repo}\0${name}`;
|
|
53
|
+
var BranchFactsCache = class {
|
|
54
|
+
constructor(opts = {}) {
|
|
55
|
+
this.opts = opts;
|
|
56
|
+
}
|
|
57
|
+
entries = /* @__PURE__ */ new Map();
|
|
58
|
+
running = 0;
|
|
59
|
+
queue = [];
|
|
60
|
+
/** What the last look found (an empty map before the first); schedules one when stale or the branches changed. */
|
|
61
|
+
get(id, jobs) {
|
|
62
|
+
const now = (this.opts.now ?? Date.now)();
|
|
63
|
+
const key = jobs.map((j) => factsKey(j.repo, j.name)).join("|");
|
|
64
|
+
const e = this.entries.get(id);
|
|
65
|
+
const moved = !!e && e.key !== key;
|
|
66
|
+
if (!e || moved || !e.inFlight && now - e.at > (this.opts.ttlMs ?? 5 * 6e4)) this.schedule(id, jobs, key);
|
|
67
|
+
return this.entries.get(id)?.value ?? /* @__PURE__ */ new Map();
|
|
68
|
+
}
|
|
69
|
+
/** Look again soon (a turn ended, a push). */
|
|
70
|
+
invalidate(id) {
|
|
71
|
+
const e = this.entries.get(id);
|
|
72
|
+
if (e) e.at = 0;
|
|
73
|
+
}
|
|
74
|
+
async idle() {
|
|
75
|
+
while (this.running > 0 || this.queue.length > 0) await new Promise((r) => setTimeout(r, 5));
|
|
76
|
+
}
|
|
77
|
+
schedule(id, jobs, key) {
|
|
78
|
+
const e = this.entries.get(id) ?? { value: /* @__PURE__ */ new Map(), at: 0, inFlight: false, key };
|
|
79
|
+
if (e.inFlight && e.key === key) return;
|
|
80
|
+
e.inFlight = true;
|
|
81
|
+
e.key = key;
|
|
82
|
+
this.entries.set(id, e);
|
|
83
|
+
this.queue.push({ id, jobs });
|
|
84
|
+
this.pump();
|
|
85
|
+
}
|
|
86
|
+
pump() {
|
|
87
|
+
while (this.running < (this.opts.concurrency ?? 2) && this.queue.length > 0) {
|
|
88
|
+
const job = this.queue.shift();
|
|
89
|
+
this.running++;
|
|
90
|
+
void lookAt(job.jobs, this.opts.run).catch((err) => {
|
|
91
|
+
logSwallowed(`branch facts for ${job.id}`, err);
|
|
92
|
+
return null;
|
|
93
|
+
}).then((found) => {
|
|
94
|
+
const e = this.entries.get(job.id);
|
|
95
|
+
e.inFlight = false;
|
|
96
|
+
e.at = (this.opts.now ?? Date.now)();
|
|
97
|
+
if (!found) return;
|
|
98
|
+
const value = new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)]));
|
|
99
|
+
const changed = JSON.stringify([...e.value]) !== JSON.stringify([...value]);
|
|
100
|
+
e.value = value;
|
|
101
|
+
this.opts.onFacts?.(job.id, found);
|
|
102
|
+
if (changed) this.opts.onChange?.();
|
|
103
|
+
}).finally(() => {
|
|
104
|
+
this.running--;
|
|
105
|
+
this.pump();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var strip = (f) => ({
|
|
111
|
+
exists: f.exists,
|
|
112
|
+
sha: f.sha,
|
|
113
|
+
pushed: f.pushed,
|
|
114
|
+
commits: f.commits,
|
|
115
|
+
unpushed: f.unpushed,
|
|
116
|
+
merged: f.merged
|
|
117
|
+
});
|
|
118
|
+
async function lookAt(jobs, run) {
|
|
119
|
+
const bases = /* @__PURE__ */ new Map();
|
|
120
|
+
const out = [];
|
|
121
|
+
for (const j of jobs) {
|
|
122
|
+
if (!bases.has(j.path)) bases.set(j.path, await repoBase(j.path, run));
|
|
123
|
+
out.push({ ...j, ...await branchFacts(j.path, j.name, run, bases.get(j.path)) });
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
function prOfBranch(ci, repo, name) {
|
|
128
|
+
const r = ci?.repos.find((x) => x.name === repo);
|
|
129
|
+
if (!r) return null;
|
|
130
|
+
if (r.branch === name && r.pr) return r.pr;
|
|
131
|
+
return r.otherPrs?.find((o) => o.branch === name)?.pr ?? null;
|
|
132
|
+
}
|
|
133
|
+
function branchesWire(rec, current, facts, ci, now) {
|
|
134
|
+
if (!rec?.branches.length) return null;
|
|
135
|
+
const rows = [];
|
|
136
|
+
for (const b of rec.branches) {
|
|
137
|
+
const pr = prOfBranch(ci, b.repo, b.name);
|
|
138
|
+
if (branchHidden(b, now, pr?.state === "MERGED")) continue;
|
|
139
|
+
const f = facts.get(factsKey(b.repo, b.name));
|
|
140
|
+
rows.push({
|
|
141
|
+
repo: b.repo,
|
|
142
|
+
name: b.name,
|
|
143
|
+
current: current(b.repo) === b.name,
|
|
144
|
+
firstSeen: b.firstSeen,
|
|
145
|
+
lastSeen: b.lastSeen,
|
|
146
|
+
...b.from ? { from: b.from } : {},
|
|
147
|
+
...f ? {
|
|
148
|
+
exists: f.exists,
|
|
149
|
+
pushed: f.pushed,
|
|
150
|
+
commits: f.commits,
|
|
151
|
+
unpushed: f.unpushed,
|
|
152
|
+
// Merged as kept once seen — unless the branch, there now, has work of its own again (commits its base
|
|
153
|
+
// lacks) or is the main line itself: a repo's own main read "6 commits · 6 not pushed · merged". Its PR
|
|
154
|
+
// merged still says so (a squash merge leaves its commits unmerged).
|
|
155
|
+
merged: pr?.state === "MERGED" || !(f.exists && (f.base || (f.commits ?? 0) > 0)) && (f.merged || !!b.merged)
|
|
156
|
+
} : b.merged || pr?.state === "MERGED" ? { merged: true } : {},
|
|
157
|
+
...pr ? { pr: { number: pr.number, url: pr.url, state: pr.state, kind: stageOfPr(pr) } } : {}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const repos = new Set(rows.map((r) => r.repo));
|
|
161
|
+
if (![...repos].some((repo) => rows.filter((r) => r.repo === repo).length > 1)) return null;
|
|
162
|
+
return rows.sort(
|
|
163
|
+
(a, b) => Number(b.current) - Number(a.current) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen) || a.repo.localeCompare(b.repo)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
function createSessionBranches(opts = {}) {
|
|
167
|
+
const now = opts.now ?? Date.now;
|
|
168
|
+
const facts = new BranchFactsCache({
|
|
169
|
+
...opts.run ? { run: opts.run } : {},
|
|
170
|
+
now,
|
|
171
|
+
onChange: opts.onChange,
|
|
172
|
+
onFacts: (id, found) => bestEffort(`keep the branch facts of ${id}`, () => (opts.keepFacts ?? ((sid, f) => noteBranchFacts(sid, f)))(id, found))
|
|
173
|
+
});
|
|
174
|
+
const backfill = opts.backfill ?? ((s) => backfillSessionBranches(s));
|
|
175
|
+
const asked = /* @__PURE__ */ new Set();
|
|
176
|
+
const waiting = [];
|
|
177
|
+
let busy = false;
|
|
178
|
+
const pump = () => {
|
|
179
|
+
if (busy) return;
|
|
180
|
+
const s = waiting.shift();
|
|
181
|
+
if (!s) return;
|
|
182
|
+
busy = true;
|
|
183
|
+
setImmediate(() => {
|
|
184
|
+
const rec = bestEffort(`read the branches of ${s.target}:${s.branch} from its reflog`, () => backfill(s));
|
|
185
|
+
busy = false;
|
|
186
|
+
if (rec && branchJobs(s, rec, now())) opts.onChange?.();
|
|
187
|
+
pump();
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
return {
|
|
191
|
+
/** The row's branches (branchesWire), from what was recorded and last looked at. */
|
|
192
|
+
wire(s, rec, ci) {
|
|
193
|
+
if (s.archivedAt) return null;
|
|
194
|
+
const id = sessionIdFor(s);
|
|
195
|
+
if (!rec?.backfilled && !asked.has(id)) {
|
|
196
|
+
asked.add(id);
|
|
197
|
+
waiting.push(s);
|
|
198
|
+
pump();
|
|
199
|
+
}
|
|
200
|
+
const plan = branchJobs(s, rec, now());
|
|
201
|
+
return plan ? branchesWire(rec, plan.current, facts.get(id, plan.jobs), ci, now()) : null;
|
|
202
|
+
},
|
|
203
|
+
invalidate: (id) => facts.invalidate(id),
|
|
204
|
+
async idle() {
|
|
205
|
+
await facts.idle();
|
|
206
|
+
while (busy || waiting.length) await new Promise((r) => setTimeout(r, 5));
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function branchJobs(s, rec, now) {
|
|
211
|
+
if (!rec?.branches.length) return null;
|
|
212
|
+
const currentOf = new Map(s.paths.map((p) => [repoNameOf(s, p), checkedOutBranch(p)]));
|
|
213
|
+
const visible = rec.branches.filter((b) => !branchHidden(b, now));
|
|
214
|
+
const repos = new Set(visible.map((b) => b.repo));
|
|
215
|
+
if (![...repos].some((r) => visible.filter((b) => b.repo === r).length > 1)) return null;
|
|
216
|
+
const pathOf = new Map(s.paths.map((p) => [repoNameOf(s, p), p]));
|
|
217
|
+
const jobs = [];
|
|
218
|
+
for (const repo of repos) {
|
|
219
|
+
const p = pathOf.get(repo);
|
|
220
|
+
if (!p) continue;
|
|
221
|
+
const isCurrent = (name) => Number(name === currentOf.get(repo));
|
|
222
|
+
const mine = visible.filter((b) => b.repo === repo).sort((a, b) => isCurrent(b.name) - isCurrent(a.name) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen)).slice(0, MAX_WATCHED_BRANCHES + 1);
|
|
223
|
+
for (const b of mine) jobs.push({ repo, path: p, name: b.name });
|
|
224
|
+
}
|
|
225
|
+
return { jobs, current: (repo) => currentOf.get(repo) ?? null };
|
|
226
|
+
}
|
|
227
|
+
async function sessionBranchesNow(s, ci, run = defaultRunner, now = Date.now()) {
|
|
228
|
+
if (s.archivedAt) return null;
|
|
229
|
+
let rec = readSessionBranches(sessionIdFor(s));
|
|
230
|
+
if (!rec?.backfilled) rec = bestEffort(`read the branches of ${s.target}:${s.branch}`, () => backfillSessionBranches(s), rec) ?? rec;
|
|
231
|
+
const plan = branchJobs(s, rec, now);
|
|
232
|
+
if (!plan) return null;
|
|
233
|
+
const found = await lookAt(plan.jobs, run);
|
|
234
|
+
return branchesWire(rec, plan.current, new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)])), ci, now);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
repoBase,
|
|
239
|
+
branchFacts,
|
|
240
|
+
createSessionBranches,
|
|
241
|
+
sessionBranchesNow
|
|
242
|
+
};
|
|
243
|
+
//# sourceMappingURL=chunk-F2NOCGMA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/stacks/branch-facts.ts"],"sourcesContent":["import { defaultRunner, type CommandRunner } from '../platform/command-runner.js';\nimport { bestEffort, logSwallowed } from '../platform/best-effort.js';\nimport type { SessionBranchWire, SessionCi, ShipPr } from '../api-types.js';\nimport { stageOfPr } from '../pr/pr-stage.js';\nimport {\n backfillSessionBranches,\n branchHidden,\n MAX_WATCHED_BRANCHES,\n noteBranchFacts,\n readSessionBranches,\n repoNameOf,\n type SessionBranches,\n} from '../sessions/session-branches.js';\nimport { checkedOutBranch } from '../git/git-head.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport type { WorktreeSession } from '../sessions/session-types.js';\n\n/**\n * What a session's other branches hold (session-branches.ts records them):\n * still there, pushed, how many commits its base lacks, how many origin\n * lacks, merged. Git through a CommandRunner (argv only), a few runs per\n * branch — so read in the background (BranchFactsCache, beside behind-main's)\n * and by the PR watch's preflight, never on a request's path.\n */\n\nexport interface BranchFacts {\n exists: boolean;\n /** Its tip, when it exists. */\n sha: string | null;\n /** `origin/<name>` exists. */\n pushed: boolean;\n /** Commits on it that its base (origin/HEAD) doesn't have; null: unknown. */\n commits: number | null;\n /** Commits on it that origin doesn't have (all of `commits` when never pushed); null: unknown. */\n unpushed: number | null;\n /** Its commits are all in its base, and it was pushed (a branch merged the usual way). Never the base itself. */\n merged: boolean;\n /** It is the repo's main line itself (`main` when origin/HEAD is origin/main): never \"merged\" into itself. */\n base?: true;\n}\n\n/** The repo's main line (`origin/main`), as origin/HEAD names it; null when it doesn't. */\nexport async function repoBase(repo: string, run: CommandRunner = defaultRunner): Promise<string | null> {\n const head = await run('git', ['-C', repo, 'rev-parse', '--abbrev-ref', 'origin/HEAD'], repo);\n const base = head.code === 0 ? head.stdout.trim() : '';\n return base && base !== 'origin/HEAD' ? base : null;\n}\n\nconst count = (out: { code: number; stdout: string }) =>\n out.code === 0 && /^\\d+$/.test(out.stdout.trim()) ? Number(out.stdout.trim()) : null;\n\n/** One branch of one repo. `base`: the repo's main line (repoBase), passed so a repo's branches ask it once. */\nexport async function branchFacts(\n repo: string,\n name: string,\n run: CommandRunner = defaultRunner,\n base?: string | null,\n): Promise<BranchFacts> {\n const git = (...args: string[]) => run('git', ['-C', repo, ...args], repo);\n const local = `refs/heads/${name}`;\n const remote = `refs/remotes/origin/${name}`;\n const tip = await git('rev-parse', '--verify', '--quiet', local);\n const exists = tip.code === 0;\n const pushed = (await git('rev-parse', '--verify', '--quiet', remote)).code === 0;\n if (!exists) return { exists, sha: null, pushed, commits: null, unpushed: null, merged: false };\n const main = base === undefined ? await repoBase(repo, run) : base;\n const commits = main ? count(await git('rev-list', '--count', `${main}..${local}`)) : null;\n const unpushed = pushed ? count(await git('rev-list', '--count', `${remote}..${local}`)) : commits;\n // The main line itself is level with origin/main whenever it's pushed: that isn't a merge (it read \"merged\").\n const isBase = !!main && main === `origin/${name}`;\n return {\n exists,\n sha: tip.stdout.trim() || null,\n pushed,\n commits,\n unpushed,\n merged: !isBase && pushed && commits === 0,\n ...(isBase ? { base: true as const } : {}),\n };\n}\n\n/** A repo's other branches to look at: by name, in its checkout. */\nexport interface BranchJob {\n repo: string;\n path: string;\n name: string;\n}\n\nexport const factsKey = (repo: string, name: string) => `${repo}\\u0000${name}`;\n\n/**\n * Per session, refreshed in the background a couple of sessions at a time;\n * reads never wait (BehindCache's way). `onFacts`: what a look found, to keep\n * (a branch seen deleted, or merged: session-branches.ts `noteBranchFacts`).\n */\nexport class BranchFactsCache {\n private readonly entries = new Map<string, { value: Map<string, BranchFacts>; at: number; inFlight: boolean; key: string }>();\n private running = 0;\n private readonly queue: Array<{ id: string; jobs: BranchJob[] }> = [];\n\n constructor(\n private readonly opts: {\n ttlMs?: number;\n concurrency?: number;\n run?: CommandRunner;\n onChange?: () => void;\n onFacts?: (id: string, facts: Array<BranchJob & BranchFacts>) => void;\n now?: () => number;\n } = {},\n ) {}\n\n /** What the last look found (an empty map before the first); schedules one when stale or the branches changed. */\n get(id: string, jobs: BranchJob[]): Map<string, BranchFacts> {\n const now = (this.opts.now ?? Date.now)();\n const key = jobs.map((j) => factsKey(j.repo, j.name)).join('|');\n const e = this.entries.get(id);\n const moved = !!e && e.key !== key;\n if (!e || moved || (!e.inFlight && now - e.at > (this.opts.ttlMs ?? 5 * 60_000))) this.schedule(id, jobs, key);\n return this.entries.get(id)?.value ?? new Map();\n }\n\n /** Look again soon (a turn ended, a push). */\n invalidate(id: string): void {\n const e = this.entries.get(id);\n if (e) e.at = 0;\n }\n\n async idle(): Promise<void> {\n while (this.running > 0 || this.queue.length > 0) await new Promise((r) => setTimeout(r, 5));\n }\n\n private schedule(id: string, jobs: BranchJob[], key: string): void {\n const e = this.entries.get(id) ?? { value: new Map<string, BranchFacts>(), at: 0, inFlight: false, key };\n if (e.inFlight && e.key === key) return;\n e.inFlight = true;\n e.key = key;\n this.entries.set(id, e);\n this.queue.push({ id, jobs });\n this.pump();\n }\n\n private pump(): void {\n while (this.running < (this.opts.concurrency ?? 2) && this.queue.length > 0) {\n const job = this.queue.shift()!;\n this.running++;\n void lookAt(job.jobs, this.opts.run)\n .catch((err) => {\n logSwallowed(`branch facts for ${job.id}`, err);\n return null;\n })\n .then((found) => {\n const e = this.entries.get(job.id)!;\n e.inFlight = false;\n e.at = (this.opts.now ?? Date.now)();\n if (!found) return;\n const value = new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)]));\n const changed = JSON.stringify([...e.value]) !== JSON.stringify([...value]);\n e.value = value;\n this.opts.onFacts?.(job.id, found);\n if (changed) this.opts.onChange?.();\n })\n .finally(() => {\n this.running--;\n this.pump();\n });\n }\n }\n}\n\nconst strip = (f: BranchJob & BranchFacts): BranchFacts => ({\n exists: f.exists,\n sha: f.sha,\n pushed: f.pushed,\n commits: f.commits,\n unpushed: f.unpushed,\n merged: f.merged,\n});\n\nasync function lookAt(jobs: BranchJob[], run?: CommandRunner): Promise<Array<BranchJob & BranchFacts>> {\n const bases = new Map<string, string | null>();\n const out: Array<BranchJob & BranchFacts> = [];\n for (const j of jobs) {\n if (!bases.has(j.path)) bases.set(j.path, await repoBase(j.path, run));\n out.push({ ...j, ...(await branchFacts(j.path, j.name, run, bases.get(j.path))) });\n }\n return out;\n}\n\n/** The PR of a repo's branch, from the PR watch's last check: the checked-out one's, or another's. */\nexport function prOfBranch(ci: SessionCi | null | undefined, repo: string, name: string): ShipPr | null {\n const r = ci?.repos.find((x) => x.name === repo);\n if (!r) return null;\n if (r.branch === name && r.pr) return r.pr;\n return r.otherPrs?.find((o) => o.branch === name)?.pr ?? null;\n}\n\n/**\n * The branches a session's row shows: every recorded one not hidden (merged\n * and deleted a while ago), each with its facts and PR, the checked-out ones\n * first, the rest newest first. Null unless some repo has been on more than\n * one: a session that stayed on its branch shows nothing new. Pure.\n */\nexport function branchesWire(\n rec: SessionBranches | null | undefined,\n current: (repo: string) => string | null,\n facts: Map<string, BranchFacts>,\n ci: SessionCi | null | undefined,\n now: number,\n): SessionBranchWire[] | null {\n if (!rec?.branches.length) return null;\n const rows: SessionBranchWire[] = [];\n for (const b of rec.branches) {\n const pr = prOfBranch(ci, b.repo, b.name);\n if (branchHidden(b, now, pr?.state === 'MERGED')) continue;\n const f = facts.get(factsKey(b.repo, b.name));\n rows.push({\n repo: b.repo,\n name: b.name,\n current: current(b.repo) === b.name,\n firstSeen: b.firstSeen,\n lastSeen: b.lastSeen,\n ...(b.from ? { from: b.from } : {}),\n ...(f\n ? {\n exists: f.exists,\n pushed: f.pushed,\n commits: f.commits,\n unpushed: f.unpushed,\n // Merged as kept once seen — unless the branch, there now, has work of its own again (commits its base\n // lacks) or is the main line itself: a repo's own main read \"6 commits · 6 not pushed · merged\". Its PR\n // merged still says so (a squash merge leaves its commits unmerged).\n merged: pr?.state === 'MERGED' || (!(f.exists && (f.base || (f.commits ?? 0) > 0)) && (f.merged || !!b.merged)),\n }\n : b.merged || pr?.state === 'MERGED'\n ? { merged: true }\n : {}),\n ...(pr ? { pr: { number: pr.number, url: pr.url, state: pr.state, kind: stageOfPr(pr) } } : {}),\n });\n }\n const repos = new Set(rows.map((r) => r.repo));\n if (![...repos].some((repo) => rows.filter((r) => r.repo === repo).length > 1)) return null;\n return rows.sort(\n (a, b) => Number(b.current) - Number(a.current) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen) || a.repo.localeCompare(b.repo),\n );\n}\n\n/**\n * The sessions list's branches (work web): each row's recorded branches with\n * their facts — read in the background (BranchFactsCache), what it finds kept\n * (deleted, merged, pushed once) — and, once per session recorded before the\n * list began, its reflog read into the record (backfillSessionBranches), one\n * session at a time, off the request's path. `wire` never runs git.\n */\nexport function createSessionBranches(\n opts: {\n onChange?: () => void;\n run?: CommandRunner;\n now?: () => number;\n /** Tests: the reflog read and the fact keeping (default: session-branches.ts). */\n backfill?: (s: WorktreeSession) => SessionBranches | void;\n keepFacts?: (id: string, facts: Array<BranchJob & BranchFacts>) => void;\n } = {},\n) {\n const now = opts.now ?? Date.now;\n const facts = new BranchFactsCache({\n ...(opts.run ? { run: opts.run } : {}),\n now,\n onChange: opts.onChange,\n onFacts: (id, found) =>\n bestEffort(`keep the branch facts of ${id}`, () => (opts.keepFacts ?? ((sid, f) => noteBranchFacts(sid, f)))(id, found)),\n });\n const backfill = opts.backfill ?? ((s: WorktreeSession) => backfillSessionBranches(s));\n const asked = new Set<string>();\n const waiting: WorktreeSession[] = [];\n let busy = false;\n const pump = () => {\n if (busy) return;\n const s = waiting.shift();\n if (!s) return;\n busy = true;\n setImmediate(() => {\n const rec = bestEffort(`read the branches of ${s.target}:${s.branch} from its reflog`, () => backfill(s));\n busy = false;\n // Only a session that turns out to have worked on more than one branch looks any different.\n if (rec && branchJobs(s, rec, now())) opts.onChange?.();\n pump();\n });\n };\n return {\n /** The row's branches (branchesWire), from what was recorded and last looked at. */\n wire(s: WorktreeSession, rec: SessionBranches | null | undefined, ci: SessionCi | null | undefined): SessionBranchWire[] | null {\n if (s.archivedAt) return null;\n const id = sessionIdFor(s);\n if (!rec?.backfilled && !asked.has(id)) {\n asked.add(id);\n waiting.push(s);\n pump();\n }\n const plan = branchJobs(s, rec, now());\n return plan ? branchesWire(rec, plan.current, facts.get(id, plan.jobs), ci, now()) : null;\n },\n invalidate: (id: string) => facts.invalidate(id),\n async idle(): Promise<void> {\n await facts.idle();\n while (busy || waiting.length) await new Promise((r) => setTimeout(r, 5));\n },\n };\n}\n\n/**\n * What to look at for a session's row: each repo's visible recorded branches (the checked-out one first, then\n * the most recent, at most MAX_WATCHED_BRANCHES others), and what each repo has checked out (HEAD files). Null\n * when no repo has been on more than one branch. No git.\n */\nexport function branchJobs(\n s: Pick<WorktreeSession, 'target' | 'isGroup' | 'paths'>,\n rec: SessionBranches | null | undefined,\n now: number,\n): { jobs: BranchJob[]; current: (repo: string) => string | null } | null {\n if (!rec?.branches.length) return null;\n const currentOf = new Map(s.paths.map((p) => [repoNameOf(s, p), checkedOutBranch(p)]));\n const visible = rec.branches.filter((b) => !branchHidden(b, now));\n const repos = new Set(visible.map((b) => b.repo));\n if (![...repos].some((r) => visible.filter((b) => b.repo === r).length > 1)) return null;\n const pathOf = new Map(s.paths.map((p) => [repoNameOf(s, p), p]));\n const jobs: BranchJob[] = [];\n for (const repo of repos) {\n const p = pathOf.get(repo);\n if (!p) continue;\n const isCurrent = (name: string) => Number(name === currentOf.get(repo));\n const mine = visible\n .filter((b) => b.repo === repo)\n .sort((a, b) => isCurrent(b.name) - isCurrent(a.name) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen))\n .slice(0, MAX_WATCHED_BRANCHES + 1);\n for (const b of mine) jobs.push({ repo, path: p, name: b.name });\n }\n return { jobs, current: (repo) => currentOf.get(repo) ?? null };\n}\n\n/**\n * The same now, for the CLI (`work sessions --json`, `work status`): the record (read from the reflog first\n * when it never was), each branch looked at with git, the PR from the PR watch's last check. Null when it stayed\n * on one branch.\n */\nexport async function sessionBranchesNow(\n s: WorktreeSession,\n ci: SessionCi | null | undefined,\n run: CommandRunner = defaultRunner,\n now = Date.now(),\n): Promise<SessionBranchWire[] | null> {\n if (s.archivedAt) return null;\n let rec = readSessionBranches(sessionIdFor(s));\n if (!rec?.backfilled) rec = bestEffort(`read the branches of ${s.target}:${s.branch}`, () => backfillSessionBranches(s), rec) ?? rec;\n const plan = branchJobs(s, rec, now);\n if (!plan) return null;\n const found = await lookAt(plan.jobs, run);\n return branchesWire(rec, plan.current, new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)])), ci, now);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,eAAsB,SAAS,MAAc,MAAqB,eAAuC;AACvG,QAAM,OAAO,MAAM,IAAI,OAAO,CAAC,MAAM,MAAM,aAAa,gBAAgB,aAAa,GAAG,IAAI;AAC5F,QAAM,OAAO,KAAK,SAAS,IAAI,KAAK,OAAO,KAAK,IAAI;AACpD,SAAO,QAAQ,SAAS,gBAAgB,OAAO;AACjD;AAEA,IAAM,QAAQ,CAAC,QACb,IAAI,SAAS,KAAK,QAAQ,KA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MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG;AACjH;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/core/pr/review-types.ts
|
|
4
|
+
var MAX_THREAD_BODY = 8e3;
|
|
5
|
+
var MAX_HUNK = 12e3;
|
|
6
|
+
function threadCode(hunk, originalStartLine, originalLine, outdated) {
|
|
7
|
+
if (typeof hunk !== "string" || !hunk.startsWith("@@")) return null;
|
|
8
|
+
const end = typeof originalLine === "number" ? originalLine : null;
|
|
9
|
+
const start = typeof originalStartLine === "number" ? originalStartLine : end;
|
|
10
|
+
const lines = end !== null && start !== null && end >= start ? Math.min(end - start + 1, 200) : 1;
|
|
11
|
+
const kept = hunk.length > MAX_HUNK ? `${hunk.split("\n")[0]}
|
|
12
|
+
${hunk.slice(-MAX_HUNK).split("\n").slice(1).join("\n")}` : hunk;
|
|
13
|
+
return { hunk: kept, lines, ...outdated ? { outdated: true } : {} };
|
|
14
|
+
}
|
|
15
|
+
function isThreadCode(v) {
|
|
16
|
+
const c = v;
|
|
17
|
+
return !!c && typeof c === "object" && typeof c.hunk === "string" && c.hunk.startsWith("@@") && typeof c.lines === "number" && c.lines >= 1 && (c.outdated === void 0 || typeof c.outdated === "boolean");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
MAX_THREAD_BODY,
|
|
22
|
+
threadCode,
|
|
23
|
+
isThreadCode
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-FGPXMAYU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/pr/review-types.ts"],"sourcesContent":["import type { ThreadCode } from '../api-types.js';\n\n/**\n * A PR's review feedback as work keeps it, whatever host it came from: its\n * threads (resolved or not, with the code each is on), the reviews and the\n * conversation comments, and who you are. Pure; each host's adapter reads\n * its own API into these (GitHub's: core/hosts/github/review.ts).\n */\n\nexport interface ReviewComment {\n id: string;\n author: string;\n /** GitHub's authorAssociation: OWNER, MEMBER, COLLABORATOR, CONTRIBUTOR,\n * FIRST_TIME_CONTRIBUTOR, NONE, … */\n association: string;\n body: string;\n url: string;\n createdAt: string;\n}\nexport interface ReviewThread {\n id: string;\n isResolved: boolean;\n isOutdated: boolean;\n path: string | null;\n line: number | null;\n /** The code it's on (its first comment's diff hunk), when it's on a line. */\n code?: ThreadCode | null;\n comments: ReviewComment[];\n}\n\n/** The most of a comment kept for the dashboard (a review can paste a log): the rest is on GitHub. */\nexport const MAX_THREAD_BODY = 8000;\n/** The most of a diff hunk kept: its end is what matters, and the view shows only the last lines. */\nconst MAX_HUNK = 12_000;\n\n/** A thread's code from what GitHub gives (its first comment's hunk, the original line range); null when it has none. Pure. */\nexport function threadCode(hunk: unknown, originalStartLine: unknown, originalLine: unknown, outdated: boolean): ThreadCode | null {\n if (typeof hunk !== 'string' || !hunk.startsWith('@@')) return null;\n const end = typeof originalLine === 'number' ? originalLine : null;\n const start = typeof originalStartLine === 'number' ? originalStartLine : end;\n const lines = end !== null && start !== null && end >= start ? Math.min(end - start + 1, 200) : 1;\n // Too long: keep the header and the end (the commented line is the last).\n const kept = hunk.length > MAX_HUNK ? `${hunk.split('\\n')[0]}\\n${hunk.slice(-MAX_HUNK).split('\\n').slice(1).join('\\n')}` : hunk;\n return { hunk: kept, lines, ...(outdated ? { outdated: true } : {}) };\n}\n\n/** A stored thread code as written here; anything else is dropped. Pure. */\nexport function isThreadCode(v: unknown): v is ThreadCode {\n const c = v as Partial<ThreadCode> | null;\n return (\n !!c &&\n typeof c === 'object' &&\n typeof c.hunk === 'string' &&\n c.hunk.startsWith('@@') &&\n typeof c.lines === 'number' &&\n c.lines >= 1 &&\n (c.outdated === undefined || typeof c.outdated === 'boolean')\n );\n}\nexport interface ReviewFeedback {\n viewer: string;\n threads: ReviewThread[];\n /** Review summaries (APPROVED / CHANGES_REQUESTED / COMMENTED) with a body. */\n reviews: Array<ReviewComment & { state: string }>;\n /** Conversation (issue) comments on the PR. */\n comments: ReviewComment[];\n}\n"],"mappings":";;;AA+BO,IAAM,kBAAkB;AAE/B,IAAM,WAAW;AAGV,SAAS,WAAW,MAAe,mBAA4B,cAAuB,UAAsC;AACjI,MAAI,OAAO,SAAS,YAAY,CAAC,KAAK,WAAW,IAAI,EAAG,QAAO;AAC/D,QAAM,MAAM,OAAO,iBAAiB,WAAW,eAAe;AAC9D,QAAM,QAAQ,OAAO,sBAAsB,WAAW,oBAAoB;AAC1E,QAAM,QAAQ,QAAQ,QAAQ,UAAU,QAAQ,OAAO,QAAQ,KAAK,IAAI,MAAM,QAAQ,GAAG,GAAG,IAAI;AAEhG,QAAM,OAAO,KAAK,SAAS,WAAW,GAAG,KAAK,MAAM,IAAI,EAAE,CAAC,CAAC;AAAA,EAAK,KAAK,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,KAAK;AAC3H,SAAO,EAAE,MAAM,MAAM,OAAO,GAAI,WAAW,EAAE,UAAU,KAAK,IAAI,CAAC,EAAG;AACtE;AAGO,SAAS,aAAa,GAA6B;AACxD,QAAM,IAAI;AACV,SACE,CAAC,CAAC,KACF,OAAO,MAAM,YACb,OAAO,EAAE,SAAS,YAClB,EAAE,KAAK,WAAW,IAAI,KACtB,OAAO,EAAE,UAAU,YACnB,EAAE,SAAS,MACV,EAAE,aAAa,UAAa,OAAO,EAAE,aAAa;AAEvD;","names":[]}
|
|
@@ -4,19 +4,26 @@ import {
|
|
|
4
4
|
findHolders,
|
|
5
5
|
normDir,
|
|
6
6
|
stopRunningFrom
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-JNBMANFM.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
isLeftover
|
|
10
|
+
} from "./chunk-AHYCZUPI.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
hostForOrigin,
|
|
13
|
+
hostOfPrUrl
|
|
14
|
+
} from "./chunk-7RHC5U7X.js";
|
|
14
15
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
originUrl,
|
|
17
|
+
readGitConfig
|
|
18
|
+
} from "./chunk-MQCDFSVF.js";
|
|
17
19
|
import {
|
|
18
20
|
defaultRunner
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-KSVYR4G2.js";
|
|
22
|
+
import {
|
|
23
|
+
DEFAULT_HOST,
|
|
24
|
+
commandsFor,
|
|
25
|
+
parsePrLink
|
|
26
|
+
} from "./chunk-ZG2M4ECW.js";
|
|
20
27
|
|
|
21
28
|
// src/core/archive/restore-leftovers.ts
|
|
22
29
|
function leftoversOf(paths) {
|
|
@@ -46,22 +53,23 @@ async function openInLeftovers(leftovers, io = {}) {
|
|
|
46
53
|
// src/core/pr/pr-ref.ts
|
|
47
54
|
function parsePrRef(input) {
|
|
48
55
|
const s = input.trim();
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
56
|
+
const link = parsePrLink(s);
|
|
57
|
+
if (link) return { repo: link.repoId, ...link.host === DEFAULT_HOST ? {} : { host: link.host }, number: link.number };
|
|
51
58
|
const n = /^#?(\d+)$/.exec(s);
|
|
52
59
|
return n && Number(n[1]) > 0 ? { number: Number(n[1]) } : null;
|
|
53
60
|
}
|
|
54
61
|
function workOnPrPrompt(pr, instruction) {
|
|
62
|
+
const cmd = commandsFor(pr.host);
|
|
55
63
|
const who = pr.author ? `@${pr.author}` : "its author";
|
|
56
64
|
const todo = instruction?.trim();
|
|
57
|
-
const upToSpeed = `Get up to speed first (
|
|
65
|
+
const upToSpeed = `Get up to speed first (${cmd.view(pr.number)}, ${cmd.diff(pr.number)})`;
|
|
58
66
|
return [
|
|
59
67
|
`Work on PR #${pr.number} by ${who}: ${pr.title}`,
|
|
60
68
|
pr.url,
|
|
61
69
|
"",
|
|
62
70
|
`This worktree is on ${who}'s branch: what you commit and push lands in their PR.`,
|
|
63
71
|
...todo ? [`${upToSpeed}, then:`, "", todo, ""] : [`${upToSpeed}, tell me where it stands, and wait for what I want done.`],
|
|
64
|
-
|
|
72
|
+
`Don't post on ${cmd.host} (no comments, reviews or replies).`
|
|
65
73
|
].join("\n");
|
|
66
74
|
}
|
|
67
75
|
|
|
@@ -69,12 +77,20 @@ function workOnPrPrompt(pr, instruction) {
|
|
|
69
77
|
async function resolvePrToStart(input, config, target, deps = {}) {
|
|
70
78
|
const run = deps.run ?? defaultRunner;
|
|
71
79
|
const gitConfig = deps.gitConfig ?? readGitConfig;
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
const linked = hostOfPrUrl(input);
|
|
81
|
+
const ref = linked ? { repo: linked.link.repoId, host: linked.host.id, number: linked.link.number } : parsePrRef(input);
|
|
82
|
+
if (!ref) return { ok: false, error: "Give a pull request link (as your browser shows it), or its number with a repo." };
|
|
83
|
+
const repoOf = (alias2) => {
|
|
84
|
+
const origin = originUrl(gitConfig(config.repos[alias2]) ?? "");
|
|
85
|
+
const host2 = hostForOrigin(origin);
|
|
86
|
+
return { host: host2, id: origin ? host2.repoId(origin) : null };
|
|
87
|
+
};
|
|
75
88
|
let alias;
|
|
76
89
|
if (ref.repo) {
|
|
77
|
-
const matches = Object.keys(config.repos).filter((a) =>
|
|
90
|
+
const matches = Object.keys(config.repos).filter((a) => {
|
|
91
|
+
const r = repoOf(a);
|
|
92
|
+
return r.id === ref.repo && (!ref.host || r.host.id === ref.host);
|
|
93
|
+
});
|
|
78
94
|
if (!matches.length) return { ok: false, error: `${ref.repo} isn't one of your repos: add it first (work config add <alias> <path>).` };
|
|
79
95
|
const within = target ? config.groups?.[target] ?? [target] : matches;
|
|
80
96
|
alias = matches.find((a) => within.includes(a));
|
|
@@ -86,51 +102,35 @@ async function resolvePrToStart(input, config, target, deps = {}) {
|
|
|
86
102
|
if (!config.repos[target]) return { ok: false, error: `${target} isn't one of your repos.` };
|
|
87
103
|
alias = target;
|
|
88
104
|
}
|
|
89
|
-
const
|
|
90
|
-
if (!
|
|
91
|
-
|
|
92
|
-
"gh",
|
|
93
|
-
[
|
|
94
|
-
"pr",
|
|
95
|
-
"view",
|
|
96
|
-
String(ref.number),
|
|
97
|
-
"--repo",
|
|
98
|
-
github,
|
|
99
|
-
"--json",
|
|
100
|
-
"number,title,url,headRefName,headRefOid,baseRefName,state,isCrossRepository,author,headRepositoryOwner"
|
|
101
|
-
],
|
|
102
|
-
config.repos[alias]
|
|
103
|
-
);
|
|
104
|
-
if (view.code === 127) return { ok: false, error: "GitHub CLI (gh) not found: install it to start from a PR." };
|
|
105
|
-
if (view.code !== 0)
|
|
106
|
-
return { ok: false, error: `PR #${ref.number} in ${github}: ${view.stderr.trim().split("\n")[0] || "gh pr view failed"}` };
|
|
107
|
-
let pr;
|
|
108
|
-
try {
|
|
109
|
-
pr = JSON.parse(view.stdout);
|
|
110
|
-
} catch {
|
|
111
|
-
return { ok: false, error: "Couldn't read what gh said about the PR." };
|
|
105
|
+
const { host, id: repoId } = repoOf(alias);
|
|
106
|
+
if (!repoId) {
|
|
107
|
+
return { ok: false, error: `${alias}'s origin isn't a ${host.name} repo work can read: it can only look up PRs on a host it knows.` };
|
|
112
108
|
}
|
|
109
|
+
const view = await host.prByNumber(run, config.repos[alias], repoId, ref.number);
|
|
110
|
+
if (!view.ok) return { ok: false, error: view.error };
|
|
111
|
+
const pr = view.pr;
|
|
113
112
|
if (pr.state && pr.state !== "OPEN") return { ok: false, error: `PR #${ref.number} is ${pr.state.toLowerCase()}.` };
|
|
114
|
-
if (pr.
|
|
115
|
-
const owner = pr.headRepositoryOwner?.login ?? "a fork";
|
|
113
|
+
if (pr.fork) {
|
|
116
114
|
return {
|
|
117
115
|
ok: false,
|
|
118
|
-
error: `PR #${ref.number} comes from a fork (${owner}): its branch isn't on origin, so a session couldn't push to it.`
|
|
116
|
+
error: `PR #${ref.number} comes from a fork (${pr.fork.owner}): its branch isn't on origin, so a session couldn't push to it.`
|
|
119
117
|
};
|
|
120
118
|
}
|
|
121
|
-
if (!pr.
|
|
122
|
-
const stale = await localGoneOtherWay(run, config.repos[alias], pr.
|
|
119
|
+
if (!pr.branch) return { ok: false, error: `PR #${ref.number}: ${host.cli.cmd} didn't say its branch.` };
|
|
120
|
+
const stale = await localGoneOtherWay(run, config.repos[alias], pr.branch, pr.headSha);
|
|
123
121
|
if (stale) return { ok: false, error: stale };
|
|
124
122
|
return {
|
|
125
123
|
ok: true,
|
|
126
124
|
pr: {
|
|
127
125
|
alias,
|
|
128
|
-
number: pr.number
|
|
129
|
-
title: pr.title
|
|
130
|
-
url: pr.url
|
|
131
|
-
branch: pr.
|
|
132
|
-
base: pr.
|
|
133
|
-
author:
|
|
126
|
+
number: pr.number,
|
|
127
|
+
title: pr.title,
|
|
128
|
+
url: pr.url,
|
|
129
|
+
branch: pr.branch,
|
|
130
|
+
base: pr.base,
|
|
131
|
+
author: pr.author,
|
|
132
|
+
// Absent for GitHub (the wire's default), so a reader from before hosts sees what it always did.
|
|
133
|
+
...host.id === DEFAULT_HOST ? {} : { host: host.id }
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
}
|
|
@@ -155,4 +155,4 @@ export {
|
|
|
155
155
|
workOnPrPrompt,
|
|
156
156
|
resolvePrToStart
|
|
157
157
|
};
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
158
|
+
//# sourceMappingURL=chunk-FLHMFRZB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/archive/restore-leftovers.ts","../src/core/pr/pr-ref.ts","../src/core/pr/pr-start.ts"],"sourcesContent":["import { isLeftover } from '../worktree/leftover.js';\nimport { describeProcess, findHolders, normDir, stopRunningFrom, type Holders } from '../platform/running-from.js';\n\n/**\n * Before a Restore makes a worktree again over what git left of it (a folder\n * it removed only in part, leftover.ts): that folder has to be moved out of\n * the way, and can't be while something runs from it — a dev server its\n * Claude left running. One place for both front-ends: the dashboard's\n * Restore (which asks \"Stop it and restore?\") and `work tree` (which says\n * what to stop).\n */\n\nexport interface LeftoverIo {\n /** What runs from or names the folders (running-from.ts). */\n holders?: (dirs: string[]) => Promise<Holders>;\n /** Stop what runs from them, saying what. */\n stop?: (dirs: string[]) => Promise<string[]>;\n}\n\n/** The session's folders git removed only in part. */\nexport function leftoversOf(paths: string[]): string[] {\n return paths.filter((p) => isLeftover(p));\n}\n\nconst names = (procs: Holders['stoppable'], dirs: string[]) =>\n procs.map((p) =>\n describeProcess(\n p,\n dirs.map((d) => normDir(d)),\n ),\n );\n\n/** What runs from the leftovers, and what has them open: one look at the processes (null: no answer). */\nexport async function lookAtLeftovers(leftovers: string[], io: LeftoverIo = {}): Promise<{ running: string[]; open: string[] } | null> {\n if (leftovers.length === 0) return { running: [], open: [] };\n const h = await (io.holders ?? ((d: string[]) => findHolders(d)))(leftovers).catch(() => null);\n if (!h) return null;\n const running = names(h.stoppable, leftovers);\n return { running, open: [...running, ...names(h.others, leftovers)] };\n}\n\n/** What runs from the leftovers now (\"node …\\vite\\bin\\vite.js --mode demo (PID 35464)\"): none to wait for, []. */\nexport async function runningFromLeftovers(leftovers: string[], io: LeftoverIo = {}): Promise<string[]> {\n return (await lookAtLeftovers(leftovers, io))?.running ?? [];\n}\n\n/** Stop what runs from the leftovers (asked for), saying what. */\nexport async function freeLeftovers(leftovers: string[], io: LeftoverIo = {}): Promise<string[]> {\n if (leftovers.length === 0) return [];\n return (io.stop ?? ((d: string[]) => stopRunningFrom(d)))(leftovers).catch(() => []);\n}\n\n/** Everything that has the leftovers open — what runs from them and what only names them (an editor) — for a failure's message. */\nexport async function openInLeftovers(leftovers: string[], io: LeftoverIo = {}): Promise<string[]> {\n return (await lookAtLeftovers(leftovers, io))?.open ?? [];\n}\n","/**\n * Starting a session on someone else's pull request — on their branch, so\n * what you push lands in their PR. Pure (the SPA and the demo use it): how a\n * PR is named, and what its session's Claude is told first. The lookup\n * (the repo's host) is `pr-start.ts`.\n */\n\nimport type { PrToStart } from '../api-types.js';\nimport { commandsFor, DEFAULT_HOST } from '../hosts/commands.js';\nimport { parsePrLink } from '../hosts/links.js';\n\nexport type { PrToStart };\n\n/** A PR as you'd name it: its link (repo known), or its number (in a repo you pick). */\nexport interface PrRef {\n /** The repo's id on its host, from a link (GitHub: `owner/name`, lowercase). */\n repo?: string;\n /** The host a link is on. */\n host?: string;\n number: number;\n}\n\n/** A PR link of a host work knows (any tail), `#123` or `123`; null for anything else. */\nexport function parsePrRef(input: string): PrRef | null {\n const s = input.trim();\n const link = parsePrLink(s);\n if (link) return { repo: link.repoId, ...(link.host === DEFAULT_HOST ? {} : { host: link.host }), number: link.number };\n const n = /^#?(\\d+)$/.exec(s);\n return n && Number(n[1]) > 0 ? { number: Number(n[1]) } : null;\n}\n\n/**\n * The first message to the session's Claude: whose PR this is, that what it\n * pushes lands there, and to get up to speed — then do `instruction`, or\n * with none, say where it stands and wait for what the user wants. Nothing\n * on the host (no comments, reviews or replies): that's the author's\n * conversation. Its commands are the PR's host's (`host`; GitHub's when absent).\n */\nexport function workOnPrPrompt(\n pr: Pick<PrToStart, 'number' | 'title' | 'url'> & { author?: string; host?: string },\n instruction?: string,\n): string {\n const cmd = commandsFor(pr.host);\n const who = pr.author ? `@${pr.author}` : 'its author';\n const todo = instruction?.trim();\n const upToSpeed = `Get up to speed first (${cmd.view(pr.number)}, ${cmd.diff(pr.number)})`;\n return [\n `Work on PR #${pr.number} by ${who}: ${pr.title}`,\n pr.url,\n '',\n `This worktree is on ${who}'s branch: what you commit and push lands in their PR.`,\n ...(todo ? [`${upToSpeed}, then:`, '', todo, ''] : [`${upToSpeed}, tell me where it stands, and wait for what I want done.`]),\n `Don't post on ${cmd.host} (no comments, reviews or replies).`,\n ].join('\\n');\n}\n","import type { WorkConfig } from '../platform/config.js';\nimport { originUrl, readGitConfig } from '../worktree/repo-scan.js';\nimport { parsePrRef, type PrRef, type PrToStart } from './pr-ref.js';\nimport { defaultRunner, type CommandRunner } from './ship.js';\nimport { DEFAULT_HOST, hostForOrigin, hostOfPrUrl } from '../hosts/index.js';\n\nexport type PrStartResult = { ok: true; pr: PrToStart } | { ok: false; error: string };\n\nexport interface PrStartDeps {\n run?: CommandRunner;\n /** A repo's `.git/config` text (tests pass their own). */\n gitConfig?: (repoPath: string) => string | null;\n}\n\n/**\n * Which of your repos a PR is in, and its branch: from its link (the repo\n * matched by its origin) or its number (in `target`, a repo). Refused: a\n * repo you haven't enrolled, a group as the repo of a bare number, a PR\n * that isn't open, and one from a fork — its branch isn't on origin, so the\n * session couldn't push to it (and `work tree` would make a new, empty\n * branch of that name instead).\n */\nexport async function resolvePrToStart(\n input: string,\n config: Pick<WorkConfig, 'repos' | 'groups'>,\n target?: string,\n deps: PrStartDeps = {},\n): Promise<PrStartResult> {\n const run = deps.run ?? defaultRunner;\n const gitConfig = deps.gitConfig ?? readGitConfig;\n // A link any host reads (one registered at run time too), else a number.\n const linked = hostOfPrUrl(input);\n const ref: PrRef | null = linked ? { repo: linked.link.repoId, host: linked.host.id, number: linked.link.number } : parsePrRef(input);\n if (!ref) return { ok: false, error: 'Give a pull request link (as your browser shows it), or its number with a repo.' };\n\n // Each repo on its own host (its origin's), with its id there.\n const repoOf = (alias: string) => {\n const origin = originUrl(gitConfig(config.repos[alias]) ?? '');\n const host = hostForOrigin(origin);\n return { host, id: origin ? host.repoId(origin) : null };\n };\n let alias: string | undefined;\n if (ref.repo) {\n const matches = Object.keys(config.repos).filter((a) => {\n const r = repoOf(a);\n return r.id === ref.repo && (!ref.host || r.host.id === ref.host);\n });\n if (!matches.length) return { ok: false, error: `${ref.repo} isn't one of your repos: add it first (work config add <alias> <path>).` };\n // A target named beside a link must hold it: the repo itself, or a group with it among its repos.\n const within = target ? (config.groups?.[target] ?? [target]) : matches;\n alias = matches.find((a) => within.includes(a));\n if (!alias) return { ok: false, error: `PR #${ref.number} is in ${matches.join(' / ')} (${ref.repo}), not ${target}.` };\n } else {\n if (!target) return { ok: false, error: `PR #${ref.number}: which repo? Give its link, or pick the repo.` };\n if (config.groups?.[target])\n return { ok: false, error: `${target} is a group: a PR is one repo's. Give its link, or one of the group's repos.` };\n if (!config.repos[target]) return { ok: false, error: `${target} isn't one of your repos.` };\n alias = target;\n }\n const { host, id: repoId } = repoOf(alias);\n if (!repoId) {\n return { ok: false, error: `${alias}'s origin isn't a ${host.name} repo work can read: it can only look up PRs on a host it knows.` };\n }\n\n const view = await host.prByNumber(run, config.repos[alias], repoId, ref.number);\n if (!view.ok) return { ok: false, error: view.error };\n const pr = view.pr;\n if (pr.state && pr.state !== 'OPEN') return { ok: false, error: `PR #${ref.number} is ${pr.state.toLowerCase()}.` };\n if (pr.fork) {\n return {\n ok: false,\n error: `PR #${ref.number} comes from a fork (${pr.fork.owner}): its branch isn't on origin, so a session couldn't push to it.`,\n };\n }\n if (!pr.branch) return { ok: false, error: `PR #${ref.number}: ${host.cli.cmd} didn't say its branch.` };\n const stale = await localGoneOtherWay(run, config.repos[alias], pr.branch, pr.headSha);\n if (stale) return { ok: false, error: stale };\n return {\n ok: true,\n pr: {\n alias,\n number: pr.number,\n title: pr.title,\n url: pr.url,\n branch: pr.branch,\n base: pr.base,\n author: pr.author,\n // Absent for GitHub (the wire's default), so a reader from before hosts sees what it always did.\n ...(host.id === DEFAULT_HOST ? {} : { host: host.id }),\n },\n };\n}\n\n/**\n * `work tree` takes a local branch of that name over origin's, moving it\n * forward when it can. One that has gone another way than the PR (the author\n * force-pushed, or an unrelated branch of the same name) would open on the\n * wrong commits, and what's pushed from it wouldn't go. Ahead (your commits\n * on top) or behind (it fast-forwards) is fine; when git can't tell (no\n * fetch), the usual warning on entering is left to say it.\n */\nasync function localGoneOtherWay(run: CommandRunner, repoPath: string, branch: string, headOid?: string): Promise<string | null> {\n if (!headOid) return null;\n const local = await run('git', ['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`], repoPath);\n if (local.code !== 0) return null;\n await run('git', ['fetch', '--quiet', 'origin', branch], repoPath);\n const contains = await run('git', ['merge-base', '--is-ancestor', headOid, `refs/heads/${branch}`], repoPath);\n if (contains.code === 0) return null;\n const behind = await run('git', ['merge-base', '--is-ancestor', `refs/heads/${branch}`, headOid], repoPath);\n if (behind.code !== 1 || contains.code !== 1) return null; // 1 = not an ancestor; anything else: git couldn't say\n return `Your local branch ${branch} and the PR's have gone separate ways (a force-push, or another branch of that name): rename yours (git branch -m ${branch} ${branch}-old) and try again, or go into its session as it is (work tree <repo> ${branch}).`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,SAAS,YAAY,OAA2B;AACrD,SAAO,MAAM,OAAO,CAAC,MAAM,WAAW,CAAC,CAAC;AAC1C;AAEA,IAAM,QAAQ,CAAC,OAA6B,SAC1C,MAAM;AAAA,EAAI,CAAC,MACT;AAAA,IACE;AAAA,IACA,KAAK,IAAI,CAAC,MAAM,QAAQ,CAAC,CAAC;AAAA,EAC5B;AACF;AAGF,eAAsB,gBAAgB,WAAqB,KAAiB,CAAC,GAA0D;AACrI,MAAI,UAAU,WAAW,EAAG,QAAO,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE;AAC3D,QAAM,IAAI,OAAO,GAAG,YAAY,CAAC,MAAgB,YAAY,CAAC,IAAI,SAAS,EAAE,MAAM,MAAM,IAAI;AAC7F,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,UAAU,MAAM,EAAE,WAAW,SAAS;AAC5C,SAAO,EAAE,SAAS,MAAM,CAAC,GAAG,SAAS,GAAG,MAAM,EAAE,QAAQ,SAAS,CAAC,EAAE;AACtE;AAQA,eAAsB,cAAc,WAAqB,KAAiB,CAAC,GAAsB;AAC/F,MAAI,UAAU,WAAW,EAAG,QAAO,CAAC;AACpC,UAAQ,GAAG,SAAS,CAAC,MAAgB,gBAAgB,CAAC,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC,CAAC;AACrF;AAGA,eAA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CAAC,QAAS,QAAO;AACrB,QAAM,QAAQ,MAAM,IAAI,OAAO,CAAC,aAAa,YAAY,WAAW,cAAc,MAAM,EAAE,GAAG,QAAQ;AACrG,MAAI,MAAM,SAAS,EAAG,QAAO;AAC7B,QAAM,IAAI,OAAO,CAAC,SAAS,WAAW,UAAU,MAAM,GAAG,QAAQ;AACjE,QAAM,WAAW,MAAM,IAAI,OAAO,CAAC,cAAc,iBAAiB,SAAS,cAAc,MAAM,EAAE,GAAG,QAAQ;AAC5G,MAAI,SAAS,SAAS,EAAG,QAAO;AAChC,QAAM,SAAS,MAAM,IAAI,OAAO,CAAC,cAAc,iBAAiB,cAAc,MAAM,IAAI,OAAO,GAAG,QAAQ;AAC1G,MAAI,OAAO,SAAS,KAAK,SAAS,SAAS,EAAG,QAAO;AACrD,SAAO,qBAAqB,MAAM,qHAAqH,MAAM,IAAI,MAAM,0EAA0E,MAAM;AACzP;","names":["alias","host"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
defaultRunner
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KSVYR4G2.js";
|
|
5
5
|
import {
|
|
6
6
|
logSwallowed
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZG2M4ECW.js";
|
|
8
8
|
|
|
9
9
|
// src/core/diff/diff-stat.ts
|
|
10
10
|
import fs from "fs";
|
|
@@ -207,4 +207,4 @@ export {
|
|
|
207
207
|
wantsDiffStat,
|
|
208
208
|
findOverlaps
|
|
209
209
|
};
|
|
210
|
-
//# sourceMappingURL=chunk-
|
|
210
|
+
//# sourceMappingURL=chunk-FR7B7QH6.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/core/sessions/legacy-unsafe.ts
|
|
4
|
+
function legacyUnsafeCase(session, hostEntry, runsOutsideHost) {
|
|
5
|
+
const oldHost = !!hostEntry && typeof hostEntry === "object" && hostEntry.unsafe === true;
|
|
6
|
+
const outside = session?.launchedUnsafe === true && runsOutsideHost();
|
|
7
|
+
if (oldHost && outside) return "both";
|
|
8
|
+
if (oldHost) return "old-host";
|
|
9
|
+
return outside ? "outside" : null;
|
|
10
|
+
}
|
|
11
|
+
var LIFT_OLD_HOST = "run `work pty-host --restart` (the host is from before --unsafe was retired)";
|
|
12
|
+
var LIFT_OUTSIDE = "quit it in its terminal and start it again with `work tree`";
|
|
13
|
+
function howToLift(c) {
|
|
14
|
+
if (c === "old-host") return LIFT_OLD_HOST;
|
|
15
|
+
if (c === "outside") return LIFT_OUTSIDE;
|
|
16
|
+
return `${LIFT_OLD_HOST}, and ${LIFT_OUTSIDE}`;
|
|
17
|
+
}
|
|
18
|
+
function stillUnsafeMessage(c) {
|
|
19
|
+
return `this agent still runs without permission prompts from before --unsafe was retired: ${howToLift(c)}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
legacyUnsafeCase,
|
|
24
|
+
howToLift,
|
|
25
|
+
stillUnsafeMessage
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-FZHFD2AY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/sessions/legacy-unsafe.ts"],"sourcesContent":["import type { WorktreeSession } from './session-types.js';\n\n// REMOVE IN THE NEXT RELEASE, with `--unsafe`'s hidden option (commands/shared/retired-unsafe.ts).\n//\n// `--unsafe` is retired: work never starts an agent with its skip-permissions flag. But an agent started that way\n// before the upgrade may still run — the PTY host outlives updates, and an older host restarting or resuming one\n// starts it again from its stored spec, flag and all; a Claude launched directly in a terminal runs until it is quit.\n// For one release, such an agent keeps the guards it had: the PR watch hands it no review text, `work send` refuses\n// it, and `work pr reply` / `post` refuse in it. Each case is lifted its own way (`stillUnsafeMessage`): an older\n// host's entry says `unsafe: true` until a current host runs it (pty-registry.ts writes only what it starts with,\n// so `work pty-host --restart`); a direct launch from before is only gone once it was quit — a current `work`\n// clears the row's flag when it launches with no agent of the session running anywhere (`clearLaunchedUnsafeWhenIdle`).\n\n/** Which agent from before keeps the guards: one an older PTY host runs (`old-host`), one launched directly in a\n * terminal and still running outside the host (`outside`), or both. */\nexport type LegacyUnsafe = 'old-host' | 'outside' | 'both';\n\n/**\n * Whether the session's agent still runs as started `--unsafe` before the retirement, and how (pure; null: it\n * doesn't). Either holds on its own: the host's restore entry saying `unsafe: true` (an older host keeps it there for\n * as long as it runs it), or the history row's `launchedUnsafe` while an agent of the session runs outside the host —\n * even when a current host also has an entry for it (a direct launch from before is still running beside it).\n */\nexport function legacyUnsafeCase(\n session: Pick<WorktreeSession, 'launchedUnsafe'> | null | undefined,\n hostEntry: unknown,\n runsOutsideHost: () => boolean,\n): LegacyUnsafe | null {\n const oldHost = !!hostEntry && typeof hostEntry === 'object' && (hostEntry as { unsafe?: unknown }).unsafe === true;\n const outside = session?.launchedUnsafe === true && runsOutsideHost();\n if (oldHost && outside) return 'both';\n if (oldHost) return 'old-host';\n return outside ? 'outside' : null;\n}\n\n/** `legacyUnsafeCase` as a yes / no. */\nexport function startedUnsafeBefore(\n session: Pick<WorktreeSession, 'launchedUnsafe'> | null | undefined,\n hostEntry: unknown,\n runsOutsideHost: () => boolean,\n): boolean {\n return legacyUnsafeCase(session, hostEntry, runsOutsideHost) !== null;\n}\n\nconst LIFT_OLD_HOST = 'run `work pty-host --restart` (the host is from before --unsafe was retired)';\nconst LIFT_OUTSIDE = 'quit it in its terminal and start it again with `work tree`';\n\n/** What lifts the guard, for the case at hand. */\nexport function howToLift(c: LegacyUnsafe): string {\n if (c === 'old-host') return LIFT_OLD_HOST;\n if (c === 'outside') return LIFT_OUTSIDE;\n return `${LIFT_OLD_HOST}, and ${LIFT_OUTSIDE}`;\n}\n\n/** What a guarded action says. */\nexport function stillUnsafeMessage(c: LegacyUnsafe): string {\n return `this agent still runs without permission prompts from before --unsafe was retired: ${howToLift(c)}`;\n}\n"],"mappings":";;;AAuBO,SAAS,iBACd,SACA,WACA,iBACqB;AACrB,QAAM,UAAU,CAAC,CAAC,aAAa,OAAO,cAAc,YAAa,UAAmC,WAAW;AAC/G,QAAM,UAAU,SAAS,mBAAmB,QAAQ,gBAAgB;AACpE,MAAI,WAAW,QAAS,QAAO;AAC/B,MAAI,QAAS,QAAO;AACpB,SAAO,UAAU,YAAY;AAC/B;AAWA,IAAM,gBAAgB;AACtB,IAAM,eAAe;AAGd,SAAS,UAAU,GAAyB;AACjD,MAAI,MAAM,WAAY,QAAO;AAC7B,MAAI,MAAM,UAAW,QAAO;AAC5B,SAAO,GAAG,aAAa,SAAS,YAAY;AAC9C;AAGO,SAAS,mBAAmB,GAAyB;AAC1D,SAAO,sFAAsF,UAAU,CAAC,CAAC;AAC3G;","names":[]}
|