@caspian2026/agent-sdk 0.0.24 → 0.0.26

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 (362) hide show
  1. package/dist/gateway/index.js +98 -22
  2. package/dist/gateway/worker.js +196 -47
  3. package/dist/sdk/query.cjs +2 -362
  4. package/dist/sdk/query.js +2 -367
  5. package/package.json +4 -6
  6. package/dist/chunk-05kvhzd7.js +0 -3561
  7. package/dist/chunk-07069jq1.js +0 -30
  8. package/dist/chunk-0731m51q.js +0 -8
  9. package/dist/chunk-08bspa4b.js +0 -673
  10. package/dist/chunk-0brkf8q8.js +0 -89
  11. package/dist/chunk-0n843xh7.js +0 -261
  12. package/dist/chunk-0nbp5jwx.js +0 -8583
  13. package/dist/chunk-0nj16az9.js +0 -169
  14. package/dist/chunk-0paqc2yw.js +0 -15
  15. package/dist/chunk-0q6b50ps.js +0 -111
  16. package/dist/chunk-0r5bb9j4.js +0 -477
  17. package/dist/chunk-0rpz1wgn.js +0 -1030
  18. package/dist/chunk-0t81d427.js +0 -41
  19. package/dist/chunk-0vaw02wq.js +0 -24
  20. package/dist/chunk-0vkfrmqm.js +0 -690
  21. package/dist/chunk-0vp3wfab.js +0 -12
  22. package/dist/chunk-0vr10742.js +0 -1809
  23. package/dist/chunk-0xjaqda8.js +0 -1124
  24. package/dist/chunk-13ehyphg.js +0 -223
  25. package/dist/chunk-15jsw9bb.js +0 -349
  26. package/dist/chunk-16m7eyyw.js +0 -1385
  27. package/dist/chunk-1ae3nt9j.js +0 -31
  28. package/dist/chunk-1gq4r3v1.js +0 -308
  29. package/dist/chunk-1gx78081.js +0 -66
  30. package/dist/chunk-1h2famwb.js +0 -49
  31. package/dist/chunk-1n546sfg.js +0 -200
  32. package/dist/chunk-1qg06d60.js +0 -494
  33. package/dist/chunk-1t0rqstn.js +0 -146
  34. package/dist/chunk-1z8p2eqd.js +0 -40
  35. package/dist/chunk-1zjh9cc5.js +0 -266
  36. package/dist/chunk-20ahkkrb.js +0 -132
  37. package/dist/chunk-21pbfch8.js +0 -105
  38. package/dist/chunk-26wtxbdc.js +0 -13870
  39. package/dist/chunk-2fwze72g.js +0 -24
  40. package/dist/chunk-2gcbr1c7.js +0 -107
  41. package/dist/chunk-2grc1yr8.js +0 -654
  42. package/dist/chunk-2gzv8nrw.js +0 -205
  43. package/dist/chunk-2r212cvt.js +0 -253
  44. package/dist/chunk-2s74bt6e.js +0 -317
  45. package/dist/chunk-2v385w7r.js +0 -7422
  46. package/dist/chunk-2wtkvpp2.js +0 -167
  47. package/dist/chunk-31rsspfr.js +0 -418
  48. package/dist/chunk-3c25bcsw.js +0 -17
  49. package/dist/chunk-3jm08aaw.js +0 -91
  50. package/dist/chunk-3mgywd32.js +0 -8
  51. package/dist/chunk-3nk79af8.js +0 -8
  52. package/dist/chunk-3v4sk2py.js +0 -101
  53. package/dist/chunk-3vwft0eh.js +0 -349
  54. package/dist/chunk-3vy1jt9p.js +0 -1010
  55. package/dist/chunk-3wvqzq9w.js +0 -92
  56. package/dist/chunk-3wvv2s8d.js +0 -336
  57. package/dist/chunk-4060b3s2.js +0 -108
  58. package/dist/chunk-434e0vh4.js +0 -275
  59. package/dist/chunk-46dm23zs.js +0 -344
  60. package/dist/chunk-4bh4qs70.js +0 -209
  61. package/dist/chunk-4cxzbqws.js +0 -94
  62. package/dist/chunk-4jm600zv.js +0 -13
  63. package/dist/chunk-4k9d7gxv.js +0 -118
  64. package/dist/chunk-4nc3t6ms.js +0 -396
  65. package/dist/chunk-4pbx3g7s.js +0 -26
  66. package/dist/chunk-4qhh8bpa.js +0 -54
  67. package/dist/chunk-4v63px9y.js +0 -133
  68. package/dist/chunk-4xnnzt3j.js +0 -74
  69. package/dist/chunk-4zchh01h.js +0 -201
  70. package/dist/chunk-5216fha8.js +0 -1163
  71. package/dist/chunk-55raexh7.js +0 -14358
  72. package/dist/chunk-5bffhf64.js +0 -81
  73. package/dist/chunk-5ccdsxgy.js +0 -74
  74. package/dist/chunk-5ddh2hyn.js +0 -91
  75. package/dist/chunk-5e6ncq5j.js +0 -61
  76. package/dist/chunk-5ekyhb1w.js +0 -422
  77. package/dist/chunk-5fy4r8rv.js +0 -52
  78. package/dist/chunk-5h5kx2jd.js +0 -34
  79. package/dist/chunk-5mbgdvyz.js +0 -847
  80. package/dist/chunk-5n1jc02d.js +0 -87
  81. package/dist/chunk-5pysjah8.js +0 -1543
  82. package/dist/chunk-5ssfz438.js +0 -323
  83. package/dist/chunk-5z28bqne.js +0 -6748
  84. package/dist/chunk-603y0mmg.js +0 -50
  85. package/dist/chunk-62v5kkff.js +0 -90
  86. package/dist/chunk-64c1avct.js +0 -13
  87. package/dist/chunk-64r16v22.js +0 -162
  88. package/dist/chunk-64smdx4a.js +0 -418
  89. package/dist/chunk-66zry909.js +0 -11
  90. package/dist/chunk-68ffk5qa.js +0 -14
  91. package/dist/chunk-69n11zng.js +0 -436
  92. package/dist/chunk-6dj5t602.js +0 -341
  93. package/dist/chunk-6dngjwkh.js +0 -63
  94. package/dist/chunk-6nsd9606.js +0 -790
  95. package/dist/chunk-6pkh8frk.js +0 -253
  96. package/dist/chunk-6qcmt5eb.js +0 -251
  97. package/dist/chunk-6ww7451s.js +0 -60
  98. package/dist/chunk-6xgb0kqz.js +0 -90
  99. package/dist/chunk-72ys9m07.js +0 -121
  100. package/dist/chunk-741sgvtx.js +0 -121
  101. package/dist/chunk-7aw745vx.js +0 -40175
  102. package/dist/chunk-7c8b8cfb.js +0 -219
  103. package/dist/chunk-7mwt4e1z.js +0 -234
  104. package/dist/chunk-7sgtxrsc.js +0 -1059
  105. package/dist/chunk-7wm5s02e.js +0 -216
  106. package/dist/chunk-7xyswgjh.js +0 -8
  107. package/dist/chunk-80a197ez.js +0 -1438
  108. package/dist/chunk-83hfzbx3.js +0 -10
  109. package/dist/chunk-8akrsgad.js +0 -55
  110. package/dist/chunk-8g5pe1gr.js +0 -37
  111. package/dist/chunk-8s07t4k7.js +0 -40
  112. package/dist/chunk-8yhf030a.js +0 -69
  113. package/dist/chunk-928tzaa8.js +0 -107
  114. package/dist/chunk-949pjzj9.js +0 -266
  115. package/dist/chunk-9aycd4z9.js +0 -490
  116. package/dist/chunk-9bzqvsz5.js +0 -211
  117. package/dist/chunk-9q3xfy27.js +0 -460
  118. package/dist/chunk-9vzg1360.js +0 -153
  119. package/dist/chunk-9wbh8n1y.js +0 -63
  120. package/dist/chunk-9x5zgy22.js +0 -12
  121. package/dist/chunk-9zdj4ypz.js +0 -206
  122. package/dist/chunk-a0bvcgyd.js +0 -127
  123. package/dist/chunk-a4m3yr2q.js +0 -117
  124. package/dist/chunk-a8jd4gee.js +0 -227
  125. package/dist/chunk-ase86y73.js +0 -15
  126. package/dist/chunk-atfzpm6r.js +0 -325
  127. package/dist/chunk-awqsddp2.js +0 -338
  128. package/dist/chunk-awrgzpk6.js +0 -29
  129. package/dist/chunk-b0kf00ff.js +0 -637
  130. package/dist/chunk-b1kcd3ss.js +0 -27
  131. package/dist/chunk-b4hy21c4.js +0 -140
  132. package/dist/chunk-b9mkm8mg.js +0 -111
  133. package/dist/chunk-bdjx14rd.js +0 -594
  134. package/dist/chunk-bfb41q9h.js +0 -295
  135. package/dist/chunk-bg4x9ex0.js +0 -21
  136. package/dist/chunk-bh5zqvyc.js +0 -36
  137. package/dist/chunk-bn0zv2y2.js +0 -1154
  138. package/dist/chunk-bn7t681c.js +0 -2669
  139. package/dist/chunk-br4wgffc.js +0 -393
  140. package/dist/chunk-brjd9zmk.js +0 -42
  141. package/dist/chunk-byfawrfx.js +0 -121
  142. package/dist/chunk-c6sjhj89.js +0 -1284
  143. package/dist/chunk-c7jwbe76.js +0 -29030
  144. package/dist/chunk-cdef9v7b.js +0 -27
  145. package/dist/chunk-cdz5yb0r.js +0 -57
  146. package/dist/chunk-cevq1787.js +0 -2718
  147. package/dist/chunk-cgfdkzhb.js +0 -12
  148. package/dist/chunk-cgqw4x5z.js +0 -155
  149. package/dist/chunk-cmmmc8e0.js +0 -212
  150. package/dist/chunk-cnsj3vq2.js +0 -35
  151. package/dist/chunk-cxrktb5g.js +0 -51
  152. package/dist/chunk-cyhrb0bk.js +0 -251
  153. package/dist/chunk-d23rmn8r.js +0 -62
  154. package/dist/chunk-d4mdda98.js +0 -94
  155. package/dist/chunk-dcwp94cj.js +0 -152
  156. package/dist/chunk-ddsjkqs4.js +0 -39
  157. package/dist/chunk-ddv56j39.js +0 -148
  158. package/dist/chunk-dfq6pbq7.js +0 -5822
  159. package/dist/chunk-dfzkwynj.js +0 -5368
  160. package/dist/chunk-dkgkd8b7.js +0 -516
  161. package/dist/chunk-dpnmf0pq.js +0 -312
  162. package/dist/chunk-dygx7vcc.js +0 -226
  163. package/dist/chunk-e0abab5b.js +0 -445
  164. package/dist/chunk-e5qhvhjy.js +0 -168
  165. package/dist/chunk-e60y6r1n.js +0 -20
  166. package/dist/chunk-e68kgvcq.js +0 -79
  167. package/dist/chunk-e9w9zc0g.js +0 -392
  168. package/dist/chunk-ecj9w6tm.js +0 -558
  169. package/dist/chunk-ehtwnxpg.js +0 -1591
  170. package/dist/chunk-eqp1rfft.js +0 -17
  171. package/dist/chunk-etdt1xz3.js +0 -19
  172. package/dist/chunk-ewadzrm8.js +0 -103
  173. package/dist/chunk-f03s83vj.js +0 -91
  174. package/dist/chunk-f3kk0p3s.js +0 -150
  175. package/dist/chunk-f3pjerx4.js +0 -4265
  176. package/dist/chunk-f6h5weh6.js +0 -61
  177. package/dist/chunk-fajg8x36.js +0 -8158
  178. package/dist/chunk-fbv4apne.js +0 -51
  179. package/dist/chunk-fcynwjpm.js +0 -1072
  180. package/dist/chunk-fdvaf6nn.js +0 -20
  181. package/dist/chunk-feyzykye.js +0 -10
  182. package/dist/chunk-ff85rwvc.js +0 -180
  183. package/dist/chunk-fqak69ft.js +0 -458
  184. package/dist/chunk-fxdkbabd.js +0 -195
  185. package/dist/chunk-fyc5fepv.js +0 -10
  186. package/dist/chunk-g78c6ztj.js +0 -89
  187. package/dist/chunk-g8ee7yza.js +0 -105
  188. package/dist/chunk-g9f19ttm.js +0 -15
  189. package/dist/chunk-gcktsbxb.js +0 -77
  190. package/dist/chunk-gdwdqewd.js +0 -19
  191. package/dist/chunk-gg55fns0.js +0 -6440
  192. package/dist/chunk-gnpt1t6q.js +0 -209364
  193. package/dist/chunk-gsbw2j2b.js +0 -276
  194. package/dist/chunk-gybt680f.js +0 -9114
  195. package/dist/chunk-gz1e8y1w.js +0 -33
  196. package/dist/chunk-gz7vn2gg.js +0 -114
  197. package/dist/chunk-h0d5eat0.js +0 -101
  198. package/dist/chunk-h27tjbp3.js +0 -33118
  199. package/dist/chunk-h2yy8k4c.js +0 -58
  200. package/dist/chunk-h5acpdqt.js +0 -103
  201. package/dist/chunk-h63r8vps.js +0 -2840
  202. package/dist/chunk-h64x5b04.js +0 -860
  203. package/dist/chunk-h92snc84.js +0 -420
  204. package/dist/chunk-h9n54swm.js +0 -27
  205. package/dist/chunk-hafcrnpc.js +0 -145
  206. package/dist/chunk-hakdhagh.js +0 -16606
  207. package/dist/chunk-hk4phsaw.js +0 -388
  208. package/dist/chunk-hph1bmqw.js +0 -65
  209. package/dist/chunk-hvnztnp3.js +0 -71
  210. package/dist/chunk-hwfknpxv.js +0 -39
  211. package/dist/chunk-j2xxd002.js +0 -1052
  212. package/dist/chunk-j3qbygme.js +0 -105
  213. package/dist/chunk-j5bth84e.js +0 -97
  214. package/dist/chunk-j64ga6ta.js +0 -8035
  215. package/dist/chunk-jbwgyskk.js +0 -385
  216. package/dist/chunk-jd32zbps.js +0 -15
  217. package/dist/chunk-jdhkh2bb.js +0 -618
  218. package/dist/chunk-jeqcwgt7.js +0 -177
  219. package/dist/chunk-jf75p9ap.js +0 -445
  220. package/dist/chunk-jgvk0za1.js +0 -260
  221. package/dist/chunk-jhpaevah.js +0 -565
  222. package/dist/chunk-jmjwrbwd.js +0 -635
  223. package/dist/chunk-jpdbfwvq.js +0 -100
  224. package/dist/chunk-jps4m6sz.js +0 -183
  225. package/dist/chunk-jwf0s51s.js +0 -867
  226. package/dist/chunk-jxge4dgh.js +0 -83
  227. package/dist/chunk-jz71gv95.js +0 -1161
  228. package/dist/chunk-jzthz1bx.js +0 -15
  229. package/dist/chunk-jzvd2ycp.js +0 -120
  230. package/dist/chunk-k0p9w03v.js +0 -4957
  231. package/dist/chunk-k4dcreh0.js +0 -442
  232. package/dist/chunk-k7akhwkn.js +0 -151
  233. package/dist/chunk-k8vp0atq.js +0 -2331
  234. package/dist/chunk-kgd7gfvk.js +0 -407
  235. package/dist/chunk-km5ycg1j.js +0 -87
  236. package/dist/chunk-kvyrxzj8.js +0 -26
  237. package/dist/chunk-kwekc97v.js +0 -18
  238. package/dist/chunk-ky1z78ve.js +0 -119
  239. package/dist/chunk-mcws22k3.js +0 -42
  240. package/dist/chunk-mjazvyd8.js +0 -528
  241. package/dist/chunk-mswx2nma.js +0 -103
  242. package/dist/chunk-mz6a0phh.js +0 -2962
  243. package/dist/chunk-n2tg12hg.js +0 -374
  244. package/dist/chunk-n3fv4ya7.js +0 -146
  245. package/dist/chunk-n4eabmqd.js +0 -93
  246. package/dist/chunk-n4tx7baq.js +0 -193
  247. package/dist/chunk-n6g4jbeh.js +0 -289
  248. package/dist/chunk-n6wzfxf1.js +0 -100
  249. package/dist/chunk-ndcmqfkv.js +0 -244
  250. package/dist/chunk-netzwgv1.js +0 -154
  251. package/dist/chunk-nhcg04jt.js +0 -120
  252. package/dist/chunk-nhsm3ntd.js +0 -439
  253. package/dist/chunk-njev89d1.js +0 -2335
  254. package/dist/chunk-nmgj86tt.js +0 -24
  255. package/dist/chunk-ns7x6xam.js +0 -22820
  256. package/dist/chunk-p7vkh4wx.js +0 -15
  257. package/dist/chunk-p8na2wwp.js +0 -14
  258. package/dist/chunk-p97fd5af.js +0 -684
  259. package/dist/chunk-pe3rkfp2.js +0 -74
  260. package/dist/chunk-pgtnj1mt.js +0 -705
  261. package/dist/chunk-phmnkw9y.js +0 -283
  262. package/dist/chunk-pnds7g1q.js +0 -130
  263. package/dist/chunk-ppwjyveh.js +0 -8
  264. package/dist/chunk-pqqxdk5f.js +0 -543
  265. package/dist/chunk-ps49ymvj.js +0 -43
  266. package/dist/chunk-pwwa7s62.js +0 -11
  267. package/dist/chunk-q3hfrat2.js +0 -313
  268. package/dist/chunk-qajrkk97.js +0 -298
  269. package/dist/chunk-qatfdxvd.js +0 -34
  270. package/dist/chunk-qb5qcctj.js +0 -206
  271. package/dist/chunk-qb6k2afy.js +0 -153
  272. package/dist/chunk-qgk93a75.js +0 -85
  273. package/dist/chunk-qkczt8cr.js +0 -24
  274. package/dist/chunk-qn1be1vf.js +0 -267
  275. package/dist/chunk-qnfx3qtx.js +0 -617
  276. package/dist/chunk-qnwne2m4.js +0 -87
  277. package/dist/chunk-qp2qdcda.js +0 -100
  278. package/dist/chunk-qpp3wwh5.js +0 -697
  279. package/dist/chunk-r0bx1gc7.js +0 -174
  280. package/dist/chunk-radnwk8x.js +0 -107
  281. package/dist/chunk-rkv5jq0y.js +0 -71
  282. package/dist/chunk-rmbbmd3s.js +0 -68
  283. package/dist/chunk-rmgbs5an.js +0 -640
  284. package/dist/chunk-rn0v1hk8.js +0 -34
  285. package/dist/chunk-rnxctq9p.js +0 -1646
  286. package/dist/chunk-rtd39n81.js +0 -95
  287. package/dist/chunk-s8gy4ky9.js +0 -122
  288. package/dist/chunk-s8kj6ajy.js +0 -32
  289. package/dist/chunk-sd36yzx8.js +0 -954
  290. package/dist/chunk-sdenh194.js +0 -121
  291. package/dist/chunk-sdtqp75c.js +0 -55
  292. package/dist/chunk-sedbc8ep.js +0 -212
  293. package/dist/chunk-sfrb15b2.js +0 -321
  294. package/dist/chunk-sgpmpn90.js +0 -35
  295. package/dist/chunk-sh02d2qn.js +0 -38
  296. package/dist/chunk-shd4yhsf.js +0 -32
  297. package/dist/chunk-shkycj1q.js +0 -178
  298. package/dist/chunk-sk7h93je.js +0 -153
  299. package/dist/chunk-sm8g6fsm.js +0 -122
  300. package/dist/chunk-snrjy66h.js +0 -671
  301. package/dist/chunk-sq4a0yjh.js +0 -116
  302. package/dist/chunk-sr3t4thh.js +0 -895
  303. package/dist/chunk-srj6qnf6.js +0 -107
  304. package/dist/chunk-sz62n77p.js +0 -155
  305. package/dist/chunk-szj5wvdy.js +0 -28
  306. package/dist/chunk-t29a6zb5.js +0 -45
  307. package/dist/chunk-t2ecddwj.js +0 -731
  308. package/dist/chunk-t33hmmmm.js +0 -113
  309. package/dist/chunk-t4khqff1.js +0 -16
  310. package/dist/chunk-t9p85zff.js +0 -24
  311. package/dist/chunk-ta3jyvxs.js +0 -984
  312. package/dist/chunk-tkx5eec8.js +0 -54
  313. package/dist/chunk-v1kzp02e.js +0 -785
  314. package/dist/chunk-v4t6dyyh.js +0 -9076
  315. package/dist/chunk-v78fj8by.js +0 -145
  316. package/dist/chunk-v8kjswxt.js +0 -61
  317. package/dist/chunk-v9smspw2.js +0 -4301
  318. package/dist/chunk-vf612n57.js +0 -472
  319. package/dist/chunk-vkhrrvfq.js +0 -44
  320. package/dist/chunk-vt5wm07k.js +0 -74
  321. package/dist/chunk-vvvrv61g.js +0 -875
  322. package/dist/chunk-vyjeh50y.js +0 -2149
  323. package/dist/chunk-w0kxcv73.js +0 -97
  324. package/dist/chunk-w6m6trzq.js +0 -58
  325. package/dist/chunk-wa8yn2p0.js +0 -2007
  326. package/dist/chunk-wb18cecv.js +0 -995
  327. package/dist/chunk-wgk9sxk7.js +0 -329
  328. package/dist/chunk-wh0ev1bw.js +0 -111
  329. package/dist/chunk-wka1647p.js +0 -98
  330. package/dist/chunk-wnwfwyj4.js +0 -90
  331. package/dist/chunk-wpdchyy2.js +0 -97
  332. package/dist/chunk-x3g44n7k.js +0 -114
  333. package/dist/chunk-x47h283a.js +0 -56
  334. package/dist/chunk-x6r4v44b.js +0 -8
  335. package/dist/chunk-x7fdwq3d.js +0 -33
  336. package/dist/chunk-x8d2ehd7.js +0 -19
  337. package/dist/chunk-xbeg2hej.js +0 -257
  338. package/dist/chunk-xeb6075z.js +0 -3435
  339. package/dist/chunk-xhfmdq1y.js +0 -147
  340. package/dist/chunk-xhscn33a.js +0 -138
  341. package/dist/chunk-xv3era3s.js +0 -8
  342. package/dist/chunk-xz5gbhc3.js +0 -93
  343. package/dist/chunk-y1784krc.js +0 -19
  344. package/dist/chunk-y1vyezct.js +0 -123
  345. package/dist/chunk-y45ecntg.js +0 -942
  346. package/dist/chunk-y4ca9kqz.js +0 -3830
  347. package/dist/chunk-y9bhjjdz.js +0 -145
  348. package/dist/chunk-yb3bxv3w.js +0 -30
  349. package/dist/chunk-ye2q9gqj.js +0 -332
  350. package/dist/chunk-yfg3adfq.js +0 -88
  351. package/dist/chunk-yst0wmgw.js +0 -269
  352. package/dist/chunk-ywe9dbnz.js +0 -460
  353. package/dist/chunk-yyex5gsf.js +0 -269
  354. package/dist/chunk-yz2kzqk5.js +0 -439
  355. package/dist/chunk-z263ehpg.js +0 -131
  356. package/dist/chunk-z2dp53wn.js +0 -17
  357. package/dist/chunk-zaq348h2.js +0 -281
  358. package/dist/chunk-zr0qx9q0.js +0 -642
  359. package/dist/chunk-zxh62ved.js +0 -31
  360. package/dist/chunk-zy5vn8sd.js +0 -329
  361. package/dist/chunk-zzm33q8x.js +0 -8
  362. package/dist/cli.js +0 -91
