@vercel/cli-support 66.4.0 → 66.5.0-snapshot-f10b9946b10d

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.
Files changed (278) hide show
  1. package/dist/chunks/add-563RV6JX.js +8 -0
  2. package/dist/chunks/add-HRB6XY33.js +8 -0
  3. package/dist/chunks/add-IUTGTBA4.js +8 -0
  4. package/dist/chunks/alerts-CIQQJC4S.js +8 -0
  5. package/dist/chunks/build-OMIYCGMR.js +7 -0
  6. package/dist/chunks/{chunk-FHMMYUAF.js → chunk-2AU6O6Z5.js} +1 -1
  7. package/dist/chunks/{chunk-VNY6WA2E.js → chunk-2D5PTFAY.js} +1 -1
  8. package/dist/chunks/{chunk-AJGLWQWP.js → chunk-2G2SALNN.js} +1 -1
  9. package/dist/chunks/{chunk-XRPGN3XZ.js → chunk-2OMI3IUW.js} +1 -1
  10. package/dist/chunks/{chunk-4ZIJL4U6.js → chunk-2RRZCRWX.js} +1 -1
  11. package/dist/chunks/{chunk-TPMBWSAM.js → chunk-33HVDSWP.js} +1 -1
  12. package/dist/chunks/{chunk-E3FOLLEC.js → chunk-3A3GU62R.js} +1 -1
  13. package/dist/chunks/{chunk-CFQPIYKY.js → chunk-3OZCZF4N.js} +1 -1
  14. package/dist/chunks/chunk-4SS6W6JK.js +11 -0
  15. package/dist/chunks/{chunk-6PAJ6GJK.js → chunk-5J4E2W4F.js} +1 -1
  16. package/dist/chunks/{chunk-AZZLV7WI.js → chunk-5O4AXCN7.js} +1 -1
  17. package/dist/chunks/{chunk-K5AHCH2B.js → chunk-6GE4V7MW.js} +1 -1
  18. package/dist/chunks/{chunk-J4ET2U4J.js → chunk-6PDKIOAO.js} +1 -1
  19. package/dist/chunks/{chunk-A7E3EGDM.js → chunk-76DSBD4X.js} +1 -1
  20. package/dist/chunks/{chunk-LKQACPVL.js → chunk-7AVHDJSP.js} +4 -4
  21. package/dist/chunks/{chunk-LD7EQJRG.js → chunk-7W565DJB.js} +1 -1
  22. package/dist/chunks/{chunk-5NLEENEL.js → chunk-ACN6DBTC.js} +1 -1
  23. package/dist/chunks/{chunk-CMHY2UFZ.js → chunk-AFHZC47H.js} +1 -1
  24. package/dist/chunks/{chunk-6JJ6MZW2.js → chunk-AIXEVICT.js} +1 -1
  25. package/dist/chunks/{chunk-O42P2UDX.js → chunk-BCAI7MED.js} +1 -1
  26. package/dist/chunks/{chunk-NKWA7NQP.js → chunk-C335SWOB.js} +1 -1
  27. package/dist/chunks/{chunk-LYL26S3N.js → chunk-CINNNQDJ.js} +1 -1
  28. package/dist/chunks/{chunk-TBWFT22U.js → chunk-CSCUVSJM.js} +1 -1
  29. package/dist/chunks/{chunk-ZKQ47ZXI.js → chunk-D2E4COIY.js} +1 -1
  30. package/dist/chunks/{chunk-OMG2DOCL.js → chunk-D2TVI7KK.js} +1 -1
  31. package/dist/chunks/{chunk-QHICDCEC.js → chunk-DEM66DOY.js} +1 -1
  32. package/dist/chunks/{chunk-JWKFVECK.js → chunk-DHKWTBF6.js} +1 -1
  33. package/dist/chunks/{chunk-Y2FVJ7YO.js → chunk-DOMBKOLJ.js} +1 -1
  34. package/dist/chunks/{chunk-BKVGBXIF.js → chunk-DZ77BIEV.js} +1 -1
  35. package/dist/chunks/{chunk-YSZREQZD.js → chunk-E4VPDMRQ.js} +1 -1
  36. package/dist/chunks/{chunk-5NMD7U2W.js → chunk-EAQAV7UZ.js} +1 -1
  37. package/dist/chunks/{chunk-YVL744ZH.js → chunk-EFFJUYYS.js} +2 -2
  38. package/dist/chunks/chunk-EFP3LK4G.js +8 -0
  39. package/dist/chunks/{chunk-IG5ACFU6.js → chunk-F4UEGELU.js} +1 -1
  40. package/dist/chunks/chunk-FEJD7MRH.js +7 -0
  41. package/dist/chunks/{chunk-I27PMO5P.js → chunk-FFN3EGSF.js} +1 -1
  42. package/dist/chunks/{chunk-OA27OSXW.js → chunk-FOFX7LHS.js} +1 -1
  43. package/dist/chunks/{chunk-JVSU3BY3.js → chunk-GB2ZWZQU.js} +1 -1
  44. package/dist/chunks/{chunk-WYD4BH6D.js → chunk-GUGP6OY2.js} +1 -1
  45. package/dist/chunks/{chunk-W4IW6A54.js → chunk-GYUNOFDD.js} +2 -2
  46. package/dist/chunks/{chunk-NMCZ5PDO.js → chunk-H2KNSYPR.js} +1 -1
  47. package/dist/chunks/{chunk-6LXXO6WG.js → chunk-IF6GA273.js} +1 -1
  48. package/dist/chunks/{chunk-L5APBYTA.js → chunk-JBYROCAC.js} +1 -1
  49. package/dist/chunks/chunk-K3MGQQEP.js +7 -0
  50. package/dist/chunks/{chunk-QXM4CNRK.js → chunk-KLYFOXYH.js} +1 -1
  51. package/dist/chunks/{chunk-MUTGN6EZ.js → chunk-KQ6X77WP.js} +1 -1
  52. package/dist/chunks/{chunk-2RCMLZIT.js → chunk-KRP4EMD2.js} +1 -1
  53. package/dist/chunks/{chunk-DMZLFZBX.js → chunk-KSGN5OCV.js} +1 -1
  54. package/dist/chunks/{chunk-6YGECVLI.js → chunk-L5PIUIUM.js} +1 -1
  55. package/dist/chunks/{chunk-HAGBKLAS.js → chunk-LNZEYUEC.js} +1 -1
  56. package/dist/chunks/chunk-MINTHN6C.js +7 -0
  57. package/dist/chunks/chunk-N6JHFCWC.js +7 -0
  58. package/dist/chunks/chunk-NLK7NGVP.js +7 -0
  59. package/dist/chunks/{chunk-SSNOY4RM.js → chunk-O7GNYVVM.js} +1 -1
  60. package/dist/chunks/{chunk-25B7DCD6.js → chunk-OE26EQSH.js} +1 -1
  61. package/dist/chunks/{chunk-S3RJKATD.js → chunk-OF32Z3UP.js} +1 -1
  62. package/dist/chunks/{chunk-4F2PK7MV.js → chunk-OISNKAC6.js} +1 -1
  63. package/dist/chunks/{chunk-Y3AAO2UW.js → chunk-OXS5VO4X.js} +1 -1
  64. package/dist/chunks/{chunk-D44WCAOX.js → chunk-PFOOPXTN.js} +2 -2
  65. package/dist/chunks/{chunk-YIL6OD24.js → chunk-PKR32I2N.js} +1 -1
  66. package/dist/chunks/{chunk-CO3S5MFZ.js → chunk-QGHAD5A5.js} +1 -1
  67. package/dist/chunks/{chunk-CYCIBBJ3.js → chunk-QRG24GJG.js} +1 -1
  68. package/dist/chunks/{chunk-VVSRVQJQ.js → chunk-QZJOKECY.js} +1 -1
  69. package/dist/chunks/{chunk-4222KNIU.js → chunk-QZKRVE44.js} +2 -2
  70. package/dist/chunks/{chunk-DT5HQUJV.js → chunk-R33HJGYA.js} +1 -1
  71. package/dist/chunks/{chunk-GVW4NA3F.js → chunk-RBW62SOU.js} +1 -1
  72. package/dist/chunks/chunk-RDDIWY3O.js +10 -0
  73. package/dist/chunks/{chunk-PY4WWD6Z.js → chunk-RVIJRFVD.js} +1 -1
  74. package/dist/chunks/{chunk-22XQ3FQJ.js → chunk-S4AANAHX.js} +1 -1
  75. package/dist/chunks/{chunk-M3Y63BLW.js → chunk-SPVOJ3HW.js} +1 -1
  76. package/dist/chunks/{chunk-JCCDHR3I.js → chunk-SQCVI2EG.js} +1 -1
  77. package/dist/chunks/{chunk-GAS6EYQH.js → chunk-SXW2G4WD.js} +2 -2
  78. package/dist/chunks/{chunk-7CAXN2PV.js → chunk-SYVWRGFQ.js} +1 -1
  79. package/dist/chunks/{chunk-D7FX3KQX.js → chunk-TC4E2TFA.js} +1 -1
  80. package/dist/chunks/chunk-TNQUCTJH.js +24 -0
  81. package/dist/chunks/{chunk-SZO73QV5.js → chunk-TSNRTRIM.js} +1 -1
  82. package/dist/chunks/{chunk-7HLAWGY2.js → chunk-UG3FZ5Q7.js} +1 -1
  83. package/dist/chunks/chunk-VF7XWPXA.js +7 -0
  84. package/dist/chunks/{chunk-AMOI3EAW.js → chunk-VPSR2O55.js} +4 -4
  85. package/dist/chunks/{chunk-7RPBEXKZ.js → chunk-VUUU4KDL.js} +1 -1
  86. package/dist/chunks/{chunk-BPIGFKNN.js → chunk-VZ4URN3U.js} +1 -1
  87. package/dist/chunks/{chunk-IF644EL7.js → chunk-W2L24GM7.js} +1 -1
  88. package/dist/chunks/{chunk-XUTUL2RN.js → chunk-WAFBTC45.js} +1 -1
  89. package/dist/chunks/{chunk-ZK4NRNJ2.js → chunk-WIF4VGYZ.js} +1 -1
  90. package/dist/chunks/{chunk-AG3KGTVM.js → chunk-X47GV5HM.js} +1 -1
  91. package/dist/chunks/{chunk-UE3YVFFX.js → chunk-X7KKWUPS.js} +1 -1
  92. package/dist/chunks/{chunk-CJXPUSBO.js → chunk-XAGG5BJT.js} +1 -1
  93. package/dist/chunks/{chunk-ZD4H7IUH.js → chunk-XBHAU2M3.js} +1 -1
  94. package/dist/chunks/{chunk-NWFONVGV.js → chunk-XDWAUOFO.js} +1 -1
  95. package/dist/chunks/{chunk-WW44HSPU.js → chunk-Y4J4STZV.js} +1 -1
  96. package/dist/chunks/{chunk-TCHR65QZ.js → chunk-Y77DXGGN.js} +1 -1
  97. package/dist/chunks/{chunk-26ZLTV7O.js → chunk-YI7NKOCU.js} +2 -2
  98. package/dist/chunks/{chunk-FLFZVZBL.js → chunk-YLLFLPNA.js} +1 -1
  99. package/dist/chunks/{chunk-TUTCJ7CX.js → chunk-YOAQNRBN.js} +1 -1
  100. package/dist/chunks/{chunk-IBZJP22D.js → chunk-Z2KANBOU.js} +34 -34
  101. package/dist/chunks/{chunk-U4J3IR2U.js → chunk-Z7WZVEPP.js} +1 -1
  102. package/dist/chunks/{chunk-B4PBNKLU.js → chunk-ZA5O22ZY.js} +1 -1
  103. package/dist/chunks/{chunk-LYBSCCZL.js → chunk-ZSGNLAAJ.js} +1 -1
  104. package/dist/chunks/clear-TH6G33QK.js +8 -0
  105. package/dist/chunks/{compile-vercel-config-TW77XH2J.js → compile-vercel-config-24IXPM4W.js} +1 -1
  106. package/dist/chunks/config-2SBML7OY.js +8 -0
  107. package/dist/chunks/config-ZSE26DSM.js +7 -0
  108. package/dist/chunks/{contract-3IQOORDY.js → contract-BLCQGFZK.js} +1 -1
  109. package/dist/chunks/delete-RGHXL4JH.js +9 -0
  110. package/dist/chunks/delete-ZV4SHUTR.js +10 -0
  111. package/dist/chunks/{describe-RRUINYLN.js → describe-442UUQIF.js} +1 -1
  112. package/dist/chunks/{detect-projects-WO6GTQRY.js → detect-projects-NBZSMQ5C.js} +1 -1
  113. package/dist/chunks/{detect-services-GQO6QEXB.js → detect-services-CRZW6FKM.js} +1 -1
  114. package/dist/chunks/disable-MYGA6HVS.js +7 -0
  115. package/dist/chunks/discard-I5TKYCDJ.js +14 -0
  116. package/dist/chunks/edit-KGCUTTOZ.js +8 -0
  117. package/dist/chunks/edit-ZRNGGRVL.js +9 -0
  118. package/dist/chunks/enable-NODSFDKF.js +7 -0
  119. package/dist/chunks/{export-JVDQWEFD.js → export-TOSUN6JO.js} +1 -1
  120. package/dist/chunks/future-RXI2OW2C.js +7 -0
  121. package/dist/chunks/generate-cert-for-deploy-7BX47IPD.js +7 -0
  122. package/dist/chunks/image-WKBQLUTQ.js +7 -0
  123. package/dist/chunks/{import-builders-3YIV3R7T.js → import-builders-I4JB6BA6.js} +1 -1
  124. package/dist/chunks/inspect-4Y2OD5MI.js +8 -0
  125. package/dist/chunks/{inspect-HUN7IHGP.js → inspect-DFYVVIJW.js} +1 -1
  126. package/dist/chunks/{inspect-PBHPRQKN.js → inspect-GBH7FAW6.js} +1 -1
  127. package/dist/chunks/inspect-STKCC3MC.js +9 -0
  128. package/dist/chunks/{inspect-6BOUR7QC.js → inspect-SX3QQUEQ.js} +1 -1
  129. package/dist/chunks/inspect-VFUV7BDM.js +13 -0
  130. package/dist/chunks/{list-WZIJ4LS3.js → list-4RRL326Z.js} +1 -1
  131. package/dist/chunks/list-6ENV2ZGG.js +12 -0
  132. package/dist/chunks/{list-TJTP6VMY.js → list-HD6KXAIG.js} +1 -1
  133. package/dist/chunks/list-MW2FV253.js +8 -0
  134. package/dist/chunks/login-O6NLJ42W.js +7 -0
  135. package/dist/chunks/login-U5VDJURN.js +9 -0
  136. package/dist/chunks/logs-X3KGHA3J.js +7 -0
  137. package/dist/chunks/ls-HRSD6VNW.js +8 -0
  138. package/dist/chunks/{ls-MRZ46D4E.js → ls-I767MTW4.js} +1 -1
  139. package/dist/chunks/ls-OLJMGFTV.js +11 -0
  140. package/dist/chunks/{ls-AH4LDLZK.js → ls-Q4WGEEBZ.js} +1 -1
  141. package/dist/chunks/{ls-FWCHBGLF.js → ls-RKOM46KV.js} +1 -1
  142. package/dist/chunks/{ls-7KTKLNDE.js → ls-TLEAYYXQ.js} +1 -1
  143. package/dist/chunks/{ls-LKOYAWGO.js → ls-VFE7PE25.js} +1 -1
  144. package/dist/chunks/{migrate-experimental-services-QUJ3Y5KW.js → migrate-experimental-services-7ZYHE5WA.js} +1 -1
  145. package/dist/chunks/mutate-BJXJON5E.js +9 -0
  146. package/dist/chunks/notifications-F3NRNUHQ.js +7 -0
  147. package/dist/chunks/open-JK42ZTLB.js +7 -0
  148. package/dist/chunks/openapi-NEYEIRF2.js +7 -0
  149. package/dist/chunks/permissions-3AQO3DCH.js +7 -0
  150. package/dist/chunks/{plugin-offer-5PC2WVPP.js → plugin-offer-NPJAEILN.js} +1 -1
  151. package/dist/chunks/prompt-missing-credentials-AHAH27TZ.js +7 -0
  152. package/dist/chunks/publish-7SCXBVZR.js +15 -0
  153. package/dist/chunks/pull-LAPD5XJG.js +7 -0
  154. package/dist/chunks/purchase-domain-if-available-7MI52MFD.js +7 -0
  155. package/dist/chunks/push-BCSGQBAM.js +7 -0
  156. package/dist/chunks/query-U72BDMAK.js +7 -0
  157. package/dist/chunks/raw-query-4UAW7M5Q.js +8 -0
  158. package/dist/chunks/reauthenticate-HGOLSK2M.js +7 -0
  159. package/dist/chunks/remove-IEEZGRB2.js +9 -0
  160. package/dist/chunks/reorder-YL6L6IWC.js +10 -0
  161. package/dist/chunks/reply-7Y5TN5UV.js +9 -0
  162. package/dist/chunks/resolve-C62436YM.js +12 -0
  163. package/dist/chunks/resolve-agent-team-SR3ALPCH.js +7 -0
  164. package/dist/chunks/restore-Z63JM5CN.js +16 -0
  165. package/dist/chunks/rm-C6QSHEA2.js +8 -0
  166. package/dist/chunks/rm-DDKE62T7.js +8 -0
  167. package/dist/chunks/rm-IUB55CCM.js +8 -0
  168. package/dist/chunks/rm-NZX43GMQ.js +8 -0
  169. package/dist/chunks/rm-UBUI7JNY.js +8 -0
  170. package/dist/chunks/rule-inspect-KF4BLH4K.js +8 -0
  171. package/dist/chunks/{schema-R5JG4UPM.js → schema-L5VCG6FJ.js} +1 -1
  172. package/dist/chunks/schema-P7DFLXCG.js +14 -0
  173. package/dist/chunks/select-org-MBBMOUK2.js +7 -0
  174. package/dist/chunks/set-6U4QIX7A.js +8 -0
  175. package/dist/chunks/set-SCKMJ7LZ.js +7 -0
  176. package/dist/chunks/setup-and-link-5TPDTJIN.js +7 -0
  177. package/dist/chunks/{skills-OA43DLRD.js → skills-ZMFZGPQL.js} +1 -1
  178. package/dist/chunks/tags-7M2EW6LU.js +7 -0
  179. package/dist/chunks/{types-CHIVX5JL.js → types-CVLZCTL2.js} +1 -1
  180. package/dist/chunks/{update-72MKFJ43.js → update-A727QN7H.js} +1 -1
  181. package/dist/chunks/usage-AL4CA45F.js +13 -0
  182. package/dist/chunks/{validate-config-DODT2AQL.js → validate-config-Q77XESW5.js} +1 -1
  183. package/dist/chunks/vercel-cli-3UQLDU2S.js +29 -0
  184. package/dist/commands/build/index.js +1 -1
  185. package/dist/commands/deploy/index.js +4 -4
  186. package/dist/commands/dev/index.js +4 -4
  187. package/dist/commands/env/index.js +12 -12
  188. package/dist/commands/link/index.js +1 -1
  189. package/dist/commands/list/index.js +1 -1
  190. package/dist/commands/project/index.js +14 -9
  191. package/dist/commands/tunnel/index.js +1 -1
  192. package/dist/commands-account.js +6 -6
  193. package/dist/commands-ai.js +18 -10
  194. package/dist/commands-blob.js +1 -1
  195. package/dist/commands-core.js +10 -10
  196. package/dist/commands-deployments.js +1 -1
  197. package/dist/commands-flags.js +1 -1
  198. package/dist/commands-integrations.js +1 -1
  199. package/dist/commands-observability.js +2 -2
  200. package/dist/commands-routing.js +4 -4
  201. package/dist/index.js +6 -6
  202. package/dist/internal-build.js +3 -3
  203. package/dist/package.json +3 -3
  204. package/dist/vc.js +22 -1
  205. package/dist/version.mjs +1 -1
  206. package/package.json +12 -12
  207. package/dist/chunks/add-5NWELDHY.js +0 -8
  208. package/dist/chunks/add-SIXKFK7V.js +0 -8
  209. package/dist/chunks/add-Y5EDLFGD.js +0 -8
  210. package/dist/chunks/alerts-Q2GDU27W.js +0 -8
  211. package/dist/chunks/build-CYUKYXMV.js +0 -7
  212. package/dist/chunks/chunk-2VBFQZ72.js +0 -7
  213. package/dist/chunks/chunk-4NV7UPZE.js +0 -7
  214. package/dist/chunks/chunk-6GKP6VUF.js +0 -7
  215. package/dist/chunks/chunk-6VFNKB5V.js +0 -24
  216. package/dist/chunks/chunk-DTUEHPME.js +0 -7
  217. package/dist/chunks/chunk-HSGWG46B.js +0 -7
  218. package/dist/chunks/chunk-M2GHHK7B.js +0 -11
  219. package/dist/chunks/chunk-PIPRXGDM.js +0 -8
  220. package/dist/chunks/chunk-QK5HTPNC.js +0 -10
  221. package/dist/chunks/chunk-QOLGACFD.js +0 -7
  222. package/dist/chunks/chunk-SNKYDS4V.js +0 -7
  223. package/dist/chunks/chunk-YFMEZ4SZ.js +0 -7
  224. package/dist/chunks/clear-5PKM3HQU.js +0 -8
  225. package/dist/chunks/config-6GAZ64VS.js +0 -7
  226. package/dist/chunks/config-Y77DO6JM.js +0 -8
  227. package/dist/chunks/delete-S5WYOZG7.js +0 -10
  228. package/dist/chunks/delete-WWNN35PK.js +0 -9
  229. package/dist/chunks/disable-LSU7JSDS.js +0 -7
  230. package/dist/chunks/discard-DN4GAN6A.js +0 -14
  231. package/dist/chunks/edit-NUFYISN6.js +0 -9
  232. package/dist/chunks/edit-WQCT2BTX.js +0 -8
  233. package/dist/chunks/enable-ILXOI3I6.js +0 -7
  234. package/dist/chunks/future-5BCEXRHZ.js +0 -7
  235. package/dist/chunks/generate-cert-for-deploy-SXTI35ZG.js +0 -7
  236. package/dist/chunks/image-6OR56EZV.js +0 -7
  237. package/dist/chunks/inspect-OWDUGXCY.js +0 -8
  238. package/dist/chunks/inspect-RU7PVRWQ.js +0 -9
  239. package/dist/chunks/inspect-WJ2A2UKB.js +0 -13
  240. package/dist/chunks/list-CYVRTOUA.js +0 -12
  241. package/dist/chunks/list-JODDYSVR.js +0 -8
  242. package/dist/chunks/login-4L35OD6Y.js +0 -9
  243. package/dist/chunks/login-W5AW34VX.js +0 -7
  244. package/dist/chunks/logs-M3LRI4WS.js +0 -7
  245. package/dist/chunks/ls-QUC3XJDN.js +0 -11
  246. package/dist/chunks/ls-UY36HOHA.js +0 -8
  247. package/dist/chunks/mutate-ETSJAFK6.js +0 -9
  248. package/dist/chunks/notifications-XFMP6MBZ.js +0 -7
  249. package/dist/chunks/open-EOOHIAZV.js +0 -7
  250. package/dist/chunks/openapi-H4PBISI7.js +0 -7
  251. package/dist/chunks/permissions-KOZS3LUK.js +0 -7
  252. package/dist/chunks/prompt-missing-credentials-IV5LGNNZ.js +0 -7
  253. package/dist/chunks/publish-E55JDFF7.js +0 -15
  254. package/dist/chunks/pull-TUTGA5JK.js +0 -7
  255. package/dist/chunks/purchase-domain-if-available-6SARYPIK.js +0 -7
  256. package/dist/chunks/push-UBTJMO6Q.js +0 -7
  257. package/dist/chunks/query-KTJNUSFP.js +0 -7
  258. package/dist/chunks/raw-query-D3KKMGEJ.js +0 -8
  259. package/dist/chunks/reauthenticate-HYQL6JW7.js +0 -7
  260. package/dist/chunks/remove-QERLIR4R.js +0 -9
  261. package/dist/chunks/reorder-UCGI2FFJ.js +0 -10
  262. package/dist/chunks/reply-FRHAEVBD.js +0 -9
  263. package/dist/chunks/resolve-Z33ONVMR.js +0 -12
  264. package/dist/chunks/resolve-agent-team-ER4RZEJT.js +0 -7
  265. package/dist/chunks/restore-LQFGPBOB.js +0 -16
  266. package/dist/chunks/rm-4Z5TWVJJ.js +0 -8
  267. package/dist/chunks/rm-AOOIB5ZS.js +0 -8
  268. package/dist/chunks/rm-HCFBMSNJ.js +0 -8
  269. package/dist/chunks/rm-PAHHUTML.js +0 -8
  270. package/dist/chunks/rm-QVKGQ4UB.js +0 -8
  271. package/dist/chunks/rule-inspect-5VM4YF7A.js +0 -8
  272. package/dist/chunks/schema-MUBIHAGZ.js +0 -14
  273. package/dist/chunks/select-org-SGALVKOW.js +0 -7
  274. package/dist/chunks/set-NFLZFD7O.js +0 -7
  275. package/dist/chunks/set-SVOTRX7Z.js +0 -8
  276. package/dist/chunks/setup-and-link-7SPTSXXZ.js +0 -7
  277. package/dist/chunks/tags-BIX4YRL3.js +0 -7
  278. package/dist/chunks/usage-24PRDBPS.js +0 -13
