@caspian2026/agent-sdk 0.0.25 → 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 +86 -41
  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-04n4fe72.js +0 -107
  7. package/dist/chunk-04ys66ej.js +0 -344
  8. package/dist/chunk-07069jq1.js +0 -30
  9. package/dist/chunk-0731m51q.js +0 -8
  10. package/dist/chunk-086x4ct4.js +0 -26
  11. package/dist/chunk-0btqb97n.js +0 -295
  12. package/dist/chunk-0paqc2yw.js +0 -15
  13. package/dist/chunk-0r1rjydx.js +0 -145
  14. package/dist/chunk-0r5bb9j4.js +0 -477
  15. package/dist/chunk-0t81d427.js +0 -41
  16. package/dist/chunk-0teq2mz0.js +0 -420
  17. package/dist/chunk-0vkfrmqm.js +0 -690
  18. package/dist/chunk-0vp3wfab.js +0 -12
  19. package/dist/chunk-0warp8dx.js +0 -253
  20. package/dist/chunk-0xjaqda8.js +0 -1124
  21. package/dist/chunk-10gzv316.js +0 -62
  22. package/dist/chunk-11pq9n08.js +0 -168
  23. package/dist/chunk-1ae3nt9j.js +0 -31
  24. package/dist/chunk-1fmb0njn.js +0 -396
  25. package/dist/chunk-1gx78081.js +0 -66
  26. package/dist/chunk-1h2famwb.js +0 -49
  27. package/dist/chunk-1ng8xwxz.js +0 -276
  28. package/dist/chunk-1v7jp29h.js +0 -206
  29. package/dist/chunk-1xxy5zhb.js +0 -673
  30. package/dist/chunk-20b73w7w.js +0 -117
  31. package/dist/chunk-20qxd83a.js +0 -1161
  32. package/dist/chunk-2239ny9q.js +0 -90
  33. package/dist/chunk-22d4rnef.js +0 -226
  34. package/dist/chunk-26wtxbdc.js +0 -13870
  35. package/dist/chunk-27225bjh.js +0 -618
  36. package/dist/chunk-2b0e32an.js +0 -5822
  37. package/dist/chunk-2bfa9w1y.js +0 -323
  38. package/dist/chunk-2epq04w1.js +0 -63
  39. package/dist/chunk-2fwze72g.js +0 -24
  40. package/dist/chunk-2gzv8nrw.js +0 -205
  41. package/dist/chunk-2mexte1r.js +0 -349
  42. package/dist/chunk-2mzaqh5g.js +0 -338
  43. package/dist/chunk-2tb6mzfc.js +0 -81
  44. package/dist/chunk-2xq0g43w.js +0 -558
  45. package/dist/chunk-334aeqg9.js +0 -90
  46. package/dist/chunk-34jx4rjd.js +0 -995
  47. package/dist/chunk-35w5nhex.js +0 -132
  48. package/dist/chunk-3c25bcsw.js +0 -17
  49. package/dist/chunk-3eaxj8dg.js +0 -151
  50. package/dist/chunk-3fdgrwd2.js +0 -111
  51. package/dist/chunk-3jw0r58d.js +0 -121
  52. package/dist/chunk-3mgywd32.js +0 -8
  53. package/dist/chunk-3nk79af8.js +0 -8
  54. package/dist/chunk-3vy1jt9p.js +0 -1010
  55. package/dist/chunk-3x78pd4j.js +0 -153
  56. package/dist/chunk-47x3dsmn.js +0 -95
  57. package/dist/chunk-49pqt48n.js +0 -108
  58. package/dist/chunk-4f7m9fjw.js +0 -317
  59. package/dist/chunk-4jm600zv.js +0 -13
  60. package/dist/chunk-4k9d7gxv.js +0 -118
  61. package/dist/chunk-4net8san.js +0 -155
  62. package/dist/chunk-4pbx3g7s.js +0 -26
  63. package/dist/chunk-4v125j4z.js +0 -58
  64. package/dist/chunk-4vxkv5vz.js +0 -1438
  65. package/dist/chunk-51fqpjy3.js +0 -121
  66. package/dist/chunk-52e64f2h.js +0 -439
  67. package/dist/chunk-52e9mdjv.js +0 -684
  68. package/dist/chunk-55raexh7.js +0 -14358
  69. package/dist/chunk-59pq5122.js +0 -269
  70. package/dist/chunk-5bsj67v1.js +0 -349
  71. package/dist/chunk-5ccdsxgy.js +0 -74
  72. package/dist/chunk-5ekyhb1w.js +0 -422
  73. package/dist/chunk-5gcqdn8x.js +0 -867
  74. package/dist/chunk-5h5kx2jd.js +0 -34
  75. package/dist/chunk-5hf3werb.js +0 -193
  76. package/dist/chunk-5n1jc02d.js +0 -87
  77. package/dist/chunk-5wfxvxm8.js +0 -127
  78. package/dist/chunk-5wjebwmn.js +0 -89
  79. package/dist/chunk-5z28bqne.js +0 -6748
  80. package/dist/chunk-5zwsxpjn.js +0 -671
  81. package/dist/chunk-60phw466.js +0 -29
  82. package/dist/chunk-64c1avct.js +0 -13
  83. package/dist/chunk-64r16v22.js +0 -162
  84. package/dist/chunk-65t1r7zs.js +0 -418
  85. package/dist/chunk-66zry909.js +0 -11
  86. package/dist/chunk-67hxjjgc.js +0 -731
  87. package/dist/chunk-68ffk5qa.js +0 -14
  88. package/dist/chunk-69dr6rrd.js +0 -177
  89. package/dist/chunk-69n11zng.js +0 -436
  90. package/dist/chunk-6dj5t602.js +0 -341
  91. package/dist/chunk-6dngjwkh.js +0 -63
  92. package/dist/chunk-6dp8sz55.js +0 -3561
  93. package/dist/chunk-6hqgg0sv.js +0 -103
  94. package/dist/chunk-6nsd9606.js +0 -790
  95. package/dist/chunk-6p0hbwz3.js +0 -65
  96. package/dist/chunk-6ywdv5vg.js +0 -97
  97. package/dist/chunk-6zc758qw.js +0 -640
  98. package/dist/chunk-7aw745vx.js +0 -40175
  99. package/dist/chunk-7fxaphbq.js +0 -116
  100. package/dist/chunk-7sgtxrsc.js +0 -1059
  101. package/dist/chunk-7wm5s02e.js +0 -216
  102. package/dist/chunk-7xdk4109.js +0 -442
  103. package/dist/chunk-7xyswgjh.js +0 -8
  104. package/dist/chunk-83hfzbx3.js +0 -10
  105. package/dist/chunk-87m69h0v.js +0 -219
  106. package/dist/chunk-8g5pe1gr.js +0 -37
  107. package/dist/chunk-8jbw0fnf.js +0 -167
  108. package/dist/chunk-8jf9se66.js +0 -321
  109. package/dist/chunk-8p65embj.js +0 -875
  110. package/dist/chunk-8qrmaff1.js +0 -2669
  111. package/dist/chunk-8r975mwc.js +0 -93
  112. package/dist/chunk-8yhf030a.js +0 -69
  113. package/dist/chunk-93emz367.js +0 -107
  114. package/dist/chunk-948mn975.js +0 -460
  115. package/dist/chunk-99chkt7r.js +0 -54
  116. package/dist/chunk-9f7c1hzz.js +0 -50
  117. package/dist/chunk-9fk9ps1g.js +0 -178
  118. package/dist/chunk-9rh0k0aq.js +0 -90
  119. package/dist/chunk-9x5zgy22.js +0 -12
  120. package/dist/chunk-a0k2vj5b.js +0 -460
  121. package/dist/chunk-a0m57ssq.js +0 -325
  122. package/dist/chunk-a0nsmmz1.js +0 -133
  123. package/dist/chunk-a25jh1v4.js +0 -105
  124. package/dist/chunk-a4j5ekv0.js +0 -83
  125. package/dist/chunk-a8k3zf58.js +0 -313
  126. package/dist/chunk-ah0zarbq.js +0 -260
  127. package/dist/chunk-ase86y73.js +0 -15
  128. package/dist/chunk-b0kf00ff.js +0 -637
  129. package/dist/chunk-b1kcd3ss.js +0 -27
  130. package/dist/chunk-b8kcqqds.js +0 -93
  131. package/dist/chunk-bg4x9ex0.js +0 -21
  132. package/dist/chunk-bh5zqvyc.js +0 -36
  133. package/dist/chunk-bqrkfekw.js +0 -267
  134. package/dist/chunk-brjd9zmk.js +0 -42
  135. package/dist/chunk-byfawrfx.js +0 -121
  136. package/dist/chunk-c6sjhj89.js +0 -1284
  137. package/dist/chunk-c7e5yv0q.js +0 -212
  138. package/dist/chunk-c7jwbe76.js +0 -29030
  139. package/dist/chunk-cb5v8w7k.js +0 -289
  140. package/dist/chunk-cdef9v7b.js +0 -27
  141. package/dist/chunk-cdz5yb0r.js +0 -57
  142. package/dist/chunk-cgfdkzhb.js +0 -12
  143. package/dist/chunk-cgqw4x5z.js +0 -155
  144. package/dist/chunk-cnsj3vq2.js +0 -35
  145. package/dist/chunk-cqxm7ggc.js +0 -123
  146. package/dist/chunk-cxrktb5g.js +0 -51
  147. package/dist/chunk-d089t7dk.js +0 -312
  148. package/dist/chunk-d1z934cp.js +0 -71
  149. package/dist/chunk-d4mdda98.js +0 -94
  150. package/dist/chunk-d7xw8v91.js +0 -332
  151. package/dist/chunk-dc06c3rw.js +0 -1154
  152. package/dist/chunk-ddsjkqs4.js +0 -39
  153. package/dist/chunk-dfzkwynj.js +0 -5368
  154. package/dist/chunk-dnmp7s85.js +0 -20
  155. package/dist/chunk-dqqwjkv3.js +0 -8583
  156. package/dist/chunk-dt2mr4vf.js +0 -2962
  157. package/dist/chunk-dztm97gg.js +0 -150
  158. package/dist/chunk-e0abab5b.js +0 -445
  159. package/dist/chunk-e0ragz46.js +0 -209386
  160. package/dist/chunk-e9w9zc0g.js +0 -392
  161. package/dist/chunk-ebwskmsr.js +0 -107
  162. package/dist/chunk-efztk52j.js +0 -114
  163. package/dist/chunk-ehd8wacx.js +0 -40
  164. package/dist/chunk-ehtwnxpg.js +0 -1591
  165. package/dist/chunk-eqp1rfft.js +0 -17
  166. package/dist/chunk-etdt1xz3.js +0 -19
  167. package/dist/chunk-eva785x8.js +0 -88
  168. package/dist/chunk-ewadzrm8.js +0 -103
  169. package/dist/chunk-f2ajmcav.js +0 -92
  170. package/dist/chunk-fajg8x36.js +0 -8158
  171. package/dist/chunk-fbv4apne.js +0 -51
  172. package/dist/chunk-fcynwjpm.js +0 -1072
  173. package/dist/chunk-fev86f95.js +0 -1052
  174. package/dist/chunk-feyzykye.js +0 -10
  175. package/dist/chunk-ff85rwvc.js +0 -180
  176. package/dist/chunk-fk6ktvg2.js +0 -275
  177. package/dist/chunk-fqak69ft.js +0 -458
  178. package/dist/chunk-fqwas4jk.js +0 -281
  179. package/dist/chunk-fs35fdpj.js +0 -439
  180. package/dist/chunk-fvr3f9s3.js +0 -55
  181. package/dist/chunk-fyc5fepv.js +0 -10
  182. package/dist/chunk-g2g9cwt9.js +0 -54
  183. package/dist/chunk-g4znz46v.js +0 -2335
  184. package/dist/chunk-g5ts4e6k.js +0 -697
  185. package/dist/chunk-g6een9wr.js +0 -654
  186. package/dist/chunk-g7cmtx8r.js +0 -77
  187. package/dist/chunk-g9f19ttm.js +0 -15
  188. package/dist/chunk-gc7ap41t.js +0 -516
  189. package/dist/chunk-gdwdqewd.js +0 -19
  190. package/dist/chunk-gg14h3n4.js +0 -131
  191. package/dist/chunk-gg55fns0.js +0 -6440
  192. package/dist/chunk-gq7zab4e.js +0 -418
  193. package/dist/chunk-gydw3qy3.js +0 -169
  194. package/dist/chunk-gz1e8y1w.js +0 -33
  195. package/dist/chunk-h19r628d.js +0 -91
  196. package/dist/chunk-h2k8mt3z.js +0 -329
  197. package/dist/chunk-h9n54swm.js +0 -27
  198. package/dist/chunk-hakdhagh.js +0 -16606
  199. package/dist/chunk-hc2chp3g.js +0 -308
  200. package/dist/chunk-hemcv9t7.js +0 -153
  201. package/dist/chunk-hm62ntv3.js +0 -20
  202. package/dist/chunk-hmq09ytj.js +0 -100
  203. package/dist/chunk-hmv4hhqt.js +0 -2718
  204. package/dist/chunk-hwfknpxv.js +0 -39
  205. package/dist/chunk-j5bth84e.js +0 -97
  206. package/dist/chunk-j64ga6ta.js +0 -8035
  207. package/dist/chunk-j6v3w4yf.js +0 -244
  208. package/dist/chunk-jc29d2nm.js +0 -130
  209. package/dist/chunk-jd32zbps.js +0 -15
  210. package/dist/chunk-jd4sx4wh.js +0 -594
  211. package/dist/chunk-jha8n8b9.js +0 -33118
  212. package/dist/chunk-jj71qx7m.js +0 -122
  213. package/dist/chunk-jka9vpak.js +0 -114
  214. package/dist/chunk-jkf6ayv0.js +0 -32
  215. package/dist/chunk-jpz6t2tt.js +0 -61
  216. package/dist/chunk-jqt3sw12.js +0 -9114
  217. package/dist/chunk-jswd1q63.js +0 -101
  218. package/dist/chunk-jtc4aa2y.js +0 -1543
  219. package/dist/chunk-jyx3h86z.js +0 -635
  220. package/dist/chunk-jzthz1bx.js +0 -15
  221. package/dist/chunk-k0p9w03v.js +0 -4957
  222. package/dist/chunk-k6x3s7x5.js +0 -211
  223. package/dist/chunk-k7kmvnnx.js +0 -942
  224. package/dist/chunk-k8vp0atq.js +0 -2331
  225. package/dist/chunk-k9vm6x6z.js +0 -257
  226. package/dist/chunk-kb1edvhs.js +0 -120
  227. package/dist/chunk-kbhbe33q.js +0 -113
  228. package/dist/chunk-kgcgpp7z.js +0 -140
  229. package/dist/chunk-kvywbvqs.js +0 -261
  230. package/dist/chunk-kwekc97v.js +0 -18
  231. package/dist/chunk-kwyk9zp1.js +0 -74
  232. package/dist/chunk-ky1z78ve.js +0 -119
  233. package/dist/chunk-mcws22k3.js +0 -42
  234. package/dist/chunk-mr2z79r3.js +0 -1385
  235. package/dist/chunk-mst9nmns.js +0 -642
  236. package/dist/chunk-mswx2nma.js +0 -103
  237. package/dist/chunk-n1e3fjpz.js +0 -266
  238. package/dist/chunk-n6vjp9yg.js +0 -138
  239. package/dist/chunk-n84tqtvv.js +0 -120
  240. package/dist/chunk-n8ssddbw.js +0 -105
  241. package/dist/chunk-na35whkd.js +0 -227
  242. package/dist/chunk-netzwgv1.js +0 -154
  243. package/dist/chunk-ng7j0yy1.js +0 -100
  244. package/dist/chunk-nmgj86tt.js +0 -24
  245. package/dist/chunk-ns7x6xam.js +0 -22820
  246. package/dist/chunk-p7vkh4wx.js +0 -15
  247. package/dist/chunk-p8na2wwp.js +0 -14
  248. package/dist/chunk-pe3rkfp2.js +0 -74
  249. package/dist/chunk-pf0152j3.js +0 -40
  250. package/dist/chunk-pgtnj1mt.js +0 -705
  251. package/dist/chunk-ppwjyveh.js +0 -8
  252. package/dist/chunk-pq5qp2y4.js +0 -388
  253. package/dist/chunk-pqqxdk5f.js +0 -543
  254. package/dist/chunk-ps49ymvj.js +0 -43
  255. package/dist/chunk-pws8gq7m.js +0 -7422
  256. package/dist/chunk-pwwa7s62.js +0 -11
  257. package/dist/chunk-pyq0fabn.js +0 -860
  258. package/dist/chunk-q0p1m40t.js +0 -79
  259. package/dist/chunk-q0vhv550.js +0 -393
  260. package/dist/chunk-q7r0kt08.js +0 -1809
  261. package/dist/chunk-qajrkk97.js +0 -298
  262. package/dist/chunk-qatfdxvd.js +0 -34
  263. package/dist/chunk-qb6k2afy.js +0 -153
  264. package/dist/chunk-qg2qgx8h.js +0 -266
  265. package/dist/chunk-qkczt8cr.js +0 -24
  266. package/dist/chunk-qnfx3qtx.js +0 -617
  267. package/dist/chunk-qp2qdcda.js +0 -100
  268. package/dist/chunk-qtwgzej9.js +0 -85
  269. package/dist/chunk-r1dh0ymt.js +0 -91
  270. package/dist/chunk-r36xvgvv.js +0 -407
  271. package/dist/chunk-r48he8g3.js +0 -251
  272. package/dist/chunk-r63tqmtk.js +0 -146
  273. package/dist/chunk-rbdd3q5k.js +0 -101
  274. package/dist/chunk-rmbbmd3s.js +0 -68
  275. package/dist/chunk-rn0v1hk8.js +0 -34
  276. package/dist/chunk-rnxctq9p.js +0 -1646
  277. package/dist/chunk-rrs2mchs.js +0 -183
  278. package/dist/chunk-rtrybvnp.js +0 -209
  279. package/dist/chunk-rw2wkn45.js +0 -494
  280. package/dist/chunk-s4kzkdhd.js +0 -847
  281. package/dist/chunk-s7a0zn7b.js +0 -55
  282. package/dist/chunk-s8gy4ky9.js +0 -122
  283. package/dist/chunk-s8kj6ajy.js +0 -32
  284. package/dist/chunk-sag785ad.js +0 -283
  285. package/dist/chunk-scqjyben.js +0 -174
  286. package/dist/chunk-sd36yzx8.js +0 -954
  287. package/dist/chunk-sdtqm0nm.js +0 -374
  288. package/dist/chunk-sg60xg0x.js +0 -52
  289. package/dist/chunk-sgpmpn90.js +0 -35
  290. package/dist/chunk-sh02d2qn.js +0 -38
  291. package/dist/chunk-sz9y6z13.js +0 -61
  292. package/dist/chunk-szj5wvdy.js +0 -28
  293. package/dist/chunk-t29a6zb5.js +0 -45
  294. package/dist/chunk-t2b49hcf.js +0 -87
  295. package/dist/chunk-t2wqdppz.js +0 -445
  296. package/dist/chunk-t4khqff1.js +0 -16
  297. package/dist/chunk-t70t2gne.js +0 -121
  298. package/dist/chunk-t9p85zff.js +0 -24
  299. package/dist/chunk-tkrstmwz.js +0 -94
  300. package/dist/chunk-tnyb4exc.js +0 -74
  301. package/dist/chunk-tpn8jsvw.js +0 -71
  302. package/dist/chunk-tt7x5j1q.js +0 -111
  303. package/dist/chunk-tw1p628z.js +0 -984
  304. package/dist/chunk-twvdafcz.js +0 -528
  305. package/dist/chunk-tzwjafgn.js +0 -24
  306. package/dist/chunk-v140t8ay.js +0 -152
  307. package/dist/chunk-v1kzp02e.js +0 -785
  308. package/dist/chunk-v4t6dyyh.js +0 -9076
  309. package/dist/chunk-v78fj8by.js +0 -145
  310. package/dist/chunk-v8kjswxt.js +0 -61
  311. package/dist/chunk-v9smspw2.js +0 -4301
  312. package/dist/chunk-vcfbjkk9.js +0 -201
  313. package/dist/chunk-ve167rcs.js +0 -148
  314. package/dist/chunk-vf612n57.js +0 -472
  315. package/dist/chunk-vhffyae8.js +0 -895
  316. package/dist/chunk-vkhrrvfq.js +0 -44
  317. package/dist/chunk-vybkmfhf.js +0 -91
  318. package/dist/chunk-vyjeh50y.js +0 -2149
  319. package/dist/chunk-w6m6trzq.js +0 -58
  320. package/dist/chunk-w9b6kngq.js +0 -234
  321. package/dist/chunk-wa8yn2p0.js +0 -2007
  322. package/dist/chunk-wanceff6.js +0 -2840
  323. package/dist/chunk-wcze2nea.js +0 -336
  324. package/dist/chunk-wgk9sxk7.js +0 -329
  325. package/dist/chunk-wnxcgfsd.js +0 -253
  326. package/dist/chunk-wyjerrr6.js +0 -565
  327. package/dist/chunk-wz9brkq5.js +0 -60
  328. package/dist/chunk-x47h283a.js +0 -56
  329. package/dist/chunk-x59j3x9c.js +0 -98
  330. package/dist/chunk-x6r4v44b.js +0 -8
  331. package/dist/chunk-x7fdwq3d.js +0 -33
  332. package/dist/chunk-x8d2ehd7.js +0 -19
  333. package/dist/chunk-xeb6075z.js +0 -3435
  334. package/dist/chunk-xfw2pxwd.js +0 -223
  335. package/dist/chunk-xh06jc72.js +0 -200
  336. package/dist/chunk-xhfmdq1y.js +0 -147
  337. package/dist/chunk-xkwyg1d2.js +0 -195
  338. package/dist/chunk-xv3era3s.js +0 -8
  339. package/dist/chunk-xyapc58m.js +0 -87
  340. package/dist/chunk-xzgnc76g.js +0 -107
  341. package/dist/chunk-y1784krc.js +0 -19
  342. package/dist/chunk-y4ca9kqz.js +0 -3830
  343. package/dist/chunk-y9bhjjdz.js +0 -145
  344. package/dist/chunk-yb3bxv3w.js +0 -30
  345. package/dist/chunk-yddek6xk.js +0 -146
  346. package/dist/chunk-ypaq3d12.js +0 -4265
  347. package/dist/chunk-yq8z040g.js +0 -111
  348. package/dist/chunk-yqs481qq.js +0 -1163
  349. package/dist/chunk-ys9a9c9h.js +0 -105
  350. package/dist/chunk-yyex5gsf.js +0 -269
  351. package/dist/chunk-yzn396hn.js +0 -89
  352. package/dist/chunk-z2dp53wn.js +0 -17
  353. package/dist/chunk-zay4xp4n.js +0 -251
  354. package/dist/chunk-zc8bwy57.js +0 -212
  355. package/dist/chunk-zhx88cfx.js +0 -97
  356. package/dist/chunk-zkh6f4ct.js +0 -385
  357. package/dist/chunk-zq56gcca.js +0 -206
  358. package/dist/chunk-zrkefd22.js +0 -490
  359. package/dist/chunk-zs5p0yq1.js +0 -1030
  360. package/dist/chunk-zxh62ved.js +0 -31
  361. package/dist/chunk-zzm33q8x.js +0 -8
  362. package/dist/cli.js +0 -220
@@ -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-e0ragz46.js";
13
- import {
14
- PluginHooksSchema,
15
- PluginManifestSchema,
16
- PluginMarketplaceEntrySchema,
17
- PluginMarketplaceSchema,
18
- init_schemas
19
- } from "./chunk-2b0e32an.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 };