@namzu/cli 59.0.0 → 60.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (595) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +1 -1
  3. package/dist/bin.js +1 -1
  4. package/dist/chunks/{acp-AQUZCZSO.js → acp-6R4I2A3Q.js} +2063 -248
  5. package/dist/chunks/acp-6R4I2A3Q.js.map +6 -0
  6. package/dist/chunks/{activity-command-Y3A6GIFW.js → activity-command-JU4HLIQJ.js} +14 -14
  7. package/dist/chunks/{add-DWFKSOYI.js → add-S6JYKDI4.js} +24 -24
  8. package/dist/chunks/{agent-Z6PJYBAO.js → agent-E343AQV7.js} +53 -50
  9. package/dist/chunks/agent-session-D6JIOCON.js +95 -0
  10. package/dist/chunks/{apply-at-exit-SHGR2BAB.js → apply-at-exit-MEOJMGNT.js} +7 -7
  11. package/dist/chunks/{archive-KYXU4AZZ.js → archive-ZPWC7GZU.js} +13 -13
  12. package/dist/chunks/{auth-R3RCZZ7U.js → auth-6NX4TMIG.js} +12 -12
  13. package/dist/chunks/{bin-main-DUZFYUCJ.js → bin-main-P3KAQDKC.js} +8 -8
  14. package/dist/chunks/{binding-5UJYMFMU.js → binding-6QZVGFQ5.js} +3 -3
  15. package/dist/chunks/{browser-7CFZ6BZS.js → browser-KK2U5524.js} +7 -7
  16. package/dist/chunks/{chat-BELD32ZP.js → chat-VEXJRSZN.js} +17 -17
  17. package/dist/chunks/{chunk-OSC47PCX.js → chunk-2DCOB33W.js} +13 -7
  18. package/dist/chunks/{chunk-OSC47PCX.js.map → chunk-2DCOB33W.js.map} +1 -1
  19. package/dist/chunks/{chunk-MDBUSIPW.js → chunk-2KVQVPJ7.js} +5 -5
  20. package/dist/chunks/chunk-32OIBGYI.js +188 -0
  21. package/dist/chunks/chunk-32OIBGYI.js.map +6 -0
  22. package/dist/chunks/{chunk-MRZHTIE7.js → chunk-42JIZXVL.js} +4 -4
  23. package/dist/chunks/{chunk-ESIICAI3.js → chunk-4473VICE.js} +3 -3
  24. package/dist/chunks/{chunk-DGYMR4WJ.js → chunk-44YG6EI4.js} +4 -4
  25. package/dist/chunks/{chunk-ZQGCZYAE.js → chunk-452SL2Y4.js} +2 -2
  26. package/dist/chunks/{chunk-VE4XIWDW.js → chunk-4BNCVR3U.js} +2 -2
  27. package/dist/chunks/{chunk-2EVP6BX4.js → chunk-4CJ3HPOT.js} +2 -2
  28. package/dist/chunks/{chunk-4BAXYUZQ.js → chunk-4DSUVT37.js} +13 -10
  29. package/dist/chunks/chunk-4DSUVT37.js.map +6 -0
  30. package/dist/chunks/{chunk-TORIEDBN.js → chunk-4ENL4VUO.js} +4 -4
  31. package/dist/chunks/{chunk-IJ6Z6FNY.js → chunk-4KVYTHY7.js} +3 -3
  32. package/dist/chunks/{chunk-YNWPC3HO.js → chunk-4Y242BU4.js} +5 -5
  33. package/dist/chunks/{chunk-OA7QKUCM.js → chunk-5F4DSPZC.js} +10 -10
  34. package/dist/chunks/{chunk-DRWJTADQ.js → chunk-5IGEQN7L.js} +4 -4
  35. package/dist/chunks/{chunk-W752G3FM.js → chunk-5ZLKTFU2.js} +3 -3
  36. package/dist/chunks/{chunk-KETRBV2E.js → chunk-66QIFMEO.js} +2 -2
  37. package/dist/chunks/{chunk-4TIUY3Q6.js → chunk-6HYK4DDB.js} +36 -14
  38. package/dist/chunks/{chunk-4TIUY3Q6.js.map → chunk-6HYK4DDB.js.map} +1 -1
  39. package/dist/chunks/{chunk-AEXGGJUW.js → chunk-6TUHWKXP.js} +15 -6
  40. package/dist/chunks/chunk-6TUHWKXP.js.map +6 -0
  41. package/dist/chunks/{chunk-CEZW3NVM.js → chunk-6W3UGXGG.js} +4 -4
  42. package/dist/chunks/{chunk-S7FE35WQ.js → chunk-75YLZNZW.js} +3 -3
  43. package/dist/chunks/{chunk-P4TCLMD6.js → chunk-AC5P6W3G.js} +2 -2
  44. package/dist/chunks/chunk-AMYP2WPW.js +1055 -0
  45. package/dist/chunks/chunk-AMYP2WPW.js.map +6 -0
  46. package/dist/chunks/{chunk-GUK47JTV.js → chunk-AYMB4AOZ.js} +4 -4
  47. package/dist/chunks/{chunk-23D5IXMW.js → chunk-B4AOCHH6.js} +3 -3
  48. package/dist/chunks/{chunk-FEOS7UZ2.js → chunk-BA7KUG6V.js} +2 -2
  49. package/dist/chunks/{chunk-D35UCVTK.js → chunk-BHQHTM3Z.js} +5 -5
  50. package/dist/chunks/chunk-BJT37HR4.js +3644 -0
  51. package/dist/chunks/chunk-BJT37HR4.js.map +6 -0
  52. package/dist/chunks/{chunk-KPOOM7QT.js → chunk-BNLIRJ3M.js} +4 -4
  53. package/dist/chunks/{chunk-MDVYEFTI.js → chunk-BURGRQWO.js} +2 -2
  54. package/dist/chunks/{chunk-DKSFQRUM.js → chunk-BWD2TUI4.js} +5 -5
  55. package/dist/chunks/{chunk-HGTOAMV6.js → chunk-BZR5PIFF.js} +2098 -812
  56. package/dist/chunks/chunk-BZR5PIFF.js.map +6 -0
  57. package/dist/chunks/{chunk-7Y4RR47U.js → chunk-C7E7YCRD.js} +5 -5
  58. package/dist/chunks/{chunk-44MFZJ24.js → chunk-CXW7I2S3.js} +2 -2
  59. package/dist/chunks/{chunk-3ETXWTV4.js → chunk-D2R47LDH.js} +121 -8
  60. package/dist/chunks/chunk-D2R47LDH.js.map +6 -0
  61. package/dist/chunks/chunk-D4TXOX34.js +342 -0
  62. package/dist/chunks/chunk-D4TXOX34.js.map +6 -0
  63. package/dist/chunks/{chunk-73HWWJYC.js → chunk-D6PB3Z7Q.js} +2 -2
  64. package/dist/chunks/{chunk-QTHG6UPU.js → chunk-DEAG4G5J.js} +2 -2
  65. package/dist/chunks/{chunk-WGC5DJEW.js → chunk-DRSQTKDN.js} +3 -3
  66. package/dist/chunks/chunk-EBBT2I5S.js +153 -0
  67. package/dist/chunks/chunk-EBBT2I5S.js.map +6 -0
  68. package/dist/chunks/{chunk-FK5C7SHM.js → chunk-EWPGU4HH.js} +10 -441
  69. package/dist/chunks/chunk-EWPGU4HH.js.map +6 -0
  70. package/dist/chunks/{chunk-WXYRLTRY.js → chunk-EXJJLYZK.js} +3 -3
  71. package/dist/chunks/{chunk-PFVYYH6O.js → chunk-F5W4TNCR.js} +2 -2
  72. package/dist/chunks/{chunk-Q6PZODSV.js → chunk-F7KOBJVW.js} +4 -4
  73. package/dist/chunks/{chunk-VSNV3U2B.js → chunk-FK4MAZV2.js} +5 -5
  74. package/dist/chunks/{chunk-ATCVFWXD.js → chunk-FMD4REZQ.js} +41 -41
  75. package/dist/chunks/{chunk-ATCVFWXD.js.map → chunk-FMD4REZQ.js.map} +1 -1
  76. package/dist/chunks/{chunk-G5LPTLLY.js → chunk-FPC3K4TT.js} +3 -3
  77. package/dist/chunks/{chunk-XLXPPVUT.js → chunk-FVIKYFYD.js} +2 -2
  78. package/dist/chunks/{chunk-PQT7624W.js → chunk-GPTYDM26.js} +8 -8
  79. package/dist/chunks/{chunk-TP7DRQXE.js → chunk-GT22EDUB.js} +6 -6
  80. package/dist/chunks/{chunk-GEVWZWLM.js → chunk-GTUTBTOV.js} +3 -3
  81. package/dist/chunks/{chunk-GQ6WXY3M.js → chunk-H6NTNPWD.js} +4 -4
  82. package/dist/chunks/{chunk-TYNAB5GR.js → chunk-HCQGZPVT.js} +2 -2
  83. package/dist/chunks/{chunk-LB4HC5U7.js → chunk-HG2PPCAE.js} +3 -3
  84. package/dist/chunks/{chunk-ABKURT35.js → chunk-HKRUNZVI.js} +3 -3
  85. package/dist/chunks/{chunk-JPM3JXZB.js → chunk-HM7L5PM2.js} +3 -3
  86. package/dist/chunks/{chunk-UFGLSUGU.js → chunk-I4RC6KQQ.js} +19 -19
  87. package/dist/chunks/{chunk-HW2QBNAA.js → chunk-IL4Y3JGT.js} +13 -13
  88. package/dist/chunks/{chunk-D3SCA6NT.js → chunk-IMMUS7IW.js} +278 -7
  89. package/dist/chunks/chunk-IMMUS7IW.js.map +6 -0
  90. package/dist/chunks/{chunk-D6XZ4ZAV.js → chunk-IQ44C7Y3.js} +33 -9
  91. package/dist/chunks/chunk-IQ44C7Y3.js.map +6 -0
  92. package/dist/chunks/{chunk-24EZWZDZ.js → chunk-J4PL65DJ.js} +6 -6
  93. package/dist/chunks/chunk-JANK2R3L.js +402 -0
  94. package/dist/chunks/chunk-JANK2R3L.js.map +6 -0
  95. package/dist/chunks/{chunk-E65IWYTT.js → chunk-JECLB23L.js} +6 -6
  96. package/dist/chunks/{chunk-3RLKUXXG.js → chunk-JJ72TLOA.js} +15 -15
  97. package/dist/chunks/{chunk-CG5CGXNF.js → chunk-JRBFL6WT.js} +2 -2
  98. package/dist/chunks/{chunk-KBLYZ7L7.js → chunk-K2EKXCLZ.js} +3 -3
  99. package/dist/chunks/{chunk-567CSU37.js → chunk-K7YZJV2X.js} +248 -24
  100. package/dist/chunks/chunk-K7YZJV2X.js.map +6 -0
  101. package/dist/chunks/chunk-KF6IKSF2.js +472 -0
  102. package/dist/chunks/chunk-KF6IKSF2.js.map +6 -0
  103. package/dist/chunks/{chunk-OQWLQUO7.js → chunk-KSRN5Y2O.js} +196 -59
  104. package/dist/chunks/chunk-KSRN5Y2O.js.map +6 -0
  105. package/dist/chunks/{chunk-WW3AU2YN.js → chunk-ME4LETA3.js} +2 -2
  106. package/dist/chunks/{chunk-J5E4DV6R.js → chunk-MF3SFDBW.js} +3 -3
  107. package/dist/chunks/{chunk-WSDZIJNK.js → chunk-MK42KB72.js} +4 -4
  108. package/dist/chunks/{chunk-RZKIZTPA.js → chunk-MUSGZEFY.js} +2 -2
  109. package/dist/chunks/{chunk-MF5KTVGJ.js → chunk-N5CCXOYK.js} +7 -7
  110. package/dist/chunks/{chunk-KVNL7XA6.js → chunk-NBJ5PRAY.js} +3 -3
  111. package/dist/chunks/{chunk-E4RVHFV6.js → chunk-NKHEBASJ.js} +2 -2
  112. package/dist/chunks/{chunk-SS6IJAPA.js → chunk-NVWD5XDT.js} +2 -2
  113. package/dist/chunks/{chunk-7LDUPEXP.js → chunk-O45DCUNX.js} +2 -2
  114. package/dist/chunks/{chunk-KHGY6QJR.js → chunk-O4EILTV6.js} +145 -20
  115. package/dist/chunks/chunk-O4EILTV6.js.map +6 -0
  116. package/dist/chunks/{chunk-G76POTWW.js → chunk-PAUMCJPX.js} +3 -3
  117. package/dist/chunks/{chunk-MF57EX7H.js → chunk-PE4MWWUW.js} +3 -3
  118. package/dist/chunks/{chunk-4RW7GDJ4.js → chunk-PLCWCIL4.js} +2 -2
  119. package/dist/chunks/{chunk-XVOPQCPD.js → chunk-PRJO4XM3.js} +2 -2
  120. package/dist/chunks/{chunk-CQFWLYTK.js → chunk-PRRX5LNR.js} +2 -2
  121. package/dist/chunks/{chunk-3PH6F6Z3.js → chunk-PS5SVAUJ.js} +2 -2
  122. package/dist/chunks/chunk-PZLPACNY.js +407 -0
  123. package/dist/chunks/chunk-PZLPACNY.js.map +6 -0
  124. package/dist/chunks/{chunk-P725GKKG.js → chunk-PZWSRAE7.js} +6 -6
  125. package/dist/chunks/{chunk-6IOZY2AB.js → chunk-QBLHOG2F.js} +36 -14
  126. package/dist/chunks/chunk-QBLHOG2F.js.map +6 -0
  127. package/dist/chunks/{chunk-CNSKJ3DZ.js → chunk-QCV3HH4P.js} +2 -2
  128. package/dist/chunks/{chunk-7J23SPSX.js → chunk-QGBR42TV.js} +8 -7
  129. package/dist/chunks/{chunk-6CSJRIUZ.js → chunk-QNJXULU7.js} +2 -2
  130. package/dist/chunks/{chunk-5JVKE4LB.js → chunk-QQ4S6MNH.js} +13638 -4103
  131. package/dist/chunks/chunk-QQ4S6MNH.js.map +6 -0
  132. package/dist/chunks/{chunk-DJKWBSVM.js → chunk-R2KAESOM.js} +2 -2
  133. package/dist/chunks/{chunk-AIQKSTVJ.js → chunk-R6M6EIAH.js} +4 -4
  134. package/dist/chunks/{chunk-VJHENTNB.js → chunk-RKKU2RE4.js} +2 -2
  135. package/dist/chunks/{chunk-JZTTOZRG.js → chunk-RMOTHWPV.js} +2 -2
  136. package/dist/chunks/{chunk-EA6YICQ7.js → chunk-RQAY7REG.js} +3 -3
  137. package/dist/chunks/{chunk-LWJJDERP.js → chunk-SLTJNYOU.js} +2 -2
  138. package/dist/chunks/{chunk-UL6MZ5OM.js → chunk-SXONHO4H.js} +9 -9
  139. package/dist/chunks/{chunk-W4S4ZBXX.js → chunk-T7ILM666.js} +11 -11
  140. package/dist/chunks/{chunk-E6FMAE5Q.js → chunk-TBGKPWCL.js} +9 -9
  141. package/dist/chunks/{chunk-ACO3LTRT.js → chunk-TBJ6XU3T.js} +3 -3
  142. package/dist/chunks/{chunk-5HMJ3DYR.js → chunk-TMPP2DEY.js} +4 -4
  143. package/dist/chunks/{chunk-6YXHH5JW.js → chunk-TSOZBRM6.js} +2 -2
  144. package/dist/chunks/{chunk-SSPHAILP.js → chunk-TTFPWGIU.js} +2 -2
  145. package/dist/chunks/{chunk-TRRKG642.js → chunk-TTKMQW6B.js} +3 -3
  146. package/dist/chunks/{chunk-2VP2Q657.js → chunk-UCML5ZXB.js} +3 -3
  147. package/dist/chunks/{chunk-OH7EYW3T.js → chunk-VG7245VJ.js} +6 -6
  148. package/dist/chunks/{chunk-QZTTIL3A.js → chunk-VQZPXK4X.js} +3 -3
  149. package/dist/chunks/{chunk-O2PZDA5H.js → chunk-VWUTJ4EU.js} +3 -3
  150. package/dist/chunks/{chunk-VL6Z2OMG.js → chunk-WDKAL7EW.js} +2 -2
  151. package/dist/chunks/{chunk-2KC52MDS.js → chunk-WJ6QRVL6.js} +2 -2
  152. package/dist/chunks/{chunk-XJALHM5Z.js → chunk-WOTA5FO5.js} +3 -3
  153. package/dist/chunks/{chunk-4TJ7AGQO.js → chunk-WPGVZMSU.js} +2 -2
  154. package/dist/chunks/{chunk-IRAG3YXW.js → chunk-WYA4QWWE.js} +181 -7
  155. package/dist/chunks/chunk-WYA4QWWE.js.map +6 -0
  156. package/dist/chunks/{chunk-DJTCZSSY.js → chunk-XDUA6PBP.js} +2 -2
  157. package/dist/chunks/{chunk-PKFXIWVX.js → chunk-XE6XT6R6.js} +4 -4
  158. package/dist/chunks/{chunk-JUDJGDYX.js → chunk-XNQY26AE.js} +31 -131
  159. package/dist/chunks/chunk-XNQY26AE.js.map +6 -0
  160. package/dist/chunks/{chunk-FRGOWO6N.js → chunk-YR3TWNIV.js} +13 -12
  161. package/dist/chunks/chunk-YR3TWNIV.js.map +6 -0
  162. package/dist/chunks/{chunk-LXJW3ZYI.js → chunk-YWRRS7SO.js} +2 -2
  163. package/dist/chunks/{chunk-OOJP5BEK.js → chunk-Z5OG4HXI.js} +51 -25
  164. package/dist/chunks/chunk-Z5OG4HXI.js.map +6 -0
  165. package/dist/chunks/{chunk-JRWUIW4J.js → chunk-ZHEEG3NS.js} +2 -2
  166. package/dist/chunks/{cli-runtime-P6LCHPBA.js → cli-runtime-ZJKKIW4H.js} +22 -22
  167. package/dist/chunks/{commands-BNHIQVYO.js → commands-TQH5DD22.js} +6 -6
  168. package/dist/chunks/{computer-6P3GAOV2.js → computer-WOU5WIIR.js} +2 -2
  169. package/dist/chunks/{config-ZMXMX2WY.js → config-APYUJ5UW.js} +13 -13
  170. package/dist/chunks/{cost-BJKADKEZ.js → cost-5YV27U7F.js} +5 -5
  171. package/dist/chunks/{crash-report-OJHGVRD7.js → crash-report-QVXU2YVL.js} +6 -6
  172. package/dist/chunks/{dist-PMSBTFU5.js → dist-2FSOLP72.js} +2 -2
  173. package/dist/chunks/{dist-43XWK3LF.js → dist-AOT4CEP5.js} +2 -2
  174. package/dist/chunks/{dist-4ZPDHZOX.js → dist-H7CAJ3ZW.js} +48 -2
  175. package/dist/chunks/{dist-NCBDELMI.js → dist-IZGKRIWL.js} +2 -2
  176. package/dist/chunks/{dist-BGJEX527.js → dist-J4UXFVYR.js} +2 -2
  177. package/dist/chunks/{dist-FMFNU4M3.js → dist-JHKRSGW6.js} +2 -2
  178. package/dist/chunks/{dist-4LEGETQA.js → dist-PZYMYR7N.js} +3 -3
  179. package/dist/chunks/{dist-ADQAO5C3.js → dist-Z2HW2SJR.js} +2 -2
  180. package/dist/chunks/{doctor-AIYB27QY.js → doctor-CM6UPXG5.js} +40 -38
  181. package/dist/chunks/{drain-PYKX4QNR.js → drain-X6RURKKC.js} +17 -17
  182. package/dist/chunks/{entry-HM5E7KCD.js → entry-QQDPY6ZL.js} +6 -6
  183. package/dist/chunks/{eval-H4NKZYVV.js → eval-GZA22B4I.js} +9 -9
  184. package/dist/chunks/{exec-2PRVZNUX.js → exec-3NE75Z6E.js} +46 -45
  185. package/dist/chunks/exec-3NE75Z6E.js.map +6 -0
  186. package/dist/chunks/{extension-4233XOZW.js → extension-N5IQNKVZ.js} +6 -5
  187. package/dist/chunks/{github-IF3JVVJF.js → github-AUOENJUY.js} +2 -2
  188. package/dist/chunks/{home-AZY7APF6.js → home-I4FIB6FV.js} +3 -3
  189. package/dist/chunks/{homes-WL6LAAY5.js → homes-WTMMXQ6G.js} +5 -5
  190. package/dist/chunks/{hooks-AK5S4YUS.js → hooks-R42OTZDT.js} +22 -21
  191. package/dist/chunks/hooks-R42OTZDT.js.map +6 -0
  192. package/dist/chunks/{hooks-report-NJLGBWN3.js → hooks-report-K6VOPVBR.js} +18 -17
  193. package/dist/chunks/{host-SX3QC5FN.js → host-65UFBZJV.js} +10 -10
  194. package/dist/chunks/host-queries-L4PYE2BW.js +37 -0
  195. package/dist/chunks/{installed-list-44QXUJFE.js → installed-list-7QIWVKLQ.js} +4 -4
  196. package/dist/chunks/{learn-LW4DLSGZ.js → learn-NZXLKYV4.js} +17 -17
  197. package/dist/chunks/{learn-builtin-4RV2XDH4.js → learn-builtin-RC4XXVBS.js} +20 -20
  198. package/dist/chunks/{lifecycle-AJCHTSAF.js → lifecycle-NLCZ6OPA.js} +30 -30
  199. package/dist/chunks/{list-DT7AJVPX.js → list-2U67CAWS.js} +18 -18
  200. package/dist/chunks/{live-Z6HZFXPW.js → live-CWJ2NWUQ.js} +39 -37
  201. package/dist/chunks/{load-454TJBPW.js → load-H52QQBVE.js} +13 -9
  202. package/dist/chunks/{logs-GRUSUSL7.js → logs-ZIW3QFU4.js} +4 -4
  203. package/dist/chunks/{mcp-AFLRDYNN.js → mcp-FNSMEMCM.js} +145 -35
  204. package/dist/chunks/mcp-FNSMEMCM.js.map +6 -0
  205. package/dist/chunks/{mcp-serve-NNWP4IES.js → mcp-serve-ZC2OKIPP.js} +17 -17
  206. package/dist/chunks/{message-command-ZR2JQBBU.js → message-command-IHZWL5GI.js} +59 -56
  207. package/dist/chunks/message-command-IHZWL5GI.js.map +6 -0
  208. package/dist/chunks/{open-Z3BELFL7.js → open-AHDQMVXI.js} +7 -7
  209. package/dist/chunks/{operator-tools-PN3SPQ3C.js → operator-tools-P5R4TF6N.js} +15 -15
  210. package/dist/chunks/{output-schema-DSR56W6A.js → output-schema-Q5RWHNKE.js} +3 -3
  211. package/dist/chunks/{pal-ZOH5ILEV.js → pal-T42HU4AK.js} +15 -15
  212. package/dist/chunks/{peers-LXNB4QSL.js → peers-5RYEA7IA.js} +7 -7
  213. package/dist/chunks/{peers-WINODTEB.js → peers-7ZG3DEBO.js} +19 -19
  214. package/dist/chunks/plugin-DGEINYG5.js +2958 -0
  215. package/dist/chunks/plugin-DGEINYG5.js.map +6 -0
  216. package/dist/chunks/{providers-UOTUEQOJ.js → providers-BXXIM7EW.js} +18 -18
  217. package/dist/chunks/{providers-AVECY67I.js → providers-I24HYZXG.js} +10 -10
  218. package/dist/chunks/{pty-GW2YC23H.js → pty-WVKM6ATI.js} +3 -3
  219. package/dist/chunks/resume-F7JEDBHI.js +25 -0
  220. package/dist/chunks/{resume-command-FXT3KGLC.js → resume-command-4I47WN7T.js} +4 -4
  221. package/dist/chunks/{running-3NLAODZ7.js → running-VID6BVT2.js} +4 -4
  222. package/dist/chunks/{schedule-TTQUT45H.js → schedule-75IZH76Z.js} +12 -12
  223. package/dist/chunks/{send-FRNTRW2M.js → send-QRYY2NCG.js} +19 -19
  224. package/dist/chunks/send-person-VADQNJBN.js +32 -0
  225. package/dist/chunks/{service-TCKPUGL5.js → service-B6BNESZB.js} +30 -30
  226. package/dist/chunks/{setting-cli-HGYOIGC6.js → setting-cli-O4YWOIU5.js} +12 -12
  227. package/dist/chunks/skills-PEMVX5C3.js +604 -0
  228. package/dist/chunks/skills-PEMVX5C3.js.map +6 -0
  229. package/dist/chunks/{start-check-C5VJXVPY.js → start-check-EKRXJ5VE.js} +2 -2
  230. package/dist/chunks/{startup-failure-YQSEQRNQ.js → startup-failure-2UJKPNMR.js} +2 -2
  231. package/dist/chunks/{state-2DBTSDEP.js → state-X3MKUFYM.js} +20 -20
  232. package/dist/chunks/{store-CZGKLVTT.js → store-4OXWHFS5.js} +12 -12
  233. package/dist/chunks/{store-RJZCW2MI.js → store-MK5IYBE5.js} +8 -8
  234. package/dist/chunks/{store-JJKCDY7Y.js → store-QFNY4BV4.js} +10 -4
  235. package/dist/chunks/{store-S4BT3ESJ.js → store-VRKKFOYW.js} +3 -3
  236. package/dist/chunks/{tui-Q7ED7VFI.js → tui-MI72TUST.js} +96 -92
  237. package/dist/chunks/tui-MI72TUST.js.map +6 -0
  238. package/dist/chunks/{update-G7D3YCH5.js → update-ELZEXYIX.js} +8 -8
  239. package/dist/chunks/{watch-EON3IWRY.js → watch-HPINGMZZ.js} +100 -96
  240. package/dist/chunks/watch-HPINGMZZ.js.map +6 -0
  241. package/dist/chunks/{workspaces-O6S2OTDL.js → workspaces-3LB4SPPS.js} +15 -15
  242. package/dist/chunks/{worktree-A2DNXLOT.js → worktree-5CWUUWNO.js} +26 -22
  243. package/dist/chunks/worktree-5CWUUWNO.js.map +6 -0
  244. package/dist/commands/acp.d.ts +4 -2
  245. package/dist/commands/acp.d.ts.map +1 -1
  246. package/dist/commands/actions/mcp.d.ts.map +1 -1
  247. package/dist/commands/actions/small.d.ts.map +1 -1
  248. package/dist/commands/desktop-host-plugins.d.ts +321 -0
  249. package/dist/commands/desktop-host-plugins.d.ts.map +1 -0
  250. package/dist/commands/desktop-host-skills.d.ts +103 -0
  251. package/dist/commands/desktop-host-skills.d.ts.map +1 -0
  252. package/dist/commands/desktop-host.d.ts +230 -18
  253. package/dist/commands/desktop-host.d.ts.map +1 -1
  254. package/dist/commands/manifest.d.ts.map +1 -1
  255. package/dist/commands/mcp.d.ts.map +1 -1
  256. package/dist/commands/plugin-install.d.ts +28 -0
  257. package/dist/commands/plugin-install.d.ts.map +1 -0
  258. package/dist/commands/plugin-records.d.ts +48 -0
  259. package/dist/commands/plugin-records.d.ts.map +1 -0
  260. package/dist/commands/plugin.d.ts.map +1 -1
  261. package/dist/commands/skills-manage.d.ts +32 -0
  262. package/dist/commands/skills-manage.d.ts.map +1 -0
  263. package/dist/commands/skills.d.ts.map +1 -1
  264. package/dist/config/hooks-report.d.ts.map +1 -1
  265. package/dist/config/load.d.ts +9 -0
  266. package/dist/config/load.d.ts.map +1 -1
  267. package/dist/config/schema.d.ts +19 -0
  268. package/dist/config/schema.d.ts.map +1 -1
  269. package/dist/config/settings-descriptors.d.ts.map +1 -1
  270. package/dist/index.js +40 -38
  271. package/dist/integrations/archive/zip.d.ts +36 -0
  272. package/dist/integrations/archive/zip.d.ts.map +1 -0
  273. package/dist/integrations/extensions/package.d.ts +7 -16
  274. package/dist/integrations/extensions/package.d.ts.map +1 -1
  275. package/dist/integrations/mcp/all-servers.d.ts +30 -0
  276. package/dist/integrations/mcp/all-servers.d.ts.map +1 -0
  277. package/dist/integrations/mcp/plugin-remote.d.ts +141 -0
  278. package/dist/integrations/mcp/plugin-remote.d.ts.map +1 -0
  279. package/dist/integrations/mcp/project-approval.d.ts +29 -1
  280. package/dist/integrations/mcp/project-approval.d.ts.map +1 -1
  281. package/dist/integrations/mcp/server-listing.d.ts +7 -3
  282. package/dist/integrations/mcp/server-listing.d.ts.map +1 -1
  283. package/dist/integrations/mcp/servers.d.ts +6 -0
  284. package/dist/integrations/mcp/servers.d.ts.map +1 -1
  285. package/dist/integrations/mcp/user-config.d.ts +10 -0
  286. package/dist/integrations/mcp/user-config.d.ts.map +1 -1
  287. package/dist/integrations/plugins/enabled-records.d.ts +78 -0
  288. package/dist/integrations/plugins/enabled-records.d.ts.map +1 -0
  289. package/dist/integrations/plugins/fetch/archive.d.ts +15 -0
  290. package/dist/integrations/plugins/fetch/archive.d.ts.map +1 -0
  291. package/dist/integrations/plugins/fetch/git.d.ts +145 -0
  292. package/dist/integrations/plugins/fetch/git.d.ts.map +1 -0
  293. package/dist/integrations/plugins/fetch/index.d.ts +33 -0
  294. package/dist/integrations/plugins/fetch/index.d.ts.map +1 -0
  295. package/dist/integrations/plugins/fetch/source.d.ts +107 -0
  296. package/dist/integrations/plugins/fetch/source.d.ts.map +1 -0
  297. package/dist/integrations/plugins/fetch/url.d.ts +34 -0
  298. package/dist/integrations/plugins/fetch/url.d.ts.map +1 -0
  299. package/dist/integrations/plugins/files.d.ts +15 -3
  300. package/dist/integrations/plugins/files.d.ts.map +1 -1
  301. package/dist/integrations/plugins/hook-entries.d.ts +2 -0
  302. package/dist/integrations/plugins/hook-entries.d.ts.map +1 -1
  303. package/dist/integrations/plugins/install-manifest.d.ts +70 -0
  304. package/dist/integrations/plugins/install-manifest.d.ts.map +1 -0
  305. package/dist/integrations/plugins/install-plan.d.ts +119 -0
  306. package/dist/integrations/plugins/install-plan.d.ts.map +1 -0
  307. package/dist/integrations/plugins/install-preview.d.ts +24 -0
  308. package/dist/integrations/plugins/install-preview.d.ts.map +1 -0
  309. package/dist/integrations/plugins/install.d.ts +118 -0
  310. package/dist/integrations/plugins/install.d.ts.map +1 -0
  311. package/dist/integrations/plugins/installed-source.d.ts +80 -0
  312. package/dist/integrations/plugins/installed-source.d.ts.map +1 -0
  313. package/dist/integrations/plugins/inventory.d.ts +2 -1
  314. package/dist/integrations/plugins/inventory.d.ts.map +1 -1
  315. package/dist/integrations/plugins/json-state.d.ts +52 -0
  316. package/dist/integrations/plugins/json-state.d.ts.map +1 -0
  317. package/dist/integrations/plugins/manifest-details.d.ts +23 -0
  318. package/dist/integrations/plugins/manifest-details.d.ts.map +1 -0
  319. package/dist/integrations/plugins/marketplace.d.ts +111 -0
  320. package/dist/integrations/plugins/marketplace.d.ts.map +1 -0
  321. package/dist/integrations/plugins/records.d.ts +127 -0
  322. package/dist/integrations/plugins/records.d.ts.map +1 -0
  323. package/dist/integrations/plugins/remote-marketplace.d.ts +100 -0
  324. package/dist/integrations/plugins/remote-marketplace.d.ts.map +1 -0
  325. package/dist/integrations/plugins/runtime.d.ts +28 -0
  326. package/dist/integrations/plugins/runtime.d.ts.map +1 -1
  327. package/dist/integrations/plugins/surface.d.ts +126 -0
  328. package/dist/integrations/plugins/surface.d.ts.map +1 -0
  329. package/dist/integrations/plugins/update-compare.d.ts +18 -0
  330. package/dist/integrations/plugins/update-compare.d.ts.map +1 -0
  331. package/dist/integrations/plugins/validate.d.ts +50 -1
  332. package/dist/integrations/plugins/validate.d.ts.map +1 -1
  333. package/dist/integrations/subagents/definitions.d.ts +4 -0
  334. package/dist/integrations/subagents/definitions.d.ts.map +1 -1
  335. package/dist/integrations/trust/folder-grants.d.ts +21 -1
  336. package/dist/integrations/trust/folder-grants.d.ts.map +1 -1
  337. package/dist/reminders/skills.d.ts.map +1 -1
  338. package/dist/rounds/types.d.ts +5 -0
  339. package/dist/rounds/types.d.ts.map +1 -1
  340. package/dist/skills/add.d.ts +104 -0
  341. package/dist/skills/add.d.ts.map +1 -0
  342. package/dist/skills/audit.d.ts +7 -1
  343. package/dist/skills/audit.d.ts.map +1 -1
  344. package/dist/skills/catalog.d.ts +14 -1
  345. package/dist/skills/catalog.d.ts.map +1 -1
  346. package/dist/skills/create.d.ts +19 -0
  347. package/dist/skills/create.d.ts.map +1 -0
  348. package/dist/skills/desktop-catalog.d.ts +64 -0
  349. package/dist/skills/desktop-catalog.d.ts.map +1 -0
  350. package/dist/skills/install.d.ts +73 -0
  351. package/dist/skills/install.d.ts.map +1 -0
  352. package/dist/skills/installed-list.d.ts +1 -1
  353. package/dist/skills/installed-list.d.ts.map +1 -1
  354. package/dist/skills/overrides.d.ts +56 -0
  355. package/dist/skills/overrides.d.ts.map +1 -0
  356. package/dist/skills/remove.d.ts +38 -0
  357. package/dist/skills/remove.d.ts.map +1 -0
  358. package/dist/skills/save.d.ts +4 -48
  359. package/dist/skills/save.d.ts.map +1 -1
  360. package/dist/skills/store.d.ts +20 -3
  361. package/dist/skills/store.d.ts.map +1 -1
  362. package/dist/skills/usage.d.ts +54 -0
  363. package/dist/skills/usage.d.ts.map +1 -0
  364. package/dist/skills/validate.d.ts +57 -0
  365. package/dist/skills/validate.d.ts.map +1 -0
  366. package/dist/tui/App.d.ts +10 -15
  367. package/dist/tui/App.d.ts.map +1 -1
  368. package/dist/tui/Composer.d.ts +6 -10
  369. package/dist/tui/Composer.d.ts.map +1 -1
  370. package/dist/tui/PendingInputPanel.d.ts +4 -4
  371. package/dist/tui/PendingInputPanel.d.ts.map +1 -1
  372. package/dist/tui/PluginScreen.d.ts +17 -0
  373. package/dist/tui/PluginScreen.d.ts.map +1 -0
  374. package/dist/tui/SaveSkillOverlay.d.ts +8 -0
  375. package/dist/tui/SaveSkillOverlay.d.ts.map +1 -1
  376. package/dist/tui/SkillsManager.d.ts +9 -0
  377. package/dist/tui/SkillsManager.d.ts.map +1 -0
  378. package/dist/tui/TrustPrompt.d.ts.map +1 -1
  379. package/dist/tui/agent.d.ts +17 -0
  380. package/dist/tui/agent.d.ts.map +1 -1
  381. package/dist/tui/plugin-screen.d.ts +243 -0
  382. package/dist/tui/plugin-screen.d.ts.map +1 -0
  383. package/dist/tui/plugin-view.d.ts +4 -0
  384. package/dist/tui/plugin-view.d.ts.map +1 -1
  385. package/dist/tui/skills/suggest-setting.d.ts +3 -3
  386. package/dist/tui/skills-manager.d.ts +145 -0
  387. package/dist/tui/skills-manager.d.ts.map +1 -0
  388. package/dist/tui/slashCommands.d.ts +1 -1
  389. package/dist/tui/slashCommands.d.ts.map +1 -1
  390. package/dist/user-commands/store.d.ts +12 -0
  391. package/dist/user-commands/store.d.ts.map +1 -1
  392. package/package.json +3 -3
  393. package/skills/skill-creator/SKILL.md +2 -2
  394. package/dist/chunks/acp-AQUZCZSO.js.map +0 -6
  395. package/dist/chunks/agent-session-WXWW7E5M.js +0 -92
  396. package/dist/chunks/chunk-3ETXWTV4.js.map +0 -6
  397. package/dist/chunks/chunk-4BAXYUZQ.js.map +0 -6
  398. package/dist/chunks/chunk-567CSU37.js.map +0 -6
  399. package/dist/chunks/chunk-5JVKE4LB.js.map +0 -6
  400. package/dist/chunks/chunk-6IOZY2AB.js.map +0 -6
  401. package/dist/chunks/chunk-AEXGGJUW.js.map +0 -6
  402. package/dist/chunks/chunk-D3SCA6NT.js.map +0 -6
  403. package/dist/chunks/chunk-D6XZ4ZAV.js.map +0 -6
  404. package/dist/chunks/chunk-FK5C7SHM.js.map +0 -6
  405. package/dist/chunks/chunk-FMQCPAKR.js +0 -116
  406. package/dist/chunks/chunk-FMQCPAKR.js.map +0 -6
  407. package/dist/chunks/chunk-FRGOWO6N.js.map +0 -6
  408. package/dist/chunks/chunk-HGTOAMV6.js.map +0 -6
  409. package/dist/chunks/chunk-IRAG3YXW.js.map +0 -6
  410. package/dist/chunks/chunk-JUDJGDYX.js.map +0 -6
  411. package/dist/chunks/chunk-KHGY6QJR.js.map +0 -6
  412. package/dist/chunks/chunk-OOJP5BEK.js.map +0 -6
  413. package/dist/chunks/chunk-OQWLQUO7.js.map +0 -6
  414. package/dist/chunks/chunk-RHJOIAFS.js +0 -201
  415. package/dist/chunks/chunk-RHJOIAFS.js.map +0 -6
  416. package/dist/chunks/exec-2PRVZNUX.js.map +0 -6
  417. package/dist/chunks/hooks-AK5S4YUS.js.map +0 -6
  418. package/dist/chunks/host-queries-HBW7AW44.js +0 -37
  419. package/dist/chunks/mcp-AFLRDYNN.js.map +0 -6
  420. package/dist/chunks/message-command-ZR2JQBBU.js.map +0 -6
  421. package/dist/chunks/plugin-MLHZ42NZ.js +0 -1132
  422. package/dist/chunks/plugin-MLHZ42NZ.js.map +0 -6
  423. package/dist/chunks/resume-AYWSKWEX.js +0 -25
  424. package/dist/chunks/send-person-57F5RJA7.js +0 -32
  425. package/dist/chunks/skills-ICVGYWBH.js +0 -350
  426. package/dist/chunks/skills-ICVGYWBH.js.map +0 -6
  427. package/dist/chunks/tui-Q7ED7VFI.js.map +0 -6
  428. package/dist/chunks/watch-EON3IWRY.js.map +0 -6
  429. package/dist/chunks/worktree-A2DNXLOT.js.map +0 -6
  430. /package/dist/chunks/{activity-command-Y3A6GIFW.js.map → activity-command-JU4HLIQJ.js.map} +0 -0
  431. /package/dist/chunks/{add-DWFKSOYI.js.map → add-S6JYKDI4.js.map} +0 -0
  432. /package/dist/chunks/{agent-Z6PJYBAO.js.map → agent-E343AQV7.js.map} +0 -0
  433. /package/dist/chunks/{agent-session-WXWW7E5M.js.map → agent-session-D6JIOCON.js.map} +0 -0
  434. /package/dist/chunks/{apply-at-exit-SHGR2BAB.js.map → apply-at-exit-MEOJMGNT.js.map} +0 -0
  435. /package/dist/chunks/{archive-KYXU4AZZ.js.map → archive-ZPWC7GZU.js.map} +0 -0
  436. /package/dist/chunks/{auth-R3RCZZ7U.js.map → auth-6NX4TMIG.js.map} +0 -0
  437. /package/dist/chunks/{bin-main-DUZFYUCJ.js.map → bin-main-P3KAQDKC.js.map} +0 -0
  438. /package/dist/chunks/{binding-5UJYMFMU.js.map → binding-6QZVGFQ5.js.map} +0 -0
  439. /package/dist/chunks/{browser-7CFZ6BZS.js.map → browser-KK2U5524.js.map} +0 -0
  440. /package/dist/chunks/{chat-BELD32ZP.js.map → chat-VEXJRSZN.js.map} +0 -0
  441. /package/dist/chunks/{chunk-MDBUSIPW.js.map → chunk-2KVQVPJ7.js.map} +0 -0
  442. /package/dist/chunks/{chunk-MRZHTIE7.js.map → chunk-42JIZXVL.js.map} +0 -0
  443. /package/dist/chunks/{chunk-ESIICAI3.js.map → chunk-4473VICE.js.map} +0 -0
  444. /package/dist/chunks/{chunk-DGYMR4WJ.js.map → chunk-44YG6EI4.js.map} +0 -0
  445. /package/dist/chunks/{chunk-ZQGCZYAE.js.map → chunk-452SL2Y4.js.map} +0 -0
  446. /package/dist/chunks/{chunk-VE4XIWDW.js.map → chunk-4BNCVR3U.js.map} +0 -0
  447. /package/dist/chunks/{chunk-2EVP6BX4.js.map → chunk-4CJ3HPOT.js.map} +0 -0
  448. /package/dist/chunks/{chunk-TORIEDBN.js.map → chunk-4ENL4VUO.js.map} +0 -0
  449. /package/dist/chunks/{chunk-IJ6Z6FNY.js.map → chunk-4KVYTHY7.js.map} +0 -0
  450. /package/dist/chunks/{chunk-YNWPC3HO.js.map → chunk-4Y242BU4.js.map} +0 -0
  451. /package/dist/chunks/{chunk-OA7QKUCM.js.map → chunk-5F4DSPZC.js.map} +0 -0
  452. /package/dist/chunks/{chunk-DRWJTADQ.js.map → chunk-5IGEQN7L.js.map} +0 -0
  453. /package/dist/chunks/{chunk-W752G3FM.js.map → chunk-5ZLKTFU2.js.map} +0 -0
  454. /package/dist/chunks/{chunk-KETRBV2E.js.map → chunk-66QIFMEO.js.map} +0 -0
  455. /package/dist/chunks/{chunk-CEZW3NVM.js.map → chunk-6W3UGXGG.js.map} +0 -0
  456. /package/dist/chunks/{chunk-S7FE35WQ.js.map → chunk-75YLZNZW.js.map} +0 -0
  457. /package/dist/chunks/{chunk-P4TCLMD6.js.map → chunk-AC5P6W3G.js.map} +0 -0
  458. /package/dist/chunks/{chunk-GUK47JTV.js.map → chunk-AYMB4AOZ.js.map} +0 -0
  459. /package/dist/chunks/{chunk-23D5IXMW.js.map → chunk-B4AOCHH6.js.map} +0 -0
  460. /package/dist/chunks/{chunk-FEOS7UZ2.js.map → chunk-BA7KUG6V.js.map} +0 -0
  461. /package/dist/chunks/{chunk-D35UCVTK.js.map → chunk-BHQHTM3Z.js.map} +0 -0
  462. /package/dist/chunks/{chunk-KPOOM7QT.js.map → chunk-BNLIRJ3M.js.map} +0 -0
  463. /package/dist/chunks/{chunk-MDVYEFTI.js.map → chunk-BURGRQWO.js.map} +0 -0
  464. /package/dist/chunks/{chunk-DKSFQRUM.js.map → chunk-BWD2TUI4.js.map} +0 -0
  465. /package/dist/chunks/{chunk-7Y4RR47U.js.map → chunk-C7E7YCRD.js.map} +0 -0
  466. /package/dist/chunks/{chunk-44MFZJ24.js.map → chunk-CXW7I2S3.js.map} +0 -0
  467. /package/dist/chunks/{chunk-73HWWJYC.js.map → chunk-D6PB3Z7Q.js.map} +0 -0
  468. /package/dist/chunks/{chunk-QTHG6UPU.js.map → chunk-DEAG4G5J.js.map} +0 -0
  469. /package/dist/chunks/{chunk-WGC5DJEW.js.map → chunk-DRSQTKDN.js.map} +0 -0
  470. /package/dist/chunks/{chunk-WXYRLTRY.js.map → chunk-EXJJLYZK.js.map} +0 -0
  471. /package/dist/chunks/{chunk-PFVYYH6O.js.map → chunk-F5W4TNCR.js.map} +0 -0
  472. /package/dist/chunks/{chunk-Q6PZODSV.js.map → chunk-F7KOBJVW.js.map} +0 -0
  473. /package/dist/chunks/{chunk-VSNV3U2B.js.map → chunk-FK4MAZV2.js.map} +0 -0
  474. /package/dist/chunks/{chunk-G5LPTLLY.js.map → chunk-FPC3K4TT.js.map} +0 -0
  475. /package/dist/chunks/{chunk-XLXPPVUT.js.map → chunk-FVIKYFYD.js.map} +0 -0
  476. /package/dist/chunks/{chunk-PQT7624W.js.map → chunk-GPTYDM26.js.map} +0 -0
  477. /package/dist/chunks/{chunk-TP7DRQXE.js.map → chunk-GT22EDUB.js.map} +0 -0
  478. /package/dist/chunks/{chunk-GEVWZWLM.js.map → chunk-GTUTBTOV.js.map} +0 -0
  479. /package/dist/chunks/{chunk-GQ6WXY3M.js.map → chunk-H6NTNPWD.js.map} +0 -0
  480. /package/dist/chunks/{chunk-TYNAB5GR.js.map → chunk-HCQGZPVT.js.map} +0 -0
  481. /package/dist/chunks/{chunk-LB4HC5U7.js.map → chunk-HG2PPCAE.js.map} +0 -0
  482. /package/dist/chunks/{chunk-ABKURT35.js.map → chunk-HKRUNZVI.js.map} +0 -0
  483. /package/dist/chunks/{chunk-JPM3JXZB.js.map → chunk-HM7L5PM2.js.map} +0 -0
  484. /package/dist/chunks/{chunk-UFGLSUGU.js.map → chunk-I4RC6KQQ.js.map} +0 -0
  485. /package/dist/chunks/{chunk-HW2QBNAA.js.map → chunk-IL4Y3JGT.js.map} +0 -0
  486. /package/dist/chunks/{chunk-24EZWZDZ.js.map → chunk-J4PL65DJ.js.map} +0 -0
  487. /package/dist/chunks/{chunk-E65IWYTT.js.map → chunk-JECLB23L.js.map} +0 -0
  488. /package/dist/chunks/{chunk-3RLKUXXG.js.map → chunk-JJ72TLOA.js.map} +0 -0
  489. /package/dist/chunks/{chunk-CG5CGXNF.js.map → chunk-JRBFL6WT.js.map} +0 -0
  490. /package/dist/chunks/{chunk-KBLYZ7L7.js.map → chunk-K2EKXCLZ.js.map} +0 -0
  491. /package/dist/chunks/{chunk-WW3AU2YN.js.map → chunk-ME4LETA3.js.map} +0 -0
  492. /package/dist/chunks/{chunk-J5E4DV6R.js.map → chunk-MF3SFDBW.js.map} +0 -0
  493. /package/dist/chunks/{chunk-WSDZIJNK.js.map → chunk-MK42KB72.js.map} +0 -0
  494. /package/dist/chunks/{chunk-RZKIZTPA.js.map → chunk-MUSGZEFY.js.map} +0 -0
  495. /package/dist/chunks/{chunk-MF5KTVGJ.js.map → chunk-N5CCXOYK.js.map} +0 -0
  496. /package/dist/chunks/{chunk-KVNL7XA6.js.map → chunk-NBJ5PRAY.js.map} +0 -0
  497. /package/dist/chunks/{chunk-E4RVHFV6.js.map → chunk-NKHEBASJ.js.map} +0 -0
  498. /package/dist/chunks/{chunk-SS6IJAPA.js.map → chunk-NVWD5XDT.js.map} +0 -0
  499. /package/dist/chunks/{chunk-7LDUPEXP.js.map → chunk-O45DCUNX.js.map} +0 -0
  500. /package/dist/chunks/{chunk-G76POTWW.js.map → chunk-PAUMCJPX.js.map} +0 -0
  501. /package/dist/chunks/{chunk-MF57EX7H.js.map → chunk-PE4MWWUW.js.map} +0 -0
  502. /package/dist/chunks/{chunk-4RW7GDJ4.js.map → chunk-PLCWCIL4.js.map} +0 -0
  503. /package/dist/chunks/{chunk-XVOPQCPD.js.map → chunk-PRJO4XM3.js.map} +0 -0
  504. /package/dist/chunks/{chunk-CQFWLYTK.js.map → chunk-PRRX5LNR.js.map} +0 -0
  505. /package/dist/chunks/{chunk-3PH6F6Z3.js.map → chunk-PS5SVAUJ.js.map} +0 -0
  506. /package/dist/chunks/{chunk-P725GKKG.js.map → chunk-PZWSRAE7.js.map} +0 -0
  507. /package/dist/chunks/{chunk-CNSKJ3DZ.js.map → chunk-QCV3HH4P.js.map} +0 -0
  508. /package/dist/chunks/{chunk-7J23SPSX.js.map → chunk-QGBR42TV.js.map} +0 -0
  509. /package/dist/chunks/{chunk-6CSJRIUZ.js.map → chunk-QNJXULU7.js.map} +0 -0
  510. /package/dist/chunks/{chunk-DJKWBSVM.js.map → chunk-R2KAESOM.js.map} +0 -0
  511. /package/dist/chunks/{chunk-AIQKSTVJ.js.map → chunk-R6M6EIAH.js.map} +0 -0
  512. /package/dist/chunks/{chunk-VJHENTNB.js.map → chunk-RKKU2RE4.js.map} +0 -0
  513. /package/dist/chunks/{chunk-JZTTOZRG.js.map → chunk-RMOTHWPV.js.map} +0 -0
  514. /package/dist/chunks/{chunk-EA6YICQ7.js.map → chunk-RQAY7REG.js.map} +0 -0
  515. /package/dist/chunks/{chunk-LWJJDERP.js.map → chunk-SLTJNYOU.js.map} +0 -0
  516. /package/dist/chunks/{chunk-UL6MZ5OM.js.map → chunk-SXONHO4H.js.map} +0 -0
  517. /package/dist/chunks/{chunk-W4S4ZBXX.js.map → chunk-T7ILM666.js.map} +0 -0
  518. /package/dist/chunks/{chunk-E6FMAE5Q.js.map → chunk-TBGKPWCL.js.map} +0 -0
  519. /package/dist/chunks/{chunk-ACO3LTRT.js.map → chunk-TBJ6XU3T.js.map} +0 -0
  520. /package/dist/chunks/{chunk-5HMJ3DYR.js.map → chunk-TMPP2DEY.js.map} +0 -0
  521. /package/dist/chunks/{chunk-6YXHH5JW.js.map → chunk-TSOZBRM6.js.map} +0 -0
  522. /package/dist/chunks/{chunk-SSPHAILP.js.map → chunk-TTFPWGIU.js.map} +0 -0
  523. /package/dist/chunks/{chunk-TRRKG642.js.map → chunk-TTKMQW6B.js.map} +0 -0
  524. /package/dist/chunks/{chunk-2VP2Q657.js.map → chunk-UCML5ZXB.js.map} +0 -0
  525. /package/dist/chunks/{chunk-OH7EYW3T.js.map → chunk-VG7245VJ.js.map} +0 -0
  526. /package/dist/chunks/{chunk-QZTTIL3A.js.map → chunk-VQZPXK4X.js.map} +0 -0
  527. /package/dist/chunks/{chunk-O2PZDA5H.js.map → chunk-VWUTJ4EU.js.map} +0 -0
  528. /package/dist/chunks/{chunk-VL6Z2OMG.js.map → chunk-WDKAL7EW.js.map} +0 -0
  529. /package/dist/chunks/{chunk-2KC52MDS.js.map → chunk-WJ6QRVL6.js.map} +0 -0
  530. /package/dist/chunks/{chunk-XJALHM5Z.js.map → chunk-WOTA5FO5.js.map} +0 -0
  531. /package/dist/chunks/{chunk-4TJ7AGQO.js.map → chunk-WPGVZMSU.js.map} +0 -0
  532. /package/dist/chunks/{chunk-DJTCZSSY.js.map → chunk-XDUA6PBP.js.map} +0 -0
  533. /package/dist/chunks/{chunk-PKFXIWVX.js.map → chunk-XE6XT6R6.js.map} +0 -0
  534. /package/dist/chunks/{chunk-LXJW3ZYI.js.map → chunk-YWRRS7SO.js.map} +0 -0
  535. /package/dist/chunks/{chunk-JRWUIW4J.js.map → chunk-ZHEEG3NS.js.map} +0 -0
  536. /package/dist/chunks/{cli-runtime-P6LCHPBA.js.map → cli-runtime-ZJKKIW4H.js.map} +0 -0
  537. /package/dist/chunks/{commands-BNHIQVYO.js.map → commands-TQH5DD22.js.map} +0 -0
  538. /package/dist/chunks/{computer-6P3GAOV2.js.map → computer-WOU5WIIR.js.map} +0 -0
  539. /package/dist/chunks/{config-ZMXMX2WY.js.map → config-APYUJ5UW.js.map} +0 -0
  540. /package/dist/chunks/{cost-BJKADKEZ.js.map → cost-5YV27U7F.js.map} +0 -0
  541. /package/dist/chunks/{crash-report-OJHGVRD7.js.map → crash-report-QVXU2YVL.js.map} +0 -0
  542. /package/dist/chunks/{dist-PMSBTFU5.js.map → dist-2FSOLP72.js.map} +0 -0
  543. /package/dist/chunks/{dist-43XWK3LF.js.map → dist-AOT4CEP5.js.map} +0 -0
  544. /package/dist/chunks/{dist-4LEGETQA.js.map → dist-H7CAJ3ZW.js.map} +0 -0
  545. /package/dist/chunks/{dist-NCBDELMI.js.map → dist-IZGKRIWL.js.map} +0 -0
  546. /package/dist/chunks/{dist-BGJEX527.js.map → dist-J4UXFVYR.js.map} +0 -0
  547. /package/dist/chunks/{dist-FMFNU4M3.js.map → dist-JHKRSGW6.js.map} +0 -0
  548. /package/dist/chunks/{dist-4ZPDHZOX.js.map → dist-PZYMYR7N.js.map} +0 -0
  549. /package/dist/chunks/{dist-ADQAO5C3.js.map → dist-Z2HW2SJR.js.map} +0 -0
  550. /package/dist/chunks/{doctor-AIYB27QY.js.map → doctor-CM6UPXG5.js.map} +0 -0
  551. /package/dist/chunks/{drain-PYKX4QNR.js.map → drain-X6RURKKC.js.map} +0 -0
  552. /package/dist/chunks/{entry-HM5E7KCD.js.map → entry-QQDPY6ZL.js.map} +0 -0
  553. /package/dist/chunks/{eval-H4NKZYVV.js.map → eval-GZA22B4I.js.map} +0 -0
  554. /package/dist/chunks/{extension-4233XOZW.js.map → extension-N5IQNKVZ.js.map} +0 -0
  555. /package/dist/chunks/{github-IF3JVVJF.js.map → github-AUOENJUY.js.map} +0 -0
  556. /package/dist/chunks/{home-AZY7APF6.js.map → home-I4FIB6FV.js.map} +0 -0
  557. /package/dist/chunks/{homes-WL6LAAY5.js.map → homes-WTMMXQ6G.js.map} +0 -0
  558. /package/dist/chunks/{hooks-report-NJLGBWN3.js.map → hooks-report-K6VOPVBR.js.map} +0 -0
  559. /package/dist/chunks/{host-SX3QC5FN.js.map → host-65UFBZJV.js.map} +0 -0
  560. /package/dist/chunks/{host-queries-HBW7AW44.js.map → host-queries-L4PYE2BW.js.map} +0 -0
  561. /package/dist/chunks/{installed-list-44QXUJFE.js.map → installed-list-7QIWVKLQ.js.map} +0 -0
  562. /package/dist/chunks/{learn-LW4DLSGZ.js.map → learn-NZXLKYV4.js.map} +0 -0
  563. /package/dist/chunks/{learn-builtin-4RV2XDH4.js.map → learn-builtin-RC4XXVBS.js.map} +0 -0
  564. /package/dist/chunks/{lifecycle-AJCHTSAF.js.map → lifecycle-NLCZ6OPA.js.map} +0 -0
  565. /package/dist/chunks/{list-DT7AJVPX.js.map → list-2U67CAWS.js.map} +0 -0
  566. /package/dist/chunks/{live-Z6HZFXPW.js.map → live-CWJ2NWUQ.js.map} +0 -0
  567. /package/dist/chunks/{load-454TJBPW.js.map → load-H52QQBVE.js.map} +0 -0
  568. /package/dist/chunks/{logs-GRUSUSL7.js.map → logs-ZIW3QFU4.js.map} +0 -0
  569. /package/dist/chunks/{mcp-serve-NNWP4IES.js.map → mcp-serve-ZC2OKIPP.js.map} +0 -0
  570. /package/dist/chunks/{open-Z3BELFL7.js.map → open-AHDQMVXI.js.map} +0 -0
  571. /package/dist/chunks/{operator-tools-PN3SPQ3C.js.map → operator-tools-P5R4TF6N.js.map} +0 -0
  572. /package/dist/chunks/{output-schema-DSR56W6A.js.map → output-schema-Q5RWHNKE.js.map} +0 -0
  573. /package/dist/chunks/{pal-ZOH5ILEV.js.map → pal-T42HU4AK.js.map} +0 -0
  574. /package/dist/chunks/{peers-LXNB4QSL.js.map → peers-5RYEA7IA.js.map} +0 -0
  575. /package/dist/chunks/{peers-WINODTEB.js.map → peers-7ZG3DEBO.js.map} +0 -0
  576. /package/dist/chunks/{providers-UOTUEQOJ.js.map → providers-BXXIM7EW.js.map} +0 -0
  577. /package/dist/chunks/{providers-AVECY67I.js.map → providers-I24HYZXG.js.map} +0 -0
  578. /package/dist/chunks/{pty-GW2YC23H.js.map → pty-WVKM6ATI.js.map} +0 -0
  579. /package/dist/chunks/{resume-AYWSKWEX.js.map → resume-F7JEDBHI.js.map} +0 -0
  580. /package/dist/chunks/{resume-command-FXT3KGLC.js.map → resume-command-4I47WN7T.js.map} +0 -0
  581. /package/dist/chunks/{running-3NLAODZ7.js.map → running-VID6BVT2.js.map} +0 -0
  582. /package/dist/chunks/{schedule-TTQUT45H.js.map → schedule-75IZH76Z.js.map} +0 -0
  583. /package/dist/chunks/{send-FRNTRW2M.js.map → send-QRYY2NCG.js.map} +0 -0
  584. /package/dist/chunks/{send-person-57F5RJA7.js.map → send-person-VADQNJBN.js.map} +0 -0
  585. /package/dist/chunks/{service-TCKPUGL5.js.map → service-B6BNESZB.js.map} +0 -0
  586. /package/dist/chunks/{setting-cli-HGYOIGC6.js.map → setting-cli-O4YWOIU5.js.map} +0 -0
  587. /package/dist/chunks/{start-check-C5VJXVPY.js.map → start-check-EKRXJ5VE.js.map} +0 -0
  588. /package/dist/chunks/{startup-failure-YQSEQRNQ.js.map → startup-failure-2UJKPNMR.js.map} +0 -0
  589. /package/dist/chunks/{state-2DBTSDEP.js.map → state-X3MKUFYM.js.map} +0 -0
  590. /package/dist/chunks/{store-CZGKLVTT.js.map → store-4OXWHFS5.js.map} +0 -0
  591. /package/dist/chunks/{store-JJKCDY7Y.js.map → store-MK5IYBE5.js.map} +0 -0
  592. /package/dist/chunks/{store-RJZCW2MI.js.map → store-QFNY4BV4.js.map} +0 -0
  593. /package/dist/chunks/{store-S4BT3ESJ.js.map → store-VRKKFOYW.js.map} +0 -0
  594. /package/dist/chunks/{update-G7D3YCH5.js.map → update-ELZEXYIX.js.map} +0 -0
  595. /package/dist/chunks/{workspaces-O6S2OTDL.js.map → workspaces-3LB4SPPS.js.map} +0 -0