@@ -0,0 +1,29 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __dirname_ } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ const __filename = __fileURLToPath(import.meta.url);
6
+ const __dirname = __dirname_(__filename);
7
+ import"./chunk-BZENIQ7N.js";import{execFile}from"child_process";import{existsSync as existsSync3}from"fs";import{mkdir as mkdir3,mkdtemp,readFile as readFile5,rm as rm3}from"fs/promises";import{homedir as homedir3,tmpdir}from"os";import{dirname as dirname5,isAbsolute as isAbsolute3,join as join6}from"path";import{promisify}from"util";import{basename,join}from"path";import{readFile,readdir,stat}from"fs/promises";import{existsSync}from"fs";import{basename as basename3,dirname as dirname4,join as join5,relative as relative4,resolve as resolve4}from"path";import{mkdir as mkdir2,cp as cp3,readFile as readFile4,readdir as readdir2,realpath as realpath2,rename,writeFile,rm as rm2}from"fs/promises";import{existsSync as existsSync2}from"fs";import{execFileSync as execFileSync3,execSync,spawnSync}from"child_process";import{createHash as createHash2}from"crypto";import{homedir as homedir2}from"os";import{cp,lstat,readlink,stat as stat2,symlink,unlink}from"fs/promises";import{dirname,isAbsolute,relative,resolve,sep}from"path";import{createHash}from"crypto";import{lstat as lstat2,readFile as readFile2}from"fs/promises";import{basename as basename2,join as join2,relative as relative2,resolve as resolve2}from"path";import{execFileSync}from"child_process";import{realpathSync}from"fs";import{cp as cp2,lstat as lstat3,mkdir,readFile as readFile3,realpath,rm}from"fs/promises";import{dirname as dirname2,isAbsolute as isAbsolute2,join as join3,relative as relative3,resolve as resolve3}from"path";import{AsyncLocalStorage}from"async_hooks";import{dirname as dirname3,join as join4}from"path";import{execFileSync as execFileSync2}from"child_process";import{homedir}from"os";async function discover(repoPath){let marketplacePaths=[join(repoPath,"marketplace.json"),join(repoPath,".plugin","marketplace.json"),join(repoPath,".claude-plugin","marketplace.json"),join(repoPath,".cursor-plugin","marketplace.json"),join(repoPath,".codex-plugin","marketplace.json")];for(let mp of marketplacePaths)if(await fileExists(mp)){let data=await readJson(mp);if(data&&typeof data=="object"&&"plugins"in data&&Array.isArray(data.plugins))return discoverFromMarketplace(repoPath,data)}if(await isPluginDir(repoPath)){let plugin=await inspectPlugin(repoPath);return{plugins:plugin?[plugin]:[],remotePlugins:[],missingPaths:[]}}let plugins=[];return await scanForPlugins(repoPath,plugins,2),{plugins,remotePlugins:[],missingPaths:[]}}async function scanForPlugins(dirPath,results,depth){if(depth<=0)return;let entries=await readDirSafe(dirPath);for(let entry of entries){if(!entry.isDirectory()||entry.name.startsWith("."))continue;let childPath=join(dirPath,entry.name);if(await isPluginDir(childPath)){let plugin=await inspectPlugin(childPath);plugin&&results.push(plugin)}else await scanForPlugins(childPath,results,depth-1)}}async function discoverFromMarketplace(repoPath,marketplace){let plugins=[],remotePlugins=[],missingPaths=[],root=marketplace.metadata?.pluginRoot??".";for(let entry of marketplace.plugins){if(typeof entry.source!="string"){remotePlugins.push({name:entry.name,description:entry.description||void 0,source:entry.source});continue}let sourcePath=join(repoPath,root,entry.source.replace(/^\.\//,""));if(!await dirExists(sourcePath)){missingPaths.push(entry.source);continue}let skills;if(entry.skills&&Array.isArray(entry.skills)){skills=[];for(let skillPath of entry.skills){let resolvedPath=join(repoPath,root,skillPath.replace(/^\.\//,"")),skillMd=join(resolvedPath,"SKILL.md");if(await fileExists(skillMd)){let content=await readFile(skillMd,"utf-8"),fm=parseFrontmatter(content);skills.push({name:fm.name??dirName(resolvedPath),description:fm.description??""})}}}else skills=await discoverSkills(sourcePath);let manifest=null;for(let manifestDir of[".plugin",".claude-plugin",".cursor-plugin",".codex-plugin"]){let manifestPath=join(sourcePath,manifestDir,"plugin.json");if(await fileExists(manifestPath)){manifest=await readJson(manifestPath);break}}let[commands,agents,rules,hasHooks,hasMcp,hasLsp]=await Promise.all([discoverCommands(sourcePath),discoverAgents(sourcePath),discoverRules(sourcePath),fileExists(join(sourcePath,"hooks","hooks.json")),fileExists(join(sourcePath,".mcp.json")),fileExists(join(sourcePath,".lsp.json"))]),name=entry.name||manifest?.name||dirName(sourcePath);plugins.push({name,version:entry.version||manifest?.version||void 0,description:entry.description||manifest?.description||void 0,path:sourcePath,marketplace:marketplace.name,skills,commands,agents,rules,hasHooks,hasMcp,hasLsp,manifest,explicitSkillPaths:entry.skills,marketplaceEntry:entry})}return{plugins,remotePlugins,missingPaths}}async function isPluginDir(dirPath){let checks=[join(dirPath,".plugin","plugin.json"),join(dirPath,".claude-plugin","plugin.json"),join(dirPath,".cursor-plugin","plugin.json"),join(dirPath,".codex-plugin","plugin.json"),join(dirPath,"skills"),join(dirPath,"commands"),join(dirPath,"agents"),join(dirPath,"SKILL.md")];for(let check of checks)if(await pathExists(check))return!0;return!1}async function inspectPlugin(pluginPath){let manifest=null;for(let manifestDir of[".plugin",".claude-plugin",".cursor-plugin",".codex-plugin"]){let manifestPath=join(pluginPath,manifestDir,"plugin.json");if(await fileExists(manifestPath)){manifest=await readJson(manifestPath);break}}let name=manifest?.name??dirName(pluginPath),[skills,commands,agents,rules,hasHooks,hasMcp,hasLsp]=await Promise.all([discoverSkills(pluginPath),discoverCommands(pluginPath),discoverAgents(pluginPath),discoverRules(pluginPath),fileExists(join(pluginPath,"hooks","hooks.json")),fileExists(join(pluginPath,".mcp.json")),fileExists(join(pluginPath,".lsp.json"))]);return{name,version:manifest?.version,description:manifest?.description,path:pluginPath,marketplace:void 0,skills,commands,agents,rules,hasHooks,hasMcp,hasLsp,manifest,explicitSkillPaths:void 0,marketplaceEntry:void 0}}async function discoverSkills(pluginPath){let skillsDir=join(pluginPath,"skills"),entries=await readDirSafe(skillsDir),skills=[];for(let entry of entries){if(!entry.isDirectory())continue;let skillMd=join(skillsDir,entry.name,"SKILL.md");if(await fileExists(skillMd)){let content=await readFile(skillMd,"utf-8"),fm=parseFrontmatter(content);skills.push({name:fm.name??entry.name,description:fm.description??""})}}if(skills.length===0){let rootSkill=join(pluginPath,"SKILL.md");if(await fileExists(rootSkill)){let content=await readFile(rootSkill,"utf-8"),fm=parseFrontmatter(content);skills.push({name:fm.name??dirName(pluginPath),description:fm.description??""})}}return skills}async function discoverCommands(pluginPath){let commandsDir=join(pluginPath,"commands"),entries=await readDirSafe(commandsDir),commands=[];for(let entry of entries){if(!entry.isFile()||!entry.name.match(/\.(md|mdc|markdown)$/))continue;let filePath=join(commandsDir,entry.name),content=await readFile(filePath,"utf-8"),fm=parseFrontmatter(content);commands.push({name:entry.name.replace(/\.(md|mdc|markdown)$/,""),description:fm.description??""})}return commands}async function discoverAgents(pluginPath){let agentsDir=join(pluginPath,"agents"),entries=await readDirSafe(agentsDir),agents=[];for(let entry of entries){if(!entry.isFile()||!entry.name.match(/\.(md|mdc|markdown)$/))continue;let filePath=join(agentsDir,entry.name),content=await readFile(filePath,"utf-8"),fm=parseFrontmatter(content);fm.name&&fm.description&&agents.push({name:fm.name,description:fm.description})}return agents}async function discoverRules(pluginPath){let rulesDir=join(pluginPath,"rules"),entries=await readDirSafe(rulesDir),rules=[];for(let entry of entries){if(!entry.isFile()||!entry.name.match(/\.(mdc|md|markdown)$/))continue;let filePath=join(rulesDir,entry.name),content=await readFile(filePath,"utf-8"),fm=parseFrontmatter(content);rules.push({name:entry.name.replace(/\.(mdc|md|markdown)$/,""),description:fm.description??""})}return rules}function parseFrontmatter(content){let match=content.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!match?.[1])return{};let result={};for(let line of match[1].split(`
8
+ `)){let kv=line.match(/^(\w[\w-]*):\s*(.+)$/);if(kv){let val=kv[2].trim();(val.startsWith('"')&&val.endsWith('"')||val.startsWith("'")&&val.endsWith("'"))&&(val=val.slice(1,-1)),val==="true"?result[kv[1]]=!0:val==="false"?result[kv[1]]=!1:result[kv[1]]=val}}return result}function dirName(p){return basename(p)||"unknown"}async function fileExists(path){try{return(await stat(path)).isFile()}catch{return!1}}async function dirExists(dirPath){try{return(await stat(dirPath)).isDirectory()}catch{return!1}}async function pathExists(p){return existsSync(p)}async function readJson(path){try{let content=await readFile(path,"utf-8");return JSON.parse(content)}catch{return null}}async function readDirSafe(dirPath){try{return await readdir(dirPath,{withFileTypes:!0})}catch{return[]}}async function copyPluginTree(source,destination,pluginRoots=[source]){let boundaries=[...pluginRoots].sort((left,right)=>right.length-left.length);await cp(source,destination,{recursive:!0,filter:async(entry,copy)=>{if(!(await lstat(entry)).isSymbolicLink())return!0;let target=await readlink(entry),root=boundaries.find(boundary=>inside(boundary,entry));if(isAbsolute(target)||!root||!inside(root,resolve(dirname(entry),target)))return!0;let type;try{type=(await stat2(entry)).isDirectory()?"dir":"file"}catch(error){if(["ENOENT","ENOTDIR","ELOOP"].includes(error.code??""))return!0;throw error}try{await unlink(copy)}catch(error){if(error.code!=="ENOENT")throw error}return await symlink(target,copy,type),!1}})}function inside(root,path){let rel=relative(root,path);return rel!==".."&&!rel.startsWith(`..${sep}`)&&!isAbsolute(rel)}var SCHEMA_PREFIX="https://agent-plugins.org/schemas/",SUPPORTED_SCHEMA=`${SCHEMA_PREFIX}1.0.0/plugin.schema.json`;function codexCacheVersion(manifest){if(!manifest||typeof manifest!="object"||Array.isArray(manifest))throw new Error("Codex plugin manifest must be an object.");let data=manifest,agentPlugin=data.$schema===SUPPORTED_SCHEMA;if(typeof data.$schema=="string"&&data.$schema.startsWith(SCHEMA_PREFIX)&&!agentPlugin)throw new Error(`Codex does not support plugin schema "${data.$schema}".`);let raw=data.version;if(raw!=null&&typeof raw!="string")throw new Error("Codex plugin version must be a string.");let version=typeof raw=="string"?raw.trim():void 0,selected=version||(agentPlugin?"1.0.0":version===void 0?"local":"");if(selected&&selected!=="."&&selected!==".."&&/^[a-zA-Z0-9._+-]+$/.test(selected))return selected;if(agentPlugin)return`agent-plugins-${createHash("sha256").update(selected).digest("hex").slice(0,24)}`;throw new Error(`Invalid Codex plugin version "${selected}" for an installed cache directory.`)}async function readCodexCacheManifest(pluginRoot,fallback){let rootPath=join2(pluginRoot,"plugin.json"),rootExists=!1;try{let info=await lstat2(rootPath);if(rootExists=!0,!info.isFile())throw new Error(`${rootPath}: Codex requires a regular manifest file.`)}catch(error){if(error.code!=="ENOENT")throw error}if(rootExists){let text=await readFile2(rootPath,"utf8"),root;try{root=JSON.parse(text)}catch{}if(root&&typeof root=="object"&&!Array.isArray(root)){let schema=root.$schema;if(typeof schema=="string"&&schema.startsWith(SCHEMA_PREFIX))return{version:codexCacheVersion(root)}}}for(let directory of[".codex-plugin",".claude-plugin",".cursor-plugin"]){let text;try{text=await readFile2(join2(pluginRoot,directory,"plugin.json"),"utf8")}catch(error){if(error.code==="ENOENT")continue;throw error}return{version:codexCacheVersion(JSON.parse(text))}}if(fallback)return{version:codexCacheVersion(fallback),fallback};throw new Error(`${pluginRoot}: Codex plugin manifest is missing.`)}function codexPluginCacheRoot(cacheDir,pluginName,marketplaceName="plugins-cli"){if(!/^[A-Za-z0-9_-]+$/.test(marketplaceName))throw new Error(`Unsafe Codex marketplace name "${marketplaceName}" for cache replacement.`);let root=resolve2(cacheDir,marketplaceName),selected=resolve2(root,pluginName);if(!pluginName||pluginName==="."||pluginName===".."||/[/\\]/.test(pluginName)||basename2(pluginName)!==pluginName||relative2(root,selected)!==pluginName||process.platform==="win32"&&/[. ]$/.test(pluginName))throw new Error(`Unsafe Codex plugin name "${pluginName}" for cache replacement.`);return selected}function enableCodexPlugin(contents,pluginKey){let key=pluginKey.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),header=new RegExp(`^[\\t ]*\\[[\\t ]*plugins[\\t ]*\\.[\\t ]*(?:"${key}"|'${key}')[\\t ]*\\][\\t ]*(?:#.*)?\\r?$`),lines=contents.split(`
9
+ `),start=lines.findIndex(line=>header.test(line)),newline=contents.includes(`\r
10
+ `)?`\r
11
+ `:`
12
+ `;if(start<0)return`${contents}${newline}[plugins.${JSON.stringify(pluginKey)}]${newline}enabled = true${newline}`;let end=start+1;for(;end<lines.length&&!/^[\t ]*\[/.test(lines[end]);)end++;for(let i=start+1;i<end;i++){if(!/^[\t ]*(?:enabled|"enabled"|'enabled')[\t ]*=/.test(lines[i]))continue;let assignment=/^([\t ]*(?:enabled|"enabled"|'enabled')[\t ]*=[\t ]*)(true|false)([\t ]*(?:#.*)?\r?)$/.exec(lines[i]);if(!assignment)throw new Error(`Codex plugin ${pluginKey}: expected a boolean enabled setting.`);return assignment[2]==="true"?contents:(lines[i]=`${assignment[1]}true${assignment[3]}`,lines.join(`
13
+ `))}return lines.splice(start+1,0,`enabled = true${lines[start].endsWith("\r")?"\r":""}`),lines.join(`
14
+ `)}function configuredCodexPlugin(contents,pluginKey){let key=pluginKey.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),header=new RegExp(`^[\\t ]*\\[[\\t ]*plugins[\\t ]*\\.[\\t ]*(?:"${key}"|'${key}')[\\t ]*\\][\\t ]*(?:#.*)?\\r?$`),childKey=String.raw`(?:[A-Za-z0-9_-]+|"[^"\\\r\n]*"|'[^'\r\n]*')`,descendant=new RegExp(`^[\\t ]*\\[[\\t ]*plugins[\\t ]*\\.[\\t ]*(?:"${key}"|'${key}')[\\t ]*(?:\\.[\\t ]*${childKey}[\\t ]*)+\\][\\t ]*(?:#.*)?\\r?$`),mention=new RegExp(`(?:"${key}"|'${key}')`),lines=contents.split(`
15
+ `),found=[],implied=!1,inPluginsTable=!1;for(let index=0;index<lines.length;index++){let line=lines[index];if(/^[\t ]*\[/.test(line)&&(inPluginsTable=/^[\t ]*\[[\t ]*plugins[\t ]*\]/.test(line)),header.test(line))found.push(index);else if(descendant.test(line))implied=!0;else if((inPluginsTable||/^[\t ]*(?:\[[^#]*plugins|plugins[\t .=])/.test(line))&&mention.test(line.split("#",1)[0]))throw new Error(`Codex plugin ${pluginKey}: unsupported configuration layout.`)}if(found.length>1)throw new Error(`Codex plugin ${pluginKey}: duplicate configured tables.`);if(found.length===0)return implied;let enabledCount=0;for(let index=found[0]+1;index<lines.length&&!/^[\t ]*\[/.test(lines[index]);index++)if(/^[\t ]*(?:enabled|"enabled"|'enabled')(?:[\t ]|=|$)/.test(lines[index])){if(!/^[\t ]*(?:enabled|"enabled"|'enabled')[\t ]*=/.test(lines[index]))throw new Error(`Codex plugin ${pluginKey}: malformed enabled setting.`);enabledCount++}if(enabledCount>1)throw new Error(`Codex plugin ${pluginKey}: duplicate enabled settings.`);return enableCodexPlugin(contents,pluginKey),!0}function codexMarketplaceManifest(entry){let{source:_source,policy:_policy,name,category,...fields}=entry;if(!(Object.keys(fields).length===0&&category==null))return{...fields,name,...category==null?{}:{category}}}async function loadCodexMarketplace(repoPath,selectedNames,source){let manifestPath=join3(repoPath,".agents","plugins","marketplace.json"),contents;try{contents=await readFile3(manifestPath,"utf8")}catch(error){if(error.code==="ENOENT")return null;throw error}let catalog=JSON.parse(contents);if(!isObject(catalog)||!Array.isArray(catalog.plugins))return null;let eligible=selectedNames.map(name=>catalog.plugins.find(entry=>isObject(entry)&&entry.name===name)).filter(entry=>isObject(entry)&&localSource(entry.source)!==void 0);if(typeof catalog.name!="string"||!/^[A-Za-z0-9_-]+$/.test(catalog.name))throw new Error(`${manifestPath}: invalid Codex marketplace name.`);let root=await realpath(repoPath),plugins=await Promise.all(eligible.map(async value=>{let entry=value,declaredPath=localSource(entry.source);if(declaredPath!=="."&&declaredPath!=="./"&&(!declaredPath.startsWith("./")||declaredPath.slice(2).split(/[/\\]/).some(part=>part==="."||part==="..")))throw new Error(`${manifestPath}: invalid local source path for ${entry.name}.`);let path=await realpath(resolve3(root,declaredPath)),within=relative3(root,path);if(isAbsolute2(within)||within===".."||within.startsWith(`..${process.platform==="win32"?"\\":"/"}`))throw new Error(`${manifestPath}: plugin ${entry.name} resolves outside its source repository.`);if(!(await lstat3(path)).isDirectory())throw new Error(`${manifestPath}: plugin ${entry.name} source must be a directory.`);return{name:entry.name,path,entry}}));return{name:catalog.name,...await codexMarketplaceSource(root,source),repoPath:root,plugins}}async function codexMarketplaceSource(repoPath,source){let root=await realpath(repoPath);if(!codexGitSource(source))return{sourceType:"local",source:root};let origin=codexGitSource(readGitOrigin(root));if(!origin)throw new Error(`${root}: acquired Git repository has no supported remote origin.`);return{sourceType:"git",source:origin}}function configuredCodexMarketplacesForSource(contents,source){let header=/^[\t ]*\[[\t ]*marketplaces[\t ]*\.[\t ]*(?:([A-Za-z0-9_-]+)|"([A-Za-z0-9_-]+)"|'([A-Za-z0-9_-]+)')[\t ]*\][\t ]*(?:#.*)?\r?$/gm,names=new Set;for(let table of contents.matchAll(header)){let name=table[1]??table[2]??table[3],body=marketplaceBody(contents,table);try{sameMarketplaceSource(readMarketplaceSource(body,name),source)&&names.add(name)}catch{}}return[...names]}function codexGitSource(source){if(/^[\w-]+\/[\w.-]+$/.test(source))return`https://github.com/${source}.git`;if(!/^(?:https?:\/\/|ssh:\/\/|git@)/.test(source))return null;let normalized=source.replace(/\/+$/,"");return normalized.startsWith("https://github.com/")&&!normalized.endsWith(".git")?`${normalized}.git`:normalized}function appendCodexMarketplaceConfiguration(contents,plan){let key=plan.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),existing=new RegExp(`^[\\t ]*\\[[\\t ]*marketplaces[\\t ]*\\.[\\t ]*(?:${key}|"${key}"|'${key}')[\\t ]*\\][\\t ]*(?:#.*)?\\r?$`,"m").exec(contents);if(existing){let body=marketplaceBody(contents,existing),registered=readMarketplaceSource(body,plan.name),ref=/^[\t ]*(?:ref|"ref"|'ref')[\t ]*=/m.test(body),sparse=/^[\t ]*(?:sparse_paths|"sparse_paths"|'sparse_paths')[\t ]*=[\t ]*(.*)$/m.exec(body),selectedPaths=sparse&&!/^\[\s*\]\s*(?:#.*)?$/.test(sparse[1]);if(!sameMarketplaceSource(registered,plan)||ref||selectedPaths)throw new Error(`Codex marketplace ${plan.name} is already registered from a different source or selection. Remove that marketplace registration before installing this source.`);return contents}return`${contents}
16
+ [marketplaces.${JSON.stringify(plan.name)}]
17
+ source_type = ${JSON.stringify(plan.sourceType)}
18
+ source = ${JSON.stringify(plan.source)}
19
+ `}async function prepareCodexMarketplace(plan,codexHome){if(plan.sourceType==="local")return;let destination=join3(codexHome,".tmp","marketplaces",plan.name),exists=!1;try{if(await realpath(destination)===plan.repoPath)return;exists=!0}catch(error){if(error.code!=="ENOENT")throw error}if(exists){let origin;try{origin=readGitOrigin(destination)}catch{throw new Error(`Codex marketplace ${plan.name} already exists without a matching Git source.`)}if(codexGitSource(origin)!==plan.source)throw new Error(`Codex marketplace ${plan.name} already belongs to a different Git source.`)}await mkdir(dirname2(destination),{recursive:!0}),await rm(destination,{recursive:!0,force:!0}),await cp2(plan.repoPath,destination,{recursive:!0})}function marketplaceBody(contents,header){return contents.slice(header.index+header[0].length).split(/^[\t ]*\[/m,1)[0]}function readMarketplaceSource(body,name){let readString=field=>{let assignment=new RegExp(`^[\\t ]*(?:${field}|"${field}"|'${field}')[\\t ]*=[\\t ]*("(?:[^"\\\\\\r\\n]|\\\\.)*"|'[^'\\r\\n]*')[\\t ]*(?:#.*)?\\r?$`,"m").exec(body);if(!assignment)throw new Error(`Codex marketplace ${name}: cannot read existing ${field} setting.`);let value=assignment[1];return value.startsWith("'")?value.slice(1,-1):JSON.parse(value)};return{sourceType:readString("source_type"),source:readString("source")}}function sameMarketplaceSource(registered,incoming){return registered.sourceType===incoming.sourceType&&(incoming.sourceType==="git"?codexGitSource(registered.source)===incoming.source:realpathSync.native(registered.source)===realpathSync.native(incoming.source))}function readGitOrigin(repoPath){return execFileSync("git",["-C",repoPath,"config","--local","--get","remote.origin.url"],{encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}function localSource(source){if(typeof source=="string")return source;if(isObject(source)&&source.source==="local"&&typeof source.path=="string")return source.path}function isObject(value){return value!==null&&typeof value=="object"&&!Array.isArray(value)}var installerContexts=new AsyncLocalStorage,cliInstallerState={cachePopulated:!1};function installerState(){return installerContexts.getStore()??cliInstallerState}function withInstallerContext(context,run){return installerContexts.run(context,run)}function currentInstallerContext(){return installerContexts.getStore()}function environmentValue(name){let env=installerContexts.getStore()?.env??process.env,key=process.platform==="win32"?Object.keys(env).find(key2=>key2.toUpperCase()===name.toUpperCase()):name;return key===void 0?void 0:env[key]}function childProcessOptions(){let context=installerContexts.getStore();return context?{cwd:context.cwd,env:context.env}:{}}function getVsCodeSettingsPath(){let product=detectBinary("code")||!detectBinary("code-insiders")?"Code":"Code - Insiders",home=homedir();return process.platform==="darwin"?join4(home,"Library","Application Support",product,"User","settings.json"):process.platform==="win32"?join4(environmentValue("APPDATA")??join4(home,"AppData","Roaming"),product,"User","settings.json"):join4(home,".config",product,"User","settings.json")}var TARGET_DEFS=[{id:"claude-code",name:"Claude Code",description:"Anthropic's CLI coding agent",configPath:()=>join4(homedir(),".claude")},{id:"cursor",name:"Cursor",description:"AI-powered editor and terminal agent",configPath:()=>join4(homedir(),".cursor")},{id:"codex",name:"Codex",description:"OpenAI's coding agent",configPath:()=>join4(homedir(),".codex")},{id:"grok",name:"Grok Build",description:"xAI's CLI coding agent",configPath:()=>join4(homedir(),".grok")},{id:"kimi",name:"Kimi Code",description:"Moonshot AI's CLI coding agent",configPath:()=>environmentValue("KIMI_CODE_HOME")??join4(homedir(),".kimi-code")},{id:"github-copilot",name:"GitHub Copilot CLI",description:"GitHub Copilot\u2019s standalone coding agent",configPath:()=>join4(homedir(),".copilot")},{id:"vscode",name:"Visual Studio Code",description:"VS Code agent plugins (Preview)",configPath:()=>dirname3(getVsCodeSettingsPath())}],SUPPORTED_TARGETS=TARGET_DEFS.map(({id,name})=>({id,name}));async function getTargets(){let targets=[];for(let def of TARGET_DEFS){let detected=detectTarget(def);targets.push({...def,configPath:def.configPath(),detected})}return targets}function detectTarget(def){switch(def.id){case"claude-code":return detectBinary("claude");case"cursor":return detectBinary("cursor")||detectBinary("cursor-agent");case"codex":return detectBinary("codex");case"grok":return detectBinary("grok");case"kimi":return getKimiBinary()!==null;case"github-copilot":return detectBinary("copilot");case"vscode":return detectBinary("code")||detectBinary("code-insiders");default:return!1}}function getKimiBinary(){let path=findBinary("kimi");if(path)return path;let home=homedir(),kimiHome=environmentValue("KIMI_CODE_HOME")??join4(home,".kimi-code"),extension=process.platform==="win32"?".exe":"",candidates=[join4(kimiHome,"bin",`kimi${extension}`),join4(home,".local","bin",`kimi${extension}`),join4(home,".kimi","bin",`kimi${extension}`)];for(let candidate of candidates)try{return execFileSync2(candidate,["--version"],{stdio:"pipe",timeout:1e4,...childProcessOptions()}),candidate}catch{}return null}function detectBinary(name){return findBinary(name)!==null}function findBinary(name){try{let windows=process.platform==="win32",systemRoot=environmentValue("SystemRoot"),locator=windows?systemRoot?join4(systemRoot,"System32","where.exe"):"where.exe":"which",output=execFileSync2(locator,[windows?`$PATH:${name}`:name],{encoding:"utf-8",stdio:"pipe",...childProcessOptions()});return(windows?output.split(/\r?\n/)[0]?.trim():output.trim())||null}catch{return null}}var isColorSupported=process.env.FORCE_COLOR!=="0"&&!process.env.NO_COLOR&&(process.env.FORCE_COLOR!==void 0||process.stdout.isTTY);function ansi(code){return isColorSupported?`\x1B[${code}m`:""}var reset=ansi("0"),bold=ansi("1"),dim=ansi("2"),italic=ansi("3"),underline=ansi("4"),red=ansi("31"),green=ansi("32"),yellow=ansi("33"),blue=ansi("34"),magenta=ansi("35"),cyan=ansi("36"),gray=ansi("90"),bgGreen=ansi("42"),bgRed=ansi("41"),bgYellow=ansi("43"),bgCyan=ansi("46"),black=ansi("30"),c={bold:s=>`${bold}${s}${reset}`,dim:s=>`${dim}${s}${reset}`,italic:s=>`${italic}${s}${reset}`,underline:s=>`${underline}${s}${reset}`,red:s=>`${red}${s}${reset}`,green:s=>`${green}${s}${reset}`,yellow:s=>`${yellow}${s}${reset}`,blue:s=>`${blue}${s}${reset}`,magenta:s=>`${magenta}${s}${reset}`,cyan:s=>`${cyan}${s}${reset}`,gray:s=>`${gray}${s}${reset}`,bgGreen:s=>`${bgGreen}${black}${s}${reset}`,bgRed:s=>`${bgRed}${black}${s}${reset}`,bgYellow:s=>`${bgYellow}${black}${s}${reset}`,bgCyan:s=>`${bgCyan}${black}${s}${reset}`},S={bar:"\u2502",barEnd:"\u2514",barStart:"\u250C",barH:"\u2500",corner:"\u256E",diamond:"\u25C7",diamondFilled:"\u25C6",bullet:"\u25CF",circle:"\u25CB",check:"\u2714",cross:"\u2716",arrow:"\u2192",warning:"\u25B2",info:"\u2139",step:"\u25C7",stepActive:"\u25C6",stepComplete:"\u25CF",stepError:"\u25A0"};function emit(type,content,rendered){let context=currentInstallerContext();context?context.report({type,text:content.replace(/\x1b\[[0-9;]*m/g,"")}):console.log(rendered)}function barLine(content=""){emit("line",content,`${c.gray(S.bar)} ${content}`)}function barEmpty(){emit("line","",`${c.gray(S.bar)}`)}var _debug=!1;function barDebug(content=""){_debug&&barLine(content)}function step(content){emit("step",content,`${c.gray(S.step)} ${content}`)}function stepDone(content){emit("step",content,`${c.green(S.stepComplete)} ${content}`)}function stepError(content){emit("error",content,`${c.red(S.stepError)} ${content}`)}function warn(message){emit("warning",message,`${c.gray(S.bar)} ${c.yellow(S.warning)} ${c.yellow(message)}`)}function printRefreshHint(targetId,subject="these local copies"){barLine(`To refresh ${subject}, repeat add with the original source:`),barLine(` ${c.cyan(`npx plugins add <original-source> --target ${targetId}`)}`)}function assertInstallScope(scope,targets,source){if(!["user","project","local"].includes(scope))throw new Error(`Unknown scope "${scope}". Expected user, project, or local.`);if(scope==="user")return;let unsupported=targets.filter(target=>target.id!=="claude-code"||!getOfficialPluginRef(source));if(unsupported.length>0)throw new Error(`Scope "${scope}" is not supported for ${unsupported.map(target=>target.name).join(", ")} with this source. Project and local scopes require --target claude-code with vercel/vercel-plugin.`)}async function installPlugins(plugins,target,scope,repoPath,source){try{return{succeeded:await installPluginsUnsafe(plugins,target,scope,repoPath,source)}}catch(err){return{succeeded:!1,message:err instanceof Error?err.message:String(err)}}}async function installPluginsUnsafe(plugins,target,scope,repoPath,source){switch(assertInstallScope(scope,[target],source),target.id){case"claude-code":{let officialRef=getOfficialPluginRef(source);if(officialRef){if(await installViaClaudeCli(officialRef,scope)){installerState().cachePopulated=!0;break}if(scope!=="user")throw new Error(`Claude's native installation could not complete scope "${scope}"; no fallback installation was performed.`);barDebug(c.dim("Falling back to direct file-based install"))}let workspace=await stageInstallWorkspace(plugins,repoPath,target.id);await installToClaudeCode(workspace.plugins,scope,workspace.repoPath,source);break}case"cursor":{if(installerState().cachePopulated)return!0;let workspace=await stageInstallWorkspace(plugins,repoPath,target.id);await installToCursor(workspace.plugins,scope,workspace.repoPath,source);break}case"codex":{if(getOfficialCodexPluginRef(source)){installViaCodexCli();break}return installToCodex(plugins,repoPath,source)}case"grok":{let nativeSource=getGrokNativeSource(source,plugins,repoPath);if(nativeSource)return installToGrok(plugins,nativeSource);let workspace=await stageInstallWorkspace(plugins,repoPath,target.id);return installToGrok(workspace.plugins)}case"kimi":{let workspace=await stageInstallWorkspace(plugins,repoPath,target.id);await installToKimi(workspace.plugins);break}case"github-copilot":{await installToGitHubCopilot(plugins,repoPath,source);break}case"vscode":{let workspace=await stageInstallWorkspace(plugins,repoPath,target.id);await installToVsCode(workspace.plugins);break}default:throw new Error(`Unsupported target: ${target.id}`)}return!0}async function stageInstallWorkspace(plugins,repoPath,targetId,stagingBaseDir=join5(homedir2(),".cache","plugins",".install-staging")){let stageKey=createHash2("sha1").update(repoPath).digest("hex"),stageRoot=join5(stagingBaseDir,stageKey,targetId),stagedRepoPath=join5(stageRoot,"repo");await mkdir2(stageRoot,{recursive:!0}),await rm2(stagedRepoPath,{recursive:!0,force:!0}),targetId==="claude-code"||targetId==="cursor"?await copyPluginTree(repoPath,stagedRepoPath,plugins.map(plugin=>plugin.path)):await cp3(repoPath,stagedRepoPath,{recursive:!0});let stagedPlugins=plugins.map(plugin=>{let relPath=relative4(repoPath,plugin.path);return{...plugin,path:relPath===""?stagedRepoPath:join5(stagedRepoPath,relPath)}});return{repoPath:stagedRepoPath,plugins:stagedPlugins}}var OFFICIAL_MARKETPLACE_SOURCE="anthropics/claude-plugins-official";function getGitHubSourceRepo(source){let repo=null,shorthand=source.match(/^([\w.-]+\/[\w.-]+?)(?:\.git)?$/);if(shorthand&&(repo=shorthand[1].toLowerCase()),!repo){let https=source.match(/^https?:\/\/github\.com\/([\w.-]+\/[\w.-]+?)(?:\.git)?$/);https&&(repo=https[1].toLowerCase())}if(!repo){let ssh=source.match(/^git@github\.com:([\w.-]+\/[\w.-]+?)(?:\.git)?$/);ssh&&(repo=ssh[1].toLowerCase())}return repo}function getOfficialPluginRef(source){return getGitHubSourceRepo(source)==="vercel/vercel-plugin"?"vercel@claude-plugins-official":null}function getOfficialCodexPluginRef(source){return getGitHubSourceRepo(source)==="vercel/vercel-plugin"?"vercel@openai-curated":null}async function installViaClaudeCli(pluginRef,scope){let claude=findClaudeOrNull();if(!claude)return!1;try{return step("Registering official Claude marketplace"),execSync(`${claude} plugin marketplace add ${OFFICIAL_MARKETPLACE_SOURCE}`,{stdio:"pipe",timeout:12e4,...childProcessOptions()}),stepDone("Official marketplace registered"),step(`Installing ${c.cyan(pluginRef)} via Claude CLI`),execSync(`${claude} plugin install "${pluginRef}" --scope ${scope}`,{stdio:"pipe",timeout:12e4,...childProcessOptions()}),stepDone(`Installed ${c.cyan(pluginRef)} via Claude CLI`),!0}catch(err){let msg=err instanceof Error?err.message:String(err);return barDebug(c.dim(`Claude CLI install failed: ${msg}`)),!1}}function installViaCodexCli(){let failures=[];step(`Installing ${c.cyan("vercel/vercel-plugin")} via Codex marketplace`);for(let ref of["vercel@openai-curated","vercel@openai-api-curated"]){let result=spawnSync("codex",["plugin","add",ref],{encoding:"utf-8",stdio:"pipe",timeout:12e4,...childProcessOptions()});if(!result.error&&result.status===0){stepDone(`Installed ${c.cyan(ref)} via Codex marketplace`);return}let detail=[result.error?.message||(result.signal?`Terminated by ${result.signal}`:""),result.stderr?.trim()].filter(Boolean).join(`
20
+ `)||`Exited with status ${result.status}`,diagnostic=`${ref}: Codex installation failed. ${detail}`;if(failures.push(diagnostic),barDebug(c.dim(diagnostic)),result.error||result.status===null)break}throw new Error(failures.join(`
21
+ `))}async function installToClaudeCode(plugins,scope,repoPath,source){await installToPluginCache(plugins,scope,repoPath,source,"claude-code")}async function installToCursor(plugins,scope,repoPath,source){installerState().cachePopulated||await installToPluginCache(plugins,scope,repoPath,source,"cursor")}async function installToPluginCache(plugins,scope,repoPath,source,targetId){let marketplaceName=plugins[0]?.marketplace??deriveMarketplaceName(source),home=homedir2(),pluginsDir=join5(home,".claude","plugins"),cacheDir=join5(pluginsDir,"cache"),marketplacesDir=join5(pluginsDir,"marketplaces"),marketplaceInstallLocation=resolve4(marketplacesDir,marketplaceName);if(!marketplaceName||marketplaceName==="."||marketplaceName===".."||basename3(marketplaceName)!==marketplaceName||relative4(marketplacesDir,marketplaceInstallLocation)!==marketplaceName||process.platform==="win32"&&/[. ]$/.test(marketplaceName))throw new Error(`Unsafe marketplace name "${marketplaceName}": expected one directory name. Use an absolute local source path or a marketplace with an explicit safe name.`);let installedPath=join5(pluginsDir,"installed_plugins.json"),installedData={version:2,plugins:{}};if(existsSync2(installedPath)){let parsed;try{parsed=JSON.parse(await readFile4(installedPath,"utf-8"))}catch(error){throw new Error(`${installedPath}: could not read existing registrations. ${error instanceof Error?error.message:String(error)}`)}if(!isRecord(parsed)||!isRecord(parsed.plugins))throw new Error(`${installedPath}: expected an object with a plugins map; existing registrations were not changed.`);installedData={...parsed,version:parsed.version??2,plugins:{...parsed.plugins}}}let gitSha;try{gitSha=execSync("git rev-parse HEAD",{...childProcessOptions(),cwd:repoPath,encoding:"utf-8",stdio:"pipe"}).trim()}catch{}let plans=plugins.map(plugin=>{let pluginKey=`${plugin.name}@${marketplaceName}`,entries=Object.hasOwn(installedData.plugins,pluginKey)?installedData.plugins[pluginKey]:[];if(!Array.isArray(entries))throw new Error(`${installedPath}: ${pluginKey} must contain an installation array; existing registrations were not changed.`);let version=plugin.version??"0.0.0",versionKey=gitSha?gitSha.slice(0,12):version,cacheDest=join5(cacheDir,marketplaceName,plugin.name,versionKey),retained=entries.filter(entry=>!isRecord(entry)||entry.scope!=="user");return{plugin,pluginKey,version,cacheDest,retained}});for(let{cacheDest}of plans)for(let records of Object.values(installedData.plugins))if(Array.isArray(records)){for(let record of records)if(isRecord(record)&&record.scope!=="user"&&typeof record.installPath=="string"&&await samePath(record.installPath,cacheDest))throw new Error(`Cannot overwrite ${cacheDest}: another installation scope uses these files. No shared plugin files or registrations were changed.`)}step("Preparing plugins for Cursor..."),barEmpty();let preparedPayload=await prepareForClaudeCode(plugins,repoPath,marketplaceName);step("Registering marketplace"),await mkdir2(pluginsDir,{recursive:!0});let knownPath=join5(pluginsDir,"known_marketplaces.json"),knownMarketplaces={};if(existsSync2(knownPath))try{knownMarketplaces=JSON.parse(await readFile4(knownPath,"utf-8"))}catch{}let githubRepo=extractGitHubRepo(source);if(await mkdir2(marketplacesDir,{recursive:!0}),existsSync2(marketplaceInstallLocation)&&await rm2(marketplaceInstallLocation,{recursive:!0}),await copyPluginTree(repoPath,marketplaceInstallLocation,plugins.map(plugin=>plugin.path)),barDebug(c.dim(`Marketplace copied to ${marketplaceInstallLocation}`)),preparedPayload){let existing=knownMarketplaces[marketplaceName];knownMarketplaces[marketplaceName]={...isRecord(existing)?existing:{},source:{source:"directory",path:marketplaceInstallLocation},installLocation:marketplaceInstallLocation,lastUpdated:new Date().toISOString(),autoUpdate:!1},await writeFile(knownPath,JSON.stringify(knownMarketplaces,null,2)),stepDone("Prepared marketplace registered")}else if(knownMarketplaces[marketplaceName])stepDone(`Marketplace ${c.dim("'"+marketplaceName+"'")} already registered`);else{let marketplaceSource;if(githubRepo)marketplaceSource={source:"github",repo:githubRepo};else if(isRemoteSource(source)){let gitUrl=normalizeGitUrl(source);marketplaceSource={source:"git",url:gitUrl.endsWith(".git")?gitUrl:gitUrl+".git"}}else marketplaceSource={source:"directory",path:repoPath};knownMarketplaces[marketplaceName]={source:marketplaceSource,installLocation:marketplaceInstallLocation,lastUpdated:new Date().toISOString()},await writeFile(knownPath,JSON.stringify(knownMarketplaces,null,2)),stepDone("Marketplace registered")}barEmpty();for(let{plugin,pluginKey,version,cacheDest,retained}of plans){let pluginRef=pluginKey;step(`Installing ${c.bold(pluginRef)}...`),await mkdir2(cacheDest,{recursive:!0}),await copyPluginTree(plugin.path,cacheDest),barDebug(c.dim(`Cached to ${cacheDest}`));let now=new Date().toISOString(),entry={scope,installPath:cacheDest,version,installedAt:now,lastUpdated:now};gitSha&&(entry.gitCommitSha=gitSha),installedData.plugins[pluginKey]=[...retained,entry],stepDone(`Installed ${c.cyan(pluginRef)}`)}await writeFile(installedPath,JSON.stringify(installedData,null,2)),barDebug(c.dim("Updated installed_plugins.json"));let settingsPath=join5(home,".claude","settings.json"),settings={},settingsCorrupted=!1;if(existsSync2(settingsPath))try{settings=JSON.parse(await readFile4(settingsPath,"utf-8"))}catch{settingsCorrupted=!0}if(settingsCorrupted)warn("Could not parse ~/.claude/settings.json \u2014 skipping enabledPlugins update to avoid overwriting existing settings."),barLine(c.dim("You may need to manually enable the plugins in Claude Code settings."));else{let enabled=settings.enabledPlugins??{};for(let plugin of plugins){let pluginKey=`${plugin.name}@${marketplaceName}`;enabled[pluginKey]=!0}settings.enabledPlugins=enabled,await writeFile(settingsPath,JSON.stringify(settings,null,2)),barDebug(c.dim("Updated settings.json enabledPlugins"))}let registered=knownMarketplaces[marketplaceName],sourceKind=isRecord(registered)&&isRecord(registered.source)?registered.source.source:void 0;sourceKind!=="git"&&sourceKind!=="github"&&printRefreshHint(targetId),installerState().cachePopulated=!0}function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}async function samePath(left,right){let normalize=path=>{let absolute=resolve4(path);return process.platform==="win32"?absolute.toLowerCase():absolute};if(normalize(left)===normalize(right))return!0;try{let[a,b]=await Promise.all([realpath2(left),realpath2(right)]);return normalize(a)===normalize(b)}catch(error){if(isRecord(error)&&["ENOENT","ENOTDIR"].includes(String(error.code)))return!1;throw error}}async function installToCodex(plugins,repoPath,source){let home=homedir2(),codexHome=join5(home,".codex"),cacheDir=join5(codexHome,"plugins","cache"),configPath=join5(codexHome,"config.toml"),marketplacePath=join5(home,".agents","plugins","marketplace.json"),originalConfig="";try{originalConfig=await readFile4(configPath,"utf8")}catch(error){if(error.code!=="ENOENT")throw error}let publisher=await loadCodexMarketplace(repoPath,plugins.map(plugin=>plugin.name),source),sourceIdentity=publisher??await codexMarketplaceSource(repoPath,source),publisherNames=new Set([...configuredCodexMarketplacesForSource(originalConfig,sourceIdentity),...publisher?[publisher.name]:[]]);publisherNames.delete("plugins-cli");let succeeded=!0,selected=[];for(let plugin of plugins){let configured=["plugins-cli",...publisherNames].filter(name=>configuredCodexPlugin(originalConfig,`${plugin.name}@${name}`)),authored=publisher?.plugins.find(entry=>entry.name===plugin.name);if(configured.length>1){stepError(`Codex ${plugin.name}: multiple copies are configured (${configured.map(name=>`${plugin.name}@${name}`).join(", ")}); skipped this plugin. Uninstall the extra copies with codex plugin remove <name@marketplace>, then rerun.`),succeeded=!1;continue}let marketplaceName=configured[0]??(authored?publisher.name:"plugins-cli");if(marketplaceName!=="plugins-cli"&&(!authored||marketplaceName!==publisher?.name)){stepError(`Codex ${plugin.name}@${marketplaceName}: this source no longer provides a package for the configured identity; skipped this plugin. Use its original source, or uninstall that copy before installing under a different identity.`),succeeded=!1;continue}selected.push({plugin,authored,marketplaceName})}if(selected.length===0)return succeeded;step("Preparing plugins for Codex..."),barEmpty();let plans=await Promise.all(selected.map(async entry=>{let plugin={...entry.plugin,path:entry.authored?.path??entry.plugin.path};entry.authored||(plugin=(await stageInstallWorkspace([plugin],plugin.path,"codex")).plugins[0],await preparePluginDirForVendor(plugin,".codex-plugin","CODEX_PLUGIN_ROOT"),await enrichForCodex(plugin));let pluginRef=`${plugin.name}@${entry.marketplaceName}`,pluginCache=codexPluginCacheRoot(cacheDir,plugin.name,entry.marketplaceName),manifest=await readCodexCacheManifest(plugin.path,entry.authored?codexMarketplaceManifest(entry.authored.entry):void 0);return enableCodexPlugin(originalConfig,pluginRef),{...entry,plugin,pluginRef,pluginCache,cacheDest:join5(pluginCache,manifest.version),fallback:manifest.fallback}}));publisher&&plans.some(plan=>plan.marketplaceName===publisher.name)&&appendCodexMarketplaceConfiguration(originalConfig,publisher);let personal={name:"plugins-cli",interface:{displayName:"Plugins CLI"},plugins:[]};if(plans.some(plan=>plan.marketplaceName==="plugins-cli"))try{let existing=JSON.parse(await readFile4(marketplacePath,"utf8"));if(!isRecord(existing)||!Array.isArray(existing.plugins)||existing.plugins.some(entry=>!isRecord(entry)))throw new Error(`${marketplacePath}: expected a personal marketplace with plugin entries.`);personal=existing}catch(error){if(error.code!=="ENOENT")throw error}publisher&&plans.some(plan=>plan.marketplaceName===publisher.name)&&await prepareCodexMarketplace(publisher,codexHome);let completed=[];for(let plan of plans){let{plugin,pluginCache,cacheDest,fallback,pluginRef}=plan;step(`Installing ${c.bold(pluginRef)}...`);try{await rm2(pluginCache,{recursive:!0,force:!0}),await mkdir2(cacheDest,{recursive:!0}),await cp3(plugin.path,cacheDest,{recursive:!0}),fallback&&(await mkdir2(join5(cacheDest,".codex-plugin"),{recursive:!0}),await writeFile(join5(cacheDest,".codex-plugin","plugin.json"),JSON.stringify(fallback,null,2))),completed.push(plan),barDebug(c.dim(`Cached to ${cacheDest}`)),stepDone(`Installed ${c.cyan(pluginRef)}`)}catch(error){stepError(`Codex install failed for ${c.cyan(plan.pluginRef)}`);let message=error instanceof Error?error.message:String(error);for(let line of message.split(/\r?\n/))barLine(c.dim(line));succeeded=!1}}if(completed.length>0){let configContent=originalConfig;publisher&&completed.some(plan=>plan.marketplaceName===publisher.name)&&(configContent=appendCodexMarketplaceConfiguration(configContent,publisher));for(let plan of completed)configContent=enableCodexPlugin(configContent,plan.pluginRef),plan.marketplaceName==="plugins-cli"&&(personal.plugins=personal.plugins.filter(entry=>entry.name!==plan.plugin.name),personal.plugins.push({name:plan.plugin.name,source:{source:"local",path:`./${relative4(home,plan.cacheDest)}`},policy:{installation:"AVAILABLE",authentication:"ON_INSTALL"},category:"Coding"}));completed.some(plan=>plan.marketplaceName==="plugins-cli")&&(step("Updating marketplace..."),await mkdir2(dirname4(marketplacePath),{recursive:!0}),await writeFile(marketplacePath,JSON.stringify(personal,null,2)),stepDone("Marketplace updated")),step("Updating config.toml..."),await mkdir2(codexHome,{recursive:!0}),configContent!==originalConfig&&await writeFile(configPath,configContent),stepDone("Config updated")}return succeeded&&completed.some(plan=>plan.marketplaceName==="plugins-cli")&&printRefreshHint("codex","@plugins-cli plugins"),succeeded}async function enrichForCodex(plugin){let codexManifestPath=join5(plugin.path,".codex-plugin","plugin.json");if(!existsSync2(codexManifestPath))return;let manifest;try{manifest=JSON.parse(await readFile4(codexManifestPath,"utf-8"))}catch{return}if(manifest.interface)return;let changed=!1;!manifest.skills&&existsSync2(join5(plugin.path,"skills"))&&(manifest.skills="./skills/",changed=!0),!manifest.mcpServers&&existsSync2(join5(plugin.path,".mcp.json"))&&(manifest.mcpServers="./.mcp.json",changed=!0),!manifest.apps&&existsSync2(join5(plugin.path,".app.json"))&&(manifest.apps="./.app.json",changed=!0);let name=manifest.name??plugin.name,description=manifest.description??plugin.description??"",author=manifest.author,iface={displayName:name.charAt(0).toUpperCase()+name.slice(1),shortDescription:description,developerName:author?.name??"Unknown",category:"Coding",capabilities:["Interactive","Write"]};manifest.homepage?iface.websiteURL=manifest.homepage:manifest.repository&&(iface.websiteURL=manifest.repository);let assetCandidates=["assets/app-icon.png","assets/icon.png","assets/logo.png","assets/logo.svg"];for(let candidate of assetCandidates)if(existsSync2(join5(plugin.path,candidate))){iface.logo=`./${candidate}`,iface.composerIcon=`./${candidate}`;break}manifest.interface=iface,changed=!0,changed&&(await writeFile(codexManifestPath,JSON.stringify(manifest,null,2)),barDebug(c.dim(`${plugin.name}: enriched .codex-plugin/plugin.json for Codex`)))}async function installToGrok(plugins,source){if(step("Preparing plugins for Grok Build..."),barEmpty(),!source)for(let plugin of plugins)await preparePluginDirForVendor(plugin,".claude-plugin","CLAUDE_PLUGIN_ROOT");let succeeded=!0;for(let plugin of plugins){step(`Installing ${c.bold(plugin.name)}${source?" from source":""}...`);try{installGrokPlugin(plugin.name,source??plugin.path,source!==void 0&&isRemoteSource(source))}catch(err){stepError(`Grok install command failed for ${c.cyan(plugin.name)}`);let message=err instanceof Error?err.message:String(err);for(let line of message.split(/\r?\n/))barLine(c.dim(line));succeeded=!1}}return succeeded&&(source===void 0||!isRemoteSource(source))&&printRefreshHint("grok"),succeeded}function grokSourceIdentity(source,isGitSource){if(!isGitSource)return resolve4(source);let trimmed=source.trim();return/^[\w-]+\/[\w.-]+$/.test(trimmed)?`https://github.com/${trimmed}`:trimmed}function installGrokPlugin(pluginName,source,isGitSource){let inventory=JSON.parse(runNativeCommand("Grok Build","grok",["plugin","list","--json"]));if(!Array.isArray(inventory)||!inventory.every(row=>isRecord(row)&&row.status==="installed"&&typeof row.name=="string"&&typeof row.source=="string"))throw new Error("Unexpected Grok plugin list response; no existing installation was replaced.");let identity=grokSourceIdentity(source,isGitSource),matching=inventory.filter(row=>grokSourceIdentity(row.source,isGitSource)===identity),installSource=source;if(matching.length>0){let sameName=inventory.filter(row=>row.name===pluginName);if(matching.length!==1||matching[0].name!==pluginName||sameName.length!==1)throw new Error(`Grok refresh is ambiguous for ${pluginName}; no existing installation was replaced.`);if(isGitSource){runNativeCommand("Grok Build","grok",["plugin","update",pluginName]),stepDone(`Updated ${c.cyan(pluginName)}`);return}runNativeCommand("Grok Build","grok",["plugin","uninstall",pluginName,"--keep-data"]),installSource=matching[0].source}runNativeCommand("Grok Build","grok",["plugin","install",installSource,"--trust"]),stepDone(`${matching.length>0?"Refreshed":"Installed"} ${c.cyan(pluginName)}`)}function getGrokNativeSource(source,plugins,repoPath){return plugins.length!==1||plugins[0]?.path!==repoPath||!existsSync2(join5(repoPath,".claude-plugin","plugin.json"))?null:/^https?:\/\//.test(source)||/^git@/.test(source)||/^[\w.-]+\/[\w.-]+(?:\.git)?$/.test(source)?source:null}async function installToKimi(plugins){step("Preparing plugins for Kimi Code..."),barEmpty();for(let plugin of plugins)await preparePluginDirForVendor(plugin,".kimi-plugin","KIMI_PLUGIN_ROOT"),await enrichForKimi(plugin);await installToKimiNativeStore(plugins),printRefreshHint("kimi")}async function installToKimiNativeStore(plugins){let kimiHome=environmentValue("KIMI_CODE_HOME")??join5(homedir2(),".kimi-code"),pluginsDir=join5(kimiHome,"plugins"),installedPath=join5(pluginsDir,"installed.json"),installed=await readKimiInstalledFile(installedPath);for(let plugin of plugins){let managedRoot=await copyToKimiManagedRoot(kimiHome,plugin.name,plugin.path),existing=installed.plugins.find(entry=>entry.id===plugin.name),now=new Date().toISOString(),record={id:plugin.name,root:managedRoot,source:"local-path",enabled:!0,installedAt:existing?.installedAt??now,updatedAt:now,originalSource:plugin.path,...existing?.capabilities?{capabilities:existing.capabilities}:{},...existing?.github?{github:existing.github}:{}};installed.plugins=installed.plugins.filter(entry=>entry.id!==plugin.name),installed.plugins.push(record),stepDone(`Installed ${c.cyan(plugin.name)}`),(plugin.agents.length>0||plugin.hasLsp)&&warn(`${plugin.name}: Kimi plugins do not currently support agents or LSP servers.`)}await mkdir2(pluginsDir,{recursive:!0});let temporaryInstalledPath=`${installedPath}.tmp`;await writeFile(temporaryInstalledPath,JSON.stringify(installed,null,2)),await rename(temporaryInstalledPath,installedPath),await removeKimiCompatibilityLayer(plugins,kimiHome),barDebug(c.dim(`Updated ${installedPath}`))}async function copyToKimiManagedRoot(kimiHome,pluginId,sourceRoot){let managedRoot=join5(kimiHome,"plugins","managed",pluginId),managedDir=dirname4(managedRoot);await mkdir2(managedDir,{recursive:!0});let stagingRoot=join5(managedDir,`${pluginId}-${Date.now()}-${process.pid}`);return await rm2(stagingRoot,{recursive:!0,force:!0}),await cp3(sourceRoot,stagingRoot,{recursive:!0}),await rm2(managedRoot,{recursive:!0,force:!0}),await rename(stagingRoot,managedRoot),managedRoot}async function readKimiInstalledFile(path){if(!existsSync2(path))return{version:1,plugins:[]};let parsed=await readJsonObject(path);if(!parsed||!Array.isArray(parsed.plugins))throw new Error(`Could not parse ${path}; Kimi plugin records were left unchanged.`);return{version:1,plugins:parsed.plugins}}async function removeKimiCompatibilityLayer(plugins,kimiHome){let prefixes=plugins.map(plugin=>`${plugin.name}-`),skillsDir=join5(kimiHome,"skills");try{let entries=await readdir2(skillsDir,{withFileTypes:!0});for(let entry of entries)prefixes.some(prefix=>entry.name.startsWith(prefix))&&await rm2(join5(skillsDir,entry.name),{recursive:!0,force:!0})}catch{}let mcpPath=join5(kimiHome,"mcp.json"),mcpConfig=await readJsonObject(mcpPath);if(!mcpConfig?.mcpServers||typeof mcpConfig.mcpServers!="object")return;let servers=mcpConfig.mcpServers,retained=Object.fromEntries(Object.entries(servers).filter(([name])=>!prefixes.some(prefix=>name.startsWith(prefix))));Object.keys(retained).length!==Object.keys(servers).length&&(mcpConfig.mcpServers=retained,await writeFile(mcpPath,JSON.stringify(mcpConfig,null,2)))}async function enrichForKimi(plugin){let manifestPath=join5(plugin.path,".kimi-plugin","plugin.json"),manifest=await readJsonObject(manifestPath);if(!manifest)return;let changed=!1;!manifest.skills&&existsSync2(join5(plugin.path,"skills"))&&(manifest.skills="./skills/",changed=!0),!manifest.commands&&existsSync2(join5(plugin.path,"commands"))&&(manifest.commands="./commands/",changed=!0);let mcpConfig=await readJsonObject(join5(plugin.path,".mcp.json"));mcpConfig?.mcpServers&&typeof mcpConfig.mcpServers=="object"&&manifest.mcpServers!==mcpConfig.mcpServers&&(manifest.mcpServers=mcpConfig.mcpServers,changed=!0);let kimiHooks=await readKimiHooks(plugin.path,manifest.hooks);kimiHooks.length>0&&(manifest.hooks=kimiHooks,changed=!0),changed&&(await writeFile(manifestPath,JSON.stringify(manifest,null,2)),barDebug(c.dim(`${plugin.name}: enriched .kimi-plugin/plugin.json for Kimi Code`)))}async function readKimiHooks(pluginPath,declaredHooks){let source=declaredHooks;if(typeof declaredHooks=="string"&&(source=await readJsonObject(join5(pluginPath,declaredHooks.replace(/^\.\//,"")))),source||(source=await readJsonObject(join5(pluginPath,"hooks","hooks.json"))),!source||typeof source!="object"||Array.isArray(source))return[];let hookMap=source.hooks;if(!hookMap||typeof hookMap!="object"||Array.isArray(hookMap))return[];let result=[];for(let[event,groups]of Object.entries(hookMap))if(Array.isArray(groups))for(let group of groups){if(!group||typeof group!="object"||Array.isArray(group))continue;let groupRecord=group,hooks=Array.isArray(groupRecord.hooks)?groupRecord.hooks:[groupRecord];for(let hook of hooks){if(!hook||typeof hook!="object"||Array.isArray(hook))continue;let hookRecord=hook;if(hookRecord.type!=="command"||typeof hookRecord.command!="string")continue;let kimiHook={event,command:hookRecord.command};typeof groupRecord.matcher=="string"&&(kimiHook.matcher=groupRecord.matcher),typeof hookRecord.timeout=="number"&&(kimiHook.timeout=hookRecord.timeout),result.push(kimiHook)}}return result}async function installToGitHubCopilot(plugins,repoPath,source){step("Preparing plugins for GitHub Copilot CLI..."),barEmpty();let sourceHasMarketplace=hasCopilotMarketplaceManifest(repoPath),marketplaceName=plugins[0]?.marketplace??deriveMarketplaceName(source),marketplaceSource=source,marketplacePlugins=plugins;if(!sourceHasMarketplace){let workspace=await stageGitHubCopilotMarketplace(plugins,repoPath,marketplaceName);marketplaceSource=workspace.repoPath,marketplacePlugins=workspace.plugins}step("Registering plugin marketplace in GitHub Copilot CLI...");try{runNativeCommand("GitHub Copilot CLI","copilot",["plugin","marketplace","add",marketplaceSource])}catch(err){barDebug(c.dim(`Copilot marketplace registration returned: ${String(err)}`))}stepDone("Plugin marketplace registered in GitHub Copilot CLI");for(let plugin of marketplacePlugins){let pluginRef=`${plugin.name}@${marketplaceName}`;step(`Installing ${c.bold(pluginRef)}...`),runNativeCommand("GitHub Copilot CLI","copilot",["plugin","install",pluginRef]),stepDone(`Installed ${c.cyan(pluginRef)}`)}sourceHasMarketplace||printRefreshHint("github-copilot")}function hasCopilotMarketplaceManifest(repoPath){return[join5(repoPath,"marketplace.json"),join5(repoPath,".github","plugin","marketplace.json"),join5(repoPath,".claude-plugin","marketplace.json")].some(existsSync2)}async function stageGitHubCopilotMarketplace(plugins,repoPath,marketplaceName,stagingBaseDir=join5(homedir2(),".cache","plugins","copilot-marketplaces")){let workspace=await stageInstallWorkspace(plugins,repoPath,"github-copilot",stagingBaseDir);for(let plugin of workspace.plugins)await preparePluginDirForVendor(plugin,".plugin","PLUGIN_ROOT");let marketplace={name:marketplaceName,owner:{name:"plugins"},plugins:workspace.plugins.map(plugin=>{let relativePath=relative4(workspace.repoPath,plugin.path);return{name:plugin.name,source:relativePath===""?"./":`./${relativePath}`,description:plugin.description??"",...plugin.version?{version:plugin.version}:{}}})},marketplaceDir=join5(workspace.repoPath,".claude-plugin");return await mkdir2(marketplaceDir,{recursive:!0}),await writeFile(join5(marketplaceDir,"marketplace.json"),JSON.stringify(marketplace,null,2)),barDebug(c.dim(`Generated durable Copilot marketplace at ${workspace.repoPath}`)),workspace}async function installToVsCode(plugins){step("Preparing plugins for Visual Studio Code..."),barEmpty();for(let plugin of plugins)await preparePluginDirForVendor(plugin,".plugin","PLUGIN_ROOT");step("Registering agent plugins in VS Code..."),await addVsCodePluginLocations(plugins.map(plugin=>plugin.path)),stepDone("Agent plugins registered in VS Code"),printRefreshHint("vscode")}async function addVsCodePluginLocations(pluginPaths,settingsPath=getVsCodeSettingsPath()){let settingsContent=`{}
22
+ `;existsSync2(settingsPath)&&(settingsContent=await readFile4(settingsPath,"utf-8"));let existing=parseJsoncObject(settingsContent,settingsPath)["chat.pluginLocations"];if(existing!==void 0&&(!existing||typeof existing!="object"||Array.isArray(existing)))throw new Error(`${settingsPath}: chat.pluginLocations must be an object.`);let locations={};if(existing)for(let[path,enabled]of Object.entries(existing))typeof enabled=="boolean"&&(locations[path]=enabled);for(let pluginPath of pluginPaths)locations[pluginPath]=!0;let updatedContent=updateJsoncRootProperty(settingsContent,"chat.pluginLocations",locations);await mkdir2(dirname4(settingsPath),{recursive:!0}),await writeFile(settingsPath,updatedContent),barDebug(c.dim(`Updated ${settingsPath} chat.pluginLocations`))}function runNativeCommand(label,command,args){try{return execFileSync3(command,args,{encoding:"utf-8",stdio:"pipe",timeout:12e4,...childProcessOptions()})}catch(err){let error=err,stderr=error.stderr?.toString().trim();throw new Error(`${label} installation failed.${stderr?` ${stderr}`:` ${error.message??""}`}`)}}async function readJsonObject(path){if(!existsSync2(path))return null;try{let parsed=JSON.parse(await readFile4(path,"utf-8"));if(parsed&&typeof parsed=="object"&&!Array.isArray(parsed))return parsed}catch{}return null}function parseJsoncObject(content,filePath){try{let parsed=JSON.parse(removeTrailingJsoncCommas(stripJsoncComments(content)));if(!parsed||typeof parsed!="object"||Array.isArray(parsed))throw new Error("root value is not an object");return parsed}catch(err){let message=err instanceof Error?err.message:String(err);throw new Error(`Could not parse ${filePath}; VS Code settings were left unchanged. ${message}`)}}function stripJsoncComments(content){let result="",inString=!1;for(let i=0;i<content.length;i++){let char=content[i];if(inString){result+=char,char==="\\"?result+=content[++i]??"":char==='"'&&(inString=!1);continue}if(char==='"'){inString=!0,result+=char;continue}if(char==="/"&&content[i+1]==="/"){for(result+=" ",i+=2;i<content.length&&content[i]!==`
23
+ `;)result+=" ",i++;i<content.length&&(result+=content[i]);continue}if(char==="/"&&content[i+1]==="*"){for(result+=" ",i+=2;i<content.length&&!(content[i]==="*"&&content[i+1]==="/");)result+=content[i]===`
24
+ `?`
25
+ `:" ",i++;i<content.length&&(result+=" ",i++);continue}result+=char}return result}function removeTrailingJsoncCommas(content){let result="",inString=!1;for(let i=0;i<content.length;i++){let char=content[i];if(inString){result+=char,char==="\\"?result+=content[++i]??"":char==='"'&&(inString=!1);continue}if(char==='"'){inString=!0,result+=char;continue}if(char===","){let next=i+1;for(;/\s/.test(content[next]??"");)next++;if(content[next]==="}"||content[next]==="]")continue}result+=char}return result}function updateJsoncRootProperty(content,key,value){let sanitized=stripJsoncComments(content),property=findJsoncRootProperty(sanitized,key),formattedValue=JSON.stringify(value,null,2).replaceAll(`
26
+ `,`
27
+ `);if(property.valueStart!==void 0&&property.valueEnd!==void 0)return`${content.slice(0,property.valueStart)}${formattedValue}${content.slice(property.valueEnd)}`;let closingBrace=property.objectEnd-1,last=closingBrace-1;for(;last>property.objectStart&&/\s/.test(sanitized[last]??"");)last--;let addition=`${!(last>property.objectStart)||sanitized[last]===","?"":","}
28
+ ${JSON.stringify(key)}: ${formattedValue}
29
+ `;return`${content.slice(0,closingBrace)}${addition}${content.slice(closingBrace)}`}function findJsoncRootProperty(content,wantedKey){let index=skipWhitespace(content,0);if(content[index]!=="{")throw new Error("VS Code settings must be a JSON object.");let objectStart=index;for(index++;;){if(index=skipWhitespace(content,index),content[index]==="}")return{objectStart,objectEnd:index+1};if(content[index]!=='"')throw new Error("Could not locate a VS Code settings property.");let keyStart=index,keyEnd=findJsonStringEnd(content,keyStart),key=JSON.parse(content.slice(keyStart,keyEnd));if(index=skipWhitespace(content,keyEnd),content[index]!==":")throw new Error("Could not locate a VS Code settings property.");let valueStart=skipWhitespace(content,index+1),valueEnd=findJsonValueEnd(content,valueStart);if(key===wantedKey)return{objectStart,objectEnd:findJsonValueEnd(content,objectStart),valueStart,valueEnd};if(index=skipWhitespace(content,valueEnd),content[index]===","){index++;continue}if(content[index]==="}")return{objectStart,objectEnd:index+1};throw new Error("Could not locate a VS Code settings property.")}}function skipWhitespace(content,index){for(;/\s/.test(content[index]??"");)index++;return index}function findJsonStringEnd(content,start){for(let index=start+1;index<content.length;index++)if(content[index]==="\\")index++;else if(content[index]==='"')return index+1;throw new Error("Unterminated JSON string.")}function findJsonValueEnd(content,start){let first=content[start];if(first==='"')return findJsonStringEnd(content,start);if(first!=="{"&&first!=="["){let index=start;for(;index<content.length&&!/[\s,}\]]/.test(content[index]);)index++;return index}let closers=[first==="{"?"}":"]"];for(let index=start+1;index<content.length;index++){let char=content[index];if(char==='"')index=findJsonStringEnd(content,index)-1;else if(char==="{")closers.push("}");else if(char==="[")closers.push("]");else if(char===closers[closers.length-1]&&(closers.pop(),closers.length===0))return index+1}throw new Error("Unterminated JSON value.")}async function prepareForClaudeCode(plugins,repoPath,marketplaceName){let claudePluginDir=join5(repoPath,".claude-plugin");await mkdir2(claudePluginDir,{recursive:!0});let marketplaceJson={name:marketplaceName,owner:{name:"plugins"},plugins:plugins.map(p=>{let rel=relative4(repoPath,p.path),sourcePath=rel===""?"./":`./${rel}`,entry={name:p.name,source:sourcePath,description:p.description??""};return p.version&&(entry.version=p.version),p.manifest?.author&&(entry.author=p.manifest.author),p.manifest?.license&&(entry.license=p.manifest.license),p.manifest?.keywords&&(entry.keywords=p.manifest.keywords),entry})};await writeFile(join5(claudePluginDir,"marketplace.json"),JSON.stringify(marketplaceJson,null,2)),barDebug(c.dim("Generated .claude-plugin/marketplace.json"));let preparedPayload=!1;for(let plugin of plugins){let changed=await preparePluginDirForVendor(plugin,".claude-plugin","CLAUDE_PLUGIN_ROOT");preparedPayload||=changed}return preparedPayload}function findClaudeOrNull(){try{let path=execSync("which claude",{encoding:"utf-8",stdio:"pipe",...childProcessOptions()}).trim();if(path)return path}catch{}let home=homedir2(),candidates=[join5(home,".local","bin","claude"),join5(home,".bun","bin","claude"),"/usr/local/bin/claude"];for(let candidate of candidates)if(existsSync2(candidate))return candidate;return null}async function preparePluginDirForVendor(plugin,vendorDir,envVar){let pluginPath=plugin.path,openPluginDir=join5(pluginPath,".plugin"),vendorPluginDir=join5(pluginPath,vendorDir),hasOpenPlugin=existsSync2(join5(openPluginDir,"plugin.json")),hasVendorPlugin=existsSync2(join5(vendorPluginDir,"plugin.json"));hasOpenPlugin&&!hasVendorPlugin&&(await cp3(openPluginDir,vendorPluginDir,{recursive:!0}),barDebug(c.dim(`${plugin.name}: translated .plugin/ \u2192 ${vendorDir}/`))),!hasOpenPlugin&&!hasVendorPlugin&&(await mkdir2(vendorPluginDir,{recursive:!0}),await writeFile(join5(vendorPluginDir,"plugin.json"),JSON.stringify({name:plugin.name,description:plugin.description??"",version:plugin.version??"0.0.0"},null,2)),barDebug(c.dim(`${plugin.name}: generated ${vendorDir}/plugin.json`)));let translatedConfig=await translateEnvVars(pluginPath,plugin.name,envVar);return!hasVendorPlugin||translatedConfig}var KNOWN_PLUGIN_ROOT_VARS=["PLUGIN_ROOT","CLAUDE_PLUGIN_ROOT","CURSOR_PLUGIN_ROOT","CODEX_PLUGIN_ROOT","KIMI_PLUGIN_ROOT"];async function translateEnvVars(pluginPath,pluginName,envVar){let translatedConfig=!1,configFiles=[join5(pluginPath,"hooks","hooks.json"),join5(pluginPath,".mcp.json"),join5(pluginPath,".lsp.json")],target=`\${${envVar}}`,patterns=KNOWN_PLUGIN_ROOT_VARS.filter(v=>v!==envVar).map(v=>`\${${v}}`);for(let filePath of configFiles){if(!existsSync2(filePath))continue;let content=await readFile4(filePath,"utf-8"),changed=!1;for(let pattern of patterns)content.includes(pattern)&&(content=content.replaceAll(pattern,target),changed=!0);changed&&(await writeFile(filePath,content),translatedConfig=!0,barDebug(c.dim(`${pluginName}: translated plugin root \u2192 \${${envVar}} in ${filePath.split("/").pop()}`)))}return translatedConfig}function deriveMarketplaceName(source){if(source.match(/^[\w-]+\/[\w.-]+$/))return source.replace("/","-");let sshMatch=source.match(/^git@[^:]+:(.+?)(?:\.git)?$/);if(sshMatch){let parts=sshMatch[1].split("/").filter(Boolean);if(parts.length>=2)return`${parts[parts.length-2]}-${parts[parts.length-1]}`}let nameSource=process.platform==="win32"&&!isRemoteSource(source)?source.replace(/\\/g,"/"):source;try{let parts=new URL(nameSource).pathname.replace(/\.git$/,"").split("/").filter(Boolean);if(parts.length>=2)return`${parts[parts.length-2]}-${parts[parts.length-1]}`}catch{}return basename3(nameSource)||"plugins"}function extractGitHubRepo(source){let shorthand=source.match(/^([\w-]+\/[\w.-]+)$/);if(shorthand)return shorthand[1];let httpsMatch=source.match(/^https?:\/\/github\.com\/([\w.-]+\/[\w.-]+?)(?:\.git)?$/);if(httpsMatch)return httpsMatch[1];let sshMatch=source.match(/^git@github\.com:([\w.-]+\/[\w.-]+?)(?:\.git)?$/);return sshMatch?sshMatch[1]:null}function isRemoteSource(source){return!!(source.match(/^[\w-]+\/[\w.-]+$/)||source.startsWith("git@")||source.startsWith("https://")||source.startsWith("http://"))}function normalizeGitUrl(source){if(source.match(/^[\w-]+\/[\w.-]+$/))return`https://github.com/${source}`;let sshMatch=source.match(/^git@([^:]+):(.+?)(?:\.git)?$/);return sshMatch?`https://${sshMatch[1]}/${sshMatch[2]}`:source}function toVercelClientResult(clientId,dryRun,outcome,failure){let succeeded=outcome!==void 0&&(dryRun||outcome.installed?.succeeded===!0),error;if(!succeeded){let reported=[],beneathError=!1;for(let event of outcome?.events??[])beneathError=event.type==="error"||beneathError&&event.type==="line",beneathError&&event.text&&reported.push(event.text);error={message:outcome?.installed?.message??failure??reported.shift()??"The Vercel plugin installation could not be completed.",details:reported}}return{clientId,status:succeeded?dryRun?"planned":"succeeded":"failed",changes:(outcome?.plugins??[]).map(name=>({kind:"package",name,action:"configure",paths:[outcome.path]})),warnings:(outcome?.events??[]).filter(event=>event.type==="warning").map(event=>event.text),configuresLocalMcpServers:outcome?.configuresLocalMcpServers??!1,...error?{error}:{}}}var VERCEL_PLUGIN_SOURCE="vercel/vercel-plugin",SDK_CLIENT_IDS={grok:"grok-build",kimi:"kimi-code-cli","github-copilot":"github-copilot-cli"};function toSdkClient({id,name}){return{id:SDK_CLIENT_IDS[id]??id,name}}function createPluginVercelCLISdk(options){if(!isAbsolute3(options.cwd))throw new TypeError("Vercel plugin installer cwd must be an absolute path.");let{cwd}=options,home=homedir3(),env={...options.env??process.env},withContext=(report,run)=>withInstallerContext({cwd,env,report},run);return{listSupportedClients(){return SUPPORTED_TARGETS.map(toSdkClient)},async listInstallableClients(){return(await withContext(()=>{},getTargets)).filter(target=>target.detected).map(toSdkClient)},async install(request){if(!request.clients.length)throw new TypeError("Select at least one plugin client.");for(let id of request.clients)if(!SUPPORTED_TARGETS.some(target=>toSdkClient(target).id===id))throw new TypeError(`Unsupported Vercel plugin user-scope client: ${JSON.stringify(id)}.`);let selected=[...new Set(request.clients)],dryRun=request.dryRun,outcomes=new Map,warnings=[],events=[],failure,temporary;try{await withContext(event=>events.push(event),async()=>{let checkout=join6(home,".cache","plugins","github.com-vercel-vercel-plugin");dryRun&&(temporary=await mkdtemp(join6(tmpdir(),"plugins-vercel-")),checkout=join6(temporary,"source")),await checkOutVercelPlugin(checkout,cwd,env);let{plugins}=await discover(checkout);if(!plugins.length)throw new Error(`No plugins found in ${VERCEL_PLUGIN_SOURCE}.`);let configuresLocalMcpServers=await declaresLocalMcpServers(plugins.map(plugin=>plugin.path));for(let target of await getTargets()){let clientId=toSdkClient(target).id;if(!selected.includes(clientId))continue;events=[];let installed=dryRun?void 0:await installPlugins(plugins,target,"user",checkout,VERCEL_PLUGIN_SOURCE);outcomes.set(clientId,{plugins:plugins.map(plugin=>plugin.name),path:target.id==="claude-code"||target.id==="cursor"?join6(home,".claude","plugins"):target.configPath,configuresLocalMcpServers,installed,events})}})}catch(error){failure=describe(error)}if(temporary)try{await rm3(temporary,{recursive:!0,force:!0})}catch(error){warnings.push(`Temporary plugin files could not be removed: ${describe(error)}`)}return{dryRun,clients:selected.map(id=>toVercelClientResult(id,dryRun,outcomes.get(id),failure)),warnings}}}}async function checkOutVercelPlugin(path,cwd,env){await mkdir3(dirname5(path),{recursive:!0}),existsSync3(join6(path,".git","HEAD"))&&await rm3(path,{recursive:!0,force:!0});try{await promisify(execFile)("git",["clone","--depth","1","-q",`https://github.com/${VERCEL_PLUGIN_SOURCE}`,path],{cwd,env:{...env,GIT_TERMINAL_PROMPT:"0"},timeout:6e4})}catch(error){await rm3(path,{recursive:!0,force:!0});let{stderr}=error;throw new Error(`Could not download ${VERCEL_PLUGIN_SOURCE}. ${stderr?.trim()||describe(error)}`)}}async function declaresLocalMcpServers(pluginPaths){for(let path of pluginPaths)try{let config=JSON.parse(await readFile5(join6(path,".mcp.json"),"utf-8"));if(Object.values(config.mcpServers??config).some(server=>typeof server?.command=="string"))return!0}catch{}return!1}function describe(error){return error instanceof Error?error.message:String(error)}export{createPluginVercelCLISdk};