@@ -1,847 +0,0 @@
1
- // @bun
2
- import {
3
- FRONTMATTER_REGEX,
4
- classifyFetchError,
5
- getPluginsDirectory,
6
- init_fetchTelemetry,
7
- init_frontmatterParser,
8
- init_pluginDirectories,
9
- init_yaml,
10
- logPluginFetch,
11
- parseYaml
12
- } from "./chunk-gnpt1t6q.js";
13
- import {
14
- PluginHooksSchema,
15
- PluginManifestSchema,
16
- PluginMarketplaceEntrySchema,
17
- PluginMarketplaceSchema,
18
- init_schemas
19
- } from "./chunk-dfq6pbq7.js";
20
- import {
21
- init_v4
22
- } from "./chunk-4pbx3g7s.js";
23
- import {
24
- exports_external
25
- } from "./chunk-26wtxbdc.js";
26
- import {
27
- errorMessage,
28
- getErrnoCode,
29
- getFsImplementation,
30
- init_debug,
31
- init_errors,
32
- init_fsOperations,
33
- init_log,
34
- init_slowOperations,
35
- isENOENT,
36
- jsonParse,
37
- jsonStringify,
38
- logError,
39
- logForDebugging
40
- } from "./chunk-gg55fns0.js";
41
- import {
42
- axios_default,
43
- init_axios
44
- } from "./chunk-55raexh7.js";
45
- import {
46
- __esm
47
- } from "./chunk-qp2qdcda.js";
48
-
49
- // src/utils/plugins/parseMarketplaceInput.ts
50
- import { homedir } from "os";
51
- import { resolve } from "path";
52
- async function parseMarketplaceInput(input) {
53
- const trimmed = input.trim();
54
- const fs = getFsImplementation();
55
- const sshMatch = trimmed.match(/^([a-zA-Z0-9._-]+@[^:]+:.+?(?:\.git)?)(#(.+))?$/);
56
- if (sshMatch?.[1]) {
57
- const url = sshMatch[1];
58
- const ref = sshMatch[3];
59
- return ref ? { source: "git", url, ref } : { source: "git", url };
60
- }
61
- if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) {
62
- const fragmentMatch = trimmed.match(/^([^#]+)(#(.+))?$/);
63
- const urlWithoutFragment = fragmentMatch?.[1] || trimmed;
64
- const ref = fragmentMatch?.[3];
65
- if (urlWithoutFragment.endsWith(".git") || urlWithoutFragment.includes("/_git/")) {
66
- return ref ? { source: "git", url: urlWithoutFragment, ref } : { source: "git", url: urlWithoutFragment };
67
- }
68
- let url;
69
- try {
70
- url = new URL(urlWithoutFragment);
71
- } catch (_err) {
72
- return { source: "url", url: urlWithoutFragment };
73
- }
74
- if (url.hostname === "github.com" || url.hostname === "www.github.com") {
75
- const match = url.pathname.match(/^\/([^/]+\/[^/]+?)(\/|\.git|$)/);
76
- if (match?.[1]) {
77
- const gitUrl = urlWithoutFragment.endsWith(".git") ? urlWithoutFragment : `${urlWithoutFragment}.git`;
78
- return ref ? { source: "git", url: gitUrl, ref } : { source: "git", url: gitUrl };
79
- }
80
- }
81
- return { source: "url", url: urlWithoutFragment };
82
- }
83
- const isWindows = process.platform === "win32";
84
- const isWindowsPath = isWindows && (trimmed.startsWith(".\\") || trimmed.startsWith("..\\") || /^[a-zA-Z]:[/\\]/.test(trimmed));
85
- if (trimmed.startsWith("./") || trimmed.startsWith("../") || trimmed.startsWith("/") || trimmed.startsWith("~") || isWindowsPath) {
86
- const resolvedPath = resolve(trimmed.startsWith("~") ? trimmed.replace(/^~/, homedir()) : trimmed);
87
- let stats;
88
- try {
89
- stats = await fs.stat(resolvedPath);
90
- } catch (e) {
91
- const code = getErrnoCode(e);
92
- return {
93
- error: code === "ENOENT" ? `Path does not exist: ${resolvedPath}` : `Cannot access path: ${resolvedPath} (${code ?? e})`
94
- };
95
- }
96
- if (stats.isFile()) {
97
- if (resolvedPath.endsWith(".json")) {
98
- return { source: "file", path: resolvedPath };
99
- } else {
100
- return {
101
- error: `File path must point to a .json file (marketplace.json), but got: ${resolvedPath}`
102
- };
103
- }
104
- } else if (stats.isDirectory()) {
105
- return { source: "directory", path: resolvedPath };
106
- } else {
107
- return {
108
- error: `Path is neither a file nor a directory: ${resolvedPath}`
109
- };
110
- }
111
- }
112
- if (trimmed.includes("/") && !trimmed.startsWith("@")) {
113
- if (trimmed.includes(":")) {
114
- return null;
115
- }
116
- const fragmentMatch = trimmed.match(/^([^#@]+)(?:[#@](.+))?$/);
117
- const repo = fragmentMatch?.[1] || trimmed;
118
- const ref = fragmentMatch?.[2];
119
- return ref ? { source: "github", repo, ref } : { source: "github", repo };
120
- }
121
- return null;
122
- }
123
- var init_parseMarketplaceInput = __esm(() => {
124
- init_errors();
125
- init_fsOperations();
126
- });
127
-
128
- // src/utils/plugins/installCounts.ts
129
- import { randomBytes } from "crypto";
130
- import { readFile, rename, unlink, writeFile } from "fs/promises";
131
- import { join } from "path";
132
- function getInstallCountsCachePath() {
133
- return join(getPluginsDirectory(), INSTALL_COUNTS_CACHE_FILENAME);
134
- }
135
- async function loadInstallCountsCache() {
136
- const cachePath = getInstallCountsCachePath();
137
- try {
138
- const content = await readFile(cachePath, { encoding: "utf-8" });
139
- const parsed = jsonParse(content);
140
- if (typeof parsed !== "object" || parsed === null || !("version" in parsed) || !("fetchedAt" in parsed) || !("counts" in parsed)) {
141
- logForDebugging("Install counts cache has invalid structure");
142
- return null;
143
- }
144
- const cache = parsed;
145
- if (cache.version !== INSTALL_COUNTS_CACHE_VERSION) {
146
- logForDebugging(`Install counts cache version mismatch (got ${cache.version}, expected ${INSTALL_COUNTS_CACHE_VERSION})`);
147
- return null;
148
- }
149
- if (typeof cache.fetchedAt !== "string" || !Array.isArray(cache.counts)) {
150
- logForDebugging("Install counts cache has invalid structure");
151
- return null;
152
- }
153
- const fetchedAt = new Date(cache.fetchedAt).getTime();
154
- if (Number.isNaN(fetchedAt)) {
155
- logForDebugging("Install counts cache has invalid fetchedAt timestamp");
156
- return null;
157
- }
158
- const validCounts = cache.counts.every((entry) => typeof entry === "object" && entry !== null && typeof entry.plugin === "string" && typeof entry.unique_installs === "number");
159
- if (!validCounts) {
160
- logForDebugging("Install counts cache has malformed entries");
161
- return null;
162
- }
163
- const now = Date.now();
164
- if (now - fetchedAt > CACHE_TTL_MS) {
165
- logForDebugging("Install counts cache is stale (>24h old)");
166
- return null;
167
- }
168
- return {
169
- version: cache.version,
170
- fetchedAt: cache.fetchedAt,
171
- counts: cache.counts
172
- };
173
- } catch (error) {
174
- const code = getErrnoCode(error);
175
- if (code !== "ENOENT") {
176
- logForDebugging(`Failed to load install counts cache: ${errorMessage(error)}`);
177
- }
178
- return null;
179
- }
180
- }
181
- async function saveInstallCountsCache(cache) {
182
- const cachePath = getInstallCountsCachePath();
183
- const tempPath = `${cachePath}.${randomBytes(8).toString("hex")}.tmp`;
184
- try {
185
- const pluginsDir = getPluginsDirectory();
186
- await getFsImplementation().mkdir(pluginsDir);
187
- const content = jsonStringify(cache, null, 2);
188
- await writeFile(tempPath, content, {
189
- encoding: "utf-8",
190
- mode: 384
191
- });
192
- await rename(tempPath, cachePath);
193
- logForDebugging("Install counts cache saved successfully");
194
- } catch (error) {
195
- logError(error);
196
- try {
197
- await unlink(tempPath);
198
- } catch {}
199
- }
200
- }
201
- async function fetchInstallCountsFromGitHub() {
202
- logForDebugging(`Fetching install counts from ${INSTALL_COUNTS_URL}`);
203
- const started = performance.now();
204
- try {
205
- const response = await axios_default.get(INSTALL_COUNTS_URL, {
206
- timeout: 1e4
207
- });
208
- if (!response.data?.plugins || !Array.isArray(response.data.plugins)) {
209
- throw new Error("Invalid response format from install counts API");
210
- }
211
- logPluginFetch("install_counts", INSTALL_COUNTS_URL, "success", performance.now() - started);
212
- return response.data.plugins;
213
- } catch (error) {
214
- logPluginFetch("install_counts", INSTALL_COUNTS_URL, "failure", performance.now() - started, classifyFetchError(error));
215
- throw error;
216
- }
217
- }
218
- async function getInstallCounts() {
219
- const cache = await loadInstallCountsCache();
220
- if (cache) {
221
- logForDebugging("Using cached install counts");
222
- logPluginFetch("install_counts", INSTALL_COUNTS_URL, "cache_hit", 0);
223
- const map = new Map;
224
- for (const entry of cache.counts) {
225
- map.set(entry.plugin, entry.unique_installs);
226
- }
227
- return map;
228
- }
229
- try {
230
- const counts = await fetchInstallCountsFromGitHub();
231
- const newCache = {
232
- version: INSTALL_COUNTS_CACHE_VERSION,
233
- fetchedAt: new Date().toISOString(),
234
- counts
235
- };
236
- await saveInstallCountsCache(newCache);
237
- const map = new Map;
238
- for (const entry of counts) {
239
- map.set(entry.plugin, entry.unique_installs);
240
- }
241
- return map;
242
- } catch (error) {
243
- logError(error);
244
- logForDebugging(`Failed to fetch install counts: ${errorMessage(error)}`);
245
- return null;
246
- }
247
- }
248
- function formatInstallCount(count) {
249
- if (count < 1000) {
250
- return String(count);
251
- }
252
- if (count < 1e6) {
253
- const k = count / 1000;
254
- const formatted2 = k.toFixed(1);
255
- return formatted2.endsWith(".0") ? `${formatted2.slice(0, -2)}K` : `${formatted2}K`;
256
- }
257
- const m = count / 1e6;
258
- const formatted = m.toFixed(1);
259
- return formatted.endsWith(".0") ? `${formatted.slice(0, -2)}M` : `${formatted}M`;
260
- }
261
- var INSTALL_COUNTS_CACHE_VERSION = 1, INSTALL_COUNTS_CACHE_FILENAME = "install-counts-cache.json", INSTALL_COUNTS_URL = "https://raw.githubusercontent.com/anthropics/claude-plugins-official/refs/heads/stats/stats/plugin-installs.json", CACHE_TTL_MS;
262
- var init_installCounts = __esm(() => {
263
- init_axios();
264
- init_debug();
265
- init_errors();
266
- init_fsOperations();
267
- init_log();
268
- init_slowOperations();
269
- init_fetchTelemetry();
270
- init_pluginDirectories();
271
- CACHE_TTL_MS = 24 * 60 * 60 * 1000;
272
- });
273
-
274
- // src/utils/plugins/validatePlugin.ts
275
- import { readdir, readFile as readFile2, stat } from "fs/promises";
276
- import * as path from "path";
277
- function detectManifestType(filePath) {
278
- const fileName = path.basename(filePath);
279
- const dirName = path.basename(path.dirname(filePath));
280
- if (fileName === "plugin.json")
281
- return "plugin";
282
- if (fileName === "marketplace.json")
283
- return "marketplace";
284
- if (dirName === ".claude-plugin") {
285
- return "plugin";
286
- }
287
- return "unknown";
288
- }
289
- function formatZodErrors(zodError) {
290
- return zodError.issues.map((error) => ({
291
- path: error.path.join(".") || "root",
292
- message: error.message,
293
- code: error.code
294
- }));
295
- }
296
- function checkPathTraversal(p, field, errors, hint) {
297
- if (p.includes("..")) {
298
- errors.push({
299
- path: field,
300
- message: hint ? `Path contains "..": ${p}. ${hint}` : `Path contains ".." which could be a path traversal attempt: ${p}`
301
- });
302
- }
303
- }
304
- function marketplaceSourceHint(p) {
305
- const stripped = p.replace(/^(\.\.\/)+/, "");
306
- const corrected = stripped !== p ? `./${stripped}` : "./plugins/my-plugin";
307
- return "Plugin source paths are resolved relative to the marketplace root (the directory " + "containing .claude-plugin/), not relative to marketplace.json. " + `Use "${corrected}" instead of "${p}".`;
308
- }
309
- async function validatePluginManifest(filePath) {
310
- const errors = [];
311
- const warnings = [];
312
- const absolutePath = path.resolve(filePath);
313
- let content;
314
- try {
315
- content = await readFile2(absolutePath, { encoding: "utf-8" });
316
- } catch (error) {
317
- const code = getErrnoCode(error);
318
- let message;
319
- if (code === "ENOENT") {
320
- message = `File not found: ${absolutePath}`;
321
- } else if (code === "EISDIR") {
322
- message = `Path is not a file: ${absolutePath}`;
323
- } else {
324
- message = `Failed to read file: ${errorMessage(error)}`;
325
- }
326
- return {
327
- success: false,
328
- errors: [{ path: "file", message, code }],
329
- warnings: [],
330
- filePath: absolutePath,
331
- fileType: "plugin"
332
- };
333
- }
334
- let parsed;
335
- try {
336
- parsed = jsonParse(content);
337
- } catch (error) {
338
- return {
339
- success: false,
340
- errors: [
341
- {
342
- path: "json",
343
- message: `Invalid JSON syntax: ${errorMessage(error)}`
344
- }
345
- ],
346
- warnings: [],
347
- filePath: absolutePath,
348
- fileType: "plugin"
349
- };
350
- }
351
- if (parsed && typeof parsed === "object") {
352
- const obj = parsed;
353
- if (obj.commands) {
354
- const commands = Array.isArray(obj.commands) ? obj.commands : [obj.commands];
355
- commands.forEach((cmd, i) => {
356
- if (typeof cmd === "string") {
357
- checkPathTraversal(cmd, `commands[${i}]`, errors);
358
- }
359
- });
360
- }
361
- if (obj.agents) {
362
- const agents = Array.isArray(obj.agents) ? obj.agents : [obj.agents];
363
- agents.forEach((agent, i) => {
364
- if (typeof agent === "string") {
365
- checkPathTraversal(agent, `agents[${i}]`, errors);
366
- }
367
- });
368
- }
369
- if (obj.skills) {
370
- const skills = Array.isArray(obj.skills) ? obj.skills : [obj.skills];
371
- skills.forEach((skill, i) => {
372
- if (typeof skill === "string") {
373
- checkPathTraversal(skill, `skills[${i}]`, errors);
374
- }
375
- });
376
- }
377
- }
378
- let toValidate = parsed;
379
- if (typeof parsed === "object" && parsed !== null) {
380
- const obj = parsed;
381
- const strayKeys = Object.keys(obj).filter((k) => MARKETPLACE_ONLY_MANIFEST_FIELDS.has(k));
382
- if (strayKeys.length > 0) {
383
- const stripped = { ...obj };
384
- for (const key of strayKeys) {
385
- delete stripped[key];
386
- warnings.push({
387
- path: key,
388
- message: `Field '${key}' belongs in the marketplace entry (marketplace.json), ` + `not plugin.json. It's harmless here but unused \u2014 Claude Code ` + `ignores it at load time.`
389
- });
390
- }
391
- toValidate = stripped;
392
- }
393
- }
394
- const result = PluginManifestSchema().strict().safeParse(toValidate);
395
- if (!result.success) {
396
- errors.push(...formatZodErrors(result.error));
397
- }
398
- if (result.success) {
399
- const manifest = result.data;
400
- if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(manifest.name)) {
401
- warnings.push({
402
- path: "name",
403
- message: `Plugin name "${manifest.name}" is not kebab-case. Claude Code accepts ` + `it, but the Claude.ai marketplace sync requires kebab-case ` + `(lowercase letters, digits, and hyphens only, e.g., "my-plugin").`
404
- });
405
- }
406
- if (!manifest.version) {
407
- warnings.push({
408
- path: "version",
409
- message: 'No version specified. Consider adding a version following semver (e.g., "1.0.0")'
410
- });
411
- }
412
- if (!manifest.description) {
413
- warnings.push({
414
- path: "description",
415
- message: "No description provided. Adding a description helps users understand what your plugin does"
416
- });
417
- }
418
- if (!manifest.author) {
419
- warnings.push({
420
- path: "author",
421
- message: "No author information provided. Consider adding author details for plugin attribution"
422
- });
423
- }
424
- }
425
- return {
426
- success: errors.length === 0,
427
- errors,
428
- warnings,
429
- filePath: absolutePath,
430
- fileType: "plugin"
431
- };
432
- }
433
- async function validateMarketplaceManifest(filePath) {
434
- const errors = [];
435
- const warnings = [];
436
- const absolutePath = path.resolve(filePath);
437
- let content;
438
- try {
439
- content = await readFile2(absolutePath, { encoding: "utf-8" });
440
- } catch (error) {
441
- const code = getErrnoCode(error);
442
- let message;
443
- if (code === "ENOENT") {
444
- message = `File not found: ${absolutePath}`;
445
- } else if (code === "EISDIR") {
446
- message = `Path is not a file: ${absolutePath}`;
447
- } else {
448
- message = `Failed to read file: ${errorMessage(error)}`;
449
- }
450
- return {
451
- success: false,
452
- errors: [{ path: "file", message, code }],
453
- warnings: [],
454
- filePath: absolutePath,
455
- fileType: "marketplace"
456
- };
457
- }
458
- let parsed;
459
- try {
460
- parsed = jsonParse(content);
461
- } catch (error) {
462
- return {
463
- success: false,
464
- errors: [
465
- {
466
- path: "json",
467
- message: `Invalid JSON syntax: ${errorMessage(error)}`
468
- }
469
- ],
470
- warnings: [],
471
- filePath: absolutePath,
472
- fileType: "marketplace"
473
- };
474
- }
475
- if (parsed && typeof parsed === "object") {
476
- const obj = parsed;
477
- if (Array.isArray(obj.plugins)) {
478
- obj.plugins.forEach((plugin, i) => {
479
- if (plugin && typeof plugin === "object" && "source" in plugin) {
480
- const source = plugin.source;
481
- if (typeof source === "string") {
482
- checkPathTraversal(source, `plugins[${i}].source`, errors, marketplaceSourceHint(source));
483
- }
484
- if (source && typeof source === "object" && "path" in source && typeof source.path === "string") {
485
- checkPathTraversal(source.path, `plugins[${i}].source.path`, errors);
486
- }
487
- }
488
- });
489
- }
490
- }
491
- const strictMarketplaceSchema = PluginMarketplaceSchema().extend({
492
- plugins: exports_external.array(PluginMarketplaceEntrySchema().strict())
493
- }).strict();
494
- const result = strictMarketplaceSchema.safeParse(parsed);
495
- if (!result.success) {
496
- errors.push(...formatZodErrors(result.error));
497
- }
498
- if (result.success) {
499
- const marketplace = result.data;
500
- if (!marketplace.plugins || marketplace.plugins.length === 0) {
501
- warnings.push({
502
- path: "plugins",
503
- message: "Marketplace has no plugins defined"
504
- });
505
- }
506
- if (marketplace.plugins) {
507
- marketplace.plugins.forEach((plugin, i) => {
508
- const duplicates = marketplace.plugins.filter((p) => p.name === plugin.name);
509
- if (duplicates.length > 1) {
510
- errors.push({
511
- path: `plugins[${i}].name`,
512
- message: `Duplicate plugin name "${plugin.name}" found in marketplace`
513
- });
514
- }
515
- });
516
- const manifestDir = path.dirname(absolutePath);
517
- const marketplaceRoot = path.basename(manifestDir) === ".claude-plugin" ? path.dirname(manifestDir) : manifestDir;
518
- for (const [i, entry] of marketplace.plugins.entries()) {
519
- if (!entry.version || typeof entry.source !== "string" || !entry.source.startsWith("./")) {
520
- continue;
521
- }
522
- const pluginJsonPath = path.join(marketplaceRoot, entry.source, ".claude-plugin", "plugin.json");
523
- let manifestVersion;
524
- try {
525
- const raw = await readFile2(pluginJsonPath, { encoding: "utf-8" });
526
- const parsed2 = jsonParse(raw);
527
- if (typeof parsed2.version === "string") {
528
- manifestVersion = parsed2.version;
529
- }
530
- } catch {
531
- continue;
532
- }
533
- if (manifestVersion && manifestVersion !== entry.version) {
534
- warnings.push({
535
- path: `plugins[${i}].version`,
536
- message: `Entry declares version "${entry.version}" but ${entry.source}/.claude-plugin/plugin.json says "${manifestVersion}". ` + `At install time, plugin.json wins (calculatePluginVersion precedence) \u2014 the entry version is silently ignored. ` + `Update this entry to "${manifestVersion}" to match.`
537
- });
538
- }
539
- }
540
- }
541
- if (!marketplace.metadata?.description) {
542
- warnings.push({
543
- path: "metadata.description",
544
- message: "No marketplace description provided. Adding a description helps users understand what this marketplace offers"
545
- });
546
- }
547
- }
548
- return {
549
- success: errors.length === 0,
550
- errors,
551
- warnings,
552
- filePath: absolutePath,
553
- fileType: "marketplace"
554
- };
555
- }
556
- function validateComponentFile(filePath, content, fileType) {
557
- const errors = [];
558
- const warnings = [];
559
- const match = content.match(FRONTMATTER_REGEX);
560
- if (!match) {
561
- warnings.push({
562
- path: "frontmatter",
563
- message: "No frontmatter block found. Add YAML frontmatter between --- delimiters " + "at the top of the file to set description and other metadata."
564
- });
565
- return { success: true, errors, warnings, filePath, fileType };
566
- }
567
- const frontmatterText = match[1] || "";
568
- let parsed;
569
- try {
570
- parsed = parseYaml(frontmatterText);
571
- } catch (e) {
572
- errors.push({
573
- path: "frontmatter",
574
- message: `YAML frontmatter failed to parse: ${errorMessage(e)}. ` + `At runtime this ${fileType} loads with empty metadata (all frontmatter ` + `fields silently dropped).`
575
- });
576
- return { success: false, errors, warnings, filePath, fileType };
577
- }
578
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
579
- errors.push({
580
- path: "frontmatter",
581
- message: "Frontmatter must be a YAML mapping (key: value pairs), got " + `${Array.isArray(parsed) ? "an array" : parsed === null ? "null" : typeof parsed}.`
582
- });
583
- return { success: false, errors, warnings, filePath, fileType };
584
- }
585
- const fm = parsed;
586
- if (fm.description !== undefined) {
587
- const d = fm.description;
588
- if (typeof d !== "string" && typeof d !== "number" && typeof d !== "boolean" && d !== null) {
589
- errors.push({
590
- path: "description",
591
- message: `description must be a string, got ${Array.isArray(d) ? "array" : typeof d}. ` + `At runtime this value is dropped.`
592
- });
593
- }
594
- } else {
595
- warnings.push({
596
- path: "description",
597
- message: `No description in frontmatter. A description helps users and Claude ` + `understand when to use this ${fileType}.`
598
- });
599
- }
600
- if (fm.name !== undefined && fm.name !== null && typeof fm.name !== "string") {
601
- errors.push({
602
- path: "name",
603
- message: `name must be a string, got ${typeof fm.name}.`
604
- });
605
- }
606
- const at = fm["allowed-tools"];
607
- if (at !== undefined && at !== null) {
608
- if (typeof at !== "string" && !Array.isArray(at)) {
609
- errors.push({
610
- path: "allowed-tools",
611
- message: `allowed-tools must be a string or array of strings, got ${typeof at}.`
612
- });
613
- } else if (Array.isArray(at) && at.some((t) => typeof t !== "string")) {
614
- errors.push({
615
- path: "allowed-tools",
616
- message: "allowed-tools array must contain only strings."
617
- });
618
- }
619
- }
620
- const sh = fm.shell;
621
- if (sh !== undefined && sh !== null) {
622
- if (typeof sh !== "string") {
623
- errors.push({
624
- path: "shell",
625
- message: `shell must be a string, got ${typeof sh}.`
626
- });
627
- } else {
628
- const normalized = sh.trim().toLowerCase();
629
- if (normalized !== "bash" && normalized !== "powershell") {
630
- errors.push({
631
- path: "shell",
632
- message: `shell must be 'bash' or 'powershell', got '${sh}'.`
633
- });
634
- }
635
- }
636
- }
637
- return { success: errors.length === 0, errors, warnings, filePath, fileType };
638
- }
639
- async function validateHooksJson(filePath) {
640
- let content;
641
- try {
642
- content = await readFile2(filePath, { encoding: "utf-8" });
643
- } catch (e) {
644
- const code = getErrnoCode(e);
645
- if (code === "ENOENT") {
646
- return {
647
- success: true,
648
- errors: [],
649
- warnings: [],
650
- filePath,
651
- fileType: "hooks"
652
- };
653
- }
654
- return {
655
- success: false,
656
- errors: [
657
- { path: "file", message: `Failed to read file: ${errorMessage(e)}` }
658
- ],
659
- warnings: [],
660
- filePath,
661
- fileType: "hooks"
662
- };
663
- }
664
- let parsed;
665
- try {
666
- parsed = jsonParse(content);
667
- } catch (e) {
668
- return {
669
- success: false,
670
- errors: [
671
- {
672
- path: "json",
673
- message: `Invalid JSON syntax: ${errorMessage(e)}. ` + `At runtime this breaks the entire plugin load.`
674
- }
675
- ],
676
- warnings: [],
677
- filePath,
678
- fileType: "hooks"
679
- };
680
- }
681
- const result = PluginHooksSchema().safeParse(parsed);
682
- if (!result.success) {
683
- return {
684
- success: false,
685
- errors: formatZodErrors(result.error),
686
- warnings: [],
687
- filePath,
688
- fileType: "hooks"
689
- };
690
- }
691
- return {
692
- success: true,
693
- errors: [],
694
- warnings: [],
695
- filePath,
696
- fileType: "hooks"
697
- };
698
- }
699
- async function collectMarkdown(dir, isSkillsDir) {
700
- let entries;
701
- try {
702
- entries = await readdir(dir, { withFileTypes: true });
703
- } catch (e) {
704
- const code = getErrnoCode(e);
705
- if (code === "ENOENT" || code === "ENOTDIR")
706
- return [];
707
- throw e;
708
- }
709
- if (isSkillsDir) {
710
- return entries.filter((e) => e.isDirectory()).map((e) => path.join(dir, e.name, "SKILL.md"));
711
- }
712
- const out = [];
713
- for (const entry of entries) {
714
- const full = path.join(dir, entry.name);
715
- if (entry.isDirectory()) {
716
- out.push(...await collectMarkdown(full, false));
717
- } else if (entry.isFile() && entry.name.toLowerCase().endsWith(".md")) {
718
- out.push(full);
719
- }
720
- }
721
- return out;
722
- }
723
- async function validatePluginContents(pluginDir) {
724
- const results = [];
725
- const dirs = [
726
- ["skill", path.join(pluginDir, "skills")],
727
- ["agent", path.join(pluginDir, "agents")],
728
- ["command", path.join(pluginDir, "commands")]
729
- ];
730
- for (const [fileType, dir] of dirs) {
731
- const files = await collectMarkdown(dir, fileType === "skill");
732
- for (const filePath of files) {
733
- let content;
734
- try {
735
- content = await readFile2(filePath, { encoding: "utf-8" });
736
- } catch (e) {
737
- if (isENOENT(e))
738
- continue;
739
- results.push({
740
- success: false,
741
- errors: [
742
- { path: "file", message: `Failed to read: ${errorMessage(e)}` }
743
- ],
744
- warnings: [],
745
- filePath,
746
- fileType
747
- });
748
- continue;
749
- }
750
- const r = validateComponentFile(filePath, content, fileType);
751
- if (r.errors.length > 0 || r.warnings.length > 0) {
752
- results.push(r);
753
- }
754
- }
755
- }
756
- const hooksResult = await validateHooksJson(path.join(pluginDir, "hooks", "hooks.json"));
757
- if (hooksResult.errors.length > 0 || hooksResult.warnings.length > 0) {
758
- results.push(hooksResult);
759
- }
760
- return results;
761
- }
762
- async function validateManifest(filePath) {
763
- const absolutePath = path.resolve(filePath);
764
- let stats = null;
765
- try {
766
- stats = await stat(absolutePath);
767
- } catch (e) {
768
- if (!isENOENT(e)) {
769
- throw e;
770
- }
771
- }
772
- if (stats?.isDirectory()) {
773
- const marketplacePath = path.join(absolutePath, ".claude-plugin", "marketplace.json");
774
- const marketplaceResult = await validateMarketplaceManifest(marketplacePath);
775
- if (marketplaceResult.errors[0]?.code !== "ENOENT") {
776
- return marketplaceResult;
777
- }
778
- const pluginPath = path.join(absolutePath, ".claude-plugin", "plugin.json");
779
- const pluginResult = await validatePluginManifest(pluginPath);
780
- if (pluginResult.errors[0]?.code !== "ENOENT") {
781
- return pluginResult;
782
- }
783
- return {
784
- success: false,
785
- errors: [
786
- {
787
- path: "directory",
788
- message: `No manifest found in directory. Expected .claude-plugin/marketplace.json or .claude-plugin/plugin.json`
789
- }
790
- ],
791
- warnings: [],
792
- filePath: absolutePath,
793
- fileType: "plugin"
794
- };
795
- }
796
- const manifestType = detectManifestType(filePath);
797
- switch (manifestType) {
798
- case "plugin":
799
- return validatePluginManifest(filePath);
800
- case "marketplace":
801
- return validateMarketplaceManifest(filePath);
802
- case "unknown": {
803
- try {
804
- const content = await readFile2(absolutePath, { encoding: "utf-8" });
805
- const parsed = jsonParse(content);
806
- if (Array.isArray(parsed.plugins)) {
807
- return validateMarketplaceManifest(filePath);
808
- }
809
- } catch (e) {
810
- const code = getErrnoCode(e);
811
- if (code === "ENOENT") {
812
- return {
813
- success: false,
814
- errors: [
815
- {
816
- path: "file",
817
- message: `File not found: ${absolutePath}`
818
- }
819
- ],
820
- warnings: [],
821
- filePath: absolutePath,
822
- fileType: "plugin"
823
- };
824
- }
825
- }
826
- return validatePluginManifest(filePath);
827
- }
828
- }
829
- }
830
- var MARKETPLACE_ONLY_MANIFEST_FIELDS;
831
- var init_validatePlugin = __esm(() => {
832
- init_v4();
833
- init_errors();
834
- init_frontmatterParser();
835
- init_slowOperations();
836
- init_yaml();
837
- init_schemas();
838
- MARKETPLACE_ONLY_MANIFEST_FIELDS = new Set([
839
- "category",
840
- "source",
841
- "tags",
842
- "strict",
843
- "id"
844
- ]);
845
- });
846
-
847
- export { parseMarketplaceInput, init_parseMarketplaceInput, getInstallCounts, formatInstallCount, init_installCounts, validatePluginContents, validateManifest, init_validatePlugin };