@@ -0,0 +1,2958 @@
1
+ import { createRequire as __namzuCreateRequire } from 'node:module';
2
+ const require = __namzuCreateRequire(import.meta.url);
3
+ import {
4
+ askYesNo
5
+ } from "./chunk-GWQEMJFS.js";
6
+ import {
7
+ PLUGIN_ACTIONS
8
+ } from "./chunk-JANK2R3L.js";
9
+ import {
10
+ DOWNLOAD_BLOCKED,
11
+ FetchError,
12
+ InstallConflict,
13
+ LOCAL_UPLOADS_MARKETPLACE,
14
+ MARKETPLACE_BLOCKED,
15
+ MARKETPLACE_NOTICE,
16
+ PLUGIN_RECORD_HELP,
17
+ PLUGIN_RECORD_VERBS,
18
+ PlanRefusal,
19
+ SimulatedCrash,
20
+ anotherPlace,
21
+ applicable,
22
+ commitInstall,
23
+ commitUpdate,
24
+ compareUpdate,
25
+ countNotInstallable,
26
+ describeSource,
27
+ discardStaging,
28
+ downloadBlocked,
29
+ failure,
30
+ fetchMarketplace,
31
+ fetchNotes,
32
+ isBlockedSource,
33
+ isInside,
34
+ lstatExists,
35
+ marketplaceConsentText,
36
+ marketplaceNameProblem,
37
+ newStaging,
38
+ newerVersions,
39
+ oneLine,
40
+ parseMarketplaceAddress,
41
+ placeMarketplace,
42
+ planInstall,
43
+ prune,
44
+ readCatalog,
45
+ readFetchedCatalog,
46
+ realPathOf,
47
+ refProblem,
48
+ refreshRemoteMarketplace,
49
+ removeInstall,
50
+ renderInstallPreview,
51
+ repoPathProblem,
52
+ resolveEntrySource,
53
+ resolveId,
54
+ runPluginRecords,
55
+ sameSource,
56
+ sameVersionChanged,
57
+ stateFailure,
58
+ trashFolder,
59
+ usedPluginNames
60
+ } from "./chunk-BJT37HR4.js";
61
+ import {
62
+ resolvePluginFileDir
63
+ } from "./chunk-32OIBGYI.js";
64
+ import {
65
+ SKILL_MANIFEST_MAX_CHARS
66
+ } from "./chunk-QBLHOG2F.js";
67
+ import {
68
+ readInstallManifest,
69
+ readLayers,
70
+ readRecordLayer,
71
+ recordLayerPath,
72
+ removeExtraKnownMarketplace,
73
+ setEnabledPlugin,
74
+ setExtraKnownMarketplace
75
+ } from "./chunk-KF6IKSF2.js";
76
+ import "./chunk-EBBT2I5S.js";
77
+ import {
78
+ COMMAND_FILE_KEYS,
79
+ parseCommandText
80
+ } from "./chunk-IQ44C7Y3.js";
81
+ import "./chunk-BBTPD3DU.js";
82
+ import "./chunk-5OYJXSMZ.js";
83
+ import {
84
+ readAgentHooks
85
+ } from "./chunk-MK42KB72.js";
86
+ import {
87
+ CONVENTIONAL_HOOKS_FILE,
88
+ readPluginHookEntriesOf
89
+ } from "./chunk-6TUHWKXP.js";
90
+ import {
91
+ readSkillHooks
92
+ } from "./chunk-TBJ6XU3T.js";
93
+ import {
94
+ RESERVED_PLUGIN_FOLDERS,
95
+ installedPluginDataFolder,
96
+ installedPluginsPath,
97
+ isPluginId,
98
+ marketplacesFolder,
99
+ putKnownMarketplace,
100
+ readInstalledPlugins,
101
+ readKnownMarketplaces,
102
+ realPathOrResolved,
103
+ removeKnownMarketplace,
104
+ samePath,
105
+ splitPluginId
106
+ } from "./chunk-D4TXOX34.js";
107
+ import "./chunk-6HYK4DDB.js";
108
+ import "./chunk-WPGVZMSU.js";
109
+ import {
110
+ isTrusted
111
+ } from "./chunk-VWUTJ4EU.js";
112
+ import {
113
+ EXIT_DATAERR,
114
+ EXIT_FAIL,
115
+ EXIT_NEEDS_CONSENT,
116
+ EXIT_NOINPUT,
117
+ EXIT_OK,
118
+ EXIT_UNAVAILABLE,
119
+ EXIT_UNTRUSTED,
120
+ EXIT_USAGE
121
+ } from "./chunk-24V2WEKR.js";
122
+ import {
123
+ terminalDisplayText
124
+ } from "./chunk-I4GTRFPK.js";
125
+ import {
126
+ planSettingChange
127
+ } from "./chunk-2DCOB33W.js";
128
+ import "./chunk-6W3UGXGG.js";
129
+ import "./chunk-FVIKYFYD.js";
130
+ import "./chunk-O4EILTV6.js";
131
+ import "./chunk-HKRUNZVI.js";
132
+ import "./chunk-5WORROIE.js";
133
+ import {
134
+ PERMISSION_MODE_NAMES
135
+ } from "./chunk-WMEZTDLT.js";
136
+ import "./chunk-LCGXWCVU.js";
137
+ import "./chunk-7YC42EXB.js";
138
+ import "./chunk-LVVD32KJ.js";
139
+ import "./chunk-GMUWAUKQ.js";
140
+ import "./chunk-PJ6IEIKJ.js";
141
+ import "./chunk-PRJO4XM3.js";
142
+ import "./chunk-G6YSAHKC.js";
143
+ import "./chunk-JORONMD3.js";
144
+ import "./chunk-F5W4TNCR.js";
145
+ import "./chunk-AYMB4AOZ.js";
146
+ import "./chunk-WRPEQ3KP.js";
147
+ import "./chunk-CXW7I2S3.js";
148
+ import {
149
+ createFormatter
150
+ } from "./chunk-A6RHRNY2.js";
151
+ import {
152
+ namzuHomePath
153
+ } from "./chunk-JRBFL6WT.js";
154
+ import "./chunk-U5UV2YRE.js";
155
+ import "./chunk-PHW6PWIJ.js";
156
+ import {
157
+ AGENT_FILE_KEYS,
158
+ PluginManifestSchema,
159
+ RENAMED_PLUGIN_HOOK_EVENTS,
160
+ SKILL_FRONTMATTER_KEYS,
161
+ assertEnableable,
162
+ assertPluginHookEvent,
163
+ hookModuleConsentLines,
164
+ isHookEntriesPath,
165
+ locateHookModule,
166
+ parseAgentMarkdown,
167
+ parsePluginManifestText,
168
+ parseSkillMarkdown,
169
+ readCommonLayout,
170
+ resolveWithinReal,
171
+ scanHookModule,
172
+ skillModelDescription,
173
+ summarizeHookModule
174
+ } from "./chunk-QQ4S6MNH.js";
175
+ import {
176
+ __name
177
+ } from "./chunk-76FLAFCG.js";
178
+
179
+ // src/commands/plugin.ts
180
+ import { resolve as resolve2 } from "node:path";
181
+
182
+ // src/integrations/plugins/validate.ts
183
+ import { constants, existsSync } from "node:fs";
184
+ import { lstat, open, readdir, realpath, stat } from "node:fs/promises";
185
+ import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
186
+ var PLUGIN_VALIDATION_REPORT_VERSION = 1;
187
+ var MAX_CHECKED_FILE_BYTES = 4 * 1024 * 1024;
188
+ var MAX_CHECKED_FILES_PER_FOLDER = 500;
189
+ var MANIFEST_FILE = "plugin.json";
190
+ function readHooksModule(root) {
191
+ const located = locateHookModule(root);
192
+ if (located.kind !== "found") return void 0;
193
+ const scan = scanHookModule(root, located.entry);
194
+ const summary = summarizeHookModule(scan);
195
+ const status = scan.refusals.length > 0 ? "refused" : summary.events.length === 0 ? "empty" : "runs";
196
+ return {
197
+ entry: located.entry,
198
+ status,
199
+ lines: hookModuleConsentLines(summary),
200
+ summary,
201
+ hooks: scan.hooks.map((hook) => ({
202
+ pattern: hook.pattern,
203
+ // A module that does not load runs none of its hooks.
204
+ runs: status === "runs" && hook.runs.length > 0,
205
+ matcher: hook.matcher,
206
+ catches: hook.catches,
207
+ file: hook.file,
208
+ line: hook.line
209
+ })),
210
+ calls: scan.calls.map((call) => ({
211
+ call: call.call,
212
+ supported: call.supported,
213
+ file: call.file,
214
+ line: call.line
215
+ })),
216
+ files: scan.files
217
+ };
218
+ }
219
+ __name(readHooksModule, "readHooksModule");
220
+ async function readInside(root, rel) {
221
+ let abs;
222
+ try {
223
+ abs = await resolveWithinReal(root, rel);
224
+ } catch (error) {
225
+ return { ok: false, kind: "outside", detail: message(error) };
226
+ }
227
+ let handle;
228
+ try {
229
+ const before = await stat(abs);
230
+ if (!before.isFile()) return { ok: false, kind: "not-file" };
231
+ handle = await open(abs, constants.O_RDONLY | constants.O_NONBLOCK);
232
+ const info = await handle.stat();
233
+ if (!info.isFile()) return { ok: false, kind: "not-file" };
234
+ if (info.size > MAX_CHECKED_FILE_BYTES) {
235
+ return { ok: false, kind: "too-large", detail: `${info.size} bytes` };
236
+ }
237
+ const buffer = Buffer.alloc(info.size);
238
+ let filled = 0;
239
+ while (filled < info.size) {
240
+ const { bytesRead } = await handle.read(buffer, filled, info.size - filled, filled);
241
+ if (bytesRead === 0) break;
242
+ filled += bytesRead;
243
+ }
244
+ const bytes = buffer.subarray(0, filled);
245
+ if (bytes.includes(0)) return { ok: false, kind: "binary" };
246
+ return { ok: true, text: bytes.toString("utf8"), abs };
247
+ } catch (error) {
248
+ const code = error.code;
249
+ if (code === "ENOENT" || code === "ENOTDIR") return { ok: false, kind: "missing" };
250
+ return { ok: false, kind: "unreadable", detail: message(error) };
251
+ } finally {
252
+ await handle?.close().catch(() => void 0);
253
+ }
254
+ }
255
+ __name(readInside, "readInside");
256
+ function message(error) {
257
+ return error instanceof Error ? error.message : String(error);
258
+ }
259
+ __name(message, "message");
260
+ function posix(path) {
261
+ return path.split(sep).join("/");
262
+ }
263
+ __name(posix, "posix");
264
+ function jsonLines(text) {
265
+ const lines = /* @__PURE__ */ new Map();
266
+ let i = 0;
267
+ let line = 1;
268
+ const skip = /* @__PURE__ */ __name(() => {
269
+ while (i < text.length) {
270
+ const c = text[i];
271
+ if (c === "\n") line++;
272
+ else if (c !== " " && c !== " " && c !== "\r" && c !== "\uFEFF") return;
273
+ i++;
274
+ }
275
+ }, "skip");
276
+ const string = /* @__PURE__ */ __name(() => {
277
+ const start = i;
278
+ i++;
279
+ while (i < text.length && text[i] !== '"') i += text[i] === "\\" ? 2 : 1;
280
+ i++;
281
+ return JSON.parse(text.slice(start, i));
282
+ }, "string");
283
+ const value = /* @__PURE__ */ __name((path) => {
284
+ skip();
285
+ const c = text[i];
286
+ if (c === "{") {
287
+ i++;
288
+ skip();
289
+ while (text[i] !== "}") {
290
+ skip();
291
+ const keyLine = line;
292
+ const key = string();
293
+ const child = path === "" ? key : `${path}/${key}`;
294
+ lines.set(child, keyLine);
295
+ skip();
296
+ i++;
297
+ value(child);
298
+ skip();
299
+ if (text[i] === ",") i++;
300
+ skip();
301
+ }
302
+ i++;
303
+ } else if (c === "[") {
304
+ i++;
305
+ skip();
306
+ let index = 0;
307
+ while (text[i] !== "]") {
308
+ skip();
309
+ const child = path === "" ? String(index) : `${path}/${index}`;
310
+ lines.set(child, line);
311
+ value(child);
312
+ index++;
313
+ skip();
314
+ if (text[i] === ",") i++;
315
+ skip();
316
+ }
317
+ i++;
318
+ } else if (c === '"') {
319
+ string();
320
+ } else {
321
+ while (i < text.length && !/[,\]}\s]/.test(text[i])) i++;
322
+ }
323
+ }, "value");
324
+ try {
325
+ value("");
326
+ } catch {
327
+ }
328
+ return lines;
329
+ }
330
+ __name(jsonLines, "jsonLines");
331
+ function frontmatterKeys(text) {
332
+ const lines = text.replace(/^/, "").split(/\r\n|\n|\r/);
333
+ let start = lines.findIndex((l) => l.trim() !== "");
334
+ if (start === -1 || lines[start]?.trim() !== "---") return [];
335
+ start++;
336
+ const keys = [];
337
+ for (let n = start; n < lines.length; n++) {
338
+ const l = lines[n];
339
+ if (/^---[ \t]*$/.test(l)) break;
340
+ const match = /^([A-Za-z0-9_-]+)\s*:/.exec(l);
341
+ if (match) keys.push({ key: match[1], line: n + 1 });
342
+ }
343
+ return keys;
344
+ }
345
+ __name(frontmatterKeys, "frontmatterKeys");
346
+ function lineForReason(text, reason) {
347
+ const keys = frontmatterKeys(text);
348
+ const named = keys.filter(
349
+ ({ key }) => new RegExp(`(^|[^A-Za-z0-9_-])${escapeRegExp(key)}([^A-Za-z0-9_-]|$)`).test(reason)
350
+ ).sort((a, b) => b.key.length - a.key.length)[0];
351
+ if (named) return named.line;
352
+ const lines = text.replace(/^/, "").split(/\r\n|\n|\r/);
353
+ const fence = lines.findIndex((l) => l.trim() === "---");
354
+ return fence === -1 ? 1 : fence + 1;
355
+ }
356
+ __name(lineForReason, "lineForReason");
357
+ function escapeRegExp(text) {
358
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
359
+ }
360
+ __name(escapeRegExp, "escapeRegExp");
361
+ function plainReason(reason, ...paths) {
362
+ let out = reason;
363
+ for (const p of paths) out = out.split(p).join("");
364
+ return out.replace(/\s+/g, " ").trim();
365
+ }
366
+ __name(plainReason, "plainReason");
367
+ var Collector = class {
368
+ static {
369
+ __name(this, "Collector");
370
+ }
371
+ problems = [];
372
+ /** Name and version read from a manifest that is otherwise refused, when they are plain text. */
373
+ identity = {};
374
+ parts = [];
375
+ part(kind, name, file) {
376
+ const id = kind === "manifest" ? "manifest" : `${kind}:${name}`;
377
+ if (!this.parts.some((p) => p.id === id)) {
378
+ this.parts.push({
379
+ kind,
380
+ name,
381
+ ...file !== void 0 ? { file } : {},
382
+ id
383
+ });
384
+ }
385
+ return id;
386
+ }
387
+ add(problem) {
388
+ const { line, ...rest } = problem;
389
+ this.problems.push({ ...rest, ...line !== void 0 ? { line } : {} });
390
+ }
391
+ finish(folder, plugin) {
392
+ const parts = this.parts.map(({ id, kind, name, file }) => {
393
+ const own = this.problems.filter((p) => p.part === id);
394
+ return {
395
+ kind,
396
+ name,
397
+ ...file !== void 0 ? { file } : {},
398
+ status: own.some((p) => p.level === "error") ? "error" : own.length > 0 ? "warning" : "ok"
399
+ };
400
+ });
401
+ const errors = this.problems.filter((p) => p.level === "error").length;
402
+ const warnings = this.problems.length - errors;
403
+ return {
404
+ version: PLUGIN_VALIDATION_REPORT_VERSION,
405
+ folder,
406
+ status: errors > 0 ? "errors" : warnings > 0 ? "warnings" : "clean",
407
+ plugin,
408
+ parts,
409
+ problems: this.problems,
410
+ summary: { errors, warnings }
411
+ };
412
+ }
413
+ };
414
+ function unreadableReport(folder, readError) {
415
+ return {
416
+ version: PLUGIN_VALIDATION_REPORT_VERSION,
417
+ folder,
418
+ status: "unreadable",
419
+ readError,
420
+ plugin: {},
421
+ parts: [],
422
+ problems: [],
423
+ summary: { errors: 0, warnings: 0 }
424
+ };
425
+ }
426
+ __name(unreadableReport, "unreadableReport");
427
+ var REFUSED = "The loader refuses the whole plugin; nothing in it is loaded.";
428
+ var FILE_NOTE = "This file is read, never run.";
429
+ async function validatePluginFolder(folder) {
430
+ let root;
431
+ try {
432
+ root = await realpath(folder);
433
+ if (!(await stat(root)).isDirectory()) {
434
+ return unreadableReport(folder, "it is not a folder.");
435
+ }
436
+ await readdir(root);
437
+ } catch (error) {
438
+ const code = error.code;
439
+ return unreadableReport(
440
+ folder,
441
+ code === "ENOENT" ? "it does not exist." : `it could not be opened: ${message(error)}`
442
+ );
443
+ }
444
+ const c = new Collector();
445
+ if (RESERVED_PLUGIN_FOLDERS.includes(basename(root)) && basename(dirname(root)) === "plugins") {
446
+ c.add({
447
+ level: "warning",
448
+ part: "manifest",
449
+ file: "",
450
+ code: "plugin-folder-reserved",
451
+ message: `The folder name "${basename(root)}" is one Namzu keeps its own plugin state in.`,
452
+ consequence: "A plugin placed in a folder with this name under plugins/ is not loaded; rename the folder."
453
+ });
454
+ }
455
+ const layout = await readCommonLayout(root, {
456
+ // The real load gives a plugin its own data folder; a placeholder stands for it here.
457
+ paths: /* @__PURE__ */ __name(() => ({ data: join(root, ".plugin-data"), project: root }), "paths")
458
+ });
459
+ if (layout.source !== "namzu" && layout.source !== "none") {
460
+ checkCommonLayout(layout, c);
461
+ const hooksModule = readHooksModule(root);
462
+ return {
463
+ ...c.finish(root, {
464
+ ...layout.manifest ? { name: layout.manifest.name, version: layout.manifest.version } : {}
465
+ }),
466
+ layout: { source: layout.source, findings: layout.findings },
467
+ ...hooksModule !== void 0 ? { hooksModule } : {}
468
+ };
469
+ }
470
+ if (layout.source === "namzu") {
471
+ for (const finding of layout.findings) {
472
+ if (finding.code === "manifest-both") {
473
+ c.add({
474
+ level: "warning",
475
+ part: "manifest",
476
+ file: MANIFEST_FILE,
477
+ code: "manifest-both",
478
+ message: finding.message,
479
+ consequence: `${MANIFEST_FILE} is used and the other manifest is ignored.`
480
+ });
481
+ }
482
+ }
483
+ }
484
+ const manifest = await checkManifest(root, c);
485
+ if (manifest) await checkParts(root, manifest, c);
486
+ return c.finish(root, manifest ? { name: manifest.name, version: manifest.version } : c.identity);
487
+ }
488
+ __name(validatePluginFolder, "validatePluginFolder");
489
+ var NOT_USED = "Namzu has no use for it; the plugin still loads.";
490
+ var NOT_USED_BY_CODE = {
491
+ "folder-shadowed-by-manifest": "The files in that folder are skipped; the plugin still loads.",
492
+ "mcp-server-remote": "It connects only after you approve it; the plugin still loads.",
493
+ "mcp-needs-setup": "It is not started until that is set up; the plugin still loads.",
494
+ "hooks-module-not-loaded": "The module is not loaded; the plugin still loads."
495
+ };
496
+ var DROPPED = "That entry is dropped; the plugin loads without it.";
497
+ var MODULE_NOT_RUN = "The module does not run; the plugin loads without it.";
498
+ function partOf(finding, c) {
499
+ const name = /* @__PURE__ */ __name((path, fallback) => path === void 0 ? fallback : path.split("/").filter((x) => x !== "SKILL.md").pop() ?? fallback, "name");
500
+ if (finding.field === "skills" && finding.path !== void 0) {
501
+ return c.part("skill", name(finding.path, "skill"), finding.path);
502
+ }
503
+ if (finding.field.startsWith("mcpServers.")) {
504
+ return c.part("mcp-server", finding.field.split(".")[1] ?? "server");
505
+ }
506
+ if (finding.field === "hooks" && finding.path !== void 0) {
507
+ return c.part("hook", finding.path, finding.path);
508
+ }
509
+ if (finding.field === "commands" && finding.path !== void 0) {
510
+ return c.part("command", name(finding.path, "command"), finding.path);
511
+ }
512
+ if (finding.field === "agents" && finding.path !== void 0) {
513
+ return c.part("agent", name(finding.path, "agent"), finding.path);
514
+ }
515
+ return "manifest";
516
+ }
517
+ __name(partOf, "partOf");
518
+ function checkCommonLayout(read, c) {
519
+ c.part("manifest", "manifest");
520
+ const manifest = read.manifest;
521
+ for (const path of manifest?.skills ?? []) c.part("skill", path.split("/").pop() ?? path, path);
522
+ for (const server of manifest?.mcpServers ?? []) c.part("mcp-server", server.name);
523
+ for (const server of manifest?.remoteMcpServers ?? []) c.part("mcp-server", server.name);
524
+ for (const path of manifest?.hooks ?? []) c.part("hook", path, path);
525
+ for (const path of manifest?.commands ?? [])
526
+ c.part("command", path.split("/").pop() ?? path, path);
527
+ for (const path of manifest?.agents ?? []) c.part("agent", path.split("/").pop() ?? path, path);
528
+ for (const finding of read.findings) {
529
+ if (finding.level === "used" || finding.level === "ignored") continue;
530
+ const whole = read.refusal === finding;
531
+ c.add({
532
+ level: finding.level === "refused" && whole ? "error" : "warning",
533
+ part: whole ? "manifest" : partOf(finding, c),
534
+ file: finding.path ?? "",
535
+ code: finding.code,
536
+ message: finding.message,
537
+ consequence: whole ? REFUSED : finding.level === "refused" ? finding.code === "hooks-module-scan-refused" ? MODULE_NOT_RUN : DROPPED : NOT_USED_BY_CODE[finding.code] ?? NOT_USED
538
+ });
539
+ }
540
+ if (manifest !== void 0) {
541
+ try {
542
+ assertEnableable(manifest, { skillsSupported: true });
543
+ } catch (error) {
544
+ c.add({
545
+ level: "error",
546
+ part: "manifest",
547
+ file: "",
548
+ code: "manifest-incompatible",
549
+ message: message(error),
550
+ consequence: REFUSED
551
+ });
552
+ }
553
+ }
554
+ }
555
+ __name(checkCommonLayout, "checkCommonLayout");
556
+ async function checkManifest(root, c) {
557
+ const part = c.part("manifest", MANIFEST_FILE, MANIFEST_FILE);
558
+ const problem = /* @__PURE__ */ __name((code, text, consequence = REFUSED, line, level = "error") => c.add({
559
+ level,
560
+ part,
561
+ file: MANIFEST_FILE,
562
+ line,
563
+ code,
564
+ message: text,
565
+ consequence
566
+ }), "problem");
567
+ let entry;
568
+ try {
569
+ entry = await lstat(join(root, MANIFEST_FILE));
570
+ } catch {
571
+ problem(
572
+ "manifest-missing",
573
+ `There is no ${MANIFEST_FILE} in this folder.`,
574
+ "The folder is not a plugin; discovery skips it and --plugin-dir refuses it."
575
+ );
576
+ return void 0;
577
+ }
578
+ if (entry.isSymbolicLink() || !entry.isFile()) {
579
+ problem(
580
+ "manifest-not-regular",
581
+ `${MANIFEST_FILE} must be a regular file, not a link or a folder.`
582
+ );
583
+ return void 0;
584
+ }
585
+ const read = await readInside(root, MANIFEST_FILE);
586
+ if (!read.ok) {
587
+ const reason = read.kind === "too-large" ? `${MANIFEST_FILE} is ${read.detail ?? "very large"}, over the ${MAX_CHECKED_FILE_BYTES} bytes this check reads.` : read.kind === "binary" ? `${MANIFEST_FILE} is not a text file.` : `${MANIFEST_FILE} could not be read${read.detail ? `: ${read.detail}` : "."}`;
588
+ if (read.kind === "too-large") {
589
+ problem(
590
+ "manifest-too-large",
591
+ `${reason} It was not read, so nothing else in this plugin was checked.`,
592
+ "The loader reads a manifest of any size; whether it accepts this one is not known here.",
593
+ void 0,
594
+ "warning"
595
+ );
596
+ return void 0;
597
+ }
598
+ problem(`manifest-${read.kind === "binary" ? "binary" : "unreadable"}`, reason);
599
+ return void 0;
600
+ }
601
+ let parsed;
602
+ try {
603
+ parsed = parsePluginManifestText(read.text);
604
+ } catch (error) {
605
+ const lines2 = jsonLines(read.text);
606
+ try {
607
+ const loose = JSON.parse(read.text);
608
+ c.identity = {
609
+ ...typeof loose.name === "string" ? { name: loose.name } : {},
610
+ ...typeof loose.version === "string" ? { version: loose.version } : {}
611
+ };
612
+ } catch {
613
+ }
614
+ const issues = error.issues;
615
+ if (Array.isArray(issues)) {
616
+ for (const issue of issues) {
617
+ const where = issue.path.map(
618
+ (step, at) => typeof step === "number" ? `[${step}]` : at === 0 ? step : `.${step}`
619
+ ).join("");
620
+ const keys = issue.code === "unrecognized_keys" && issue.keys ? issue.keys : void 0;
621
+ const text = keys ? `${where ? `"${where}" has` : "The manifest has"} ${keys.length === 1 ? "a field" : "fields"} the loader does not accept: ${keys.map((k) => `"${k}"`).join(", ")}.` : `${where ? `"${where}": ` : ""}${issue.message}.`;
622
+ const path = [...issue.path, ...keys?.[0] ? [keys[0]] : []].join("/");
623
+ problem(
624
+ "manifest-schema",
625
+ text,
626
+ REFUSED,
627
+ lines2.get(path) ?? lines2.get(issue.path.join("/"))
628
+ );
629
+ }
630
+ } else {
631
+ const text = message(error);
632
+ const at = /line (\d+)/.exec(text);
633
+ const position = /position (\d+)/.exec(text);
634
+ const line = at ? Number(at[1]) : position ? read.text.slice(0, Number(position[1])).split("\n").length : void 0;
635
+ problem("manifest-json", `${MANIFEST_FILE} is not valid JSON: ${text}.`, REFUSED, line);
636
+ }
637
+ return void 0;
638
+ }
639
+ try {
640
+ assertEnableable(parsed, { skillsSupported: true });
641
+ } catch (error) {
642
+ problem("manifest-incompatible", plainReason(message(error)));
643
+ }
644
+ const lines = jsonLines(read.text);
645
+ let raw;
646
+ try {
647
+ raw = JSON.parse(read.text);
648
+ } catch {
649
+ raw = void 0;
650
+ }
651
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
652
+ const known = new Set(Object.keys(PluginManifestSchema.shape));
653
+ for (const key of Object.keys(raw)) {
654
+ if (known.has(key)) continue;
655
+ problem(
656
+ "manifest-unknown-key",
657
+ `"${key}" is not a field Namzu reads in a manifest, so it is ignored. If it is a misspelling, the part it was meant to declare is missing.`,
658
+ "The loader drops the field without a word.",
659
+ lines.get(key),
660
+ "warning"
661
+ );
662
+ }
663
+ }
664
+ if (!/^\d+\.\d+\.\d+([-+].*)?$/.test(parsed.version)) {
665
+ problem(
666
+ "manifest-version-format",
667
+ `"version" is "${parsed.version}", which is not a semantic version such as 1.0.0.`,
668
+ "The loader accepts any text; tools that compare versions will not.",
669
+ lines.get("version"),
670
+ "warning"
671
+ );
672
+ }
673
+ const contributes = (parsed.tools?.length ?? 0) + (parsed.skills?.length ?? 0) + (parsed.hooks?.length ?? 0) + Object.keys(parsed.hookEntries ?? {}).length + (existsSync(join(root, CONVENTIONAL_HOOKS_FILE)) ? 1 : 0) + (parsed.mcpServers?.length ?? 0) + (parsed.commands?.length ?? 0) + (parsed.agents?.length ?? 0) + (parsed.instructions ? 1 : 0);
674
+ if (contributes === 0) {
675
+ problem(
676
+ "manifest-empty",
677
+ "The plugin declares no tools, skills, hooks, MCP servers, commands, agents or instructions, so it adds nothing.",
678
+ "It loads and does nothing.",
679
+ void 0,
680
+ "warning"
681
+ );
682
+ }
683
+ return parsed;
684
+ }
685
+ __name(checkManifest, "checkManifest");
686
+ async function checkParts(root, manifest, c) {
687
+ const pluginName = manifest.name;
688
+ for (const [kind, list] of [
689
+ ["tool", manifest.tools],
690
+ ["hook", manifest.hooks]
691
+ ]) {
692
+ const seen = /* @__PURE__ */ new Set();
693
+ for (const [index, rel] of (list ?? []).entries()) {
694
+ const part = c.part(kind, rel, rel);
695
+ const key = `${kind === "tool" ? "tools" : "hooks"}/${index}`;
696
+ if (seen.has(rel)) {
697
+ c.add({
698
+ level: "warning",
699
+ part,
700
+ file: MANIFEST_FILE,
701
+ code: "part-duplicate",
702
+ message: `"${rel}" is listed twice in "${kind === "tool" ? "tools" : "hooks"}".`,
703
+ consequence: "The module is imported once, but its tools or hooks are registered twice."
704
+ });
705
+ }
706
+ seen.add(rel);
707
+ if (kind === "hook" && isHookEntriesPath(rel)) continue;
708
+ await checkModule(root, kind, rel, part, key, c);
709
+ }
710
+ }
711
+ checkHookEntries(root, manifest, c);
712
+ const skillNames = /* @__PURE__ */ new Set();
713
+ for (const rel of manifest.skills ?? []) {
714
+ const part = c.part("skill", rel, rel);
715
+ await checkSkill(root, rel, part, skillNames, c);
716
+ }
717
+ checkMcpServers(root, manifest, c);
718
+ const commandNames = /* @__PURE__ */ new Map();
719
+ for (const rel of manifest.commands ?? []) {
720
+ await checkFolder(root, rel, "commands", pluginName, c, async (file, text, abs) => {
721
+ const base = file.slice(0, -".md".length);
722
+ const name = `${pluginName}__${base}`;
723
+ const rel2 = posix(relative(root, abs));
724
+ const part = c.part("command", name, rel2);
725
+ const prior = commandNames.get(name);
726
+ if (prior !== void 0) {
727
+ c.add({
728
+ level: "warning",
729
+ part,
730
+ file: rel2,
731
+ code: "command-duplicate",
732
+ message: `/${name} is also written by ${prior}.`,
733
+ consequence: "The file read last replaces the other."
734
+ });
735
+ }
736
+ commandNames.set(name, rel2);
737
+ if (/\s/.test(base)) {
738
+ c.add({
739
+ level: "warning",
740
+ part,
741
+ file: rel2,
742
+ code: "command-name",
743
+ message: `The file name "${file}" has a space, so "/${name}" cannot be typed as one word.`,
744
+ consequence: "The command is listed but cannot be run by name."
745
+ });
746
+ }
747
+ const command = parseCommandText(text, abs, name, "plugin");
748
+ if (command.problem) {
749
+ c.add({
750
+ level: "error",
751
+ part,
752
+ file: rel2,
753
+ line: lineForReason(text, command.problem),
754
+ code: "command-invalid",
755
+ message: `The command file ${plainReason(command.problem, abs)}.`,
756
+ consequence: "The command is listed with this reason and cannot be used."
757
+ });
758
+ return;
759
+ }
760
+ if (command.template.trim() === "") {
761
+ c.add({
762
+ level: "warning",
763
+ part,
764
+ file: rel2,
765
+ code: "command-empty",
766
+ message: "The file has no prompt text after its frontmatter.",
767
+ consequence: "The command sends an empty prompt."
768
+ });
769
+ }
770
+ unknownKeys(text, COMMAND_FILE_KEYS, part, rel2, "command-unknown-key", c, "a command file");
771
+ });
772
+ }
773
+ const agentNames = /* @__PURE__ */ new Map();
774
+ for (const rel of manifest.agents ?? []) {
775
+ await checkFolder(root, rel, "agents", pluginName, c, async (file, text, abs) => {
776
+ const rel2 = posix(relative(root, abs));
777
+ const fallback = `${pluginName}__${file.slice(0, -".md".length)}`;
778
+ const found = parseAgentMarkdown(
779
+ text,
780
+ abs,
781
+ "plugin",
782
+ void 0,
783
+ /* @__PURE__ */ new Set([...PERMISSION_MODE_NAMES, "inherit"])
784
+ );
785
+ const part = c.part(
786
+ "agent",
787
+ "reason" in found ? fallback : `${pluginName}__${found.name}`,
788
+ rel2
789
+ );
790
+ if ("reason" in found) {
791
+ c.add({
792
+ level: "error",
793
+ part,
794
+ file: rel2,
795
+ line: lineForReason(text, found.reason),
796
+ code: "agent-invalid",
797
+ message: `The agent file ${plainReason(found.reason, abs)}.`,
798
+ consequence: "The file is skipped and named in the log; the other agents load."
799
+ });
800
+ return;
801
+ }
802
+ const full = `${pluginName}__${found.name}`;
803
+ const prior = agentNames.get(full);
804
+ if (prior !== void 0) {
805
+ c.add({
806
+ level: "warning",
807
+ part,
808
+ file: rel2,
809
+ code: "agent-duplicate",
810
+ message: `The agent "${full}" is also defined by ${prior}.`,
811
+ consequence: "The file read last replaces the other."
812
+ });
813
+ }
814
+ agentNames.set(full, rel2);
815
+ unknownKeys(text, AGENT_FILE_KEYS, part, rel2, "agent-unknown-key", c, "an agent file");
816
+ if (found.hooksSource !== void 0) {
817
+ const hooks = readAgentHooks(found.hooksSource, full);
818
+ for (const problem of hooks.problems) {
819
+ c.add({
820
+ // An entry that would have guarded something and cannot be loaded keeps the agent from being offered.
821
+ level: problem.severity === "problem" ? "error" : "warning",
822
+ part,
823
+ file: rel2,
824
+ line: lineOfKey(text, "hooks"),
825
+ code: "agent-hooks-problem",
826
+ message: `"${full}" hooks, ${problem.event}: ${problem.message}`,
827
+ consequence: problem.severity === "problem" ? "The agent is not offered, and starting it is refused with this line." : "The agent runs with this part of its hooks left out."
828
+ });
829
+ }
830
+ }
831
+ });
832
+ }
833
+ }
834
+ __name(checkParts, "checkParts");
835
+ function unknownKeys(text, known, part, file, code, c, what) {
836
+ for (const { key, line } of frontmatterKeys(text)) {
837
+ if (known.includes(key)) continue;
838
+ c.add({
839
+ level: "warning",
840
+ part,
841
+ file,
842
+ line,
843
+ code,
844
+ message: `"${key}" is not a key ${what} reads, so it is ignored. If it is a misspelling, what it was meant to set is not set.`,
845
+ consequence: "The loader drops the key without a word."
846
+ });
847
+ }
848
+ }
849
+ __name(unknownKeys, "unknownKeys");
850
+ function readProblem(read, what, rel) {
851
+ switch (read.kind) {
852
+ case "outside":
853
+ return {
854
+ code: "path-outside",
855
+ text: `${what} "${rel}" leaves the plugin folder, so it is not followed.`
856
+ };
857
+ case "missing":
858
+ return { code: "path-missing", text: `${what} "${rel}" does not exist.` };
859
+ case "not-file":
860
+ return {
861
+ code: "path-not-file",
862
+ text: `${what} "${rel}" is not a regular file.`
863
+ };
864
+ case "too-large":
865
+ return {
866
+ code: "file-too-large",
867
+ text: `${what} "${rel}" is ${read.detail ?? "very large"}, over the ${MAX_CHECKED_FILE_BYTES} bytes this check reads, so it was not read.`
868
+ };
869
+ case "binary":
870
+ return {
871
+ code: "file-binary",
872
+ text: `${what} "${rel}" is not a text file.`
873
+ };
874
+ default:
875
+ return {
876
+ code: "file-unreadable",
877
+ text: `${what} "${rel}" could not be read${read.detail ? `: ${read.detail}` : "."}`
878
+ };
879
+ }
880
+ }
881
+ __name(readProblem, "readProblem");
882
+ var MARKDOWN_LOOKALIKE = /\.(md|markdown|mdown|mkd|mdx)$/i;
883
+ var MODULE_EXTENSIONS = [".js", ".mjs", ".cjs"];
884
+ function checkHookEntries(root, manifest, c) {
885
+ const read = readPluginHookEntriesOf({ rootDir: root, manifest });
886
+ for (const file of read.files) {
887
+ c.part(
888
+ "hook",
889
+ file === "plugin.json hookEntries" ? "hookEntries" : file,
890
+ file === "plugin.json hookEntries" ? MANIFEST_FILE : file
891
+ );
892
+ }
893
+ for (const problem of read.problems) {
894
+ const inline = problem.file === "plugin.json hookEntries";
895
+ const file = inline ? MANIFEST_FILE : problem.file;
896
+ c.add({
897
+ level: problem.severity === "problem" ? "error" : "warning",
898
+ part: c.part("hook", inline ? "hookEntries" : problem.file, file),
899
+ file,
900
+ code: problem.code,
901
+ message: problem.message,
902
+ consequence: problem.severity === "problem" ? "These hook entries are not attached (the plugin itself still loads), so what they were meant to guard is not checked." : "The hook entries load without it."
903
+ });
904
+ }
905
+ }
906
+ __name(checkHookEntries, "checkHookEntries");
907
+ async function checkModule(root, kind, rel, part, _key, c) {
908
+ const what = kind === "tool" ? "The tool module" : "The hook module";
909
+ const read = await readInside(root, rel);
910
+ if (!read.ok) {
911
+ const { code, text } = readProblem(read, what, rel);
912
+ const scanOnly = read.kind === "too-large";
913
+ c.add({
914
+ level: scanOnly ? "warning" : "error",
915
+ part,
916
+ file: MANIFEST_FILE,
917
+ code,
918
+ message: text,
919
+ consequence: scanOnly ? "The module is not scanned; whether it loads is decided when it is imported." : REFUSED
920
+ });
921
+ return;
922
+ }
923
+ const file = posix(relative(root, read.abs));
924
+ if (!MODULE_EXTENSIONS.some((ext) => read.abs.endsWith(ext))) {
925
+ c.add({
926
+ level: "warning",
927
+ part,
928
+ file,
929
+ code: "module-extension",
930
+ message: `${what} "${rel}" does not end in .js, .mjs or .cjs. Namzu imports it with Node, which loads only those with certainty.`,
931
+ consequence: "The import may fail, and then the loader refuses the whole plugin."
932
+ });
933
+ }
934
+ const exportName = kind === "tool" ? "tools" : "hooks";
935
+ if (!new RegExp(`\\b${exportName}\\b`).test(read.text)) {
936
+ c.add({
937
+ level: "warning",
938
+ part,
939
+ file,
940
+ code: "module-export",
941
+ message: `The text of ${what.toLowerCase()} "${rel}" never mentions "${exportName}". The loader needs the module to export a "${exportName}" array. ${FILE_NOTE}`,
942
+ consequence: REFUSED
943
+ });
944
+ }
945
+ if (kind === "hook") {
946
+ const seen = /* @__PURE__ */ new Set();
947
+ for (const match of withoutComments(read.text).matchAll(
948
+ /\bevent\s*:\s*(['"`])([A-Za-z0-9_]+)\1/g
949
+ )) {
950
+ const event = match[2];
951
+ if (seen.has(event)) continue;
952
+ seen.add(event);
953
+ try {
954
+ assertPluginHookEvent(event);
955
+ } catch (error) {
956
+ const renamed = RENAMED_PLUGIN_HOOK_EVENTS[event];
957
+ c.add({
958
+ level: "warning",
959
+ part,
960
+ file,
961
+ line: read.text.slice(0, match.index).split("\n").length,
962
+ code: "hook-event-unknown",
963
+ message: renamed ? `The hook event "${event}" was renamed to "${renamed}", so a hook written under the old name cannot be registered.` : `"${event}" is not a hook event Namzu has, so a hook written for it cannot be registered.`,
964
+ consequence: `Found by reading the text, not by running it. If the module really registers it, the loader refuses the whole plugin (${plainReason(message(error))}).`
965
+ });
966
+ }
967
+ }
968
+ }
969
+ }
970
+ __name(checkModule, "checkModule");
971
+ function withoutComments(text) {
972
+ return text.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, " ")).replace(/(^|[^:'"`\\])\/\/[^\n]*/gm, (_m, lead) => lead);
973
+ }
974
+ __name(withoutComments, "withoutComments");
975
+ async function checkSkill(root, rel, part, names, c) {
976
+ let dir;
977
+ try {
978
+ dir = await resolveWithinReal(root, rel);
979
+ } catch {
980
+ c.add({
981
+ level: "error",
982
+ part,
983
+ file: MANIFEST_FILE,
984
+ code: "path-outside",
985
+ message: `The skill folder "${rel}" leaves the plugin folder, so it is not followed.`,
986
+ consequence: REFUSED
987
+ });
988
+ return;
989
+ }
990
+ let isDir = false;
991
+ try {
992
+ isDir = (await stat(dir)).isDirectory();
993
+ } catch {
994
+ isDir = false;
995
+ }
996
+ if (!isDir) {
997
+ c.add({
998
+ level: "error",
999
+ part,
1000
+ file: MANIFEST_FILE,
1001
+ code: "path-missing",
1002
+ message: `The skill folder "${rel}" does not exist or is not a folder.`,
1003
+ consequence: REFUSED
1004
+ });
1005
+ return;
1006
+ }
1007
+ const skillFile = posix(join(relative(root, dir), "SKILL.md"));
1008
+ const read = await readInside(root, skillFile);
1009
+ if (!read.ok) {
1010
+ if (read.kind === "outside") {
1011
+ c.add({
1012
+ level: "warning",
1013
+ part,
1014
+ file: skillFile,
1015
+ code: "path-outside",
1016
+ message: `SKILL.md in "${rel}" is a link to a file outside the plugin folder, so it is not followed and was not checked.`,
1017
+ consequence: "The loader reads it through the link, so what it holds is up to whatever is there."
1018
+ });
1019
+ return;
1020
+ }
1021
+ const { code, text } = readProblem(read, "The skill file", skillFile);
1022
+ c.add({
1023
+ // Too large to read here, but the loader reads any size: not read is not refused.
1024
+ level: read.kind === "too-large" ? "warning" : "error",
1025
+ part,
1026
+ file: skillFile,
1027
+ code: read.kind === "missing" ? "path-missing" : code,
1028
+ message: read.kind === "missing" ? `"${rel}" has no SKILL.md.` : text,
1029
+ consequence: read.kind === "too-large" ? "The loader reads it whatever its size." : REFUSED
1030
+ });
1031
+ return;
1032
+ }
1033
+ let skill;
1034
+ try {
1035
+ skill = parseSkillMarkdown(read.text, dir);
1036
+ } catch (error) {
1037
+ const reason = message(error);
1038
+ c.add({
1039
+ level: "error",
1040
+ part,
1041
+ file: skillFile,
1042
+ line: lineForReason(read.text, reason),
1043
+ code: "skill-invalid",
1044
+ message: `The skill file ${plainReason(reason, `SKILL.md at "${dir}": `, `SKILL.md at "${dir}"`)}.`,
1045
+ consequence: REFUSED
1046
+ });
1047
+ return;
1048
+ }
1049
+ const full = skill.metadata.name;
1050
+ if (names.has(full)) {
1051
+ c.add({
1052
+ level: "error",
1053
+ part,
1054
+ file: skillFile,
1055
+ code: "skill-duplicate",
1056
+ message: `Two declared skills are named "${full}".`,
1057
+ consequence: REFUSED
1058
+ });
1059
+ }
1060
+ names.add(full);
1061
+ const model = skillModelDescription(skill.metadata).length;
1062
+ const entry = model + full.length + dir.length + 90;
1063
+ if (entry > SKILL_MANIFEST_MAX_CHARS / 4) {
1064
+ c.add({
1065
+ level: "warning",
1066
+ part,
1067
+ file: skillFile,
1068
+ code: "skill-description-large",
1069
+ message: `The description and when_to_use of "${full}" take ${model} characters; with its name and place they use about ${entry} of the ${SKILL_MANIFEST_MAX_CHARS} the list of skills may use.`,
1070
+ consequence: "Skills after it can be left out of the list the model sees (they stay loadable by name)."
1071
+ });
1072
+ }
1073
+ if (skill.body.trim() === "") {
1074
+ c.add({
1075
+ level: "warning",
1076
+ part,
1077
+ file: skillFile,
1078
+ code: "skill-body-empty",
1079
+ message: `"${full}" has no instructions after its frontmatter.`,
1080
+ consequence: "It loads and gives the model nothing to follow."
1081
+ });
1082
+ }
1083
+ unknownKeys(read.text, SKILL_FRONTMATTER_KEYS, part, skillFile, "skill-unknown-key", c, "a skill");
1084
+ if (skill.metadata.hooksSource !== void 0) {
1085
+ const hooks = readSkillHooks(skill.metadata.hooksSource, `skill ${full}`);
1086
+ for (const problem of hooks.problems) {
1087
+ c.add({
1088
+ level: "warning",
1089
+ part,
1090
+ file: skillFile,
1091
+ line: lineOfKey(read.text, "hooks"),
1092
+ code: "skill-hooks-problem",
1093
+ message: `"${full}" hooks, ${problem.event}: ${problem.message}`,
1094
+ consequence: problem.severity === "problem" ? "The skill loads without any of its hooks and without its allowed-tools pre-approval, and says so." : "The skill is used with this part of its hooks left out."
1095
+ });
1096
+ }
1097
+ }
1098
+ }
1099
+ __name(checkSkill, "checkSkill");
1100
+ function lineOfKey(text, key) {
1101
+ return frontmatterKeys(text).find((found) => found.key === key)?.line;
1102
+ }
1103
+ __name(lineOfKey, "lineOfKey");
1104
+ function leavesFolder(root, value) {
1105
+ if (value.startsWith("~")) return true;
1106
+ if (isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value)) {
1107
+ const rel = relative(root, value);
1108
+ return rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel);
1109
+ }
1110
+ return value.split(/[\\/]/).includes("..");
1111
+ }
1112
+ __name(leavesFolder, "leavesFolder");
1113
+ function checkMcpServers(root, manifest, c) {
1114
+ const names = /* @__PURE__ */ new Set();
1115
+ for (const server of manifest.mcpServers ?? []) {
1116
+ const part = c.part("mcp-server", server.name, MANIFEST_FILE);
1117
+ if (names.has(server.name)) {
1118
+ c.add({
1119
+ level: "warning",
1120
+ part,
1121
+ file: MANIFEST_FILE,
1122
+ code: "mcp-duplicate-server",
1123
+ message: `Two MCP servers are named "${server.name}".`,
1124
+ consequence: "Both start, and their tool names collide."
1125
+ });
1126
+ }
1127
+ names.add(server.name);
1128
+ if (server.command.includes("/") || server.command.includes("\\")) {
1129
+ if (leavesFolder(root, server.command)) {
1130
+ c.add({
1131
+ level: "warning",
1132
+ part,
1133
+ file: MANIFEST_FILE,
1134
+ code: "mcp-command-outside",
1135
+ message: `The command "${server.command}" of "${server.name}" points outside the plugin folder. It was not run and not looked at.`,
1136
+ consequence: "It starts whatever is there on the machine that loads the plugin."
1137
+ });
1138
+ }
1139
+ }
1140
+ for (const arg of server.args ?? []) {
1141
+ if (/^(\/|[a-zA-Z]:[\\/]|\.\.?[\\/]|~)/.test(arg) && leavesFolder(root, arg)) {
1142
+ c.add({
1143
+ level: "warning",
1144
+ part,
1145
+ file: MANIFEST_FILE,
1146
+ code: "mcp-arg-outside",
1147
+ message: `The argument "${arg}" of "${server.name}" points outside the plugin folder.`,
1148
+ consequence: "The server is started with it as written."
1149
+ });
1150
+ }
1151
+ }
1152
+ }
1153
+ }
1154
+ __name(checkMcpServers, "checkMcpServers");
1155
+ async function checkFolder(root, rel, field, pluginName, c, each) {
1156
+ const resolved = resolvePluginFileDir(root, rel);
1157
+ const part = c.part(field === "commands" ? "command" : "agent", `${field}:${rel}`, rel);
1158
+ const dropPlaceholder = /* @__PURE__ */ __name(() => {
1159
+ const at = c.parts.findIndex((p) => p.id === part);
1160
+ if (at !== -1 && !c.problems.some((p) => p.part === part)) c.parts.splice(at, 1);
1161
+ }, "dropPlaceholder");
1162
+ if (resolved.kind !== "inside") {
1163
+ c.add({
1164
+ level: "error",
1165
+ part,
1166
+ file: MANIFEST_FILE,
1167
+ code: resolved.kind === "outside" ? "path-outside" : "path-missing",
1168
+ message: resolved.kind === "outside" ? `The ${field} folder "${rel}" leads outside the plugin folder, so it is not followed.` : `The ${field} folder "${rel}" was not found.`,
1169
+ consequence: `The folder is skipped and named in the log; the plugin's other parts load.`
1170
+ });
1171
+ return;
1172
+ }
1173
+ let entries;
1174
+ let passedOver = [];
1175
+ try {
1176
+ const all = await readdir(resolved.dir, { withFileTypes: true });
1177
+ entries = all.filter((e) => e.name.endsWith(".md"));
1178
+ passedOver = all.filter(
1179
+ (e) => !e.isDirectory() && !e.name.endsWith(".md") && MARKDOWN_LOOKALIKE.test(e.name)
1180
+ );
1181
+ } catch (error) {
1182
+ c.add({
1183
+ level: "error",
1184
+ part,
1185
+ file: MANIFEST_FILE,
1186
+ code: "file-unreadable",
1187
+ message: `The ${field} folder "${rel}" could not be read: ${message(error)}`,
1188
+ consequence: "The folder is skipped."
1189
+ });
1190
+ return;
1191
+ }
1192
+ entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
1193
+ passedOver.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
1194
+ for (const entry of passedOver.slice(0, MAX_CHECKED_FILES_PER_FOLDER)) {
1195
+ const rel2 = posix(relative(root, join(resolved.dir, entry.name)));
1196
+ c.add({
1197
+ level: "warning",
1198
+ part,
1199
+ file: rel2,
1200
+ code: "file-ignored",
1201
+ message: `"${entry.name}" looks like a markdown file, but only names ending in lowercase ".md" are read, so it is not.`,
1202
+ consequence: `The loader passes it over without a word; rename it to end in ".md" to use it as ${field === "commands" ? "a command" : "an agent"}.`
1203
+ });
1204
+ }
1205
+ if (entries.length > MAX_CHECKED_FILES_PER_FOLDER) {
1206
+ c.add({
1207
+ level: "warning",
1208
+ part,
1209
+ file: rel,
1210
+ code: "entries-truncated",
1211
+ message: `The folder "${rel}" holds ${entries.length} markdown files; only the first ${MAX_CHECKED_FILES_PER_FOLDER} were checked.`,
1212
+ consequence: "The loader reads them all."
1213
+ });
1214
+ entries = entries.slice(0, MAX_CHECKED_FILES_PER_FOLDER);
1215
+ }
1216
+ for (const entry of entries) {
1217
+ const file = entry.name;
1218
+ const abs = join(resolved.dir, file);
1219
+ const rel2 = posix(relative(root, abs));
1220
+ if (!entry.isFile()) {
1221
+ c.add({
1222
+ level: "warning",
1223
+ part,
1224
+ file: rel2,
1225
+ code: "file-ignored",
1226
+ message: `"${file}" is a link or a folder, not a regular file, so it is not read.`,
1227
+ consequence: "The loader passes it over without a word."
1228
+ });
1229
+ continue;
1230
+ }
1231
+ const read = await readInside(root, rel2);
1232
+ if (!read.ok) {
1233
+ const { code, text } = readProblem(
1234
+ read,
1235
+ field === "commands" ? "The command file" : "The agent file",
1236
+ rel2
1237
+ );
1238
+ c.add({
1239
+ level: read.kind === "too-large" && field === "commands" ? "warning" : "error",
1240
+ part: c.part(
1241
+ field === "commands" ? "command" : "agent",
1242
+ `${pluginName}__${file.slice(0, -".md".length)}`,
1243
+ rel2
1244
+ ),
1245
+ file: rel2,
1246
+ code,
1247
+ message: text,
1248
+ consequence: field === "commands" ? "The command cannot be used." : "The file is skipped and named in the log."
1249
+ });
1250
+ continue;
1251
+ }
1252
+ await each(file, read.text, read.abs);
1253
+ }
1254
+ dropPlaceholder();
1255
+ }
1256
+ __name(checkFolder, "checkFolder");
1257
+
1258
+ // src/commands/plugin-install.ts
1259
+ import { existsSync as existsSync2, lstatSync, readFileSync } from "node:fs";
1260
+ import { join as join2, resolve } from "node:path";
1261
+ var PLUGIN_INSTALL_VERBS = ["install", "uninstall", "update", "prune"];
1262
+ var MARKETPLACE_VERBS = ["add", "list", "remove", "update"];
1263
+ var PLUGIN_INSTALL_HELP = [
1264
+ "Install from a folder, a file, a Git repository or an https address:",
1265
+ " namzu plugin marketplace add <owner/repo|https://...|folder|file.json> [--ref <ref>] [--sparse <path>...]",
1266
+ " [--scope user|project|local] [--dry-run] [--yes] [--json]",
1267
+ " namzu plugin marketplace list [--json]",
1268
+ " namzu plugin marketplace update [<name>] [--json]",
1269
+ " namzu plugin marketplace remove <name> [--yes] [--json]",
1270
+ " namzu plugin install <name>@<marketplace> | <folder> | <file.zip|file.plugin>",
1271
+ " [--scope user|project|local] [--dry-run] [--enable-loading]",
1272
+ " [--yes | --accept-surface <sha256>] [--json]",
1273
+ " namzu plugin update <id> [--yes | --accept-surface <sha256>] [--json]",
1274
+ " namzu plugin uninstall <id> [--scope user|project|local] [--delete-data] [--yes] [--json]",
1275
+ " namzu plugin prune [--dry-run] [--yes]",
1276
+ "",
1277
+ "install Copies the plugin aside, shows everything in it that runs, and installs it only after",
1278
+ " you say yes. --yes accepts what is shown; --accept-surface accepts only the surface",
1279
+ " whose digest you pass. With no terminal and neither flag it prints the preview and exits 75.",
1280
+ "update Reads the plugin again from where it came from (a download for a remote one) and shows",
1281
+ " what changed in what runs. marketplace update only refreshes the list of plugins.",
1282
+ "uninstall Removes the install. The plugin\u2019s data is kept unless --delete-data.",
1283
+ "prune Removes copies no record names, and leftovers of installs that did not finish."
1284
+ ].join("\n");
1285
+ var BOOLEAN_FLAGS = {
1286
+ "--json": "json",
1287
+ "--yes": "yes",
1288
+ "--dry-run": "dryRun",
1289
+ "--enable-loading": "enableLoading",
1290
+ "--delete-data": "deleteData"
1291
+ };
1292
+ function parseFlags(args) {
1293
+ const flags = {
1294
+ json: false,
1295
+ yes: false,
1296
+ dryRun: false,
1297
+ enableLoading: false,
1298
+ deleteData: false,
1299
+ sparse: [],
1300
+ positional: []
1301
+ };
1302
+ const bad = /* @__PURE__ */ __name((message2) => ({ ...flags, error: message2 }), "bad");
1303
+ for (let i = 0; i < args.length; i++) {
1304
+ const arg = args[i];
1305
+ const [name, inline] = arg.startsWith("--") && arg.includes("=") ? splitOnce(arg) : [arg, void 0];
1306
+ const flag = BOOLEAN_FLAGS[name];
1307
+ if (flag !== void 0) {
1308
+ if (inline !== void 0) return bad(`${name} takes no value.`);
1309
+ flags[flag] = true;
1310
+ } else if (name === "--scope") {
1311
+ const v = inline ?? args[++i];
1312
+ if (v !== "user" && v !== "project" && v !== "local")
1313
+ return bad("--scope is user, project or local.");
1314
+ flags.scope = v;
1315
+ } else if (name === "--cwd") {
1316
+ const v = inline ?? args[++i];
1317
+ if (v === void 0 || v === "") return bad("--cwd needs a folder.");
1318
+ flags.cwd = v;
1319
+ } else if (name === "--ref") {
1320
+ const v = inline ?? args[++i];
1321
+ if (v === void 0 || v === "" || v.startsWith("-"))
1322
+ return bad("--ref needs a branch, tag or commit.");
1323
+ flags.ref = v;
1324
+ } else if (name === "--sparse") {
1325
+ const first = inline ?? args[++i];
1326
+ if (first === void 0 || first === "" || first.startsWith("-"))
1327
+ return bad("--sparse needs one or more folders of the repository.");
1328
+ flags.sparse.push(first);
1329
+ while (inline === void 0 && i + 1 < args.length && !args[i + 1].startsWith("-"))
1330
+ flags.sparse.push(args[++i]);
1331
+ } else if (name === "--accept-surface") {
1332
+ const v = inline ?? args[++i];
1333
+ if (v === void 0 || v === "")
1334
+ return bad("--accept-surface needs the digest that was shown.");
1335
+ flags.acceptSurface = v.replace(/^sha256:/i, "").toLowerCase();
1336
+ } else if (arg.startsWith("-") && arg !== "-") return bad(`unknown option: ${arg}`);
1337
+ else flags.positional.push(arg);
1338
+ }
1339
+ if (flags.yes && flags.acceptSurface !== void 0)
1340
+ return bad("--yes and --accept-surface conflict: use one.");
1341
+ return flags;
1342
+ }
1343
+ __name(parseFlags, "parseFlags");
1344
+ function splitOnce(arg) {
1345
+ const at = arg.indexOf("=");
1346
+ return [arg.slice(0, at), arg.slice(at + 1)];
1347
+ }
1348
+ __name(splitOnce, "splitOnce");
1349
+ function contextOf(deps, flags) {
1350
+ const cwd = resolve(deps.cwd(), flags.cwd ?? ".");
1351
+ return { cwd: realPathOrResolved(cwd), trusted: deps.isTrusted(cwd) };
1352
+ }
1353
+ __name(contextOf, "contextOf");
1354
+ var UNTRUSTED = "This folder is not trusted yet. Open it with namzu once, or use --scope user.";
1355
+ function scopeLine(scope) {
1356
+ return scope === "user" ? "scope: user (every folder on this computer)" : scope === "project" ? "scope: project (this folder, shared in .namzu/settings.json)" : "scope: local (this folder, only on this computer)";
1357
+ }
1358
+ __name(scopeLine, "scopeLine");
1359
+ function sayJson(deps, value) {
1360
+ deps.out(`${JSON.stringify(value)}
1361
+ `);
1362
+ }
1363
+ __name(sayJson, "sayJson");
1364
+ function show(deps, json, text) {
1365
+ if (json) deps.err(`${text}
1366
+ `);
1367
+ else deps.out(`${text}
1368
+ `);
1369
+ }
1370
+ __name(show, "show");
1371
+ function declined(deps, json, command, code, message2, extra = {}) {
1372
+ if (json) sayJson(deps, { command, outcome: "declined", message: message2, ...extra });
1373
+ else deps.err(`${message2}
1374
+ `);
1375
+ return code;
1376
+ }
1377
+ __name(declined, "declined");
1378
+ function describeError(error) {
1379
+ if (error instanceof SimulatedCrash) throw error;
1380
+ if (error instanceof PlanRefusal) return { code: error.code, message: error.message };
1381
+ if (error instanceof FetchError) return { code: error.code, message: error.message };
1382
+ if (error instanceof InstallConflict) return { code: error.code, message: error.message };
1383
+ return stateFailure(error);
1384
+ }
1385
+ __name(describeError, "describeError");
1386
+ async function consentFor(deps, flags, input) {
1387
+ if (flags.yes) {
1388
+ if (!flags.json) deps.err(`${input.preview}
1389
+ `);
1390
+ return { ok: true };
1391
+ }
1392
+ if (flags.acceptSurface !== void 0) {
1393
+ if (flags.acceptSurface !== input.digest)
1394
+ return {
1395
+ ok: false,
1396
+ code: declined(
1397
+ deps,
1398
+ flags.json,
1399
+ input.command,
1400
+ EXIT_NEEDS_CONSENT,
1401
+ "What this plugin does changed since you read it. Read it again with --dry-run.",
1402
+ input.extra
1403
+ )
1404
+ };
1405
+ if (input.needsYes !== void 0)
1406
+ return {
1407
+ ok: false,
1408
+ code: declined(
1409
+ deps,
1410
+ flags.json,
1411
+ input.command,
1412
+ EXIT_NEEDS_CONSENT,
1413
+ `${input.needsYes} Add --yes to confirm.`,
1414
+ input.extra
1415
+ )
1416
+ };
1417
+ return { ok: true };
1418
+ }
1419
+ show(deps, flags.json, input.preview);
1420
+ if (!deps.interactive)
1421
+ return {
1422
+ ok: false,
1423
+ code: declined(
1424
+ deps,
1425
+ flags.json,
1426
+ input.command,
1427
+ EXIT_NEEDS_CONSENT,
1428
+ "Nothing was changed: this runs code, and there is no terminal to ask on. Run it again with --yes, or with --accept-surface <sha256> using the digest above.",
1429
+ input.extra
1430
+ )
1431
+ };
1432
+ if (input.needsYes !== void 0) show(deps, flags.json, input.needsYes);
1433
+ if (await deps.ask(input.question)) return { ok: true };
1434
+ return {
1435
+ ok: false,
1436
+ code: declined(deps, flags.json, input.command, EXIT_FAIL, input.declinedMessage, input.extra)
1437
+ };
1438
+ }
1439
+ __name(consentFor, "consentFor");
1440
+ function looksLikePath(arg) {
1441
+ return /[\\/]/.test(arg) || arg.startsWith(".") || arg.startsWith("~") || /\.(zip|plugin)$/i.test(arg);
1442
+ }
1443
+ __name(looksLikePath, "looksLikePath");
1444
+ function expandHome(path) {
1445
+ if (path === "~" || /^~[\\/]/.test(path))
1446
+ return join2(process.env.HOME ?? process.env.USERPROFILE ?? "", path.slice(1));
1447
+ return path;
1448
+ }
1449
+ __name(expandHome, "expandHome");
1450
+ function readKnown(deps) {
1451
+ const known = readKnownMarketplaces(deps.namzuHome);
1452
+ return known;
1453
+ }
1454
+ __name(readKnown, "readKnown");
1455
+ function catalogOf(known) {
1456
+ const kind = known.source.source === "file" ? "file" : "directory";
1457
+ return readCatalog(known.installLocation, kind);
1458
+ }
1459
+ __name(catalogOf, "catalogOf");
1460
+ async function sourceFor(deps, flags, command, arg) {
1461
+ if (looksLikePath(arg)) return { kind: "path", path: resolve(deps.cwd(), expandHome(arg)) };
1462
+ const known = readKnown(deps);
1463
+ if (known.state === "unreadable")
1464
+ return failure(
1465
+ deps,
1466
+ flags.json,
1467
+ command,
1468
+ EXIT_NOINPUT,
1469
+ `The marketplace list could not be read, so nothing was changed (${known.reason}).`
1470
+ );
1471
+ let wanted;
1472
+ let from;
1473
+ if (isPluginId(arg)) {
1474
+ const parts = splitPluginId(arg);
1475
+ wanted = parts.name;
1476
+ from = parts.marketplace;
1477
+ } else if (arg.includes("@"))
1478
+ return failure(
1479
+ deps,
1480
+ flags.json,
1481
+ command,
1482
+ EXIT_USAGE,
1483
+ `"${arg}" is not a plugin id (name@marketplace).`
1484
+ );
1485
+ else wanted = arg;
1486
+ if (from === LOCAL_UPLOADS_MARKETPLACE)
1487
+ return failure(
1488
+ deps,
1489
+ flags.json,
1490
+ command,
1491
+ EXIT_USAGE,
1492
+ `${LOCAL_UPLOADS_MARKETPLACE} holds plugins installed from a file or folder. Give the folder or file to install it again.`
1493
+ );
1494
+ const found = [];
1495
+ if (from !== void 0) {
1496
+ const market2 = known.marketplaces.get(from);
1497
+ if (market2 === void 0)
1498
+ return failure(
1499
+ deps,
1500
+ flags.json,
1501
+ command,
1502
+ EXIT_NOINPUT,
1503
+ `Marketplace "${from}" is not added. Add it first: namzu plugin marketplace add <folder|file.json>`
1504
+ );
1505
+ const read = catalogOf(market2);
1506
+ if (!read.ok)
1507
+ return failure(
1508
+ deps,
1509
+ flags.json,
1510
+ command,
1511
+ read.missing ? EXIT_NOINPUT : EXIT_FAIL,
1512
+ read.reason
1513
+ );
1514
+ found.push({ marketplace: from, catalog: read.catalog });
1515
+ } else {
1516
+ for (const [name, market2] of known.marketplaces) {
1517
+ const read = catalogOf(market2);
1518
+ if (read.ok && read.catalog.entries.some((entry2) => entry2.name === wanted))
1519
+ found.push({ marketplace: name, catalog: read.catalog });
1520
+ }
1521
+ found.sort((a, b) => a.marketplace.localeCompare(b.marketplace));
1522
+ if (found.length > 1)
1523
+ return failure(
1524
+ deps,
1525
+ flags.json,
1526
+ command,
1527
+ EXIT_USAGE,
1528
+ `More than one marketplace has ${wanted}: ${found.map((f) => `${wanted}@${f.marketplace}`).join(", ")}. Name one of them.`
1529
+ );
1530
+ }
1531
+ const hit = found[0];
1532
+ const entry = hit?.catalog.entries.find((candidate) => candidate.name === wanted);
1533
+ if (hit === void 0 || entry === void 0) {
1534
+ const hint = existsSync2(resolve(deps.cwd(), arg)) ? ` If you meant the folder, write ./${arg}.` : "";
1535
+ return failure(
1536
+ deps,
1537
+ flags.json,
1538
+ command,
1539
+ EXIT_NOINPUT,
1540
+ from !== void 0 ? `Plugin "${wanted}" is not in marketplace "${from}". See what is added: namzu plugin marketplace list.${hint}` : `No added marketplace has a plugin named "${wanted}". See what is added: namzu plugin marketplace list.${hint}`
1541
+ );
1542
+ }
1543
+ const market = known.marketplaces.get(hit.marketplace);
1544
+ const resolved = await resolveEntrySource(entry, hit.catalog, {
1545
+ hosted: market?.source.source === "url",
1546
+ ...deps.fetch?.allowFileProtocol ? { allowFileProtocol: true } : {}
1547
+ });
1548
+ if (resolved.kind === "unsupported")
1549
+ return failure(deps, flags.json, command, EXIT_UNAVAILABLE, resolved.reason, {
1550
+ id: `${wanted}@${hit.marketplace}`
1551
+ });
1552
+ if (resolved.kind === "invalid")
1553
+ return failure(
1554
+ deps,
1555
+ flags.json,
1556
+ command,
1557
+ EXIT_DATAERR,
1558
+ // The remote-source reasons already begin with the plugin's name.
1559
+ resolved.reason.startsWith(`${entry.name}: `) ? resolved.reason : `${entry.name}: ${resolved.reason}`
1560
+ );
1561
+ if (resolved.kind === "remote") {
1562
+ const remote = resolved.remote;
1563
+ if (downloadBlocked(market, remote, deps.blockedMarketplaces))
1564
+ return failure(deps, flags.json, command, EXIT_UNTRUSTED, DOWNLOAD_BLOCKED);
1565
+ return { kind: "remote-catalog", marketplace: hit.marketplace, entry, remote };
1566
+ }
1567
+ const marketCommit = market !== void 0 && (market.source.source === "github" || market.source.source === "git") ? market.commit : void 0;
1568
+ return {
1569
+ kind: "catalog",
1570
+ marketplace: hit.marketplace,
1571
+ entry,
1572
+ dir: resolved.dir,
1573
+ ...marketCommit !== void 0 ? { commit: marketCommit } : {}
1574
+ };
1575
+ }
1576
+ __name(sourceFor, "sourceFor");
1577
+ function dataOriginWarning(deps, plan) {
1578
+ try {
1579
+ const stamp = JSON.parse(
1580
+ readFileSync(
1581
+ join2(installedPluginDataFolder(deps.namzuHome, plan.id), ".origin.json"),
1582
+ "utf8"
1583
+ )
1584
+ );
1585
+ if (stamp.source === null || stamp.source === void 0) return void 0;
1586
+ if (JSON.stringify(stamp.source) === JSON.stringify(plan.installedFrom)) return void 0;
1587
+ return "Data kept from an earlier install of this plugin came from another source.";
1588
+ } catch {
1589
+ return void 0;
1590
+ }
1591
+ }
1592
+ __name(dataOriginWarning, "dataOriginWarning");
1593
+ async function offerLoading(deps, flags) {
1594
+ const notes = [];
1595
+ if (deps.loadingOn) return { loading: "on", notes };
1596
+ const turnOn = /* @__PURE__ */ __name(async () => {
1597
+ try {
1598
+ notes.push(deps.enableLoading());
1599
+ return true;
1600
+ } catch (error) {
1601
+ notes.push(
1602
+ `Plugin loading could not be turned on (${error instanceof Error ? error.message : String(error)}). Run: namzu config set plugins.enabled true`
1603
+ );
1604
+ return false;
1605
+ }
1606
+ }, "turnOn");
1607
+ if (flags.enableLoading) return { loading: await turnOn() ? "on" : "off", notes };
1608
+ if (deps.interactive && !flags.yes && flags.acceptSurface === void 0) {
1609
+ if (await deps.ask("Plugin loading is off on this computer. Turn it on?"))
1610
+ return { loading: await turnOn() ? "on" : "off", notes };
1611
+ }
1612
+ notes.push(
1613
+ "Plugin loading is off, so it will not run until you run: namzu config set plugins.enabled true"
1614
+ );
1615
+ return { loading: "off", notes };
1616
+ }
1617
+ __name(offerLoading, "offerLoading");
1618
+ async function runInstall(deps, flags) {
1619
+ const command = "plugin install";
1620
+ if (flags.positional.length !== 1)
1621
+ return failure(
1622
+ deps,
1623
+ flags.json,
1624
+ command,
1625
+ EXIT_USAGE,
1626
+ "plugin install takes one plugin: <name>@<marketplace>, a folder, or a .zip or .plugin file."
1627
+ );
1628
+ if (flags.deleteData)
1629
+ return failure(deps, flags.json, command, EXIT_USAGE, "unknown option: --delete-data");
1630
+ const ctx = contextOf(deps, flags);
1631
+ const scope = flags.scope ?? "user";
1632
+ if (scope !== "user" && !ctx.trusted)
1633
+ return failure(deps, flags.json, command, EXIT_UNTRUSTED, UNTRUSTED);
1634
+ const source = await sourceFor(deps, flags, command, flags.positional[0]);
1635
+ if (typeof source === "number") return source;
1636
+ let plan;
1637
+ try {
1638
+ plan = await planInstall(source, {
1639
+ home: deps.namzuHome,
1640
+ cwd: ctx.cwd,
1641
+ ...deps.fetch ? { fetch: deps.fetch } : {}
1642
+ });
1643
+ } catch (error) {
1644
+ const failed = describeError(error);
1645
+ return failure(deps, flags.json, command, failed.code, failed.message);
1646
+ }
1647
+ try {
1648
+ const surfaceJson = {
1649
+ id: plan.id,
1650
+ scope,
1651
+ version: plan.version,
1652
+ commit: plan.commit ?? null,
1653
+ layout: plan.layout,
1654
+ findings: plan.findings,
1655
+ surface: plan.surface,
1656
+ surfaceSha256: plan.digest,
1657
+ inventory: plan.inventory
1658
+ };
1659
+ const read = readInstalledPlugins(deps.namzuHome);
1660
+ const have = read.state === "unreadable" ? void 0 : (read.plugins.get(plan.id) ?? []).find(
1661
+ (record) => record.scope === scope && (scope === "user" || record.projectPath !== void 0 && samePath(record.projectPath, ctx.cwd))
1662
+ );
1663
+ const manifest = readInstallManifest(deps.namzuHome, plan.id);
1664
+ const own = readRecordLayer(recordLayerPath(scope, { home: deps.namzuHome, cwd: ctx.cwd }));
1665
+ const answered = own.state !== "unreadable" && own.enabledPlugins.has(plan.id);
1666
+ if (have !== void 0 && have.version === plan.version && answered && manifest.state === "ok" && manifest.manifest.surfaceSha256 === plan.digest) {
1667
+ const message3 = `${plan.id} ${plan.version} is already installed (scope: ${scope}); nothing changed.`;
1668
+ if (flags.json)
1669
+ sayJson(deps, {
1670
+ command,
1671
+ outcome: "already-installed",
1672
+ message: message3,
1673
+ ...surfaceJson,
1674
+ loading: deps.loadingOn ? "on" : "off"
1675
+ });
1676
+ else deps.out(`${message3}
1677
+ `);
1678
+ return EXIT_OK;
1679
+ }
1680
+ const preview = renderInstallPreview(plan, { scopeLine: scopeLine(scope) });
1681
+ if (flags.dryRun) {
1682
+ if (flags.json)
1683
+ sayJson(deps, {
1684
+ command,
1685
+ outcome: "dry-run",
1686
+ message: "Nothing was installed.",
1687
+ ...surfaceJson,
1688
+ loading: deps.loadingOn ? "on" : "off"
1689
+ });
1690
+ else deps.out(`${preview}
1691
+
1692
+ Dry run: nothing was installed.
1693
+ `);
1694
+ return EXIT_OK;
1695
+ }
1696
+ const warning = dataOriginWarning(deps, plan);
1697
+ const consent = await consentFor(deps, flags, {
1698
+ command,
1699
+ preview,
1700
+ question: "Install?",
1701
+ digest: plan.digest,
1702
+ extra: surfaceJson,
1703
+ declinedMessage: "Not installed.",
1704
+ ...warning !== void 0 ? { needsYes: warning } : {}
1705
+ });
1706
+ if (!consent.ok) return consent.code;
1707
+ let outcome;
1708
+ try {
1709
+ outcome = commitInstall(plan, {
1710
+ home: deps.namzuHome,
1711
+ now: deps.now(),
1712
+ scope,
1713
+ cwd: ctx.cwd,
1714
+ consent: { by: "cli", nonInteractive: !deps.interactive },
1715
+ ...deps.faults ? { faults: deps.faults } : {}
1716
+ });
1717
+ } catch (error) {
1718
+ const failed = describeError(error);
1719
+ return failure(deps, flags.json, command, failed.code, failed.message, { id: plan.id });
1720
+ }
1721
+ const { loading, notes } = await offerLoading(deps, flags);
1722
+ const message2 = outcome.outcome === "already-installed" ? `${plan.id} ${plan.version} is already installed (scope: ${scope}); nothing changed.` : `Installed ${plan.id} ${plan.version} (scope: ${scope}). It loads in new conversations.`;
1723
+ if (flags.json)
1724
+ sayJson(deps, {
1725
+ command,
1726
+ outcome: outcome.outcome,
1727
+ message: message2,
1728
+ ...surfaceJson,
1729
+ loading,
1730
+ ...notes.length > 0 ? { notes } : {}
1731
+ });
1732
+ else deps.out(`${[message2, ...notes].join("\n")}
1733
+ `);
1734
+ return EXIT_OK;
1735
+ } finally {
1736
+ discardStaging(plan.stagingDir);
1737
+ }
1738
+ }
1739
+ __name(runInstall, "runInstall");
1740
+ async function runUpdate(deps, flags) {
1741
+ const command = "plugin update";
1742
+ if (flags.positional.length !== 1)
1743
+ return failure(deps, flags.json, command, EXIT_USAGE, "plugin update takes one plugin id.");
1744
+ const ctx = contextOf(deps, flags);
1745
+ const resolved = resolveId(deps, flags.json, command, flags.positional[0]);
1746
+ if (typeof resolved === "number") return resolved;
1747
+ const { id, records } = resolved;
1748
+ if (flags.scope !== void 0 && !records.some((record) => record.scope === flags.scope))
1749
+ return failure(
1750
+ deps,
1751
+ flags.json,
1752
+ command,
1753
+ EXIT_NOINPUT,
1754
+ `${id} is not installed at scope ${flags.scope}.`,
1755
+ { id }
1756
+ );
1757
+ const recorded = readInstallManifest(deps.namzuHome, id);
1758
+ if (recorded.state !== "ok")
1759
+ return failure(
1760
+ deps,
1761
+ flags.json,
1762
+ command,
1763
+ EXIT_NOINPUT,
1764
+ `${id} has no readable install manifest, so there is nothing to compare an update with. Reinstall it.`,
1765
+ { id }
1766
+ );
1767
+ const from = recorded.manifest.installedFrom ?? {};
1768
+ const { name, marketplace } = splitPluginId(id);
1769
+ let source;
1770
+ if (marketplace === LOCAL_UPLOADS_MARKETPLACE) {
1771
+ const path = typeof from.source === "string" ? from.source : void 0;
1772
+ if (path === void 0 || !existsSync2(path))
1773
+ return failure(
1774
+ deps,
1775
+ flags.json,
1776
+ command,
1777
+ EXIT_NOINPUT,
1778
+ `${id} was installed from ${path ?? "a file or folder"}, which is not there now. Install it again from where it is.`,
1779
+ { id }
1780
+ );
1781
+ source = { kind: "path", path };
1782
+ } else {
1783
+ const found = await sourceFor(deps, flags, command, id);
1784
+ if (typeof found === "number") return found;
1785
+ source = found;
1786
+ }
1787
+ let plan;
1788
+ try {
1789
+ plan = await planInstall(source, {
1790
+ home: deps.namzuHome,
1791
+ cwd: ctx.cwd,
1792
+ ...deps.fetch ? { fetch: deps.fetch } : {}
1793
+ });
1794
+ } catch (error) {
1795
+ const failed = describeError(error);
1796
+ return failure(deps, flags.json, command, failed.code, failed.message, { id });
1797
+ }
1798
+ try {
1799
+ const current = records[0];
1800
+ const surfaceJson = {
1801
+ id,
1802
+ from: current.version ?? null,
1803
+ to: plan.version,
1804
+ commit: plan.commit ?? null,
1805
+ findings: plan.findings,
1806
+ surface: plan.surface,
1807
+ surfaceSha256: plan.digest
1808
+ };
1809
+ if (plan.name !== name)
1810
+ return failure(
1811
+ deps,
1812
+ flags.json,
1813
+ command,
1814
+ EXIT_DATAERR,
1815
+ `The source now holds "${plan.name}", not ${name}.`,
1816
+ { id }
1817
+ );
1818
+ if (current.version === plan.version && recorded.manifest.surfaceSha256 === plan.digest) {
1819
+ const message3 = `${id} is up to date (${plan.version}).`;
1820
+ if (flags.json) sayJson(deps, { command, outcome: "up-to-date", message: message3, ...surfaceJson });
1821
+ else deps.out(`${message3}
1822
+ `);
1823
+ return EXIT_OK;
1824
+ }
1825
+ if (current.version === plan.version)
1826
+ return failure(
1827
+ deps,
1828
+ flags.json,
1829
+ command,
1830
+ EXIT_DATAERR,
1831
+ sameVersionChanged(id, plan.version),
1832
+ { id }
1833
+ );
1834
+ const { changes, unchangedSurface } = compareUpdate(recorded.manifest, plan);
1835
+ if (!unchangedSurface) {
1836
+ const preview = renderInstallPreview(plan, {
1837
+ scopeLine: "",
1838
+ headline: `Update ${oneLine(id)} from ${oneLine(current.version ?? "?")} to ${oneLine(plan.version)}${plan.commit !== void 0 ? ` (commit ${plan.commit.slice(0, 7)})` : ""}?`,
1839
+ changes: [
1840
+ ...current.version !== plan.version ? [`Version ${oneLine(current.version ?? "?")} to ${oneLine(plan.version)}`] : [],
1841
+ ...changes.length > 0 ? changes : ["Files that configure or run the plugin changed."]
1842
+ ]
1843
+ });
1844
+ if (flags.dryRun) {
1845
+ if (flags.json)
1846
+ sayJson(deps, {
1847
+ command,
1848
+ outcome: "dry-run",
1849
+ message: "Nothing was updated.",
1850
+ changes,
1851
+ ...surfaceJson
1852
+ });
1853
+ else deps.out(`${preview}
1854
+
1855
+ Dry run: nothing was updated.
1856
+ `);
1857
+ return EXIT_OK;
1858
+ }
1859
+ const consent = await consentFor(deps, flags, {
1860
+ command,
1861
+ preview,
1862
+ question: "Update?",
1863
+ digest: plan.digest,
1864
+ extra: { ...surfaceJson, changes },
1865
+ declinedMessage: "Not updated."
1866
+ });
1867
+ if (!consent.ok) return consent.code;
1868
+ } else if (flags.dryRun) {
1869
+ if (flags.json)
1870
+ sayJson(deps, {
1871
+ command,
1872
+ outcome: "dry-run",
1873
+ message: "Nothing was updated.",
1874
+ changes,
1875
+ ...surfaceJson
1876
+ });
1877
+ else
1878
+ deps.out(
1879
+ `${id} would change from ${current.version ?? "?"} to ${plan.version}. What runs does not change.
1880
+ `
1881
+ );
1882
+ return EXIT_OK;
1883
+ }
1884
+ let result;
1885
+ try {
1886
+ result = commitUpdate(plan, {
1887
+ home: deps.namzuHome,
1888
+ now: deps.now(),
1889
+ consent: { by: "cli", nonInteractive: !deps.interactive },
1890
+ ...deps.faults ? { faults: deps.faults } : {}
1891
+ });
1892
+ } catch (error) {
1893
+ const failed = describeError(error);
1894
+ return failure(deps, flags.json, command, failed.code, failed.message, { id });
1895
+ }
1896
+ const message2 = result.outcome === "up-to-date" ? `${id} is up to date (${plan.version}).` : `Updated ${id} from ${result.from ?? "?"} to ${result.to}. It loads in new conversations.`;
1897
+ if (flags.json)
1898
+ sayJson(deps, { command, outcome: result.outcome, message: message2, changes, ...surfaceJson });
1899
+ else
1900
+ deps.out(
1901
+ `${[...unchangedSurface && changes.length === 0 ? [] : changes.map((change) => ` ${change}`), message2].join("\n")}
1902
+ `
1903
+ );
1904
+ return EXIT_OK;
1905
+ } finally {
1906
+ discardStaging(plan.stagingDir);
1907
+ }
1908
+ }
1909
+ __name(runUpdate, "runUpdate");
1910
+ async function runUninstall(deps, flags) {
1911
+ const command = "plugin uninstall";
1912
+ if (flags.positional.length !== 1)
1913
+ return failure(deps, flags.json, command, EXIT_USAGE, "plugin uninstall takes one plugin id.");
1914
+ const ctx = contextOf(deps, flags);
1915
+ const arg = flags.positional[0];
1916
+ const read = readInstalledPlugins(deps.namzuHome);
1917
+ if (read.state !== "unreadable" && !isPluginId(arg) && !arg.includes("@")) {
1918
+ const holder = (await usedPluginNames({ home: deps.namzuHome, cwd: ctx.cwd })).get(arg);
1919
+ const installed = [...read.plugins.keys()].some((id2) => splitPluginId(id2).name === arg);
1920
+ if (!installed && holder?.startsWith("the plugin folder"))
1921
+ return failure(
1922
+ deps,
1923
+ flags.json,
1924
+ command,
1925
+ EXIT_USAGE,
1926
+ "This plugin is a folder you placed in .namzu/plugins. Remove the folder yourself."
1927
+ );
1928
+ }
1929
+ const resolved = resolveId(deps, flags.json, command, arg);
1930
+ if (typeof resolved === "number") return resolved;
1931
+ const { id } = resolved;
1932
+ const found = applicable(resolved.records, ctx.cwd, ctx.trusted);
1933
+ let chosen;
1934
+ if (flags.scope !== void 0) chosen = found.here.find((record) => record.scope === flags.scope);
1935
+ else if (found.here.length === 1) chosen = found.here[0];
1936
+ else if (found.here.length > 1)
1937
+ return failure(
1938
+ deps,
1939
+ flags.json,
1940
+ command,
1941
+ EXIT_USAGE,
1942
+ `${id} is installed at more than one scope here (${found.here.map((r) => r.scope).join(", ")}). Say which with --scope.`,
1943
+ { id }
1944
+ );
1945
+ if (chosen === void 0) {
1946
+ if (found.unread > 0 && flags.scope === void 0)
1947
+ return failure(deps, flags.json, command, EXIT_UNTRUSTED, UNTRUSTED, { id });
1948
+ return failure(
1949
+ deps,
1950
+ flags.json,
1951
+ command,
1952
+ EXIT_NOINPUT,
1953
+ flags.scope ? `${id} is not installed at scope ${flags.scope} here.` : `${id} is not installed for this folder or for you.`,
1954
+ { id }
1955
+ );
1956
+ }
1957
+ if (chosen.scope !== "user" && !ctx.trusted)
1958
+ return failure(deps, flags.json, command, EXIT_UNTRUSTED, UNTRUSTED, { id });
1959
+ const dataPath = installedPluginDataFolder(deps.namzuHome, id);
1960
+ if (chosen.scope === "project" && !flags.yes) {
1961
+ const sharedFile = ".namzu/settings.json";
1962
+ if (!deps.interactive)
1963
+ return declined(
1964
+ deps,
1965
+ flags.json,
1966
+ command,
1967
+ EXIT_NEEDS_CONSENT,
1968
+ `Removing ${id} edits the shared ${sharedFile}, which your teammates use. Add --yes to do that, or run: namzu plugin disable ${id} to turn it off only for you.`,
1969
+ { id, scope: chosen.scope }
1970
+ );
1971
+ if (!await deps.ask(`Remove ${id} for everyone (edits the shared ${sharedFile})?`)) {
1972
+ if (await deps.ask("Turn it off for you only instead?")) {
1973
+ const path = recordLayerPath("local", { home: deps.namzuHome, cwd: ctx.cwd });
1974
+ try {
1975
+ setEnabledPlugin(path, deps.namzuHome, id, false);
1976
+ } catch (error) {
1977
+ const failed = stateFailure(error);
1978
+ return failure(deps, flags.json, command, failed.code, failed.message, { id });
1979
+ }
1980
+ const message3 = `Turned off ${id} for you only. It takes effect in new conversations.`;
1981
+ if (flags.json)
1982
+ sayJson(deps, { command, outcome: "disabled", id, scope: chosen.scope, message: message3 });
1983
+ else deps.out(`${message3}
1984
+ `);
1985
+ return EXIT_OK;
1986
+ }
1987
+ return declined(deps, flags.json, command, EXIT_FAIL, "Nothing was removed.", { id });
1988
+ }
1989
+ }
1990
+ let result;
1991
+ try {
1992
+ result = removeInstall(
1993
+ id,
1994
+ {
1995
+ scope: chosen.scope,
1996
+ ...chosen.projectPath !== void 0 ? { projectPath: chosen.projectPath } : {}
1997
+ },
1998
+ { home: deps.namzuHome, now: deps.now(), deleteData: flags.deleteData }
1999
+ );
2000
+ } catch (error) {
2001
+ const failed = describeError(error);
2002
+ return failure(deps, flags.json, command, failed.code, failed.message, { id });
2003
+ }
2004
+ if (!result.removedRecord)
2005
+ return failure(
2006
+ deps,
2007
+ flags.json,
2008
+ command,
2009
+ EXIT_NOINPUT,
2010
+ `${id} is not installed at scope ${chosen.scope}.`,
2011
+ { id }
2012
+ );
2013
+ const parts = [`Removed ${id} (scope: ${chosen.scope}).`];
2014
+ if (result.dataKept) parts.push(`Its data is kept in ${dataPath}; delete it with --delete-data.`);
2015
+ if (result.dataDeleted) parts.push("Its data was deleted.");
2016
+ if (result.remaining > 0)
2017
+ parts.push(
2018
+ `It is still installed at ${result.remaining} other ${result.remaining === 1 ? "scope" : "scopes"}.`
2019
+ );
2020
+ const message2 = parts.join(" ");
2021
+ if (flags.json)
2022
+ sayJson(deps, {
2023
+ command,
2024
+ outcome: "uninstalled",
2025
+ id,
2026
+ scope: chosen.scope,
2027
+ message: message2,
2028
+ dataKept: result.dataKept,
2029
+ dataDeleted: result.dataDeleted,
2030
+ remaining: result.remaining
2031
+ });
2032
+ else deps.out(`${message2}
2033
+ `);
2034
+ return EXIT_OK;
2035
+ }
2036
+ __name(runUninstall, "runUninstall");
2037
+ async function runPrune(deps, flags) {
2038
+ const command = "plugin prune";
2039
+ if (flags.positional.length > 0)
2040
+ return failure(deps, flags.json, command, EXIT_USAGE, "plugin prune takes no arguments.");
2041
+ let plan;
2042
+ try {
2043
+ plan = prune(deps.namzuHome, deps.now(), false);
2044
+ } catch (error) {
2045
+ const failed = describeError(error);
2046
+ return failure(deps, flags.json, command, failed.code, failed.message);
2047
+ }
2048
+ const listing = [
2049
+ ...plan.items.map((item) => ` ${oneLine(item.path)} (${item.reason})`),
2050
+ ...plan.kept.map((item) => ` ${oneLine(item.path)} (kept: ${item.reason})`)
2051
+ ];
2052
+ if (plan.items.length === 0) {
2053
+ const message3 = "Nothing to remove.";
2054
+ if (flags.json)
2055
+ sayJson(deps, { command, outcome: "nothing-to-do", message: message3, items: [], kept: plan.kept });
2056
+ else deps.out(`${[message3, ...listing].join("\n")}
2057
+ `);
2058
+ return EXIT_OK;
2059
+ }
2060
+ if (flags.dryRun) {
2061
+ if (flags.json)
2062
+ sayJson(deps, { command, outcome: "dry-run", items: plan.items, kept: plan.kept });
2063
+ else deps.out(`Would remove:
2064
+ ${listing.join("\n")}
2065
+ `);
2066
+ return EXIT_OK;
2067
+ }
2068
+ if (!flags.yes) {
2069
+ show(deps, flags.json, `Would remove:
2070
+ ${listing.join("\n")}`);
2071
+ if (!deps.interactive)
2072
+ return declined(
2073
+ deps,
2074
+ flags.json,
2075
+ command,
2076
+ EXIT_NEEDS_CONSENT,
2077
+ "Nothing was removed. Add --yes to remove these.",
2078
+ { items: plan.items }
2079
+ );
2080
+ if (!await deps.ask("Remove them?"))
2081
+ return declined(deps, flags.json, command, EXIT_FAIL, "Nothing was removed.");
2082
+ }
2083
+ let done;
2084
+ try {
2085
+ done = prune(deps.namzuHome, deps.now(), true);
2086
+ } catch (error) {
2087
+ const failed = describeError(error);
2088
+ return failure(deps, flags.json, command, failed.code, failed.message);
2089
+ }
2090
+ const message2 = `Removed ${done.items.length} ${done.items.length === 1 ? "item" : "items"}.`;
2091
+ if (flags.json)
2092
+ sayJson(deps, { command, outcome: "pruned", message: message2, items: done.items, kept: done.kept });
2093
+ else deps.out(`${message2}
2094
+ `);
2095
+ return EXIT_OK;
2096
+ }
2097
+ __name(runPrune, "runPrune");
2098
+ async function runPluginInstall(verb, args, deps) {
2099
+ const flags = parseFlags(args);
2100
+ if (flags.error) return failure(deps, flags.json, `plugin ${verb}`, EXIT_USAGE, flags.error);
2101
+ if (flags.ref !== void 0 || flags.sparse.length > 0)
2102
+ return failure(
2103
+ deps,
2104
+ flags.json,
2105
+ `plugin ${verb}`,
2106
+ EXIT_USAGE,
2107
+ "--ref and --sparse belong to marketplace add."
2108
+ );
2109
+ if (flags.deleteData && verb !== "uninstall")
2110
+ return failure(deps, flags.json, `plugin ${verb}`, EXIT_USAGE, "unknown option: --delete-data");
2111
+ if (flags.enableLoading && verb !== "install")
2112
+ return failure(
2113
+ deps,
2114
+ flags.json,
2115
+ `plugin ${verb}`,
2116
+ EXIT_USAGE,
2117
+ "unknown option: --enable-loading"
2118
+ );
2119
+ switch (verb) {
2120
+ case "install":
2121
+ return runInstall(deps, flags);
2122
+ case "update":
2123
+ return runUpdate(deps, flags);
2124
+ case "uninstall":
2125
+ return runUninstall(deps, flags);
2126
+ case "prune":
2127
+ return runPrune(deps, flags);
2128
+ }
2129
+ }
2130
+ __name(runPluginInstall, "runPluginInstall");
2131
+ async function runMarketplaceAdd(deps, flags) {
2132
+ const command = "plugin marketplace add";
2133
+ if (flags.positional.length !== 1)
2134
+ return failure(
2135
+ deps,
2136
+ flags.json,
2137
+ command,
2138
+ EXIT_USAGE,
2139
+ "plugin marketplace add takes one address: owner/repo, an https:// address, a folder, or a .json file."
2140
+ );
2141
+ if (flags.enableLoading || flags.deleteData || flags.acceptSurface !== void 0)
2142
+ return failure(
2143
+ deps,
2144
+ flags.json,
2145
+ command,
2146
+ EXIT_USAGE,
2147
+ "that option does not belong to marketplace add."
2148
+ );
2149
+ const ctx = contextOf(deps, flags);
2150
+ const scope = flags.scope ?? "user";
2151
+ const address = parseMarketplaceAddress(flags.positional[0], deps.cwd());
2152
+ if (address.kind === "refused")
2153
+ return failure(deps, flags.json, command, EXIT_USAGE, address.message);
2154
+ if (scope !== "user" && !ctx.trusted)
2155
+ return failure(deps, flags.json, command, EXIT_UNTRUSTED, UNTRUSTED);
2156
+ if (address.kind === "remote")
2157
+ return runRemoteMarketplaceAdd(deps, flags, address.source, ctx, scope);
2158
+ if (flags.ref !== void 0 || flags.sparse.length > 0)
2159
+ return failure(
2160
+ deps,
2161
+ flags.json,
2162
+ command,
2163
+ EXIT_USAGE,
2164
+ "--ref and --sparse are for a Git repository, not a folder or file."
2165
+ );
2166
+ if (scope !== "user" && !ctx.trusted)
2167
+ return failure(deps, flags.json, command, EXIT_UNTRUSTED, UNTRUSTED);
2168
+ const real = realPathOf(address.path);
2169
+ if (real === void 0)
2170
+ return failure(
2171
+ deps,
2172
+ flags.json,
2173
+ command,
2174
+ EXIT_NOINPUT,
2175
+ `${oneLine(address.path)} was not found.`
2176
+ );
2177
+ if (/^\\\\/.test(real))
2178
+ return failure(
2179
+ deps,
2180
+ flags.json,
2181
+ command,
2182
+ EXIT_USAGE,
2183
+ "A network share is not accepted. Copy the marketplace to this computer first."
2184
+ );
2185
+ let kind;
2186
+ try {
2187
+ const stat2 = lstatSync(real);
2188
+ if (stat2.isDirectory()) kind = "directory";
2189
+ else if (stat2.isFile() && real.toLowerCase().endsWith(".json")) kind = "file";
2190
+ else
2191
+ return failure(
2192
+ deps,
2193
+ flags.json,
2194
+ command,
2195
+ EXIT_USAGE,
2196
+ "Not a marketplace address. A marketplace is a folder or a .json file."
2197
+ );
2198
+ } catch {
2199
+ return failure(deps, flags.json, command, EXIT_NOINPUT, `${oneLine(real)} was not found.`);
2200
+ }
2201
+ const source = { source: kind, path: real };
2202
+ if (flags.dryRun) {
2203
+ if (flags.json)
2204
+ sayJson(deps, { command, outcome: "dry-run", source, notice: MARKETPLACE_NOTICE });
2205
+ else deps.out(`Would add the marketplace at ${oneLine(real)}.
2206
+
2207
+ ${MARKETPLACE_NOTICE}
2208
+ `);
2209
+ return EXIT_OK;
2210
+ }
2211
+ const read = readCatalog(real, kind);
2212
+ if (!read.ok)
2213
+ return failure(
2214
+ deps,
2215
+ flags.json,
2216
+ command,
2217
+ read.missing ? EXIT_NOINPUT : EXIT_DATAERR,
2218
+ read.reason
2219
+ );
2220
+ const { catalog } = read;
2221
+ const problem = marketplaceNameProblem(catalog.name);
2222
+ if (problem !== void 0) return failure(deps, flags.json, command, EXIT_DATAERR, problem);
2223
+ const known = readKnownMarketplaces(deps.namzuHome);
2224
+ if (known.state === "unreadable")
2225
+ return failure(
2226
+ deps,
2227
+ flags.json,
2228
+ command,
2229
+ EXIT_NOINPUT,
2230
+ `The marketplace list could not be read, so nothing was changed (${known.reason}).`
2231
+ );
2232
+ const existing = known.marketplaces.get(catalog.name);
2233
+ if (existing !== void 0) {
2234
+ if (existing.source.source === kind && samePath(String(existing.source.path ?? ""), real)) {
2235
+ const layerPath = recordLayerPath(scope, { home: deps.namzuHome, cwd: ctx.cwd });
2236
+ const layer = readRecordLayer(layerPath);
2237
+ if (layer.state !== "unreadable" && !layer.marketplaces.has(catalog.name)) {
2238
+ try {
2239
+ setExtraKnownMarketplace(layerPath, deps.namzuHome, catalog.name, source);
2240
+ } catch (error) {
2241
+ const failed = stateFailure(error);
2242
+ return failure(deps, flags.json, command, failed.code, failed.message);
2243
+ }
2244
+ const added = `Marketplace "${catalog.name}" was already added; it is now also declared for scope ${scope}.`;
2245
+ if (flags.json)
2246
+ sayJson(deps, {
2247
+ command,
2248
+ outcome: "added",
2249
+ name: catalog.name,
2250
+ source,
2251
+ scope,
2252
+ message: added
2253
+ });
2254
+ else deps.out(`${added}
2255
+ `);
2256
+ return EXIT_OK;
2257
+ }
2258
+ const message3 = `Marketplace "${catalog.name}" is already added; nothing changed.`;
2259
+ if (flags.json)
2260
+ sayJson(deps, { command, outcome: "already-added", name: catalog.name, source, message: message3 });
2261
+ else deps.out(`${message3}
2262
+ `);
2263
+ return EXIT_OK;
2264
+ }
2265
+ return failure(
2266
+ deps,
2267
+ flags.json,
2268
+ command,
2269
+ EXIT_DATAERR,
2270
+ anotherPlace(catalog.name, existing.source, source)
2271
+ );
2272
+ }
2273
+ show(deps, flags.json, MARKETPLACE_NOTICE);
2274
+ const now = deps.now().toISOString();
2275
+ try {
2276
+ putKnownMarketplace(deps.namzuHome, catalog.name, {
2277
+ source,
2278
+ installLocation: real,
2279
+ lastUpdated: now,
2280
+ autoUpdate: false,
2281
+ consent: { at: now, by: "cli", notice: "marketplace-v1" }
2282
+ });
2283
+ setExtraKnownMarketplace(
2284
+ recordLayerPath(scope, { home: deps.namzuHome, cwd: ctx.cwd }),
2285
+ deps.namzuHome,
2286
+ catalog.name,
2287
+ source
2288
+ );
2289
+ } catch (error) {
2290
+ const failed = stateFailure(error);
2291
+ return failure(deps, flags.json, command, failed.code, failed.message);
2292
+ }
2293
+ const unsupported = await countNotInstallable(
2294
+ catalog,
2295
+ false,
2296
+ deps.fetch?.allowFileProtocol === true
2297
+ );
2298
+ const message2 = `Added marketplace "${catalog.name}" (${catalog.entries.length} ${catalog.entries.length === 1 ? "plugin" : "plugins"}${unsupported > 0 ? `, ${unsupported} cannot be installed here` : ""}).`;
2299
+ if (flags.json)
2300
+ sayJson(deps, {
2301
+ command,
2302
+ outcome: "added",
2303
+ name: catalog.name,
2304
+ source,
2305
+ scope,
2306
+ plugins: catalog.entries.length,
2307
+ notInstallable: unsupported,
2308
+ warnings: catalog.warnings,
2309
+ message: message2
2310
+ });
2311
+ else deps.out(`${[message2, ...catalog.warnings.map((w) => `Note: ${oneLine(w)}`)].join("\n")}
2312
+ `);
2313
+ return EXIT_OK;
2314
+ }
2315
+ __name(runMarketplaceAdd, "runMarketplaceAdd");
2316
+ function withFlags(source, flags) {
2317
+ if (flags.ref === void 0 && flags.sparse.length === 0) return source;
2318
+ if (source.source === "url")
2319
+ return "--ref and --sparse are for a Git repository, not a hosted marketplace.json.";
2320
+ if (flags.ref !== void 0) {
2321
+ const problem = refProblem(flags.ref);
2322
+ if (problem !== void 0) return problem;
2323
+ }
2324
+ for (const path of flags.sparse) {
2325
+ const problem = repoPathProblem(path);
2326
+ if (problem !== void 0) return problem;
2327
+ }
2328
+ return {
2329
+ ...source,
2330
+ ...flags.ref !== void 0 ? { ref: flags.ref } : {},
2331
+ ...flags.sparse.length > 0 ? { sparsePaths: [...flags.sparse] } : {}
2332
+ };
2333
+ }
2334
+ __name(withFlags, "withFlags");
2335
+ async function runRemoteMarketplaceAdd(deps, flags, typed, ctx, scope) {
2336
+ const command = "plugin marketplace add";
2337
+ const applied = withFlags(typed, flags);
2338
+ if (typeof applied === "string") return failure(deps, flags.json, command, EXIT_USAGE, applied);
2339
+ const source = applied;
2340
+ const display = describeSource(source);
2341
+ if (isBlockedSource(source, deps.blockedMarketplaces))
2342
+ return failure(deps, flags.json, command, EXIT_UNTRUSTED, MARKETPLACE_BLOCKED);
2343
+ if (flags.dryRun) {
2344
+ if (flags.json)
2345
+ sayJson(deps, { command, outcome: "dry-run", source, notice: MARKETPLACE_NOTICE });
2346
+ else deps.out(`Would add the marketplace at ${oneLine(display)}.
2347
+
2348
+ ${MARKETPLACE_NOTICE}
2349
+ `);
2350
+ return EXIT_OK;
2351
+ }
2352
+ if (!flags.yes && !deps.interactive)
2353
+ return declined(
2354
+ deps,
2355
+ flags.json,
2356
+ command,
2357
+ EXIT_NEEDS_CONSENT,
2358
+ `A marketplace can run code. Add --yes to confirm that you trust ${oneLine(display)}.`,
2359
+ { source }
2360
+ );
2361
+ const known = readKnownMarketplaces(deps.namzuHome);
2362
+ if (known.state === "unreadable")
2363
+ return failure(
2364
+ deps,
2365
+ flags.json,
2366
+ command,
2367
+ EXIT_NOINPUT,
2368
+ `The marketplace list could not be read, so nothing was changed (${known.reason}).`
2369
+ );
2370
+ const staging = newStaging(deps.namzuHome);
2371
+ try {
2372
+ let fetched;
2373
+ try {
2374
+ fetched = await fetchMarketplace(source, staging, deps.fetch);
2375
+ } catch (error) {
2376
+ const failed = describeError(error);
2377
+ return failure(deps, flags.json, command, failed.code, failed.message);
2378
+ }
2379
+ const read = readFetchedCatalog(fetched.dir, display);
2380
+ if (!read.ok) return failure(deps, flags.json, command, EXIT_DATAERR, read.message);
2381
+ const { catalog } = read;
2382
+ const problem = marketplaceNameProblem(catalog.name);
2383
+ if (problem !== void 0) return failure(deps, flags.json, command, EXIT_DATAERR, problem);
2384
+ const existing = known.marketplaces.get(catalog.name);
2385
+ if (existing !== void 0) {
2386
+ if (!sameSource(existing.source, source))
2387
+ return failure(
2388
+ deps,
2389
+ flags.json,
2390
+ command,
2391
+ EXIT_DATAERR,
2392
+ anotherPlace(catalog.name, existing.source, source)
2393
+ );
2394
+ const layerPath = recordLayerPath(scope, { home: deps.namzuHome, cwd: ctx.cwd });
2395
+ const layer = readRecordLayer(layerPath);
2396
+ let message3 = `Marketplace "${catalog.name}" is already added; nothing changed.`;
2397
+ let outcome = "already-added";
2398
+ if (layer.state !== "unreadable" && !layer.marketplaces.has(catalog.name)) {
2399
+ try {
2400
+ setExtraKnownMarketplace(layerPath, deps.namzuHome, catalog.name, source);
2401
+ } catch (error) {
2402
+ const failed = stateFailure(error);
2403
+ return failure(deps, flags.json, command, failed.code, failed.message);
2404
+ }
2405
+ message3 = `Marketplace "${catalog.name}" was already added; it is now also declared for scope ${scope}.`;
2406
+ outcome = "added";
2407
+ }
2408
+ if (flags.json)
2409
+ sayJson(deps, { command, outcome, name: catalog.name, source, scope, message: message3 });
2410
+ else deps.out(`${message3}
2411
+ `);
2412
+ return EXIT_OK;
2413
+ }
2414
+ const notInstallable = await countNotInstallable(
2415
+ catalog,
2416
+ source.source === "url",
2417
+ deps.fetch?.allowFileProtocol === true
2418
+ );
2419
+ const ref = source.source === "url" ? void 0 : source.ref;
2420
+ const consent = marketplaceConsentText(
2421
+ catalog.name,
2422
+ display,
2423
+ catalog,
2424
+ notInstallable,
2425
+ fetched.commit,
2426
+ ref
2427
+ );
2428
+ if (flags.yes) {
2429
+ if (!flags.json) deps.err(`${consent}
2430
+ `);
2431
+ } else {
2432
+ show(deps, flags.json, consent);
2433
+ if (!await deps.ask("Add this marketplace?"))
2434
+ return declined(deps, flags.json, command, EXIT_FAIL, "Not added.", { source });
2435
+ }
2436
+ try {
2437
+ placeMarketplace(catalog, source, fetched, {
2438
+ home: deps.namzuHome,
2439
+ cwd: ctx.cwd,
2440
+ scope,
2441
+ now: deps.now(),
2442
+ by: "cli",
2443
+ layerPath: recordLayerPath(scope, { home: deps.namzuHome, cwd: ctx.cwd })
2444
+ });
2445
+ } catch (error) {
2446
+ const failed = describeError(error);
2447
+ return failure(deps, flags.json, command, failed.code, failed.message);
2448
+ }
2449
+ const notes = [...catalog.warnings, ...fetchNotes(fetched)];
2450
+ const message2 = `Added marketplace "${catalog.name}" (${catalog.entries.length} ${catalog.entries.length === 1 ? "plugin" : "plugins"}${notInstallable > 0 ? `, ${notInstallable} cannot be installed here` : ""}).`;
2451
+ if (flags.json)
2452
+ sayJson(deps, {
2453
+ command,
2454
+ outcome: "added",
2455
+ name: catalog.name,
2456
+ source,
2457
+ scope,
2458
+ plugins: catalog.entries.length,
2459
+ notInstallable,
2460
+ commit: fetched.commit ?? null,
2461
+ lfsPointers: fetched.lfsPointers,
2462
+ submodules: fetched.submodules,
2463
+ warnings: notes,
2464
+ message: message2
2465
+ });
2466
+ else deps.out(`${[message2, ...notes.map((note) => `Note: ${oneLine(note)}`)].join("\n")}
2467
+ `);
2468
+ return EXIT_OK;
2469
+ } finally {
2470
+ discardStaging(staging);
2471
+ }
2472
+ }
2473
+ __name(runRemoteMarketplaceAdd, "runRemoteMarketplaceAdd");
2474
+ async function updateOne(deps, market) {
2475
+ const kind = market.source.source;
2476
+ if (kind === "directory" || kind === "file") {
2477
+ const read = catalogOf(market);
2478
+ if (!read.ok)
2479
+ return {
2480
+ name: market.name,
2481
+ outcome: "failed",
2482
+ message: read.reason,
2483
+ newPlugins: [],
2484
+ changedPlugins: [],
2485
+ newer: []
2486
+ };
2487
+ return {
2488
+ name: market.name,
2489
+ outcome: "re-read",
2490
+ message: `re-read (${read.catalog.entries.length} ${read.catalog.entries.length === 1 ? "plugin" : "plugins"})`,
2491
+ newPlugins: [],
2492
+ changedPlugins: [],
2493
+ newer: newerVersions(deps.namzuHome, market.name, read.catalog)
2494
+ };
2495
+ }
2496
+ return refreshRemoteMarketplace(market, {
2497
+ home: deps.namzuHome,
2498
+ now: deps.now(),
2499
+ ...deps.blockedMarketplaces !== void 0 ? { blockedMarketplaces: deps.blockedMarketplaces } : {},
2500
+ ...deps.fetch !== void 0 ? { fetch: deps.fetch } : {},
2501
+ describe: /* @__PURE__ */ __name((error) => describeError(error).message, "describe")
2502
+ });
2503
+ }
2504
+ __name(updateOne, "updateOne");
2505
+ async function runMarketplaceUpdate(deps, flags) {
2506
+ const command = "plugin marketplace update";
2507
+ if (flags.positional.length > 1)
2508
+ return failure(
2509
+ deps,
2510
+ flags.json,
2511
+ command,
2512
+ EXIT_USAGE,
2513
+ "plugin marketplace update takes at most one marketplace name."
2514
+ );
2515
+ const known = readKnownMarketplaces(deps.namzuHome);
2516
+ if (known.state === "unreadable")
2517
+ return failure(
2518
+ deps,
2519
+ flags.json,
2520
+ command,
2521
+ EXIT_NOINPUT,
2522
+ `The marketplace list could not be read, so nothing was changed (${known.reason}).`
2523
+ );
2524
+ const wanted = flags.positional[0];
2525
+ if (wanted !== void 0 && !known.marketplaces.has(wanted))
2526
+ return failure(deps, flags.json, command, EXIT_NOINPUT, `Marketplace "${wanted}" is not added.`);
2527
+ const targets = [...known.marketplaces.values()].filter((market) => wanted === void 0 || market.name === wanted).sort((a, b) => a.name.localeCompare(b.name));
2528
+ const rows = [];
2529
+ for (const market of targets) rows.push(await updateOne(deps, market));
2530
+ const failed = rows.filter((row) => row.outcome === "failed");
2531
+ if (flags.json) {
2532
+ sayJson(deps, { command, results: rows });
2533
+ return failed.length > 0 ? EXIT_UNAVAILABLE : EXIT_OK;
2534
+ }
2535
+ const lines = [];
2536
+ if (rows.length === 0) lines.push("No marketplaces are added.");
2537
+ for (const row of rows) {
2538
+ lines.push(`${oneLine(row.name)}: ${oneLine(row.message)}`);
2539
+ for (const item of row.newer)
2540
+ lines.push(
2541
+ ` ${oneLine(item.id)} ${oneLine(item.installed)} is installed; ${oneLine(item.available)} is available: namzu plugin update ${oneLine(item.id)}`
2542
+ );
2543
+ }
2544
+ deps.out(`${lines.join("\n")}
2545
+ `);
2546
+ if (failed.length > 0)
2547
+ deps.err(
2548
+ `${failed.length} could not be updated: ${failed.map((row) => oneLine(row.name)).join(", ")}.
2549
+ `
2550
+ );
2551
+ return failed.length > 0 ? EXIT_UNAVAILABLE : EXIT_OK;
2552
+ }
2553
+ __name(runMarketplaceUpdate, "runMarketplaceUpdate");
2554
+ async function runMarketplaceList(deps, flags) {
2555
+ const command = "plugin marketplace list";
2556
+ if (flags.positional.length > 0)
2557
+ return failure(
2558
+ deps,
2559
+ flags.json,
2560
+ command,
2561
+ EXIT_USAGE,
2562
+ "plugin marketplace list takes no arguments."
2563
+ );
2564
+ const ctx = contextOf(deps, flags);
2565
+ const known = readKnownMarketplaces(deps.namzuHome);
2566
+ if (known.state === "unreadable")
2567
+ return failure(
2568
+ deps,
2569
+ flags.json,
2570
+ command,
2571
+ EXIT_NOINPUT,
2572
+ `The marketplace list could not be read (${known.reason}). Nothing was changed.`
2573
+ );
2574
+ const installed = readInstalledPlugins(deps.namzuHome);
2575
+ const counts = /* @__PURE__ */ new Map();
2576
+ if (installed.state !== "unreadable")
2577
+ for (const id of installed.plugins.keys()) {
2578
+ const { marketplace } = splitPluginId(id);
2579
+ counts.set(marketplace, (counts.get(marketplace) ?? 0) + 1);
2580
+ }
2581
+ const rows = [...known.marketplaces.values()].sort((a, b) => a.name.localeCompare(b.name)).map((market) => {
2582
+ const read = catalogOf(market);
2583
+ return {
2584
+ name: market.name,
2585
+ source: market.source,
2586
+ installLocation: market.installLocation,
2587
+ lastUpdated: market.lastUpdated ?? null,
2588
+ autoUpdate: market.autoUpdate ?? false,
2589
+ plugins: read.ok ? read.catalog.entries.length : null,
2590
+ installed: counts.get(market.name) ?? 0,
2591
+ commit: market.commit ?? null,
2592
+ ...read.ok ? {} : { problem: read.reason }
2593
+ };
2594
+ });
2595
+ const layers = readLayers(deps.namzuHome, ctx.cwd, ctx.trusted);
2596
+ const declared = [];
2597
+ for (const layer of ["project", "local"]) {
2598
+ const read = layers[layer];
2599
+ if (read === void 0 || read.state === "unreadable") continue;
2600
+ for (const market of read.marketplaces.values())
2601
+ if (!known.marketplaces.has(market.name))
2602
+ declared.push({ name: market.name, declaredBy: layer, source: market.source });
2603
+ }
2604
+ if (flags.json) {
2605
+ sayJson(deps, {
2606
+ command,
2607
+ marketplaces: rows,
2608
+ declaredByProject: declared,
2609
+ problems: known.invalid.map((p) => `${p.id}: ${p.reason}`)
2610
+ });
2611
+ return EXIT_OK;
2612
+ }
2613
+ const lines = [];
2614
+ if (rows.length === 0) lines.push("No marketplaces are added.");
2615
+ for (const row of rows)
2616
+ lines.push(
2617
+ `${oneLine(row.name)} ${oneLine(describeSource(row.source))} ${row.plugins ?? "?"} plugins, ${row.installed} installed auto-update ${row.autoUpdate ? "on" : "off"}${"problem" in row ? `
2618
+ ${oneLine(String(row.problem))}` : ""}`
2619
+ );
2620
+ if (declared.length > 0) {
2621
+ lines.push("", "Declared by this project, not added:");
2622
+ for (const item of declared) lines.push(` ${oneLine(item.name)}`);
2623
+ }
2624
+ deps.out(`${lines.join("\n")}
2625
+ `);
2626
+ return EXIT_OK;
2627
+ }
2628
+ __name(runMarketplaceList, "runMarketplaceList");
2629
+ async function runMarketplaceRemove(deps, flags) {
2630
+ const command = "plugin marketplace remove";
2631
+ if (flags.positional.length !== 1)
2632
+ return failure(
2633
+ deps,
2634
+ flags.json,
2635
+ command,
2636
+ EXIT_USAGE,
2637
+ "plugin marketplace remove takes one marketplace name."
2638
+ );
2639
+ const name = flags.positional[0];
2640
+ if (name === LOCAL_UPLOADS_MARKETPLACE)
2641
+ return failure(
2642
+ deps,
2643
+ flags.json,
2644
+ command,
2645
+ EXIT_USAGE,
2646
+ `${LOCAL_UPLOADS_MARKETPLACE} is not a marketplace; remove its plugins one by one with: namzu plugin uninstall <id>`
2647
+ );
2648
+ const ctx = contextOf(deps, flags);
2649
+ const known = readKnownMarketplaces(deps.namzuHome);
2650
+ if (known.state === "unreadable")
2651
+ return failure(
2652
+ deps,
2653
+ flags.json,
2654
+ command,
2655
+ EXIT_NOINPUT,
2656
+ `The marketplace list could not be read, so nothing was changed (${known.reason}).`
2657
+ );
2658
+ if (!known.marketplaces.has(name))
2659
+ return failure(deps, flags.json, command, EXIT_NOINPUT, `Marketplace "${name}" is not added.`);
2660
+ const installed = readInstalledPlugins(deps.namzuHome);
2661
+ if (installed.state === "unreadable")
2662
+ return failure(
2663
+ deps,
2664
+ flags.json,
2665
+ command,
2666
+ EXIT_NOINPUT,
2667
+ `The install record could not be read, so nothing was changed: ${installedPluginsPath(deps.namzuHome)} (${installed.reason}).`
2668
+ );
2669
+ const doomed = [];
2670
+ for (const [id, records] of installed.plugins)
2671
+ if (splitPluginId(id).marketplace === name)
2672
+ for (const record of records) doomed.push({ id, record });
2673
+ const target = known.marketplaces.get(name);
2674
+ const ownCopy = target.source.source !== "directory" && target.source.source !== "file" && isInside(marketplacesFolder(deps.namzuHome), target.installLocation);
2675
+ const layers = ["user"];
2676
+ if (ctx.trusted) layers.push("project", "local");
2677
+ const goes = layers.filter((layer) => {
2678
+ const read = readRecordLayer(recordLayerPath(layer, { home: deps.namzuHome, cwd: ctx.cwd }));
2679
+ return read.state !== "unreadable" && read.marketplaces.has(name);
2680
+ });
2681
+ const lines = [
2682
+ `Remove marketplace "${name}"?`,
2683
+ doomed.length > 0 ? ` Its installed plugins are uninstalled (their data is kept): ${doomed.map((d) => `${d.id} (${d.record.scope})`).map(oneLine).join(", ")}` : " No plugins from it are installed.",
2684
+ ...goes.map((layer) => ` Its entry in the ${layer} settings goes.`),
2685
+ ownCopy ? " The copy Namzu downloaded goes too." : " The marketplace\u2019s own folder is never touched."
2686
+ ];
2687
+ if (!flags.yes) {
2688
+ show(deps, flags.json, lines.join("\n"));
2689
+ if (!deps.interactive)
2690
+ return declined(
2691
+ deps,
2692
+ flags.json,
2693
+ command,
2694
+ EXIT_NEEDS_CONSENT,
2695
+ "Nothing was removed. Add --yes to remove it.",
2696
+ { name }
2697
+ );
2698
+ if (!await deps.ask("Remove it?"))
2699
+ return declined(deps, flags.json, command, EXIT_FAIL, "Nothing was removed.", { name });
2700
+ }
2701
+ const removed = [];
2702
+ try {
2703
+ for (const { id, record } of doomed) {
2704
+ const result = removeInstall(
2705
+ id,
2706
+ {
2707
+ scope: record.scope,
2708
+ ...record.projectPath !== void 0 ? { projectPath: record.projectPath } : {}
2709
+ },
2710
+ { home: deps.namzuHome, now: deps.now(), deleteData: false }
2711
+ );
2712
+ if (result.removedRecord) removed.push(`${id} (${record.scope})`);
2713
+ }
2714
+ removeKnownMarketplace(deps.namzuHome, name);
2715
+ if (ownCopy && lstatExists(target.installLocation))
2716
+ trashFolder(deps.namzuHome, target.installLocation);
2717
+ for (const layer of goes)
2718
+ removeExtraKnownMarketplace(
2719
+ recordLayerPath(layer, { home: deps.namzuHome, cwd: ctx.cwd }),
2720
+ deps.namzuHome,
2721
+ name
2722
+ );
2723
+ } catch (error) {
2724
+ const failed = describeError(error);
2725
+ return failure(deps, flags.json, command, failed.code, failed.message, { name, removed });
2726
+ }
2727
+ const message2 = `Removed marketplace "${name}"${removed.length > 0 ? ` and uninstalled ${removed.length} ${removed.length === 1 ? "plugin" : "plugins"}` : ""}.`;
2728
+ if (flags.json)
2729
+ sayJson(deps, { command, outcome: "removed", name, uninstalled: removed, message: message2 });
2730
+ else deps.out(`${message2}
2731
+ `);
2732
+ return EXIT_OK;
2733
+ }
2734
+ __name(runMarketplaceRemove, "runMarketplaceRemove");
2735
+ async function runMarketplace(args, deps) {
2736
+ const [sub, ...rest] = args;
2737
+ if (sub === void 0 || !MARKETPLACE_VERBS.includes(sub))
2738
+ return failure(
2739
+ deps,
2740
+ false,
2741
+ "plugin marketplace",
2742
+ EXIT_USAGE,
2743
+ sub === void 0 ? "plugin marketplace needs add, list or remove." : `unknown plugin marketplace command: ${sub}. The ones there are: ${MARKETPLACE_VERBS.join(", ")}.`
2744
+ );
2745
+ const flags = parseFlags(rest);
2746
+ if (flags.error)
2747
+ return failure(deps, flags.json, `plugin marketplace ${sub}`, EXIT_USAGE, flags.error);
2748
+ if ((flags.ref !== void 0 || flags.sparse.length > 0) && sub !== "add")
2749
+ return failure(
2750
+ deps,
2751
+ flags.json,
2752
+ `plugin marketplace ${sub}`,
2753
+ EXIT_USAGE,
2754
+ "--ref and --sparse belong to marketplace add."
2755
+ );
2756
+ switch (sub) {
2757
+ case "add":
2758
+ return runMarketplaceAdd(deps, flags);
2759
+ case "list":
2760
+ return runMarketplaceList(deps, flags);
2761
+ case "remove":
2762
+ return runMarketplaceRemove(deps, flags);
2763
+ case "update":
2764
+ return runMarketplaceUpdate(deps, flags);
2765
+ }
2766
+ }
2767
+ __name(runMarketplace, "runMarketplace");
2768
+
2769
+ // src/commands/plugin.ts
2770
+ var PLUGIN_VALIDATE_EXIT = {
2771
+ clean: EXIT_OK,
2772
+ errors: EXIT_FAIL,
2773
+ warnings: 10,
2774
+ unreadable: EXIT_NOINPUT,
2775
+ usage: EXIT_USAGE
2776
+ };
2777
+ var HELP = [
2778
+ "Usage: namzu plugin validate [--json] [--] [path]",
2779
+ " namzu plugin list | details <id> | enable <id> | disable <id> (installed plugins)",
2780
+ " namzu plugin install | uninstall | update | prune | marketplace (see below)",
2781
+ "",
2782
+ "Check a plugin folder (default: the current folder) and every part it carries,",
2783
+ "without running anything from it: no hook, MCP server, command or script is",
2784
+ "started, no module is imported and nothing is fetched. Files are read inside",
2785
+ "the folder only; a reference that leaves it is reported and not followed.",
2786
+ "A hooks module is read, not run: the report lists the events it hooks, the",
2787
+ "calls it makes, and whether it runs commands, reads files or uses the network.",
2788
+ "",
2789
+ "Each problem names the file, the line when it is known, what is wrong and what",
2790
+ "the loader would do about it. An error is something that makes the loader",
2791
+ "refuse the plugin or skip a part; a warning loads but is very likely not what",
2792
+ "you meant.",
2793
+ "",
2794
+ "Options:",
2795
+ " --json Print one JSON report (version 1) on standard output and nothing else",
2796
+ " -- End of options, for a folder whose name starts with a dash",
2797
+ "",
2798
+ "Exit status:",
2799
+ " 0 no problems",
2800
+ " 10 warnings only",
2801
+ " 1 at least one error",
2802
+ " 66 the folder could not be read",
2803
+ " 64 the command line is wrong",
2804
+ "",
2805
+ PLUGIN_RECORD_HELP,
2806
+ "",
2807
+ PLUGIN_INSTALL_HELP
2808
+ ].join("\n");
2809
+ function parseArgs(rawArgs) {
2810
+ const [sub, ...rest] = rawArgs;
2811
+ if (sub !== "validate") {
2812
+ return {
2813
+ path: ".",
2814
+ json: false,
2815
+ error: sub === void 0 ? "plugin needs a subcommand: validate, list, details, enable or disable. Run `namzu plugin --help`." : `unknown plugin subcommand: ${sub}. The ones there are: validate, ${PLUGIN_RECORD_VERBS.join(", ")}, ${PLUGIN_INSTALL_VERBS.join(", ")}, marketplace (${MARKETPLACE_VERBS.join(", ")}).`
2816
+ };
2817
+ }
2818
+ let json = false;
2819
+ const paths = [];
2820
+ let literal = false;
2821
+ for (const arg of rest) {
2822
+ if (literal) paths.push(arg);
2823
+ else if (arg === "--") literal = true;
2824
+ else if (arg === "--json") json = true;
2825
+ else if (arg.startsWith("-") && arg !== "-") {
2826
+ return { path: ".", json, error: `unknown plugin validate option: ${arg}` };
2827
+ } else paths.push(arg);
2828
+ }
2829
+ if (paths.length > 1) {
2830
+ return { path: ".", json, error: "plugin validate takes one folder at a time." };
2831
+ }
2832
+ return { path: paths[0] ?? ".", json };
2833
+ }
2834
+ __name(parseArgs, "parseArgs");
2835
+ function exitStatusFor(report) {
2836
+ switch (report.status) {
2837
+ case "clean":
2838
+ return PLUGIN_VALIDATE_EXIT.clean;
2839
+ case "warnings":
2840
+ return PLUGIN_VALIDATE_EXIT.warnings;
2841
+ case "errors":
2842
+ return PLUGIN_VALIDATE_EXIT.errors;
2843
+ default:
2844
+ return PLUGIN_VALIDATE_EXIT.unreadable;
2845
+ }
2846
+ }
2847
+ __name(exitStatusFor, "exitStatusFor");
2848
+ function oneLine2(value) {
2849
+ return terminalDisplayText(value).replace(/[\t\n\r]+/g, " ");
2850
+ }
2851
+ __name(oneLine2, "oneLine");
2852
+ function renderPluginReport(report) {
2853
+ if (report.status === "unreadable") {
2854
+ return `Could not read ${oneLine2(report.folder)}: ${oneLine2(report.readError ?? "unknown reason")}`;
2855
+ }
2856
+ const who = report.plugin.name ? `${oneLine2(report.plugin.name)} ${oneLine2(report.plugin.version ?? "")}`.trim() : "plugin";
2857
+ const lines = [`Checked ${who} in ${oneLine2(report.folder)}`];
2858
+ for (const problem of report.problems) {
2859
+ const where = problem.file ? `${oneLine2(problem.file)}${problem.line !== void 0 ? `:${problem.line}` : ""}` : "";
2860
+ lines.push(
2861
+ `${problem.level === "error" ? "error " : "warning"} ${where ? `${where} ` : ""}${oneLine2(problem.message)}`
2862
+ );
2863
+ lines.push(` ${oneLine2(problem.consequence)}`);
2864
+ }
2865
+ if (report.hooksModule !== void 0) {
2866
+ const module = report.hooksModule;
2867
+ if (module.status === "refused") {
2868
+ lines.push(`hooks module ${oneLine2(module.entry)} is not run:`);
2869
+ for (const line of module.summary.refused) lines.push(` ${oneLine2(line)}`);
2870
+ } else if (module.status === "empty") {
2871
+ lines.push(
2872
+ `hooks module ${oneLine2(module.entry)} is not loaded: it registers nothing Namzu runs.`
2873
+ );
2874
+ } else {
2875
+ lines.push(
2876
+ `hooks module ${oneLine2(module.entry)} runs in an isolated worker when the plugin is on:`
2877
+ );
2878
+ for (const line of module.lines) lines.push(` ${oneLine2(line)}`);
2879
+ }
2880
+ for (const hook of module.hooks) {
2881
+ const flags = [hook.matcher ? "with a matcher" : "", hook.catches ? "with .catch" : ""].filter((flag) => flag !== "").join(", ");
2882
+ lines.push(
2883
+ ` ${hook.runs ? "hooks" : "not used"} ${oneLine2(hook.pattern)}${flags ? ` (${flags})` : ""} ${oneLine2(hook.file)}:${hook.line}`
2884
+ );
2885
+ }
2886
+ const calls = [...new Set(module.calls.map((call) => call.call))];
2887
+ if (calls.length > 0) lines.push(` calls ${calls.map(oneLine2).join(", ")}`);
2888
+ for (const line of module.summary.notUsed) {
2889
+ if (report.problems.some((problem) => problem.message === line)) continue;
2890
+ lines.push(` not used ${oneLine2(line)}`);
2891
+ }
2892
+ }
2893
+ const parts = `${report.parts.length} ${report.parts.length === 1 ? "part" : "parts"}`;
2894
+ const { errors, warnings } = report.summary;
2895
+ lines.push(
2896
+ errors === 0 && warnings === 0 ? `No problems in ${parts}.` : `${parts} checked: ${errors} ${errors === 1 ? "error" : "errors"}, ${warnings} ${warnings === 1 ? "warning" : "warnings"}.`
2897
+ );
2898
+ return lines.join("\n");
2899
+ }
2900
+ __name(renderPluginReport, "renderPluginReport");
2901
+ var pluginCommand = {
2902
+ name: "plugin",
2903
+ description: "Check a plugin folder, install plugins from folders and files, and list, inspect, update and remove them",
2904
+ passThrough: true,
2905
+ help: HELP,
2906
+ actions: PLUGIN_ACTIONS,
2907
+ handler: /* @__PURE__ */ __name(async ({ ctx, rawArgs }) => {
2908
+ const verb = rawArgs[0];
2909
+ const isMarketplace = verb === "marketplace";
2910
+ const isRecord = PLUGIN_RECORD_VERBS.includes(verb ?? "");
2911
+ const isInstall = PLUGIN_INSTALL_VERBS.includes(verb ?? "");
2912
+ if (isRecord || isInstall || isMarketplace) {
2913
+ const interactive = process.stdin.isTTY === true && process.stderr.isTTY === true;
2914
+ const deps = {
2915
+ out: /* @__PURE__ */ __name((text) => process.stdout.write(text), "out"),
2916
+ err: /* @__PURE__ */ __name((text) => process.stderr.write(text), "err"),
2917
+ cwd: /* @__PURE__ */ __name(() => process.cwd(), "cwd"),
2918
+ namzuHome: namzuHomePath(),
2919
+ isTrusted: /* @__PURE__ */ __name((dir) => isTrusted(dir), "isTrusted"),
2920
+ loadingOn: ctx.config.plugins?.enabled === true,
2921
+ blockedMarketplaces: ctx.config.plugins?.blockedMarketplaces ?? [],
2922
+ interactive,
2923
+ ask: askYesNo,
2924
+ now: /* @__PURE__ */ __name(() => /* @__PURE__ */ new Date(), "now"),
2925
+ enableLoading: /* @__PURE__ */ __name(() => {
2926
+ const plan = planSettingChange("plugins.enabled", "true");
2927
+ if (!plan.ok) throw new Error(plan.error);
2928
+ return plan.apply().replace(/^Plugins is now/, "Plugin loading is now");
2929
+ }, "enableLoading")
2930
+ };
2931
+ if (isRecord) return runPluginRecords(verb, rawArgs.slice(1), deps);
2932
+ return isMarketplace ? runMarketplace(rawArgs.slice(1), deps) : runPluginInstall(verb, rawArgs.slice(1), deps);
2933
+ }
2934
+ const args = parseArgs(rawArgs);
2935
+ if (args.error) {
2936
+ ctx.formatter.error({ message: args.error });
2937
+ return PLUGIN_VALIDATE_EXIT.usage;
2938
+ }
2939
+ const report = await validatePluginFolder(resolve2(args.path));
2940
+ if (args.json || ctx.formatter.name === "json") {
2941
+ createFormatter("json", { quiet: true }).print(report);
2942
+ } else if (ctx.formatter.name === "yaml") {
2943
+ ctx.formatter.print(report);
2944
+ } else if (report.status === "unreadable") {
2945
+ ctx.formatter.error({ message: renderPluginReport(report) });
2946
+ } else {
2947
+ ctx.formatter.print({ text: renderPluginReport(report) });
2948
+ }
2949
+ return exitStatusFor(report);
2950
+ }, "handler")
2951
+ };
2952
+ export {
2953
+ PLUGIN_VALIDATE_EXIT,
2954
+ exitStatusFor,
2955
+ pluginCommand,
2956
+ renderPluginReport
2957
+ };
2958
+ //# sourceMappingURL=plugin-DGEINYG5.js.map