@namzu/cli 60.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.
- package/CHANGELOG.md +36 -0
- package/dist/bin.js +1 -1
- package/dist/chunks/{acp-QLIZHXKX.js → acp-6R4I2A3Q.js} +2060 -245
- package/dist/chunks/acp-6R4I2A3Q.js.map +6 -0
- package/dist/chunks/{activity-command-IVAID3QG.js → activity-command-JU4HLIQJ.js} +14 -14
- package/dist/chunks/{add-W4VXIXR3.js → add-S6JYKDI4.js} +24 -24
- package/dist/chunks/{agent-3VVUFK46.js → agent-E343AQV7.js} +53 -50
- package/dist/chunks/agent-session-D6JIOCON.js +95 -0
- package/dist/chunks/{apply-at-exit-UW5DQZED.js → apply-at-exit-MEOJMGNT.js} +7 -7
- package/dist/chunks/{archive-VGG3TNKD.js → archive-ZPWC7GZU.js} +13 -13
- package/dist/chunks/{auth-XUAD35SY.js → auth-6NX4TMIG.js} +12 -12
- package/dist/chunks/{bin-main-3A5QPUJN.js → bin-main-P3KAQDKC.js} +8 -8
- package/dist/chunks/{binding-743KPSRO.js → binding-6QZVGFQ5.js} +3 -3
- package/dist/chunks/{browser-Y6PS3RBO.js → browser-KK2U5524.js} +7 -7
- package/dist/chunks/{chat-P3OKHK34.js → chat-VEXJRSZN.js} +17 -17
- package/dist/chunks/{chunk-AXCSETAX.js → chunk-2DCOB33W.js} +6 -6
- package/dist/chunks/{chunk-24PN4KZ7.js → chunk-2KVQVPJ7.js} +5 -5
- package/dist/chunks/chunk-32OIBGYI.js +188 -0
- package/dist/chunks/chunk-32OIBGYI.js.map +6 -0
- package/dist/chunks/{chunk-ITFIXESL.js → chunk-42JIZXVL.js} +4 -4
- package/dist/chunks/{chunk-44V3FNMT.js → chunk-4473VICE.js} +3 -3
- package/dist/chunks/{chunk-D5ORLKON.js → chunk-44YG6EI4.js} +4 -4
- package/dist/chunks/{chunk-OTNW5ZO6.js → chunk-452SL2Y4.js} +2 -2
- package/dist/chunks/{chunk-SR4DQPOI.js → chunk-4BNCVR3U.js} +2 -2
- package/dist/chunks/{chunk-IGZGAC75.js → chunk-4CJ3HPOT.js} +2 -2
- package/dist/chunks/{chunk-WWMSEDXA.js → chunk-4DSUVT37.js} +13 -10
- package/dist/chunks/chunk-4DSUVT37.js.map +6 -0
- package/dist/chunks/{chunk-TSHMH45O.js → chunk-4ENL4VUO.js} +4 -4
- package/dist/chunks/{chunk-ONVEH4H7.js → chunk-4KVYTHY7.js} +3 -3
- package/dist/chunks/{chunk-KBIVQ5RH.js → chunk-4Y242BU4.js} +5 -5
- package/dist/chunks/{chunk-2P427DDU.js → chunk-5F4DSPZC.js} +10 -10
- package/dist/chunks/{chunk-QI6XNUH6.js → chunk-5IGEQN7L.js} +4 -4
- package/dist/chunks/{chunk-5Y455HIT.js → chunk-5ZLKTFU2.js} +3 -3
- package/dist/chunks/{chunk-SNKDM7FT.js → chunk-66QIFMEO.js} +2 -2
- package/dist/chunks/{chunk-ATL46ZCR.js → chunk-6HYK4DDB.js} +3 -3
- package/dist/chunks/{chunk-D3OHAYMX.js → chunk-6TUHWKXP.js} +15 -6
- package/dist/chunks/chunk-6TUHWKXP.js.map +6 -0
- package/dist/chunks/{chunk-FISBMAF4.js → chunk-6W3UGXGG.js} +4 -4
- package/dist/chunks/{chunk-P2PWTXHD.js → chunk-75YLZNZW.js} +3 -3
- package/dist/chunks/{chunk-37S6BVTN.js → chunk-AC5P6W3G.js} +2 -2
- package/dist/chunks/chunk-AMYP2WPW.js +1055 -0
- package/dist/chunks/chunk-AMYP2WPW.js.map +6 -0
- package/dist/chunks/{chunk-XNALFKQ2.js → chunk-AYMB4AOZ.js} +4 -4
- package/dist/chunks/{chunk-ZFEDNTIB.js → chunk-B4AOCHH6.js} +3 -3
- package/dist/chunks/{chunk-7PD3LHIR.js → chunk-BA7KUG6V.js} +2 -2
- package/dist/chunks/{chunk-3JCHJOU3.js → chunk-BHQHTM3Z.js} +5 -5
- package/dist/chunks/chunk-BJT37HR4.js +3644 -0
- package/dist/chunks/chunk-BJT37HR4.js.map +6 -0
- package/dist/chunks/{chunk-52T26DYZ.js → chunk-BNLIRJ3M.js} +4 -4
- package/dist/chunks/{chunk-ZHRBJT5B.js → chunk-BURGRQWO.js} +2 -2
- package/dist/chunks/{chunk-3P5TQ3VZ.js → chunk-BWD2TUI4.js} +5 -5
- package/dist/chunks/{chunk-LQFUO2RZ.js → chunk-BZR5PIFF.js} +300 -292
- package/dist/chunks/chunk-BZR5PIFF.js.map +6 -0
- package/dist/chunks/{chunk-OK3QKISP.js → chunk-C7E7YCRD.js} +5 -5
- package/dist/chunks/{chunk-YMVJOKBZ.js → chunk-CXW7I2S3.js} +2 -2
- package/dist/chunks/{chunk-4KRQ6EWL.js → chunk-D2R47LDH.js} +121 -8
- package/dist/chunks/chunk-D2R47LDH.js.map +6 -0
- package/dist/chunks/chunk-D4TXOX34.js +342 -0
- package/dist/chunks/chunk-D4TXOX34.js.map +6 -0
- package/dist/chunks/{chunk-BJWJPQ66.js → chunk-D6PB3Z7Q.js} +2 -2
- package/dist/chunks/{chunk-FOS5YJED.js → chunk-DEAG4G5J.js} +2 -2
- package/dist/chunks/{chunk-DHQJRU7E.js → chunk-DRSQTKDN.js} +3 -3
- package/dist/chunks/chunk-EBBT2I5S.js +153 -0
- package/dist/chunks/chunk-EBBT2I5S.js.map +6 -0
- package/dist/chunks/{chunk-JAPP6DFJ.js → chunk-EWPGU4HH.js} +10 -364
- package/dist/chunks/chunk-EWPGU4HH.js.map +6 -0
- package/dist/chunks/{chunk-HNSJJXIO.js → chunk-EXJJLYZK.js} +3 -3
- package/dist/chunks/{chunk-L7DZ2QPD.js → chunk-F5W4TNCR.js} +2 -2
- package/dist/chunks/{chunk-XIBT7TAZ.js → chunk-F7KOBJVW.js} +4 -4
- package/dist/chunks/{chunk-XLWFT4QC.js → chunk-FK4MAZV2.js} +5 -5
- package/dist/chunks/{chunk-NIHIVQJS.js → chunk-FMD4REZQ.js} +41 -41
- package/dist/chunks/{chunk-NIHIVQJS.js.map → chunk-FMD4REZQ.js.map} +1 -1
- package/dist/chunks/{chunk-J2AH4QK4.js → chunk-FPC3K4TT.js} +3 -3
- package/dist/chunks/{chunk-RE5EUO3F.js → chunk-FVIKYFYD.js} +2 -2
- package/dist/chunks/{chunk-TN7MDKW2.js → chunk-GPTYDM26.js} +8 -8
- package/dist/chunks/{chunk-3APHAS77.js → chunk-GT22EDUB.js} +6 -6
- package/dist/chunks/{chunk-PGD2EYI7.js → chunk-GTUTBTOV.js} +3 -3
- package/dist/chunks/{chunk-ZY7N242I.js → chunk-H6NTNPWD.js} +4 -4
- package/dist/chunks/{chunk-2X53RSPY.js → chunk-HCQGZPVT.js} +2 -2
- package/dist/chunks/{chunk-BBBVDHRH.js → chunk-HG2PPCAE.js} +3 -3
- package/dist/chunks/{chunk-JR66BLKY.js → chunk-HKRUNZVI.js} +3 -3
- package/dist/chunks/{chunk-BBBFPJV3.js → chunk-HM7L5PM2.js} +3 -3
- package/dist/chunks/{chunk-2CP6CJXJ.js → chunk-I4RC6KQQ.js} +19 -19
- package/dist/chunks/{chunk-GRCEOMSP.js → chunk-IL4Y3JGT.js} +13 -13
- package/dist/chunks/{chunk-RYV4P5CO.js → chunk-IMMUS7IW.js} +278 -7
- package/dist/chunks/chunk-IMMUS7IW.js.map +6 -0
- package/dist/chunks/{chunk-HT6A5LCI.js → chunk-IQ44C7Y3.js} +33 -9
- package/dist/chunks/chunk-IQ44C7Y3.js.map +6 -0
- package/dist/chunks/{chunk-VUKFKBOO.js → chunk-J4PL65DJ.js} +6 -6
- package/dist/chunks/chunk-JANK2R3L.js +402 -0
- package/dist/chunks/chunk-JANK2R3L.js.map +6 -0
- package/dist/chunks/{chunk-TYD5K7MT.js → chunk-JECLB23L.js} +6 -6
- package/dist/chunks/{chunk-XVML5P53.js → chunk-JJ72TLOA.js} +15 -15
- package/dist/chunks/{chunk-FQ3DUX7L.js → chunk-JRBFL6WT.js} +2 -2
- package/dist/chunks/{chunk-UCDXXMAD.js → chunk-K2EKXCLZ.js} +3 -3
- package/dist/chunks/{chunk-MN3CC4AF.js → chunk-K7YZJV2X.js} +248 -24
- package/dist/chunks/chunk-K7YZJV2X.js.map +6 -0
- package/dist/chunks/chunk-KF6IKSF2.js +472 -0
- package/dist/chunks/chunk-KF6IKSF2.js.map +6 -0
- package/dist/chunks/{chunk-XS6GGF4E.js → chunk-KSRN5Y2O.js} +64 -45
- package/dist/chunks/chunk-KSRN5Y2O.js.map +6 -0
- package/dist/chunks/{chunk-JCK6FM7F.js → chunk-ME4LETA3.js} +2 -2
- package/dist/chunks/{chunk-2FP2UHZO.js → chunk-MF3SFDBW.js} +3 -3
- package/dist/chunks/{chunk-HA46XY4I.js → chunk-MK42KB72.js} +4 -4
- package/dist/chunks/{chunk-EYF7VILP.js → chunk-MUSGZEFY.js} +2 -2
- package/dist/chunks/{chunk-XAMOWP2G.js → chunk-N5CCXOYK.js} +7 -7
- package/dist/chunks/{chunk-DFOULHWV.js → chunk-NBJ5PRAY.js} +3 -3
- package/dist/chunks/{chunk-ZPWWUTSR.js → chunk-NKHEBASJ.js} +2 -2
- package/dist/chunks/{chunk-R6WB34IP.js → chunk-NVWD5XDT.js} +2 -2
- package/dist/chunks/{chunk-CQNVNHRL.js → chunk-O45DCUNX.js} +2 -2
- package/dist/chunks/{chunk-7MC2ACNB.js → chunk-O4EILTV6.js} +111 -20
- package/dist/chunks/chunk-O4EILTV6.js.map +6 -0
- package/dist/chunks/{chunk-OVJOSPJ5.js → chunk-PAUMCJPX.js} +3 -3
- package/dist/chunks/{chunk-E5GQTEDW.js → chunk-PE4MWWUW.js} +3 -3
- package/dist/chunks/{chunk-3533PAJJ.js → chunk-PLCWCIL4.js} +2 -2
- package/dist/chunks/{chunk-G4XSQIFF.js → chunk-PRJO4XM3.js} +2 -2
- package/dist/chunks/{chunk-6V6MRHZZ.js → chunk-PRRX5LNR.js} +2 -2
- package/dist/chunks/{chunk-LONNSCMP.js → chunk-PS5SVAUJ.js} +2 -2
- package/dist/chunks/chunk-PZLPACNY.js +407 -0
- package/dist/chunks/chunk-PZLPACNY.js.map +6 -0
- package/dist/chunks/{chunk-EN2E63G6.js → chunk-PZWSRAE7.js} +6 -6
- package/dist/chunks/{chunk-S6LFXBVK.js → chunk-QBLHOG2F.js} +3 -3
- package/dist/chunks/{chunk-4FMBST2N.js → chunk-QCV3HH4P.js} +2 -2
- package/dist/chunks/{chunk-R2TBZK62.js → chunk-QGBR42TV.js} +7 -7
- package/dist/chunks/{chunk-TFOFFJNY.js → chunk-QNJXULU7.js} +2 -2
- package/dist/chunks/{chunk-IOTYZLY5.js → chunk-QQ4S6MNH.js} +13548 -4076
- package/dist/chunks/chunk-QQ4S6MNH.js.map +6 -0
- package/dist/chunks/{chunk-PIUHVCR3.js → chunk-R2KAESOM.js} +2 -2
- package/dist/chunks/{chunk-G52WH6JI.js → chunk-R6M6EIAH.js} +4 -4
- package/dist/chunks/{chunk-2PEIKBGP.js → chunk-RKKU2RE4.js} +2 -2
- package/dist/chunks/{chunk-YHFKTEU6.js → chunk-RMOTHWPV.js} +2 -2
- package/dist/chunks/{chunk-ZX5C2ELY.js → chunk-RQAY7REG.js} +3 -3
- package/dist/chunks/{chunk-MXLAVYBS.js → chunk-SLTJNYOU.js} +2 -2
- package/dist/chunks/{chunk-JARQ4I4Q.js → chunk-SXONHO4H.js} +9 -9
- package/dist/chunks/{chunk-YWBOZNDX.js → chunk-T7ILM666.js} +11 -11
- package/dist/chunks/{chunk-OOIVZ5PA.js → chunk-TBGKPWCL.js} +9 -9
- package/dist/chunks/{chunk-M4LHZRTX.js → chunk-TBJ6XU3T.js} +3 -3
- package/dist/chunks/{chunk-UI3ELYQU.js → chunk-TMPP2DEY.js} +4 -4
- package/dist/chunks/{chunk-DLMDCCO7.js → chunk-TSOZBRM6.js} +2 -2
- package/dist/chunks/{chunk-7XLZPKOT.js → chunk-TTFPWGIU.js} +2 -2
- package/dist/chunks/{chunk-NCPOOJD4.js → chunk-TTKMQW6B.js} +3 -3
- package/dist/chunks/{chunk-S5GKG5GV.js → chunk-UCML5ZXB.js} +3 -3
- package/dist/chunks/{chunk-HAIG4TLP.js → chunk-VG7245VJ.js} +6 -6
- package/dist/chunks/{chunk-IXJ6A2XE.js → chunk-VQZPXK4X.js} +3 -3
- package/dist/chunks/{chunk-2MEBOBOM.js → chunk-VWUTJ4EU.js} +3 -3
- package/dist/chunks/{chunk-VJFBRQZ4.js → chunk-WDKAL7EW.js} +2 -2
- package/dist/chunks/{chunk-2ED34AXP.js → chunk-WJ6QRVL6.js} +2 -2
- package/dist/chunks/{chunk-CKMF72VE.js → chunk-WOTA5FO5.js} +3 -3
- package/dist/chunks/{chunk-QUUDXDDL.js → chunk-WPGVZMSU.js} +2 -2
- package/dist/chunks/{chunk-ULJAPIOG.js → chunk-WYA4QWWE.js} +181 -7
- package/dist/chunks/chunk-WYA4QWWE.js.map +6 -0
- package/dist/chunks/{chunk-EVJKQAZM.js → chunk-XDUA6PBP.js} +2 -2
- package/dist/chunks/{chunk-GVHUHRGI.js → chunk-XE6XT6R6.js} +4 -4
- package/dist/chunks/{chunk-QFJ5IWYL.js → chunk-XNQY26AE.js} +31 -131
- package/dist/chunks/chunk-XNQY26AE.js.map +6 -0
- package/dist/chunks/{chunk-LGUIDOA7.js → chunk-YR3TWNIV.js} +9 -9
- package/dist/chunks/{chunk-K4APHATW.js → chunk-YWRRS7SO.js} +2 -2
- package/dist/chunks/{chunk-F6YNTG3K.js → chunk-Z5OG4HXI.js} +26 -22
- package/dist/chunks/chunk-Z5OG4HXI.js.map +6 -0
- package/dist/chunks/{chunk-ESLOAQRL.js → chunk-ZHEEG3NS.js} +2 -2
- package/dist/chunks/{cli-runtime-SL6YG4EX.js → cli-runtime-ZJKKIW4H.js} +22 -22
- package/dist/chunks/{commands-XRQOUFRE.js → commands-TQH5DD22.js} +6 -6
- package/dist/chunks/{computer-6P3GAOV2.js → computer-WOU5WIIR.js} +2 -2
- package/dist/chunks/{config-W3ABQG5K.js → config-APYUJ5UW.js} +13 -13
- package/dist/chunks/{cost-ZKKW4JSZ.js → cost-5YV27U7F.js} +5 -5
- package/dist/chunks/{crash-report-Q2WAKIU5.js → crash-report-QVXU2YVL.js} +6 -6
- package/dist/chunks/{dist-JY4FIVBZ.js → dist-2FSOLP72.js} +2 -2
- package/dist/chunks/{dist-O2QP5QCU.js → dist-AOT4CEP5.js} +2 -2
- package/dist/chunks/{dist-OXSKWJNB.js → dist-H7CAJ3ZW.js} +44 -2
- package/dist/chunks/{dist-IPR6EVQM.js → dist-IZGKRIWL.js} +2 -2
- package/dist/chunks/{dist-WI7EX7ZF.js → dist-J4UXFVYR.js} +2 -2
- package/dist/chunks/{dist-YE6ADUZP.js → dist-JHKRSGW6.js} +2 -2
- package/dist/chunks/{dist-R4PUUPXV.js → dist-PZYMYR7N.js} +3 -3
- package/dist/chunks/{dist-VT4VSQTO.js → dist-Z2HW2SJR.js} +2 -2
- package/dist/chunks/{doctor-EUH7WGN6.js → doctor-CM6UPXG5.js} +40 -38
- package/dist/chunks/{drain-3DDY42KQ.js → drain-X6RURKKC.js} +17 -17
- package/dist/chunks/{entry-FNHGVOQM.js → entry-QQDPY6ZL.js} +6 -6
- package/dist/chunks/{eval-CFKAWR3B.js → eval-GZA22B4I.js} +9 -9
- package/dist/chunks/{exec-BR6L3C3T.js → exec-3NE75Z6E.js} +46 -45
- package/dist/chunks/exec-3NE75Z6E.js.map +6 -0
- package/dist/chunks/{extension-4VR722KH.js → extension-N5IQNKVZ.js} +6 -5
- package/dist/chunks/{github-IF3JVVJF.js → github-AUOENJUY.js} +2 -2
- package/dist/chunks/{home-JCDINY64.js → home-I4FIB6FV.js} +3 -3
- package/dist/chunks/{homes-53P37RPB.js → homes-WTMMXQ6G.js} +5 -5
- package/dist/chunks/{hooks-6EV4IEHU.js → hooks-R42OTZDT.js} +22 -21
- package/dist/chunks/hooks-R42OTZDT.js.map +6 -0
- package/dist/chunks/{hooks-report-OK5PIOSF.js → hooks-report-K6VOPVBR.js} +18 -17
- package/dist/chunks/{host-KF63UW3T.js → host-65UFBZJV.js} +10 -10
- package/dist/chunks/host-queries-L4PYE2BW.js +37 -0
- package/dist/chunks/{installed-list-QLVA6XBV.js → installed-list-7QIWVKLQ.js} +4 -4
- package/dist/chunks/{learn-XNVRCNGV.js → learn-NZXLKYV4.js} +17 -17
- package/dist/chunks/{learn-builtin-XABWBGRU.js → learn-builtin-RC4XXVBS.js} +20 -20
- package/dist/chunks/{lifecycle-K7REDQBN.js → lifecycle-NLCZ6OPA.js} +30 -30
- package/dist/chunks/{list-US5UDLON.js → list-2U67CAWS.js} +18 -18
- package/dist/chunks/{live-DNA4UB2B.js → live-CWJ2NWUQ.js} +39 -37
- package/dist/chunks/{load-2WCYASMC.js → load-H52QQBVE.js} +13 -9
- package/dist/chunks/{logs-ZF7YJNOC.js → logs-ZIW3QFU4.js} +4 -4
- package/dist/chunks/{mcp-FBJXQJ6I.js → mcp-FNSMEMCM.js} +145 -35
- package/dist/chunks/mcp-FNSMEMCM.js.map +6 -0
- package/dist/chunks/{mcp-serve-TTZ33VMY.js → mcp-serve-ZC2OKIPP.js} +17 -17
- package/dist/chunks/{message-command-FMT4APFA.js → message-command-IHZWL5GI.js} +59 -56
- package/dist/chunks/message-command-IHZWL5GI.js.map +6 -0
- package/dist/chunks/{open-I4YKGQSW.js → open-AHDQMVXI.js} +7 -7
- package/dist/chunks/{operator-tools-FC5JFH42.js → operator-tools-P5R4TF6N.js} +15 -15
- package/dist/chunks/{output-schema-KMYL2UB6.js → output-schema-Q5RWHNKE.js} +3 -3
- package/dist/chunks/{pal-UZFR42OY.js → pal-T42HU4AK.js} +15 -15
- package/dist/chunks/{peers-NM5HJGSR.js → peers-5RYEA7IA.js} +7 -7
- package/dist/chunks/{peers-V7XCJUFZ.js → peers-7ZG3DEBO.js} +19 -19
- package/dist/chunks/plugin-DGEINYG5.js +2958 -0
- package/dist/chunks/plugin-DGEINYG5.js.map +6 -0
- package/dist/chunks/{providers-BQ25F6LA.js → providers-BXXIM7EW.js} +18 -18
- package/dist/chunks/{providers-VS37WA3E.js → providers-I24HYZXG.js} +10 -10
- package/dist/chunks/{pty-NWEV3DSP.js → pty-WVKM6ATI.js} +3 -3
- package/dist/chunks/resume-F7JEDBHI.js +25 -0
- package/dist/chunks/{resume-command-KEXAVL6P.js → resume-command-4I47WN7T.js} +4 -4
- package/dist/chunks/{running-JLMG6IL4.js → running-VID6BVT2.js} +4 -4
- package/dist/chunks/{schedule-6ERJJOA3.js → schedule-75IZH76Z.js} +12 -12
- package/dist/chunks/{send-UXJ7GXKN.js → send-QRYY2NCG.js} +19 -19
- package/dist/chunks/send-person-VADQNJBN.js +32 -0
- package/dist/chunks/{service-NYJZCLH2.js → service-B6BNESZB.js} +30 -30
- package/dist/chunks/{setting-cli-ILFKSR4D.js → setting-cli-O4YWOIU5.js} +12 -12
- package/dist/chunks/skills-PEMVX5C3.js +604 -0
- package/dist/chunks/skills-PEMVX5C3.js.map +6 -0
- package/dist/chunks/{start-check-7GBRCGVJ.js → start-check-EKRXJ5VE.js} +2 -2
- package/dist/chunks/{startup-failure-UA32GGJB.js → startup-failure-2UJKPNMR.js} +2 -2
- package/dist/chunks/{state-SSRHEX5K.js → state-X3MKUFYM.js} +20 -20
- package/dist/chunks/{store-2GFZ5XXW.js → store-4OXWHFS5.js} +12 -12
- package/dist/chunks/{store-ROR7VTZ2.js → store-MK5IYBE5.js} +8 -8
- package/dist/chunks/{store-WRRTTRBT.js → store-QFNY4BV4.js} +4 -4
- package/dist/chunks/{store-MP5EB266.js → store-VRKKFOYW.js} +3 -3
- package/dist/chunks/{tui-2JTNW2G7.js → tui-MI72TUST.js} +96 -92
- package/dist/chunks/tui-MI72TUST.js.map +6 -0
- package/dist/chunks/{update-32IRH5TG.js → update-ELZEXYIX.js} +8 -8
- package/dist/chunks/{watch-PXPP5QXP.js → watch-HPINGMZZ.js} +100 -96
- package/dist/chunks/watch-HPINGMZZ.js.map +6 -0
- package/dist/chunks/{workspaces-4YXZSENL.js → workspaces-3LB4SPPS.js} +15 -15
- package/dist/chunks/{worktree-DJHBLFHZ.js → worktree-5CWUUWNO.js} +26 -22
- package/dist/chunks/worktree-5CWUUWNO.js.map +6 -0
- package/dist/commands/acp.d.ts +4 -2
- package/dist/commands/acp.d.ts.map +1 -1
- package/dist/commands/actions/mcp.d.ts.map +1 -1
- package/dist/commands/actions/small.d.ts.map +1 -1
- package/dist/commands/desktop-host-plugins.d.ts +321 -0
- package/dist/commands/desktop-host-plugins.d.ts.map +1 -0
- package/dist/commands/desktop-host-skills.d.ts +103 -0
- package/dist/commands/desktop-host-skills.d.ts.map +1 -0
- package/dist/commands/desktop-host.d.ts +230 -18
- package/dist/commands/desktop-host.d.ts.map +1 -1
- package/dist/commands/manifest.d.ts.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/plugin-install.d.ts +28 -0
- package/dist/commands/plugin-install.d.ts.map +1 -0
- package/dist/commands/plugin-records.d.ts +48 -0
- package/dist/commands/plugin-records.d.ts.map +1 -0
- package/dist/commands/plugin.d.ts.map +1 -1
- package/dist/commands/skills-manage.d.ts +32 -0
- package/dist/commands/skills-manage.d.ts.map +1 -0
- package/dist/commands/skills.d.ts.map +1 -1
- package/dist/config/load.d.ts +9 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/schema.d.ts +7 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/settings-descriptors.d.ts.map +1 -1
- package/dist/index.js +40 -38
- package/dist/integrations/archive/zip.d.ts +36 -0
- package/dist/integrations/archive/zip.d.ts.map +1 -0
- package/dist/integrations/extensions/package.d.ts +7 -16
- package/dist/integrations/extensions/package.d.ts.map +1 -1
- package/dist/integrations/mcp/all-servers.d.ts +30 -0
- package/dist/integrations/mcp/all-servers.d.ts.map +1 -0
- package/dist/integrations/mcp/plugin-remote.d.ts +141 -0
- package/dist/integrations/mcp/plugin-remote.d.ts.map +1 -0
- package/dist/integrations/mcp/project-approval.d.ts +29 -1
- package/dist/integrations/mcp/project-approval.d.ts.map +1 -1
- package/dist/integrations/mcp/server-listing.d.ts +7 -3
- package/dist/integrations/mcp/server-listing.d.ts.map +1 -1
- package/dist/integrations/mcp/servers.d.ts +6 -0
- package/dist/integrations/mcp/servers.d.ts.map +1 -1
- package/dist/integrations/mcp/user-config.d.ts +10 -0
- package/dist/integrations/mcp/user-config.d.ts.map +1 -1
- package/dist/integrations/plugins/enabled-records.d.ts +78 -0
- package/dist/integrations/plugins/enabled-records.d.ts.map +1 -0
- package/dist/integrations/plugins/fetch/archive.d.ts +15 -0
- package/dist/integrations/plugins/fetch/archive.d.ts.map +1 -0
- package/dist/integrations/plugins/fetch/git.d.ts +145 -0
- package/dist/integrations/plugins/fetch/git.d.ts.map +1 -0
- package/dist/integrations/plugins/fetch/index.d.ts +33 -0
- package/dist/integrations/plugins/fetch/index.d.ts.map +1 -0
- package/dist/integrations/plugins/fetch/source.d.ts +107 -0
- package/dist/integrations/plugins/fetch/source.d.ts.map +1 -0
- package/dist/integrations/plugins/fetch/url.d.ts +34 -0
- package/dist/integrations/plugins/fetch/url.d.ts.map +1 -0
- package/dist/integrations/plugins/files.d.ts +15 -3
- package/dist/integrations/plugins/files.d.ts.map +1 -1
- package/dist/integrations/plugins/hook-entries.d.ts +2 -0
- package/dist/integrations/plugins/hook-entries.d.ts.map +1 -1
- package/dist/integrations/plugins/install-manifest.d.ts +70 -0
- package/dist/integrations/plugins/install-manifest.d.ts.map +1 -0
- package/dist/integrations/plugins/install-plan.d.ts +119 -0
- package/dist/integrations/plugins/install-plan.d.ts.map +1 -0
- package/dist/integrations/plugins/install-preview.d.ts +24 -0
- package/dist/integrations/plugins/install-preview.d.ts.map +1 -0
- package/dist/integrations/plugins/install.d.ts +118 -0
- package/dist/integrations/plugins/install.d.ts.map +1 -0
- package/dist/integrations/plugins/installed-source.d.ts +80 -0
- package/dist/integrations/plugins/installed-source.d.ts.map +1 -0
- package/dist/integrations/plugins/inventory.d.ts +2 -1
- package/dist/integrations/plugins/inventory.d.ts.map +1 -1
- package/dist/integrations/plugins/json-state.d.ts +52 -0
- package/dist/integrations/plugins/json-state.d.ts.map +1 -0
- package/dist/integrations/plugins/manifest-details.d.ts +23 -0
- package/dist/integrations/plugins/manifest-details.d.ts.map +1 -0
- package/dist/integrations/plugins/marketplace.d.ts +111 -0
- package/dist/integrations/plugins/marketplace.d.ts.map +1 -0
- package/dist/integrations/plugins/records.d.ts +127 -0
- package/dist/integrations/plugins/records.d.ts.map +1 -0
- package/dist/integrations/plugins/remote-marketplace.d.ts +100 -0
- package/dist/integrations/plugins/remote-marketplace.d.ts.map +1 -0
- package/dist/integrations/plugins/runtime.d.ts +28 -0
- package/dist/integrations/plugins/runtime.d.ts.map +1 -1
- package/dist/integrations/plugins/surface.d.ts +126 -0
- package/dist/integrations/plugins/surface.d.ts.map +1 -0
- package/dist/integrations/plugins/update-compare.d.ts +18 -0
- package/dist/integrations/plugins/update-compare.d.ts.map +1 -0
- package/dist/integrations/plugins/validate.d.ts +50 -1
- package/dist/integrations/plugins/validate.d.ts.map +1 -1
- package/dist/integrations/subagents/definitions.d.ts +4 -0
- package/dist/integrations/subagents/definitions.d.ts.map +1 -1
- package/dist/integrations/trust/folder-grants.d.ts +21 -1
- package/dist/integrations/trust/folder-grants.d.ts.map +1 -1
- package/dist/rounds/types.d.ts +5 -0
- package/dist/rounds/types.d.ts.map +1 -1
- package/dist/skills/add.d.ts +104 -0
- package/dist/skills/add.d.ts.map +1 -0
- package/dist/skills/audit.d.ts +7 -1
- package/dist/skills/audit.d.ts.map +1 -1
- package/dist/skills/create.d.ts +19 -0
- package/dist/skills/create.d.ts.map +1 -0
- package/dist/skills/desktop-catalog.d.ts +64 -0
- package/dist/skills/desktop-catalog.d.ts.map +1 -0
- package/dist/skills/install.d.ts +73 -0
- package/dist/skills/install.d.ts.map +1 -0
- package/dist/skills/remove.d.ts +38 -0
- package/dist/skills/remove.d.ts.map +1 -0
- package/dist/skills/save.d.ts +2 -27
- package/dist/skills/save.d.ts.map +1 -1
- package/dist/skills/validate.d.ts +57 -0
- package/dist/skills/validate.d.ts.map +1 -0
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/Composer.d.ts +6 -10
- package/dist/tui/Composer.d.ts.map +1 -1
- package/dist/tui/PendingInputPanel.d.ts +4 -4
- package/dist/tui/PendingInputPanel.d.ts.map +1 -1
- package/dist/tui/TrustPrompt.d.ts.map +1 -1
- package/dist/tui/agent.d.ts +11 -0
- package/dist/tui/agent.d.ts.map +1 -1
- package/dist/tui/slashCommands.d.ts.map +1 -1
- package/dist/user-commands/store.d.ts +12 -0
- package/dist/user-commands/store.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/acp-QLIZHXKX.js.map +0 -6
- package/dist/chunks/agent-session-TXDHPZJX.js +0 -92
- package/dist/chunks/chunk-4KRQ6EWL.js.map +0 -6
- package/dist/chunks/chunk-4YUR4SIL.js +0 -116
- package/dist/chunks/chunk-4YUR4SIL.js.map +0 -6
- package/dist/chunks/chunk-7MC2ACNB.js.map +0 -6
- package/dist/chunks/chunk-D3OHAYMX.js.map +0 -6
- package/dist/chunks/chunk-F6YNTG3K.js.map +0 -6
- package/dist/chunks/chunk-HT6A5LCI.js.map +0 -6
- package/dist/chunks/chunk-IOTYZLY5.js.map +0 -6
- package/dist/chunks/chunk-JAPP6DFJ.js.map +0 -6
- package/dist/chunks/chunk-LQFUO2RZ.js.map +0 -6
- package/dist/chunks/chunk-MN3CC4AF.js.map +0 -6
- package/dist/chunks/chunk-QFJ5IWYL.js.map +0 -6
- package/dist/chunks/chunk-RHJOIAFS.js +0 -201
- package/dist/chunks/chunk-RHJOIAFS.js.map +0 -6
- package/dist/chunks/chunk-RYV4P5CO.js.map +0 -6
- package/dist/chunks/chunk-ULJAPIOG.js.map +0 -6
- package/dist/chunks/chunk-WWMSEDXA.js.map +0 -6
- package/dist/chunks/chunk-XS6GGF4E.js.map +0 -6
- package/dist/chunks/exec-BR6L3C3T.js.map +0 -6
- package/dist/chunks/hooks-6EV4IEHU.js.map +0 -6
- package/dist/chunks/host-queries-5ZWYD4VD.js +0 -37
- package/dist/chunks/mcp-FBJXQJ6I.js.map +0 -6
- package/dist/chunks/message-command-FMT4APFA.js.map +0 -6
- package/dist/chunks/plugin-UEPWXCB4.js +0 -1132
- package/dist/chunks/plugin-UEPWXCB4.js.map +0 -6
- package/dist/chunks/resume-Y7P3TAVG.js +0 -25
- package/dist/chunks/send-person-DLJU45IU.js +0 -32
- package/dist/chunks/skills-4HM2LPS4.js +0 -350
- package/dist/chunks/skills-4HM2LPS4.js.map +0 -6
- package/dist/chunks/tui-2JTNW2G7.js.map +0 -6
- package/dist/chunks/watch-PXPP5QXP.js.map +0 -6
- package/dist/chunks/worktree-DJHBLFHZ.js.map +0 -6
- /package/dist/chunks/{activity-command-IVAID3QG.js.map → activity-command-JU4HLIQJ.js.map} +0 -0
- /package/dist/chunks/{add-W4VXIXR3.js.map → add-S6JYKDI4.js.map} +0 -0
- /package/dist/chunks/{agent-3VVUFK46.js.map → agent-E343AQV7.js.map} +0 -0
- /package/dist/chunks/{agent-session-TXDHPZJX.js.map → agent-session-D6JIOCON.js.map} +0 -0
- /package/dist/chunks/{apply-at-exit-UW5DQZED.js.map → apply-at-exit-MEOJMGNT.js.map} +0 -0
- /package/dist/chunks/{archive-VGG3TNKD.js.map → archive-ZPWC7GZU.js.map} +0 -0
- /package/dist/chunks/{auth-XUAD35SY.js.map → auth-6NX4TMIG.js.map} +0 -0
- /package/dist/chunks/{bin-main-3A5QPUJN.js.map → bin-main-P3KAQDKC.js.map} +0 -0
- /package/dist/chunks/{binding-743KPSRO.js.map → binding-6QZVGFQ5.js.map} +0 -0
- /package/dist/chunks/{browser-Y6PS3RBO.js.map → browser-KK2U5524.js.map} +0 -0
- /package/dist/chunks/{chat-P3OKHK34.js.map → chat-VEXJRSZN.js.map} +0 -0
- /package/dist/chunks/{chunk-AXCSETAX.js.map → chunk-2DCOB33W.js.map} +0 -0
- /package/dist/chunks/{chunk-24PN4KZ7.js.map → chunk-2KVQVPJ7.js.map} +0 -0
- /package/dist/chunks/{chunk-ITFIXESL.js.map → chunk-42JIZXVL.js.map} +0 -0
- /package/dist/chunks/{chunk-44V3FNMT.js.map → chunk-4473VICE.js.map} +0 -0
- /package/dist/chunks/{chunk-D5ORLKON.js.map → chunk-44YG6EI4.js.map} +0 -0
- /package/dist/chunks/{chunk-OTNW5ZO6.js.map → chunk-452SL2Y4.js.map} +0 -0
- /package/dist/chunks/{chunk-SR4DQPOI.js.map → chunk-4BNCVR3U.js.map} +0 -0
- /package/dist/chunks/{chunk-IGZGAC75.js.map → chunk-4CJ3HPOT.js.map} +0 -0
- /package/dist/chunks/{chunk-TSHMH45O.js.map → chunk-4ENL4VUO.js.map} +0 -0
- /package/dist/chunks/{chunk-ONVEH4H7.js.map → chunk-4KVYTHY7.js.map} +0 -0
- /package/dist/chunks/{chunk-KBIVQ5RH.js.map → chunk-4Y242BU4.js.map} +0 -0
- /package/dist/chunks/{chunk-2P427DDU.js.map → chunk-5F4DSPZC.js.map} +0 -0
- /package/dist/chunks/{chunk-QI6XNUH6.js.map → chunk-5IGEQN7L.js.map} +0 -0
- /package/dist/chunks/{chunk-5Y455HIT.js.map → chunk-5ZLKTFU2.js.map} +0 -0
- /package/dist/chunks/{chunk-SNKDM7FT.js.map → chunk-66QIFMEO.js.map} +0 -0
- /package/dist/chunks/{chunk-ATL46ZCR.js.map → chunk-6HYK4DDB.js.map} +0 -0
- /package/dist/chunks/{chunk-FISBMAF4.js.map → chunk-6W3UGXGG.js.map} +0 -0
- /package/dist/chunks/{chunk-P2PWTXHD.js.map → chunk-75YLZNZW.js.map} +0 -0
- /package/dist/chunks/{chunk-37S6BVTN.js.map → chunk-AC5P6W3G.js.map} +0 -0
- /package/dist/chunks/{chunk-XNALFKQ2.js.map → chunk-AYMB4AOZ.js.map} +0 -0
- /package/dist/chunks/{chunk-ZFEDNTIB.js.map → chunk-B4AOCHH6.js.map} +0 -0
- /package/dist/chunks/{chunk-7PD3LHIR.js.map → chunk-BA7KUG6V.js.map} +0 -0
- /package/dist/chunks/{chunk-3JCHJOU3.js.map → chunk-BHQHTM3Z.js.map} +0 -0
- /package/dist/chunks/{chunk-52T26DYZ.js.map → chunk-BNLIRJ3M.js.map} +0 -0
- /package/dist/chunks/{chunk-ZHRBJT5B.js.map → chunk-BURGRQWO.js.map} +0 -0
- /package/dist/chunks/{chunk-3P5TQ3VZ.js.map → chunk-BWD2TUI4.js.map} +0 -0
- /package/dist/chunks/{chunk-OK3QKISP.js.map → chunk-C7E7YCRD.js.map} +0 -0
- /package/dist/chunks/{chunk-YMVJOKBZ.js.map → chunk-CXW7I2S3.js.map} +0 -0
- /package/dist/chunks/{chunk-BJWJPQ66.js.map → chunk-D6PB3Z7Q.js.map} +0 -0
- /package/dist/chunks/{chunk-FOS5YJED.js.map → chunk-DEAG4G5J.js.map} +0 -0
- /package/dist/chunks/{chunk-DHQJRU7E.js.map → chunk-DRSQTKDN.js.map} +0 -0
- /package/dist/chunks/{chunk-HNSJJXIO.js.map → chunk-EXJJLYZK.js.map} +0 -0
- /package/dist/chunks/{chunk-L7DZ2QPD.js.map → chunk-F5W4TNCR.js.map} +0 -0
- /package/dist/chunks/{chunk-XIBT7TAZ.js.map → chunk-F7KOBJVW.js.map} +0 -0
- /package/dist/chunks/{chunk-XLWFT4QC.js.map → chunk-FK4MAZV2.js.map} +0 -0
- /package/dist/chunks/{chunk-J2AH4QK4.js.map → chunk-FPC3K4TT.js.map} +0 -0
- /package/dist/chunks/{chunk-RE5EUO3F.js.map → chunk-FVIKYFYD.js.map} +0 -0
- /package/dist/chunks/{chunk-TN7MDKW2.js.map → chunk-GPTYDM26.js.map} +0 -0
- /package/dist/chunks/{chunk-3APHAS77.js.map → chunk-GT22EDUB.js.map} +0 -0
- /package/dist/chunks/{chunk-PGD2EYI7.js.map → chunk-GTUTBTOV.js.map} +0 -0
- /package/dist/chunks/{chunk-ZY7N242I.js.map → chunk-H6NTNPWD.js.map} +0 -0
- /package/dist/chunks/{chunk-2X53RSPY.js.map → chunk-HCQGZPVT.js.map} +0 -0
- /package/dist/chunks/{chunk-BBBVDHRH.js.map → chunk-HG2PPCAE.js.map} +0 -0
- /package/dist/chunks/{chunk-JR66BLKY.js.map → chunk-HKRUNZVI.js.map} +0 -0
- /package/dist/chunks/{chunk-BBBFPJV3.js.map → chunk-HM7L5PM2.js.map} +0 -0
- /package/dist/chunks/{chunk-2CP6CJXJ.js.map → chunk-I4RC6KQQ.js.map} +0 -0
- /package/dist/chunks/{chunk-GRCEOMSP.js.map → chunk-IL4Y3JGT.js.map} +0 -0
- /package/dist/chunks/{chunk-VUKFKBOO.js.map → chunk-J4PL65DJ.js.map} +0 -0
- /package/dist/chunks/{chunk-TYD5K7MT.js.map → chunk-JECLB23L.js.map} +0 -0
- /package/dist/chunks/{chunk-XVML5P53.js.map → chunk-JJ72TLOA.js.map} +0 -0
- /package/dist/chunks/{chunk-FQ3DUX7L.js.map → chunk-JRBFL6WT.js.map} +0 -0
- /package/dist/chunks/{chunk-UCDXXMAD.js.map → chunk-K2EKXCLZ.js.map} +0 -0
- /package/dist/chunks/{chunk-JCK6FM7F.js.map → chunk-ME4LETA3.js.map} +0 -0
- /package/dist/chunks/{chunk-2FP2UHZO.js.map → chunk-MF3SFDBW.js.map} +0 -0
- /package/dist/chunks/{chunk-HA46XY4I.js.map → chunk-MK42KB72.js.map} +0 -0
- /package/dist/chunks/{chunk-EYF7VILP.js.map → chunk-MUSGZEFY.js.map} +0 -0
- /package/dist/chunks/{chunk-XAMOWP2G.js.map → chunk-N5CCXOYK.js.map} +0 -0
- /package/dist/chunks/{chunk-DFOULHWV.js.map → chunk-NBJ5PRAY.js.map} +0 -0
- /package/dist/chunks/{chunk-ZPWWUTSR.js.map → chunk-NKHEBASJ.js.map} +0 -0
- /package/dist/chunks/{chunk-R6WB34IP.js.map → chunk-NVWD5XDT.js.map} +0 -0
- /package/dist/chunks/{chunk-CQNVNHRL.js.map → chunk-O45DCUNX.js.map} +0 -0
- /package/dist/chunks/{chunk-OVJOSPJ5.js.map → chunk-PAUMCJPX.js.map} +0 -0
- /package/dist/chunks/{chunk-E5GQTEDW.js.map → chunk-PE4MWWUW.js.map} +0 -0
- /package/dist/chunks/{chunk-3533PAJJ.js.map → chunk-PLCWCIL4.js.map} +0 -0
- /package/dist/chunks/{chunk-G4XSQIFF.js.map → chunk-PRJO4XM3.js.map} +0 -0
- /package/dist/chunks/{chunk-6V6MRHZZ.js.map → chunk-PRRX5LNR.js.map} +0 -0
- /package/dist/chunks/{chunk-LONNSCMP.js.map → chunk-PS5SVAUJ.js.map} +0 -0
- /package/dist/chunks/{chunk-EN2E63G6.js.map → chunk-PZWSRAE7.js.map} +0 -0
- /package/dist/chunks/{chunk-S6LFXBVK.js.map → chunk-QBLHOG2F.js.map} +0 -0
- /package/dist/chunks/{chunk-4FMBST2N.js.map → chunk-QCV3HH4P.js.map} +0 -0
- /package/dist/chunks/{chunk-R2TBZK62.js.map → chunk-QGBR42TV.js.map} +0 -0
- /package/dist/chunks/{chunk-TFOFFJNY.js.map → chunk-QNJXULU7.js.map} +0 -0
- /package/dist/chunks/{chunk-PIUHVCR3.js.map → chunk-R2KAESOM.js.map} +0 -0
- /package/dist/chunks/{chunk-G52WH6JI.js.map → chunk-R6M6EIAH.js.map} +0 -0
- /package/dist/chunks/{chunk-2PEIKBGP.js.map → chunk-RKKU2RE4.js.map} +0 -0
- /package/dist/chunks/{chunk-YHFKTEU6.js.map → chunk-RMOTHWPV.js.map} +0 -0
- /package/dist/chunks/{chunk-ZX5C2ELY.js.map → chunk-RQAY7REG.js.map} +0 -0
- /package/dist/chunks/{chunk-MXLAVYBS.js.map → chunk-SLTJNYOU.js.map} +0 -0
- /package/dist/chunks/{chunk-JARQ4I4Q.js.map → chunk-SXONHO4H.js.map} +0 -0
- /package/dist/chunks/{chunk-YWBOZNDX.js.map → chunk-T7ILM666.js.map} +0 -0
- /package/dist/chunks/{chunk-OOIVZ5PA.js.map → chunk-TBGKPWCL.js.map} +0 -0
- /package/dist/chunks/{chunk-M4LHZRTX.js.map → chunk-TBJ6XU3T.js.map} +0 -0
- /package/dist/chunks/{chunk-UI3ELYQU.js.map → chunk-TMPP2DEY.js.map} +0 -0
- /package/dist/chunks/{chunk-DLMDCCO7.js.map → chunk-TSOZBRM6.js.map} +0 -0
- /package/dist/chunks/{chunk-7XLZPKOT.js.map → chunk-TTFPWGIU.js.map} +0 -0
- /package/dist/chunks/{chunk-NCPOOJD4.js.map → chunk-TTKMQW6B.js.map} +0 -0
- /package/dist/chunks/{chunk-S5GKG5GV.js.map → chunk-UCML5ZXB.js.map} +0 -0
- /package/dist/chunks/{chunk-HAIG4TLP.js.map → chunk-VG7245VJ.js.map} +0 -0
- /package/dist/chunks/{chunk-IXJ6A2XE.js.map → chunk-VQZPXK4X.js.map} +0 -0
- /package/dist/chunks/{chunk-2MEBOBOM.js.map → chunk-VWUTJ4EU.js.map} +0 -0
- /package/dist/chunks/{chunk-VJFBRQZ4.js.map → chunk-WDKAL7EW.js.map} +0 -0
- /package/dist/chunks/{chunk-2ED34AXP.js.map → chunk-WJ6QRVL6.js.map} +0 -0
- /package/dist/chunks/{chunk-CKMF72VE.js.map → chunk-WOTA5FO5.js.map} +0 -0
- /package/dist/chunks/{chunk-QUUDXDDL.js.map → chunk-WPGVZMSU.js.map} +0 -0
- /package/dist/chunks/{chunk-EVJKQAZM.js.map → chunk-XDUA6PBP.js.map} +0 -0
- /package/dist/chunks/{chunk-GVHUHRGI.js.map → chunk-XE6XT6R6.js.map} +0 -0
- /package/dist/chunks/{chunk-LGUIDOA7.js.map → chunk-YR3TWNIV.js.map} +0 -0
- /package/dist/chunks/{chunk-K4APHATW.js.map → chunk-YWRRS7SO.js.map} +0 -0
- /package/dist/chunks/{chunk-ESLOAQRL.js.map → chunk-ZHEEG3NS.js.map} +0 -0
- /package/dist/chunks/{cli-runtime-SL6YG4EX.js.map → cli-runtime-ZJKKIW4H.js.map} +0 -0
- /package/dist/chunks/{commands-XRQOUFRE.js.map → commands-TQH5DD22.js.map} +0 -0
- /package/dist/chunks/{computer-6P3GAOV2.js.map → computer-WOU5WIIR.js.map} +0 -0
- /package/dist/chunks/{config-W3ABQG5K.js.map → config-APYUJ5UW.js.map} +0 -0
- /package/dist/chunks/{cost-ZKKW4JSZ.js.map → cost-5YV27U7F.js.map} +0 -0
- /package/dist/chunks/{crash-report-Q2WAKIU5.js.map → crash-report-QVXU2YVL.js.map} +0 -0
- /package/dist/chunks/{dist-JY4FIVBZ.js.map → dist-2FSOLP72.js.map} +0 -0
- /package/dist/chunks/{dist-O2QP5QCU.js.map → dist-AOT4CEP5.js.map} +0 -0
- /package/dist/chunks/{dist-OXSKWJNB.js.map → dist-H7CAJ3ZW.js.map} +0 -0
- /package/dist/chunks/{dist-IPR6EVQM.js.map → dist-IZGKRIWL.js.map} +0 -0
- /package/dist/chunks/{dist-WI7EX7ZF.js.map → dist-J4UXFVYR.js.map} +0 -0
- /package/dist/chunks/{dist-YE6ADUZP.js.map → dist-JHKRSGW6.js.map} +0 -0
- /package/dist/chunks/{dist-R4PUUPXV.js.map → dist-PZYMYR7N.js.map} +0 -0
- /package/dist/chunks/{dist-VT4VSQTO.js.map → dist-Z2HW2SJR.js.map} +0 -0
- /package/dist/chunks/{doctor-EUH7WGN6.js.map → doctor-CM6UPXG5.js.map} +0 -0
- /package/dist/chunks/{drain-3DDY42KQ.js.map → drain-X6RURKKC.js.map} +0 -0
- /package/dist/chunks/{entry-FNHGVOQM.js.map → entry-QQDPY6ZL.js.map} +0 -0
- /package/dist/chunks/{eval-CFKAWR3B.js.map → eval-GZA22B4I.js.map} +0 -0
- /package/dist/chunks/{extension-4VR722KH.js.map → extension-N5IQNKVZ.js.map} +0 -0
- /package/dist/chunks/{github-IF3JVVJF.js.map → github-AUOENJUY.js.map} +0 -0
- /package/dist/chunks/{home-JCDINY64.js.map → home-I4FIB6FV.js.map} +0 -0
- /package/dist/chunks/{homes-53P37RPB.js.map → homes-WTMMXQ6G.js.map} +0 -0
- /package/dist/chunks/{hooks-report-OK5PIOSF.js.map → hooks-report-K6VOPVBR.js.map} +0 -0
- /package/dist/chunks/{host-KF63UW3T.js.map → host-65UFBZJV.js.map} +0 -0
- /package/dist/chunks/{host-queries-5ZWYD4VD.js.map → host-queries-L4PYE2BW.js.map} +0 -0
- /package/dist/chunks/{installed-list-QLVA6XBV.js.map → installed-list-7QIWVKLQ.js.map} +0 -0
- /package/dist/chunks/{learn-XNVRCNGV.js.map → learn-NZXLKYV4.js.map} +0 -0
- /package/dist/chunks/{learn-builtin-XABWBGRU.js.map → learn-builtin-RC4XXVBS.js.map} +0 -0
- /package/dist/chunks/{lifecycle-K7REDQBN.js.map → lifecycle-NLCZ6OPA.js.map} +0 -0
- /package/dist/chunks/{list-US5UDLON.js.map → list-2U67CAWS.js.map} +0 -0
- /package/dist/chunks/{live-DNA4UB2B.js.map → live-CWJ2NWUQ.js.map} +0 -0
- /package/dist/chunks/{load-2WCYASMC.js.map → load-H52QQBVE.js.map} +0 -0
- /package/dist/chunks/{logs-ZF7YJNOC.js.map → logs-ZIW3QFU4.js.map} +0 -0
- /package/dist/chunks/{mcp-serve-TTZ33VMY.js.map → mcp-serve-ZC2OKIPP.js.map} +0 -0
- /package/dist/chunks/{open-I4YKGQSW.js.map → open-AHDQMVXI.js.map} +0 -0
- /package/dist/chunks/{operator-tools-FC5JFH42.js.map → operator-tools-P5R4TF6N.js.map} +0 -0
- /package/dist/chunks/{output-schema-KMYL2UB6.js.map → output-schema-Q5RWHNKE.js.map} +0 -0
- /package/dist/chunks/{pal-UZFR42OY.js.map → pal-T42HU4AK.js.map} +0 -0
- /package/dist/chunks/{peers-NM5HJGSR.js.map → peers-5RYEA7IA.js.map} +0 -0
- /package/dist/chunks/{peers-V7XCJUFZ.js.map → peers-7ZG3DEBO.js.map} +0 -0
- /package/dist/chunks/{providers-BQ25F6LA.js.map → providers-BXXIM7EW.js.map} +0 -0
- /package/dist/chunks/{providers-VS37WA3E.js.map → providers-I24HYZXG.js.map} +0 -0
- /package/dist/chunks/{pty-NWEV3DSP.js.map → pty-WVKM6ATI.js.map} +0 -0
- /package/dist/chunks/{resume-Y7P3TAVG.js.map → resume-F7JEDBHI.js.map} +0 -0
- /package/dist/chunks/{resume-command-KEXAVL6P.js.map → resume-command-4I47WN7T.js.map} +0 -0
- /package/dist/chunks/{running-JLMG6IL4.js.map → running-VID6BVT2.js.map} +0 -0
- /package/dist/chunks/{schedule-6ERJJOA3.js.map → schedule-75IZH76Z.js.map} +0 -0
- /package/dist/chunks/{send-UXJ7GXKN.js.map → send-QRYY2NCG.js.map} +0 -0
- /package/dist/chunks/{send-person-DLJU45IU.js.map → send-person-VADQNJBN.js.map} +0 -0
- /package/dist/chunks/{service-NYJZCLH2.js.map → service-B6BNESZB.js.map} +0 -0
- /package/dist/chunks/{setting-cli-ILFKSR4D.js.map → setting-cli-O4YWOIU5.js.map} +0 -0
- /package/dist/chunks/{start-check-7GBRCGVJ.js.map → start-check-EKRXJ5VE.js.map} +0 -0
- /package/dist/chunks/{startup-failure-UA32GGJB.js.map → startup-failure-2UJKPNMR.js.map} +0 -0
- /package/dist/chunks/{state-SSRHEX5K.js.map → state-X3MKUFYM.js.map} +0 -0
- /package/dist/chunks/{store-2GFZ5XXW.js.map → store-4OXWHFS5.js.map} +0 -0
- /package/dist/chunks/{store-MP5EB266.js.map → store-MK5IYBE5.js.map} +0 -0
- /package/dist/chunks/{store-ROR7VTZ2.js.map → store-QFNY4BV4.js.map} +0 -0
- /package/dist/chunks/{store-WRRTTRBT.js.map → store-VRKKFOYW.js.map} +0 -0
- /package/dist/chunks/{update-32IRH5TG.js.map → update-ELZEXYIX.js.map} +0 -0
- /package/dist/chunks/{workspaces-4YXZSENL.js.map → workspaces-3LB4SPPS.js.map} +0 -0
|
@@ -0,0 +1,3644 @@
|
|
|
1
|
+
import { createRequire as __namzuCreateRequire } from 'node:module';
|
|
2
|
+
const require = __namzuCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
listMarkdownNames,
|
|
5
|
+
resolvePluginFileDirs
|
|
6
|
+
} from "./chunk-32OIBGYI.js";
|
|
7
|
+
import {
|
|
8
|
+
INSTALL_MANIFEST_VERSION,
|
|
9
|
+
admissionScope,
|
|
10
|
+
currentEnabledAnswer,
|
|
11
|
+
installManifestPath,
|
|
12
|
+
isConfigFile,
|
|
13
|
+
isExecutablePath,
|
|
14
|
+
isInsidePluginCache,
|
|
15
|
+
loadInstalledManifest,
|
|
16
|
+
readInstallManifest,
|
|
17
|
+
readLayers,
|
|
18
|
+
readRecordLayer,
|
|
19
|
+
recordLayerPath,
|
|
20
|
+
setEnabledPlugin,
|
|
21
|
+
setExtraKnownMarketplace,
|
|
22
|
+
sha256Hex,
|
|
23
|
+
surfaceDigest,
|
|
24
|
+
verifyInstalledCopy
|
|
25
|
+
} from "./chunk-KF6IKSF2.js";
|
|
26
|
+
import {
|
|
27
|
+
ArchiveError,
|
|
28
|
+
openArchive
|
|
29
|
+
} from "./chunk-EBBT2I5S.js";
|
|
30
|
+
import {
|
|
31
|
+
readPluginHookEntriesOf
|
|
32
|
+
} from "./chunk-6TUHWKXP.js";
|
|
33
|
+
import {
|
|
34
|
+
readSkillHooks
|
|
35
|
+
} from "./chunk-TBJ6XU3T.js";
|
|
36
|
+
import {
|
|
37
|
+
PLUGIN_ID_PATTERN,
|
|
38
|
+
installManifestsFolder,
|
|
39
|
+
installedPluginDataFolder,
|
|
40
|
+
installedPluginsPath,
|
|
41
|
+
isPluginId,
|
|
42
|
+
isRecord,
|
|
43
|
+
isReservedPluginDir,
|
|
44
|
+
marketplacesFolder,
|
|
45
|
+
pluginCacheFolder,
|
|
46
|
+
pluginsFolder,
|
|
47
|
+
putInstallRecord,
|
|
48
|
+
putKnownMarketplace,
|
|
49
|
+
readInstalledPlugins,
|
|
50
|
+
readKnownMarketplaces,
|
|
51
|
+
realPathOrResolved,
|
|
52
|
+
removeInstallRecord,
|
|
53
|
+
samePath,
|
|
54
|
+
splitPluginId
|
|
55
|
+
} from "./chunk-D4TXOX34.js";
|
|
56
|
+
import {
|
|
57
|
+
parseSkillMarkdown
|
|
58
|
+
} from "./chunk-6HYK4DDB.js";
|
|
59
|
+
import {
|
|
60
|
+
EXIT_DATAERR,
|
|
61
|
+
EXIT_FAIL,
|
|
62
|
+
EXIT_NOINPUT,
|
|
63
|
+
EXIT_OK,
|
|
64
|
+
EXIT_UNAVAILABLE,
|
|
65
|
+
EXIT_UNTRUSTED,
|
|
66
|
+
EXIT_USAGE
|
|
67
|
+
} from "./chunk-24V2WEKR.js";
|
|
68
|
+
import {
|
|
69
|
+
terminalDisplayText
|
|
70
|
+
} from "./chunk-I4GTRFPK.js";
|
|
71
|
+
import {
|
|
72
|
+
StateFileBusyError,
|
|
73
|
+
StateFileUnreadableError,
|
|
74
|
+
unreadableStateFile,
|
|
75
|
+
withStateFileLock
|
|
76
|
+
} from "./chunk-F5W4TNCR.js";
|
|
77
|
+
import {
|
|
78
|
+
COMMON_MANIFEST_DIR,
|
|
79
|
+
COMMON_MARKETPLACE_FILE,
|
|
80
|
+
PLUGIN_MANIFEST_FILENAME,
|
|
81
|
+
discoverAllPluginDirs,
|
|
82
|
+
findCommonLayoutRoot,
|
|
83
|
+
hookModuleConsentEntry,
|
|
84
|
+
isHookEntriesPath,
|
|
85
|
+
isOfficialLookingMarketplaceName,
|
|
86
|
+
loadPluginManifest,
|
|
87
|
+
loadPluginManifestWithFindings,
|
|
88
|
+
locateHookModule,
|
|
89
|
+
parsePluginManifestText,
|
|
90
|
+
readCommonLayout,
|
|
91
|
+
resolveWithinReal,
|
|
92
|
+
scanHookModule
|
|
93
|
+
} from "./chunk-QQ4S6MNH.js";
|
|
94
|
+
import {
|
|
95
|
+
__name
|
|
96
|
+
} from "./chunk-76FLAFCG.js";
|
|
97
|
+
|
|
98
|
+
// src/commands/plugin-records.ts
|
|
99
|
+
import { lstatSync as lstatSync7, readdirSync as readdirSync5 } from "node:fs";
|
|
100
|
+
import { join as join9, resolve as resolve3 } from "node:path";
|
|
101
|
+
|
|
102
|
+
// src/integrations/plugins/manifest-details.ts
|
|
103
|
+
import { readFile, stat } from "node:fs/promises";
|
|
104
|
+
import { join } from "node:path";
|
|
105
|
+
var MAX_DETAIL_ITEMS = 100;
|
|
106
|
+
var NAME_MAX = 200;
|
|
107
|
+
var DESCRIPTION_MAX = 1024;
|
|
108
|
+
async function readPluginManifestDetails(rootDir, given) {
|
|
109
|
+
const file = join(rootDir, PLUGIN_MANIFEST_FILENAME);
|
|
110
|
+
let manifest;
|
|
111
|
+
let updatedAt;
|
|
112
|
+
if (given) {
|
|
113
|
+
manifest = given;
|
|
114
|
+
} else {
|
|
115
|
+
try {
|
|
116
|
+
manifest = parsePluginManifestText(await readFile(file, "utf8"));
|
|
117
|
+
updatedAt = (await stat(file)).mtime.toISOString();
|
|
118
|
+
} catch {
|
|
119
|
+
return {};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const skills = [];
|
|
123
|
+
for (const path of (manifest.skills ?? []).slice(0, MAX_DETAIL_ITEMS)) {
|
|
124
|
+
try {
|
|
125
|
+
const folder = await resolveWithinReal(rootDir, path);
|
|
126
|
+
const parsed = parseSkillMarkdown(
|
|
127
|
+
await readFile(join(folder, "SKILL.md"), "utf8"),
|
|
128
|
+
join(folder, "SKILL.md")
|
|
129
|
+
);
|
|
130
|
+
const name = parsed.name ?? path.split(/[\\/]/).filter(Boolean).pop() ?? path;
|
|
131
|
+
skills.push({
|
|
132
|
+
name: `${manifest.name}__${name}`.slice(0, NAME_MAX),
|
|
133
|
+
description: (parsed.description ?? "").slice(0, DESCRIPTION_MAX)
|
|
134
|
+
});
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const servers = (manifest.mcpServers ?? []).slice(0, MAX_DETAIL_ITEMS).map((server) => ({ name: server.name.slice(0, NAME_MAX) }));
|
|
139
|
+
return {
|
|
140
|
+
...skills.length > 0 ? { skills } : {},
|
|
141
|
+
...servers.length > 0 ? { servers } : {},
|
|
142
|
+
...manifest.author ? { author: manifest.author.slice(0, NAME_MAX) } : {},
|
|
143
|
+
...updatedAt ? { updatedAt } : {}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
__name(readPluginManifestDetails, "readPluginManifestDetails");
|
|
147
|
+
|
|
148
|
+
// src/integrations/plugins/remote-marketplace.ts
|
|
149
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
150
|
+
import { lstatSync as lstatSync6, mkdirSync as mkdirSync6, renameSync as renameSync3 } from "node:fs";
|
|
151
|
+
import { isAbsolute as isAbsolute3, join as join8, relative as relative2 } from "node:path";
|
|
152
|
+
|
|
153
|
+
// src/integrations/plugins/fetch/index.ts
|
|
154
|
+
import { lstatSync as lstatSync2, mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
155
|
+
import { join as join3 } from "node:path";
|
|
156
|
+
|
|
157
|
+
// src/integrations/plugins/fetch/archive.ts
|
|
158
|
+
import { createHash } from "node:crypto";
|
|
159
|
+
import { mkdirSync as mkdirSync2, writeFileSync } from "node:fs";
|
|
160
|
+
import { dirname } from "node:path";
|
|
161
|
+
|
|
162
|
+
// src/integrations/plugins/fetch/git.ts
|
|
163
|
+
import { execFile, spawn } from "node:child_process";
|
|
164
|
+
import {
|
|
165
|
+
closeSync,
|
|
166
|
+
existsSync,
|
|
167
|
+
lstatSync,
|
|
168
|
+
mkdirSync,
|
|
169
|
+
openSync,
|
|
170
|
+
readFileSync,
|
|
171
|
+
readSync,
|
|
172
|
+
readdirSync,
|
|
173
|
+
rmSync
|
|
174
|
+
} from "node:fs";
|
|
175
|
+
import { join as join2 } from "node:path";
|
|
176
|
+
|
|
177
|
+
// src/integrations/plugins/fetch/source.ts
|
|
178
|
+
var NOT_AN_ADDRESS = "Not a marketplace address. Use owner/repo, an https:// address, or a folder path.";
|
|
179
|
+
var KNOWN_GIT_HOSTS = ["github.com", "gitlab.com", "bitbucket.org"];
|
|
180
|
+
var SCP_FORM = /^([A-Za-z0-9_][\w.-]*)@([A-Za-z0-9][\w.-]*):([^\s\\]+)$/;
|
|
181
|
+
var SHORTHAND = /^([\w][\w.-]*)\/([\w][\w.-]*?)(?:\.git)?(?:[#@](.+))?$/;
|
|
182
|
+
var COMMIT_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
183
|
+
function isCommitId(value) {
|
|
184
|
+
return COMMIT_ID.test(value);
|
|
185
|
+
}
|
|
186
|
+
__name(isCommitId, "isCommitId");
|
|
187
|
+
function refProblem(ref) {
|
|
188
|
+
if (!/^[A-Za-z0-9_][A-Za-z0-9._/+-]{0,199}$/.test(ref) || ref.includes("..") || ref.includes("//") || ref.endsWith("/") || ref.endsWith(".") || ref.endsWith(".lock"))
|
|
189
|
+
return `"${ref}" is not a branch, tag or commit name Namzu will pass to Git.`;
|
|
190
|
+
return void 0;
|
|
191
|
+
}
|
|
192
|
+
__name(refProblem, "refProblem");
|
|
193
|
+
function repoPathProblem(path) {
|
|
194
|
+
if (path === "" || path.length > 300 || path.startsWith("/") || path.startsWith("-") || path.startsWith("~") || /^[A-Za-z]:/.test(path) || path.includes("\\") || // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what is refused
|
|
195
|
+
/[\u0000-\u001f\u007f]/.test(path) || path.split("/").some((part) => part === ".." || part === "." || part === ""))
|
|
196
|
+
return `"${path}" is not a folder inside the repository (no .., no absolute path).`;
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
__name(repoPathProblem, "repoPathProblem");
|
|
200
|
+
function splitRef(value) {
|
|
201
|
+
const at = value.indexOf("#");
|
|
202
|
+
if (at < 0) return { base: value };
|
|
203
|
+
return { base: value.slice(0, at), ref: value.slice(at + 1) };
|
|
204
|
+
}
|
|
205
|
+
__name(splitRef, "splitRef");
|
|
206
|
+
function parseRemoteAddress(input) {
|
|
207
|
+
const value = input.trim();
|
|
208
|
+
if (value === "" || value.startsWith("-") || /\s/.test(value))
|
|
209
|
+
return { ok: false, message: NOT_AN_ADDRESS };
|
|
210
|
+
const scp = SCP_FORM.exec(splitRef(value).base);
|
|
211
|
+
if (scp !== null) {
|
|
212
|
+
const { base, ref } = splitRef(value);
|
|
213
|
+
if (ref !== void 0) {
|
|
214
|
+
const problem = refProblem(ref);
|
|
215
|
+
if (problem !== void 0) return { ok: false, message: problem };
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
ok: true,
|
|
219
|
+
form: "git",
|
|
220
|
+
source: { source: "git", url: base, ...ref !== void 0 ? { ref } : {} }
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (/^https:\/\//i.test(value)) return parseHttps(value);
|
|
224
|
+
const short = SHORTHAND.exec(value);
|
|
225
|
+
if (short !== null && !value.includes(":")) {
|
|
226
|
+
const [, owner, repo, ref] = short;
|
|
227
|
+
if (owner === "." || owner === ".." || repo === "." || repo === "..")
|
|
228
|
+
return { ok: false, message: NOT_AN_ADDRESS };
|
|
229
|
+
if (ref !== void 0) {
|
|
230
|
+
const problem = refProblem(ref);
|
|
231
|
+
if (problem !== void 0) return { ok: false, message: problem };
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
ok: true,
|
|
235
|
+
form: "github",
|
|
236
|
+
source: { source: "github", repo: `${owner}/${repo}`, ...ref !== void 0 ? { ref } : {} }
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (value.includes("/") && !value.includes(":"))
|
|
240
|
+
return {
|
|
241
|
+
ok: false,
|
|
242
|
+
message: `'${value.slice(0, 80)}' is not a valid GitHub owner/repo shorthand. For a Git repository use its full https:// address. For a hosted marketplace.json use its https:// address. For a folder on this computer start with ./ or use an absolute path.`
|
|
243
|
+
};
|
|
244
|
+
return { ok: false, message: NOT_AN_ADDRESS };
|
|
245
|
+
}
|
|
246
|
+
__name(parseRemoteAddress, "parseRemoteAddress");
|
|
247
|
+
function parseHttps(value) {
|
|
248
|
+
const { base, ref } = splitRef(value);
|
|
249
|
+
let url;
|
|
250
|
+
try {
|
|
251
|
+
url = new URL(base);
|
|
252
|
+
} catch {
|
|
253
|
+
return { ok: false, message: NOT_AN_ADDRESS };
|
|
254
|
+
}
|
|
255
|
+
if (url.username !== "" || url.password !== "" || url.search !== "")
|
|
256
|
+
return {
|
|
257
|
+
ok: false,
|
|
258
|
+
message: "Remove the sign-in details from the address; Namzu uses your own Git setup."
|
|
259
|
+
};
|
|
260
|
+
if (ref !== void 0) {
|
|
261
|
+
const problem = refProblem(ref);
|
|
262
|
+
if (problem !== void 0) return { ok: false, message: problem };
|
|
263
|
+
}
|
|
264
|
+
const host = url.hostname.toLowerCase();
|
|
265
|
+
const path = url.pathname.replace(/\/+$/, "");
|
|
266
|
+
if (host === "github.com" && /\/(tree|blob)\//.test(path))
|
|
267
|
+
return {
|
|
268
|
+
ok: false,
|
|
269
|
+
message: "Use the repository address (owner/repo), not a page inside it."
|
|
270
|
+
};
|
|
271
|
+
const isGit = path.endsWith(".git") || path.includes("/_git/");
|
|
272
|
+
const hosted = KNOWN_GIT_HOSTS.includes(host) ? /^\/([\w.-]+)\/([\w.-]+?)(?:\.git)?$/.exec(path) : null;
|
|
273
|
+
if (hosted !== null && host === "github.com")
|
|
274
|
+
return {
|
|
275
|
+
ok: true,
|
|
276
|
+
form: "https",
|
|
277
|
+
source: {
|
|
278
|
+
source: "github",
|
|
279
|
+
repo: `${hosted[1]}/${hosted[2]}`,
|
|
280
|
+
...ref !== void 0 ? { ref } : {}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
if (isGit || hosted !== null) {
|
|
284
|
+
const clean = hosted !== null ? `https://${host}/${hosted[1]}/${hosted[2]}.git` : `https://${host}${url.port ? `:${url.port}` : ""}${path}`;
|
|
285
|
+
return {
|
|
286
|
+
ok: true,
|
|
287
|
+
form: "https",
|
|
288
|
+
source: { source: "git", url: clean, ...ref !== void 0 ? { ref } : {} }
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (ref !== void 0)
|
|
292
|
+
return {
|
|
293
|
+
ok: false,
|
|
294
|
+
message: "A hosted marketplace.json address takes no #ref: it is one file, not a repository."
|
|
295
|
+
};
|
|
296
|
+
return {
|
|
297
|
+
ok: true,
|
|
298
|
+
form: "https",
|
|
299
|
+
source: { source: "url", url: `https://${host}${url.port ? `:${url.port}` : ""}${path}` }
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
__name(parseHttps, "parseHttps");
|
|
303
|
+
function gitUrlOf(source) {
|
|
304
|
+
return source.source === "github" ? `https://github.com/${source.repo}.git` : source.url;
|
|
305
|
+
}
|
|
306
|
+
__name(gitUrlOf, "gitUrlOf");
|
|
307
|
+
function describeSource(source) {
|
|
308
|
+
switch (source.source) {
|
|
309
|
+
case "github":
|
|
310
|
+
return `github.com/${String(source.repo)}`;
|
|
311
|
+
case "git":
|
|
312
|
+
case "url":
|
|
313
|
+
return String(source.url);
|
|
314
|
+
default:
|
|
315
|
+
return String(source.path ?? source.source);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
__name(describeSource, "describeSource");
|
|
319
|
+
function normalizeAddress(text2) {
|
|
320
|
+
let value = text2.trim();
|
|
321
|
+
const scp = /^[^@/\s]+@([^:/\s]+):\/?(.+)$/.exec(value);
|
|
322
|
+
let host;
|
|
323
|
+
let path;
|
|
324
|
+
if (scp !== null && !/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) {
|
|
325
|
+
host = scp[1];
|
|
326
|
+
path = scp[2];
|
|
327
|
+
} else if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) {
|
|
328
|
+
try {
|
|
329
|
+
const url = new URL(value);
|
|
330
|
+
host = url.hostname;
|
|
331
|
+
path = url.pathname;
|
|
332
|
+
} catch {
|
|
333
|
+
value = value.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "");
|
|
334
|
+
const at = value.indexOf("/");
|
|
335
|
+
host = at < 0 ? value : value.slice(0, at);
|
|
336
|
+
path = at < 0 ? "" : value.slice(at);
|
|
337
|
+
}
|
|
338
|
+
} else {
|
|
339
|
+
const at = value.indexOf("/");
|
|
340
|
+
host = at < 0 ? value : value.slice(0, at);
|
|
341
|
+
path = at < 0 ? "" : value.slice(at);
|
|
342
|
+
}
|
|
343
|
+
host = host.replace(/^[^@]*@/, "").replace(/:\d*$/, "").toLowerCase().replace(/\.+$/, "");
|
|
344
|
+
if (host.startsWith("www.") && KNOWN_GIT_HOSTS.includes(host.slice(4))) host = host.slice(4);
|
|
345
|
+
try {
|
|
346
|
+
path = decodeURIComponent(path);
|
|
347
|
+
} catch {
|
|
348
|
+
}
|
|
349
|
+
path = path.toLowerCase().replace(/\/{2,}/g, "/").replace(/\/+$/, "").replace(/\.git$/, "").replace(/\/+$/, "");
|
|
350
|
+
return `${host}${path.startsWith("/") || path === "" ? "" : "/"}${path}`;
|
|
351
|
+
}
|
|
352
|
+
__name(normalizeAddress, "normalizeAddress");
|
|
353
|
+
function sourceKey(source) {
|
|
354
|
+
if (source.source === "github") return normalizeAddress(`github.com/${String(source.repo)}`);
|
|
355
|
+
if (source.source === "git" || source.source === "url")
|
|
356
|
+
return normalizeAddress(String(source.url));
|
|
357
|
+
return void 0;
|
|
358
|
+
}
|
|
359
|
+
__name(sourceKey, "sourceKey");
|
|
360
|
+
function isBlockedSource(source, blocked) {
|
|
361
|
+
if (blocked === void 0 || blocked.length === 0) return false;
|
|
362
|
+
const key = sourceKey(source);
|
|
363
|
+
if (key === void 0) return false;
|
|
364
|
+
for (const raw of blocked) {
|
|
365
|
+
let entry = raw.trim().toLowerCase();
|
|
366
|
+
if (entry === "") continue;
|
|
367
|
+
const wildcard = entry.endsWith("/*");
|
|
368
|
+
if (wildcard) entry = entry.slice(0, -2);
|
|
369
|
+
const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//.test(entry);
|
|
370
|
+
if (!hasScheme && !entry.split("/")[0]?.includes(".") && !entry.includes("@"))
|
|
371
|
+
entry = `github.com/${entry}`;
|
|
372
|
+
entry = normalizeAddress(entry);
|
|
373
|
+
if (entry === "") continue;
|
|
374
|
+
if (wildcard) {
|
|
375
|
+
if (key.startsWith(`${entry}/`)) return true;
|
|
376
|
+
} else if (!entry.includes("/")) {
|
|
377
|
+
if (key === entry || key.startsWith(`${entry}/`)) return true;
|
|
378
|
+
} else if (key === entry) return true;
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
__name(isBlockedSource, "isBlockedSource");
|
|
383
|
+
var SHA256 = /^[0-9a-f]{64}$/i;
|
|
384
|
+
function gitUrlProblem(url, allowFile) {
|
|
385
|
+
if (url.startsWith("-") || /\s/.test(url)) return "it is not a Git address";
|
|
386
|
+
if (SCP_FORM.test(url)) return void 0;
|
|
387
|
+
if (/^https:\/\//i.test(url) || /^ssh:\/\//i.test(url)) {
|
|
388
|
+
let parsed;
|
|
389
|
+
try {
|
|
390
|
+
parsed = new URL(url);
|
|
391
|
+
} catch {
|
|
392
|
+
return "it is not a Git address";
|
|
393
|
+
}
|
|
394
|
+
if (parsed.password !== "" || parsed.protocol === "https:" && parsed.username !== "")
|
|
395
|
+
return "it has sign-in details in it";
|
|
396
|
+
if (parsed.hostname === "" || parsed.hostname.startsWith("-")) return "it names no host";
|
|
397
|
+
if (parsed.protocol === "ssh:") {
|
|
398
|
+
let user = parsed.username;
|
|
399
|
+
try {
|
|
400
|
+
user = decodeURIComponent(user);
|
|
401
|
+
} catch {
|
|
402
|
+
return "it has sign-in details Namzu cannot read";
|
|
403
|
+
}
|
|
404
|
+
if (user.startsWith("-") || /[\u0000-\u001f\u007f\s]/.test(user))
|
|
405
|
+
return "its user name is not one Namzu will pass to Git";
|
|
406
|
+
}
|
|
407
|
+
return void 0;
|
|
408
|
+
}
|
|
409
|
+
if (allowFile && (url.startsWith("/") || /^file:\/\//i.test(url))) return void 0;
|
|
410
|
+
return "only https and ssh addresses are accepted";
|
|
411
|
+
}
|
|
412
|
+
__name(gitUrlProblem, "gitUrlProblem");
|
|
413
|
+
function parseEntrySource(name, source, entry, allowFile = false) {
|
|
414
|
+
const kind = typeof source.source === "string" ? source.source : "";
|
|
415
|
+
const invalid = /* @__PURE__ */ __name((reason) => ({ ok: false, unsupported: false, reason }), "invalid");
|
|
416
|
+
const text2 = /* @__PURE__ */ __name((value) => typeof value === "string" && value !== "" ? value : void 0, "text");
|
|
417
|
+
if (kind === "npm" || kind === "command" || kind === "")
|
|
418
|
+
return {
|
|
419
|
+
ok: false,
|
|
420
|
+
unsupported: true,
|
|
421
|
+
reason: `${name} is obtained by ${kind === "" ? "an unknown means" : kind}, which Namzu does not install: it would run a package manager or another program to get the code.`
|
|
422
|
+
};
|
|
423
|
+
if (kind !== "github" && kind !== "url" && kind !== "git" && kind !== "git-subdir" && kind !== "archive")
|
|
424
|
+
return {
|
|
425
|
+
ok: false,
|
|
426
|
+
unsupported: true,
|
|
427
|
+
reason: `${name} is obtained by ${kind}, which Namzu does not install.`
|
|
428
|
+
};
|
|
429
|
+
if ("headers" in entry || "headersHelper" in entry || "headers" in source || "headersHelper" in source)
|
|
430
|
+
return {
|
|
431
|
+
ok: false,
|
|
432
|
+
unsupported: true,
|
|
433
|
+
reason: `${name} needs request headers or a helper program to download, which Namzu does not run.`
|
|
434
|
+
};
|
|
435
|
+
const ref = text2(source.ref);
|
|
436
|
+
const sha = text2(source.sha);
|
|
437
|
+
if (ref !== void 0) {
|
|
438
|
+
const problem2 = refProblem(ref);
|
|
439
|
+
if (problem2 !== void 0) return invalid(`${name}: ${problem2}`);
|
|
440
|
+
}
|
|
441
|
+
if (sha !== void 0 && !isCommitId(sha.toLowerCase()))
|
|
442
|
+
return invalid(`${name}: the sha pin must be a full 40 or 64 character commit id.`);
|
|
443
|
+
const pins = {
|
|
444
|
+
...ref !== void 0 ? { ref } : {},
|
|
445
|
+
...sha !== void 0 ? { sha: sha.toLowerCase() } : {}
|
|
446
|
+
};
|
|
447
|
+
if (kind === "github") {
|
|
448
|
+
const repo = text2(source.repo);
|
|
449
|
+
if (repo === void 0 || !/^[\w][\w.-]*\/[\w][\w.-]*$/.test(repo))
|
|
450
|
+
return invalid(`${name}: the GitHub source needs repo as owner/repo.`);
|
|
451
|
+
return { ok: true, source: { kind: "github", repo, ...pins } };
|
|
452
|
+
}
|
|
453
|
+
if (kind === "archive") {
|
|
454
|
+
const url2 = text2(source.url);
|
|
455
|
+
if (url2 === void 0 || !/^https:\/\//i.test(url2))
|
|
456
|
+
return invalid(`${name}: an archive must be downloaded over https.`);
|
|
457
|
+
let parsed;
|
|
458
|
+
try {
|
|
459
|
+
parsed = new URL(url2);
|
|
460
|
+
} catch {
|
|
461
|
+
return invalid(`${name}: the archive address is not an address.`);
|
|
462
|
+
}
|
|
463
|
+
if (parsed.username !== "" || parsed.password !== "")
|
|
464
|
+
return invalid(`${name}: remove the sign-in details from the archive address.`);
|
|
465
|
+
const sha256 = text2(source.sha256);
|
|
466
|
+
if (sha256 !== void 0 && !SHA256.test(sha256))
|
|
467
|
+
return invalid(`${name}: sha256 must be 64 hexadecimal characters.`);
|
|
468
|
+
return {
|
|
469
|
+
ok: true,
|
|
470
|
+
source: {
|
|
471
|
+
kind: "archive",
|
|
472
|
+
url: url2,
|
|
473
|
+
...sha256 !== void 0 ? { sha256: sha256.toLowerCase() } : {}
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
const url = text2(source.url);
|
|
478
|
+
if (url === void 0) return invalid(`${name}: the source has no url.`);
|
|
479
|
+
const problem = gitUrlProblem(url, allowFile);
|
|
480
|
+
if (problem !== void 0) return invalid(`${name}: ${problem}.`);
|
|
481
|
+
if (kind === "url") return { ok: true, source: { kind: "git", url, ...pins } };
|
|
482
|
+
const path = text2(source.path);
|
|
483
|
+
if (path === void 0) return invalid(`${name}: a git-subdir source needs a path.`);
|
|
484
|
+
const pathProblem = repoPathProblem(path);
|
|
485
|
+
if (pathProblem !== void 0) return invalid(`${name}: ${pathProblem}`);
|
|
486
|
+
return { ok: true, source: { kind: "git-subdir", url, path, ...pins } };
|
|
487
|
+
}
|
|
488
|
+
__name(parseEntrySource, "parseEntrySource");
|
|
489
|
+
|
|
490
|
+
// src/integrations/plugins/fetch/git.ts
|
|
491
|
+
var FetchError = class extends Error {
|
|
492
|
+
constructor(code, message, kind) {
|
|
493
|
+
super(message);
|
|
494
|
+
this.code = code;
|
|
495
|
+
this.kind = kind;
|
|
496
|
+
}
|
|
497
|
+
code;
|
|
498
|
+
kind;
|
|
499
|
+
static {
|
|
500
|
+
__name(this, "FetchError");
|
|
501
|
+
}
|
|
502
|
+
name = "FetchError";
|
|
503
|
+
};
|
|
504
|
+
function cancelledFetch() {
|
|
505
|
+
return new FetchError(EXIT_FAIL, "Cancelled.", "cancelled");
|
|
506
|
+
}
|
|
507
|
+
__name(cancelledFetch, "cancelledFetch");
|
|
508
|
+
var DEFAULT_GIT_TIMEOUT_MS = 12e4;
|
|
509
|
+
var MAX_GIT_TIMEOUT_MS = 6e5;
|
|
510
|
+
var GIT_OUTPUT_CAP = 1024 * 1024;
|
|
511
|
+
var GIT_WRITE_MAX_BYTES = 512 * 1024 * 1024;
|
|
512
|
+
var GIT_WRITE_MAX_FILES = 1e5;
|
|
513
|
+
var GIT_WATCH_MS = 1e3;
|
|
514
|
+
var GIT_KILL_GRACE_MS = 5e3;
|
|
515
|
+
function gitTimeoutMs(env = process.env) {
|
|
516
|
+
const raw = env.NAMZU_PLUGIN_GIT_TIMEOUT_MS;
|
|
517
|
+
if (raw === void 0 || !/^\d+$/.test(raw)) return DEFAULT_GIT_TIMEOUT_MS;
|
|
518
|
+
const value = Number(raw);
|
|
519
|
+
if (!Number.isSafeInteger(value) || value < 1) return DEFAULT_GIT_TIMEOUT_MS;
|
|
520
|
+
return Math.min(value, MAX_GIT_TIMEOUT_MS);
|
|
521
|
+
}
|
|
522
|
+
__name(gitTimeoutMs, "gitTimeoutMs");
|
|
523
|
+
function killProcessTree(pid, platform) {
|
|
524
|
+
if (platform === "win32") {
|
|
525
|
+
return new Promise((resolve4) => {
|
|
526
|
+
execFile(
|
|
527
|
+
join2(process.env.SystemRoot ?? "C:\\Windows", "System32", "taskkill.exe"),
|
|
528
|
+
["/PID", String(pid), "/T", "/F"],
|
|
529
|
+
{ windowsHide: true, timeout: 5e3 },
|
|
530
|
+
() => resolve4()
|
|
531
|
+
);
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
try {
|
|
535
|
+
process.kill(-pid, "SIGKILL");
|
|
536
|
+
} catch {
|
|
537
|
+
try {
|
|
538
|
+
process.kill(pid, "SIGKILL");
|
|
539
|
+
} catch {
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
__name(killProcessTree, "killProcessTree");
|
|
544
|
+
function measureFolder(dir, maxFiles) {
|
|
545
|
+
let bytes2 = 0;
|
|
546
|
+
let files = 0;
|
|
547
|
+
const walk = /* @__PURE__ */ __name((path) => {
|
|
548
|
+
let entries;
|
|
549
|
+
try {
|
|
550
|
+
entries = readdirSync(path, { withFileTypes: true });
|
|
551
|
+
} catch {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
for (const entry of entries) {
|
|
555
|
+
if (files > maxFiles) return;
|
|
556
|
+
const child = join2(path, entry.name);
|
|
557
|
+
if (entry.isDirectory()) walk(child);
|
|
558
|
+
else {
|
|
559
|
+
files += 1;
|
|
560
|
+
try {
|
|
561
|
+
bytes2 += lstatSync(child).size;
|
|
562
|
+
} catch {
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}, "walk");
|
|
567
|
+
walk(dir);
|
|
568
|
+
return { bytes: bytes2, files };
|
|
569
|
+
}
|
|
570
|
+
__name(measureFolder, "measureFolder");
|
|
571
|
+
var live = /* @__PURE__ */ new Map();
|
|
572
|
+
var hooked = false;
|
|
573
|
+
function stopLiveGits() {
|
|
574
|
+
for (const [pid, entry] of [...live]) {
|
|
575
|
+
try {
|
|
576
|
+
entry.kill();
|
|
577
|
+
} catch {
|
|
578
|
+
}
|
|
579
|
+
live.delete(pid);
|
|
580
|
+
if (entry.dir !== void 0) {
|
|
581
|
+
try {
|
|
582
|
+
rmSync(entry.dir, { recursive: true, force: true });
|
|
583
|
+
} catch {
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
__name(stopLiveGits, "stopLiveGits");
|
|
589
|
+
var HOOK_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
590
|
+
function onSignal(signal) {
|
|
591
|
+
stopLiveGits();
|
|
592
|
+
unhook();
|
|
593
|
+
if (process.listenerCount(signal) === 0) process.kill(process.pid, signal);
|
|
594
|
+
}
|
|
595
|
+
__name(onSignal, "onSignal");
|
|
596
|
+
var signalListeners = {
|
|
597
|
+
SIGINT: /* @__PURE__ */ __name(() => onSignal("SIGINT"), "SIGINT"),
|
|
598
|
+
SIGTERM: /* @__PURE__ */ __name(() => onSignal("SIGTERM"), "SIGTERM"),
|
|
599
|
+
SIGHUP: /* @__PURE__ */ __name(() => onSignal("SIGHUP"), "SIGHUP")
|
|
600
|
+
};
|
|
601
|
+
function hook() {
|
|
602
|
+
if (hooked) return;
|
|
603
|
+
hooked = true;
|
|
604
|
+
process.on("exit", stopLiveGits);
|
|
605
|
+
for (const signal of HOOK_SIGNALS) process.on(signal, signalListeners[signal]);
|
|
606
|
+
}
|
|
607
|
+
__name(hook, "hook");
|
|
608
|
+
function unhook() {
|
|
609
|
+
if (!hooked) return;
|
|
610
|
+
hooked = false;
|
|
611
|
+
process.removeListener("exit", stopLiveGits);
|
|
612
|
+
for (const signal of HOOK_SIGNALS) process.removeListener(signal, signalListeners[signal]);
|
|
613
|
+
}
|
|
614
|
+
__name(unhook, "unhook");
|
|
615
|
+
function createGitRunner(deps = {}) {
|
|
616
|
+
const platform = deps.platform ?? process.platform;
|
|
617
|
+
const start = deps.spawn ?? ((command, args, options) => spawn(command, [...args], options));
|
|
618
|
+
const kill = deps.killTree ?? ((pid) => killProcessTree(pid, platform));
|
|
619
|
+
const later = deps.setTimeout ?? ((fn, ms) => setTimeout(fn, ms));
|
|
620
|
+
const cancel = deps.clearTimeout ?? ((handle) => clearTimeout(handle));
|
|
621
|
+
const sizeOf = deps.sizeOf ?? measureFolder;
|
|
622
|
+
return (args, options) => new Promise((resolve4) => {
|
|
623
|
+
let stdout = "";
|
|
624
|
+
let stderr = "";
|
|
625
|
+
let done = false;
|
|
626
|
+
let timedOut = false;
|
|
627
|
+
let oversize = false;
|
|
628
|
+
let stopping = false;
|
|
629
|
+
let watcher;
|
|
630
|
+
let grace;
|
|
631
|
+
let pid;
|
|
632
|
+
const finish = /* @__PURE__ */ __name((code, missing = false) => {
|
|
633
|
+
if (done) return;
|
|
634
|
+
done = true;
|
|
635
|
+
cancel(timer);
|
|
636
|
+
if (watcher !== void 0) cancel(watcher);
|
|
637
|
+
if (grace !== void 0) cancel(grace);
|
|
638
|
+
options.signal?.removeEventListener("abort", stop);
|
|
639
|
+
if (pid !== void 0) {
|
|
640
|
+
live.delete(pid);
|
|
641
|
+
if (live.size === 0) unhook();
|
|
642
|
+
}
|
|
643
|
+
resolve4({ code, stdout, stderr, timedOut, missing, ...oversize ? { oversize } : {} });
|
|
644
|
+
}, "finish");
|
|
645
|
+
const stop = /* @__PURE__ */ __name(() => {
|
|
646
|
+
if (stopping) return;
|
|
647
|
+
stopping = true;
|
|
648
|
+
if (child.pid === void 0) {
|
|
649
|
+
child.kill("SIGKILL");
|
|
650
|
+
finish(null);
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
void Promise.resolve(kill(child.pid)).then(() => {
|
|
654
|
+
if (!done) grace = later(() => finish(null), GIT_KILL_GRACE_MS);
|
|
655
|
+
});
|
|
656
|
+
}, "stop");
|
|
657
|
+
const child = start("git", args, {
|
|
658
|
+
...options.cwd !== void 0 ? { cwd: options.cwd } : {},
|
|
659
|
+
env: options.env,
|
|
660
|
+
shell: false,
|
|
661
|
+
detached: platform !== "win32",
|
|
662
|
+
windowsHide: true,
|
|
663
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
664
|
+
});
|
|
665
|
+
if (options.signal?.aborted) stop();
|
|
666
|
+
else options.signal?.addEventListener("abort", stop, { once: true });
|
|
667
|
+
const take = /* @__PURE__ */ __name((current, chunk) => current.length >= GIT_OUTPUT_CAP ? current : (current + String(chunk)).slice(0, GIT_OUTPUT_CAP), "take");
|
|
668
|
+
child.stdout?.on("data", (chunk) => {
|
|
669
|
+
stdout = take(stdout, chunk);
|
|
670
|
+
});
|
|
671
|
+
child.stderr?.on("data", (chunk) => {
|
|
672
|
+
stderr = take(stderr, chunk);
|
|
673
|
+
});
|
|
674
|
+
child.on("error", (error) => {
|
|
675
|
+
if (error.code === "ENOENT") finish(null, true);
|
|
676
|
+
else {
|
|
677
|
+
stderr = take(stderr, error.message);
|
|
678
|
+
finish(null);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
child.on("close", (code) => finish(code));
|
|
682
|
+
const timer = later(() => {
|
|
683
|
+
timedOut = true;
|
|
684
|
+
stop();
|
|
685
|
+
}, options.timeoutMs);
|
|
686
|
+
if (child.pid !== void 0) {
|
|
687
|
+
pid = child.pid;
|
|
688
|
+
const childPid = child.pid;
|
|
689
|
+
live.set(childPid, {
|
|
690
|
+
kill: /* @__PURE__ */ __name(() => void kill(childPid), "kill"),
|
|
691
|
+
dir: options.watch?.dir
|
|
692
|
+
});
|
|
693
|
+
hook();
|
|
694
|
+
}
|
|
695
|
+
const watch = options.watch;
|
|
696
|
+
if (watch !== void 0) {
|
|
697
|
+
const poll = /* @__PURE__ */ __name(() => {
|
|
698
|
+
if (done || stopping) return;
|
|
699
|
+
const size = sizeOf(watch.dir, watch.maxFiles);
|
|
700
|
+
if (size.bytes > watch.maxBytes || size.files > watch.maxFiles) {
|
|
701
|
+
oversize = true;
|
|
702
|
+
stop();
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
watcher = later(poll, GIT_WATCH_MS);
|
|
706
|
+
}, "poll");
|
|
707
|
+
watcher = later(poll, GIT_WATCH_MS);
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
__name(createGitRunner, "createGitRunner");
|
|
712
|
+
var defaultRunner = createGitRunner();
|
|
713
|
+
function gitEnvironment(base, allowFile) {
|
|
714
|
+
const env = {};
|
|
715
|
+
for (const [key, value] of Object.entries(base))
|
|
716
|
+
if (value !== void 0 && !/^GIT_/i.test(key)) env[key] = value;
|
|
717
|
+
env.GIT_TERMINAL_PROMPT = "0";
|
|
718
|
+
env.GIT_ASKPASS = "";
|
|
719
|
+
env.SSH_ASKPASS = "";
|
|
720
|
+
env.SSH_ASKPASS_REQUIRE = "never";
|
|
721
|
+
env.GIT_SSH_COMMAND = "ssh -o BatchMode=yes -o StrictHostKeyChecking=yes";
|
|
722
|
+
env.GIT_ALLOW_PROTOCOL = allowFile ? "https:ssh:file" : "https:ssh";
|
|
723
|
+
env.GIT_LFS_SKIP_SMUDGE = "1";
|
|
724
|
+
env.GIT_OPTIONAL_LOCKS = "0";
|
|
725
|
+
env.LC_ALL = "C";
|
|
726
|
+
env.LANG = "C";
|
|
727
|
+
return env;
|
|
728
|
+
}
|
|
729
|
+
__name(gitEnvironment, "gitEnvironment");
|
|
730
|
+
function gitSettings(allowFile, platform = process.platform) {
|
|
731
|
+
const nullDevice = platform === "win32" ? "NUL" : "/dev/null";
|
|
732
|
+
const settings = [
|
|
733
|
+
`core.hooksPath=${nullDevice}`,
|
|
734
|
+
"core.fsmonitor=false",
|
|
735
|
+
"core.symlinks=false",
|
|
736
|
+
"protocol.ext.allow=never",
|
|
737
|
+
`protocol.file.allow=${allowFile ? "always" : "never"}`,
|
|
738
|
+
"transfer.fsckObjects=true",
|
|
739
|
+
"fetch.fsckObjects=true",
|
|
740
|
+
"receive.fsckObjects=true",
|
|
741
|
+
"submodule.recurse=false",
|
|
742
|
+
"fetch.recurseSubmodules=false",
|
|
743
|
+
"core.autocrlf=false"
|
|
744
|
+
];
|
|
745
|
+
return settings.flatMap((setting) => ["-c", setting]);
|
|
746
|
+
}
|
|
747
|
+
__name(gitSettings, "gitSettings");
|
|
748
|
+
function hostOf(url) {
|
|
749
|
+
const scp = /^[^@/]+@([^:/]+):/.exec(url);
|
|
750
|
+
if (scp !== null) return scp[1];
|
|
751
|
+
try {
|
|
752
|
+
return new URL(url).hostname;
|
|
753
|
+
} catch {
|
|
754
|
+
return "that host";
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
__name(hostOf, "hostOf");
|
|
758
|
+
function explainGitFailure(run, url, timeoutMs) {
|
|
759
|
+
if (run.missing)
|
|
760
|
+
return new FetchError(
|
|
761
|
+
EXIT_UNAVAILABLE,
|
|
762
|
+
"Git is needed for this address. Install Git and run the command again.",
|
|
763
|
+
"git-missing"
|
|
764
|
+
);
|
|
765
|
+
if (run.oversize)
|
|
766
|
+
return new FetchError(
|
|
767
|
+
EXIT_DATAERR,
|
|
768
|
+
`The repository is larger than Namzu takes (more than ${GIT_WRITE_MAX_BYTES / (1024 * 1024)} MiB or ${GIT_WRITE_MAX_FILES} files), so it was stopped and nothing was taken from it.`,
|
|
769
|
+
"too-large"
|
|
770
|
+
);
|
|
771
|
+
if (run.timedOut)
|
|
772
|
+
return new FetchError(
|
|
773
|
+
EXIT_UNAVAILABLE,
|
|
774
|
+
`Git took longer than ${Math.round(timeoutMs / 1e3)} seconds and was stopped. Try again, or raise NAMZU_PLUGIN_GIT_TIMEOUT_MS (at most 600000).`,
|
|
775
|
+
"timeout"
|
|
776
|
+
);
|
|
777
|
+
const text2 = run.stderr;
|
|
778
|
+
if (/could not read (Username|Password)|terminal prompts disabled|Authentication failed|Permission denied \(publickey|Host key verification failed|no (supported )?authentication/i.test(
|
|
779
|
+
text2
|
|
780
|
+
))
|
|
781
|
+
return new FetchError(
|
|
782
|
+
EXIT_NOINPUT,
|
|
783
|
+
`Repository not found or not accessible: ${hostOf(url)} asked for a sign-in. Namzu uses your own Git setup and cannot ask for a password.`,
|
|
784
|
+
"auth"
|
|
785
|
+
);
|
|
786
|
+
if (/Remote branch .* not found|couldn't find remote ref|not our ref|did not match any|invalid reference|reference is not a tree|unadvertised object/i.test(
|
|
787
|
+
text2
|
|
788
|
+
))
|
|
789
|
+
return new FetchError(
|
|
790
|
+
EXIT_NOINPUT,
|
|
791
|
+
"That branch, tag or commit does not exist in the repository.",
|
|
792
|
+
"ref"
|
|
793
|
+
);
|
|
794
|
+
if (/Repository not found|not found|does not appear to be a git repository|does not exist|404/i.test(
|
|
795
|
+
text2
|
|
796
|
+
))
|
|
797
|
+
return new FetchError(
|
|
798
|
+
EXIT_NOINPUT,
|
|
799
|
+
"Repository not found or not accessible. Check the address, and that your own Git setup may read it.",
|
|
800
|
+
"not-found"
|
|
801
|
+
);
|
|
802
|
+
if (/Could not resolve host|Failed to connect|Connection (timed out|refused|reset)|Network is unreachable|unable to access|Could not resolve hostname|Operation timed out/i.test(
|
|
803
|
+
text2
|
|
804
|
+
))
|
|
805
|
+
return new FetchError(EXIT_UNAVAILABLE, `Could not reach ${hostOf(url)}.`, "network");
|
|
806
|
+
if (/protocol .* is not allowed|transport .* not allowed/i.test(text2))
|
|
807
|
+
return new FetchError(EXIT_DATAERR, "That kind of address is not allowed.", "protocol");
|
|
808
|
+
if (/fsck|bad object|corrupt|object .* is (broken|invalid)|invalid .* in (commit|tree)/i.test(text2))
|
|
809
|
+
return new FetchError(
|
|
810
|
+
EXIT_DATAERR,
|
|
811
|
+
"The repository failed Git\u2019s integrity checks, so nothing was taken from it.",
|
|
812
|
+
"fsck"
|
|
813
|
+
);
|
|
814
|
+
const first = text2.split("\n").map((line) => line.trim()).find((line) => line !== "");
|
|
815
|
+
return new FetchError(
|
|
816
|
+
EXIT_FAIL,
|
|
817
|
+
`Git could not fetch the repository${first !== void 0 ? ` (${[...first].map((c) => c.charCodeAt(0) < 32 ? " " : c).join("").slice(0, 200)})` : ""}.`,
|
|
818
|
+
"git"
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
__name(explainGitFailure, "explainGitFailure");
|
|
822
|
+
var Git = class {
|
|
823
|
+
constructor(options, dest) {
|
|
824
|
+
this.options = options;
|
|
825
|
+
this.dest = dest;
|
|
826
|
+
const allowFile = options.allowFileProtocol === true;
|
|
827
|
+
this.env = gitEnvironment(options.env ?? process.env, allowFile);
|
|
828
|
+
this.settings = gitSettings(allowFile);
|
|
829
|
+
this.timeoutMs = options.timeoutMs ?? gitTimeoutMs(options.env ?? process.env);
|
|
830
|
+
this.runner = options.runner ?? defaultRunner;
|
|
831
|
+
}
|
|
832
|
+
options;
|
|
833
|
+
dest;
|
|
834
|
+
static {
|
|
835
|
+
__name(this, "Git");
|
|
836
|
+
}
|
|
837
|
+
env;
|
|
838
|
+
settings;
|
|
839
|
+
timeoutMs;
|
|
840
|
+
runner;
|
|
841
|
+
async run(args, url, cwd) {
|
|
842
|
+
const run = await this.runner([...this.settings, ...args], {
|
|
843
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
844
|
+
env: this.env,
|
|
845
|
+
timeoutMs: this.timeoutMs,
|
|
846
|
+
watch: { dir: this.dest, maxBytes: GIT_WRITE_MAX_BYTES, maxFiles: GIT_WRITE_MAX_FILES },
|
|
847
|
+
...this.options.signal !== void 0 ? { signal: this.options.signal } : {}
|
|
848
|
+
});
|
|
849
|
+
if (this.options.signal?.aborted) throw cancelledFetch();
|
|
850
|
+
if (run.code !== 0) throw explainGitFailure(run, url, this.timeoutMs);
|
|
851
|
+
return run;
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
var LFS_HEADER = "version https://git-lfs.github.com/spec/v1";
|
|
855
|
+
function countLfsPointers(root) {
|
|
856
|
+
let count = 0;
|
|
857
|
+
let seen = 0;
|
|
858
|
+
const walk = /* @__PURE__ */ __name((dir) => {
|
|
859
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
860
|
+
if (entry.name === ".git") continue;
|
|
861
|
+
const path = join2(dir, entry.name);
|
|
862
|
+
if (entry.isDirectory()) walk(path);
|
|
863
|
+
else if (entry.isFile()) {
|
|
864
|
+
if (++seen > 5e4) return;
|
|
865
|
+
try {
|
|
866
|
+
const stat2 = lstatSync(path);
|
|
867
|
+
if (stat2.size < 20 || stat2.size > 1024) continue;
|
|
868
|
+
const fd = openSync(path, "r");
|
|
869
|
+
try {
|
|
870
|
+
const head = Buffer.alloc(LFS_HEADER.length);
|
|
871
|
+
readSync(fd, head, 0, head.length, 0);
|
|
872
|
+
if (head.toString("utf8") === LFS_HEADER) count += 1;
|
|
873
|
+
} finally {
|
|
874
|
+
closeSync(fd);
|
|
875
|
+
}
|
|
876
|
+
} catch {
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}, "walk");
|
|
881
|
+
try {
|
|
882
|
+
walk(root);
|
|
883
|
+
} catch {
|
|
884
|
+
}
|
|
885
|
+
return count;
|
|
886
|
+
}
|
|
887
|
+
__name(countLfsPointers, "countLfsPointers");
|
|
888
|
+
async function cloneRepository(request, options = {}) {
|
|
889
|
+
if (options.signal?.aborted) throw cancelledFetch();
|
|
890
|
+
const allowFile = options.allowFileProtocol === true;
|
|
891
|
+
const problem = gitUrlProblem(request.url, allowFile);
|
|
892
|
+
if (problem !== void 0)
|
|
893
|
+
throw new FetchError(
|
|
894
|
+
EXIT_USAGE,
|
|
895
|
+
`${hostOf(request.url)} cannot be used: ${problem}.`,
|
|
896
|
+
"address"
|
|
897
|
+
);
|
|
898
|
+
const sparse = request.sparsePaths ?? [];
|
|
899
|
+
for (const path of sparse) {
|
|
900
|
+
const bad = repoPathProblem(path);
|
|
901
|
+
if (bad !== void 0) throw new FetchError(EXIT_USAGE, bad, "path");
|
|
902
|
+
}
|
|
903
|
+
const url = options.rewriteUrl?.(request.url) ?? request.url;
|
|
904
|
+
const git = new Git(options, request.dest);
|
|
905
|
+
const byId = request.sha ?? (request.ref !== void 0 && isCommitId(request.ref) ? request.ref : void 0);
|
|
906
|
+
const filter = sparse.length > 0 ? ["--filter=blob:none"] : [];
|
|
907
|
+
mkdirSync(request.dest, { recursive: true, mode: 448 });
|
|
908
|
+
if (byId !== void 0) {
|
|
909
|
+
await git.run(["init", "--quiet"], request.url, request.dest);
|
|
910
|
+
await git.run(["remote", "add", "origin", "--", url], request.url, request.dest);
|
|
911
|
+
if (sparse.length > 0)
|
|
912
|
+
await git.run(
|
|
913
|
+
["sparse-checkout", "set", "--cone", "--", ...sparse],
|
|
914
|
+
request.url,
|
|
915
|
+
request.dest
|
|
916
|
+
);
|
|
917
|
+
await git.run(
|
|
918
|
+
["fetch", "--depth", "1", "--no-tags", "--no-recurse-submodules", ...filter, "origin", byId],
|
|
919
|
+
request.url,
|
|
920
|
+
request.dest
|
|
921
|
+
);
|
|
922
|
+
await git.run(["checkout", "--quiet", "--detach", "FETCH_HEAD"], request.url, request.dest);
|
|
923
|
+
} else {
|
|
924
|
+
await git.run(
|
|
925
|
+
[
|
|
926
|
+
"clone",
|
|
927
|
+
"--quiet",
|
|
928
|
+
"--depth",
|
|
929
|
+
"1",
|
|
930
|
+
"--no-tags",
|
|
931
|
+
"--single-branch",
|
|
932
|
+
"--no-recurse-submodules",
|
|
933
|
+
...request.ref !== void 0 ? ["--branch", request.ref] : [],
|
|
934
|
+
...sparse.length > 0 ? [...filter, "--sparse"] : [],
|
|
935
|
+
"--",
|
|
936
|
+
url,
|
|
937
|
+
request.dest
|
|
938
|
+
],
|
|
939
|
+
request.url
|
|
940
|
+
);
|
|
941
|
+
if (sparse.length > 0)
|
|
942
|
+
await git.run(
|
|
943
|
+
["sparse-checkout", "set", "--cone", "--", ...sparse],
|
|
944
|
+
request.url,
|
|
945
|
+
request.dest
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
const head = await git.run(["rev-parse", "HEAD"], request.url, request.dest);
|
|
949
|
+
const commit = head.stdout.trim();
|
|
950
|
+
if (!isCommitId(commit))
|
|
951
|
+
throw new FetchError(EXIT_FAIL, "Git did not say which commit it fetched.", "git");
|
|
952
|
+
if (request.sha !== void 0 && commit !== request.sha.toLowerCase())
|
|
953
|
+
throw new FetchError(
|
|
954
|
+
EXIT_DATAERR,
|
|
955
|
+
`The repository is at ${commit.slice(0, 7)}, not the commit ${request.sha.slice(0, 7)} it is pinned to. Nothing was taken from it.`,
|
|
956
|
+
"pin"
|
|
957
|
+
);
|
|
958
|
+
let submodules = 0;
|
|
959
|
+
try {
|
|
960
|
+
const files = await git.run(["ls-files", "--stage"], request.url, request.dest);
|
|
961
|
+
submodules = files.stdout.split("\n").filter((line) => line.startsWith("160000 ")).length;
|
|
962
|
+
} catch {
|
|
963
|
+
}
|
|
964
|
+
if (submodules === 0 && existsSync(join2(request.dest, ".gitmodules"))) {
|
|
965
|
+
try {
|
|
966
|
+
submodules = (readFileSync(join2(request.dest, ".gitmodules"), "utf8").match(/^\s*\[submodule /gm) ?? []).length;
|
|
967
|
+
} catch {
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
return { commit, lfsPointers: countLfsPointers(request.dest), submodules };
|
|
971
|
+
}
|
|
972
|
+
__name(cloneRepository, "cloneRepository");
|
|
973
|
+
|
|
974
|
+
// src/integrations/plugins/fetch/url.ts
|
|
975
|
+
var CATALOG_DOWNLOAD_MAX_BYTES = 10 * 1024 * 1024;
|
|
976
|
+
var CATALOG_DOWNLOAD_TIMEOUT_MS = 3e4;
|
|
977
|
+
var ARCHIVE_DOWNLOAD_MAX_BYTES = 200 * 1024 * 1024;
|
|
978
|
+
var ARCHIVE_DOWNLOAD_TIMEOUT_MS = 12e4;
|
|
979
|
+
var MAX_REDIRECTS = 5;
|
|
980
|
+
function allowedUrl(url, options) {
|
|
981
|
+
if (url.protocol === "https:") return true;
|
|
982
|
+
return options.allowLoopbackHttp === true && url.protocol === "http:" && url.hostname === "127.0.0.1";
|
|
983
|
+
}
|
|
984
|
+
__name(allowedUrl, "allowedUrl");
|
|
985
|
+
function isCatalogType(contentType) {
|
|
986
|
+
const type = contentType.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
987
|
+
return type === "" || type === "application/json" || type.endsWith("+json") || type.startsWith("text/plain");
|
|
988
|
+
}
|
|
989
|
+
__name(isCatalogType, "isCatalogType");
|
|
990
|
+
function isArchiveType(contentType) {
|
|
991
|
+
const type = contentType.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
992
|
+
return type !== "text/html" && type !== "application/json";
|
|
993
|
+
}
|
|
994
|
+
__name(isArchiveType, "isArchiveType");
|
|
995
|
+
async function download(request, options = {}) {
|
|
996
|
+
let current;
|
|
997
|
+
try {
|
|
998
|
+
current = new URL(options.rewriteUrl?.(request.url) ?? request.url);
|
|
999
|
+
} catch {
|
|
1000
|
+
throw new FetchError(EXIT_USAGE, `${request.url.slice(0, 80)} is not an address.`, "address");
|
|
1001
|
+
}
|
|
1002
|
+
if (!allowedUrl(current, options))
|
|
1003
|
+
throw new FetchError(EXIT_USAGE, "Only https:// addresses are downloaded.", "address");
|
|
1004
|
+
if (current.username !== "" || current.password !== "")
|
|
1005
|
+
throw new FetchError(
|
|
1006
|
+
EXIT_USAGE,
|
|
1007
|
+
"Remove the sign-in details from the address; Namzu does not send them.",
|
|
1008
|
+
"address"
|
|
1009
|
+
);
|
|
1010
|
+
const fetcher = options.fetchImpl ?? fetch;
|
|
1011
|
+
if (options.signal?.aborted) throw cancelledFetch();
|
|
1012
|
+
const controller = new AbortController();
|
|
1013
|
+
const onAbort = /* @__PURE__ */ __name(() => controller.abort(), "onAbort");
|
|
1014
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
1015
|
+
let timedOut = false;
|
|
1016
|
+
const timer = setTimeout(() => {
|
|
1017
|
+
timedOut = true;
|
|
1018
|
+
controller.abort();
|
|
1019
|
+
}, request.timeoutMs);
|
|
1020
|
+
const host = current.hostname;
|
|
1021
|
+
try {
|
|
1022
|
+
for (let hop = 0; ; hop++) {
|
|
1023
|
+
let response;
|
|
1024
|
+
try {
|
|
1025
|
+
response = await fetcher(current.toString(), {
|
|
1026
|
+
redirect: "manual",
|
|
1027
|
+
signal: controller.signal,
|
|
1028
|
+
headers: {
|
|
1029
|
+
accept: "application/json, text/plain;q=0.9, */*;q=0.1",
|
|
1030
|
+
"user-agent": "namzu-plugins"
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
} catch {
|
|
1034
|
+
if (options.signal?.aborted) throw cancelledFetch();
|
|
1035
|
+
if (timedOut)
|
|
1036
|
+
throw new FetchError(
|
|
1037
|
+
EXIT_UNAVAILABLE,
|
|
1038
|
+
`${host} did not finish answering within ${Math.round(request.timeoutMs / 1e3)} seconds.`,
|
|
1039
|
+
"timeout"
|
|
1040
|
+
);
|
|
1041
|
+
throw new FetchError(EXIT_UNAVAILABLE, `Could not reach ${host}.`, "network");
|
|
1042
|
+
}
|
|
1043
|
+
if (response.status >= 300 && response.status < 400) {
|
|
1044
|
+
const location = response.headers.get("location");
|
|
1045
|
+
await response.body?.cancel().catch(() => void 0);
|
|
1046
|
+
if (location === null)
|
|
1047
|
+
throw new FetchError(
|
|
1048
|
+
EXIT_UNAVAILABLE,
|
|
1049
|
+
`${host} redirected without saying where.`,
|
|
1050
|
+
"redirect"
|
|
1051
|
+
);
|
|
1052
|
+
if (hop >= MAX_REDIRECTS)
|
|
1053
|
+
throw new FetchError(
|
|
1054
|
+
EXIT_UNAVAILABLE,
|
|
1055
|
+
`${host} redirected more than ${MAX_REDIRECTS} times.`,
|
|
1056
|
+
"redirect"
|
|
1057
|
+
);
|
|
1058
|
+
let next;
|
|
1059
|
+
try {
|
|
1060
|
+
next = new URL(location, current);
|
|
1061
|
+
} catch {
|
|
1062
|
+
throw new FetchError(
|
|
1063
|
+
EXIT_UNAVAILABLE,
|
|
1064
|
+
`${host} redirected to something that is not an address.`,
|
|
1065
|
+
"redirect"
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
if (!allowedUrl(next, options))
|
|
1069
|
+
throw new FetchError(
|
|
1070
|
+
EXIT_DATAERR,
|
|
1071
|
+
`${host} redirected to an address that is not https, so the download was stopped.`,
|
|
1072
|
+
"redirect"
|
|
1073
|
+
);
|
|
1074
|
+
current = next;
|
|
1075
|
+
continue;
|
|
1076
|
+
}
|
|
1077
|
+
if (response.status === 404 || response.status === 410)
|
|
1078
|
+
throw new FetchError(
|
|
1079
|
+
EXIT_NOINPUT,
|
|
1080
|
+
`Nothing is at that address on ${current.hostname} (${response.status}).`,
|
|
1081
|
+
"not-found"
|
|
1082
|
+
);
|
|
1083
|
+
if (response.status === 401 || response.status === 403)
|
|
1084
|
+
throw new FetchError(
|
|
1085
|
+
EXIT_NOINPUT,
|
|
1086
|
+
`${current.hostname} wants a sign-in for that address, which Namzu does not send.`,
|
|
1087
|
+
"auth"
|
|
1088
|
+
);
|
|
1089
|
+
if (!response.ok)
|
|
1090
|
+
throw new FetchError(
|
|
1091
|
+
EXIT_UNAVAILABLE,
|
|
1092
|
+
`${current.hostname} answered ${response.status}.`,
|
|
1093
|
+
"status"
|
|
1094
|
+
);
|
|
1095
|
+
if (!request.acceptType(response.headers.get("content-type") ?? ""))
|
|
1096
|
+
throw new FetchError(
|
|
1097
|
+
EXIT_DATAERR,
|
|
1098
|
+
`${current.hostname} sent something that is not a ${request.subject} (${(response.headers.get("content-type") ?? "").split(";")[0]}).`,
|
|
1099
|
+
"type"
|
|
1100
|
+
);
|
|
1101
|
+
const declared = Number(response.headers.get("content-length") ?? "");
|
|
1102
|
+
const tooBig = new FetchError(
|
|
1103
|
+
EXIT_DATAERR,
|
|
1104
|
+
`The ${request.subject} is larger than ${Math.round(request.maxBytes / (1024 * 1024))} MiB, so it was not downloaded.`,
|
|
1105
|
+
"size"
|
|
1106
|
+
);
|
|
1107
|
+
if (Number.isFinite(declared) && declared > request.maxBytes) {
|
|
1108
|
+
await response.body?.cancel().catch(() => void 0);
|
|
1109
|
+
throw tooBig;
|
|
1110
|
+
}
|
|
1111
|
+
if (response.body === null) return Buffer.alloc(0);
|
|
1112
|
+
const reader = response.body.getReader();
|
|
1113
|
+
const chunks = [];
|
|
1114
|
+
let total = 0;
|
|
1115
|
+
try {
|
|
1116
|
+
for (; ; ) {
|
|
1117
|
+
const { done, value } = await reader.read();
|
|
1118
|
+
if (done) break;
|
|
1119
|
+
total += value.byteLength;
|
|
1120
|
+
if (total > request.maxBytes) {
|
|
1121
|
+
await reader.cancel().catch(() => void 0);
|
|
1122
|
+
throw tooBig;
|
|
1123
|
+
}
|
|
1124
|
+
chunks.push(Buffer.from(value));
|
|
1125
|
+
}
|
|
1126
|
+
} catch (error) {
|
|
1127
|
+
if (error instanceof FetchError) throw error;
|
|
1128
|
+
if (options.signal?.aborted) throw cancelledFetch();
|
|
1129
|
+
if (timedOut)
|
|
1130
|
+
throw new FetchError(
|
|
1131
|
+
EXIT_UNAVAILABLE,
|
|
1132
|
+
`${host} did not finish sending within ${Math.round(request.timeoutMs / 1e3)} seconds.`,
|
|
1133
|
+
"timeout"
|
|
1134
|
+
);
|
|
1135
|
+
throw new FetchError(EXIT_UNAVAILABLE, `The download from ${host} was cut off.`, "network");
|
|
1136
|
+
}
|
|
1137
|
+
return Buffer.concat(chunks);
|
|
1138
|
+
}
|
|
1139
|
+
} finally {
|
|
1140
|
+
clearTimeout(timer);
|
|
1141
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
__name(download, "download");
|
|
1145
|
+
async function fetchCatalogText(url, options = {}) {
|
|
1146
|
+
const bytes2 = await download(
|
|
1147
|
+
{
|
|
1148
|
+
url,
|
|
1149
|
+
maxBytes: CATALOG_DOWNLOAD_MAX_BYTES,
|
|
1150
|
+
timeoutMs: CATALOG_DOWNLOAD_TIMEOUT_MS,
|
|
1151
|
+
acceptType: isCatalogType,
|
|
1152
|
+
subject: "catalog"
|
|
1153
|
+
},
|
|
1154
|
+
options
|
|
1155
|
+
);
|
|
1156
|
+
return bytes2.toString("utf8");
|
|
1157
|
+
}
|
|
1158
|
+
__name(fetchCatalogText, "fetchCatalogText");
|
|
1159
|
+
|
|
1160
|
+
// src/integrations/plugins/fetch/archive.ts
|
|
1161
|
+
async function downloadArchive(url, dest, expectedSha256, options = {}) {
|
|
1162
|
+
const body = await download(
|
|
1163
|
+
{
|
|
1164
|
+
url,
|
|
1165
|
+
maxBytes: ARCHIVE_DOWNLOAD_MAX_BYTES,
|
|
1166
|
+
timeoutMs: ARCHIVE_DOWNLOAD_TIMEOUT_MS,
|
|
1167
|
+
acceptType: isArchiveType,
|
|
1168
|
+
subject: "archive"
|
|
1169
|
+
},
|
|
1170
|
+
options
|
|
1171
|
+
);
|
|
1172
|
+
const sha256 = createHash("sha256").update(body).digest("hex");
|
|
1173
|
+
if (expectedSha256 !== void 0 && sha256 !== expectedSha256.toLowerCase())
|
|
1174
|
+
throw new FetchError(
|
|
1175
|
+
EXIT_DATAERR,
|
|
1176
|
+
`The download does not match the digest the marketplace gave for it (expected ${expectedSha256.slice(0, 12)}, got ${sha256.slice(0, 12)}). Nothing was installed.`,
|
|
1177
|
+
"digest"
|
|
1178
|
+
);
|
|
1179
|
+
mkdirSync2(dirname(dest), { recursive: true, mode: 448 });
|
|
1180
|
+
writeFileSync(dest, body, { mode: 384 });
|
|
1181
|
+
return { file: dest, sha256, bytes: body.length };
|
|
1182
|
+
}
|
|
1183
|
+
__name(downloadArchive, "downloadArchive");
|
|
1184
|
+
|
|
1185
|
+
// src/integrations/plugins/fetch/index.ts
|
|
1186
|
+
async function fetchMarketplace(source, staging, options = {}) {
|
|
1187
|
+
const dir = join3(staging, "m");
|
|
1188
|
+
if (source.source === "url") {
|
|
1189
|
+
const text2 = await fetchCatalogText(source.url, options);
|
|
1190
|
+
const file = join3(dir, COMMON_MANIFEST_DIR, COMMON_MARKETPLACE_FILE);
|
|
1191
|
+
mkdirSync3(join3(dir, COMMON_MANIFEST_DIR), { recursive: true, mode: 448 });
|
|
1192
|
+
writeFileSync2(file, text2, { mode: 384 });
|
|
1193
|
+
return { dir, lfsPointers: 0, submodules: 0 };
|
|
1194
|
+
}
|
|
1195
|
+
const sparse = source.sparsePaths;
|
|
1196
|
+
const result = await cloneRepository(
|
|
1197
|
+
{
|
|
1198
|
+
url: gitUrlOf(source),
|
|
1199
|
+
...source.ref !== void 0 ? { ref: source.ref } : {},
|
|
1200
|
+
...sparse !== void 0 && sparse.length > 0 ? { sparsePaths: [.../* @__PURE__ */ new Set([...sparse, COMMON_MANIFEST_DIR])] } : {},
|
|
1201
|
+
dest: dir
|
|
1202
|
+
},
|
|
1203
|
+
options
|
|
1204
|
+
);
|
|
1205
|
+
return {
|
|
1206
|
+
dir,
|
|
1207
|
+
commit: result.commit,
|
|
1208
|
+
lfsPointers: result.lfsPointers,
|
|
1209
|
+
submodules: result.submodules
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
__name(fetchMarketplace, "fetchMarketplace");
|
|
1213
|
+
async function fetchPlugin(source, staging, options = {}) {
|
|
1214
|
+
if (source.kind === "archive") {
|
|
1215
|
+
const archive = await downloadArchive(
|
|
1216
|
+
source.url,
|
|
1217
|
+
join3(staging, "plugin.zip"),
|
|
1218
|
+
source.sha256,
|
|
1219
|
+
options
|
|
1220
|
+
);
|
|
1221
|
+
return { archive, lfsPointers: 0, submodules: 0 };
|
|
1222
|
+
}
|
|
1223
|
+
const dest = join3(staging, "fetched");
|
|
1224
|
+
const result = await cloneRepository(
|
|
1225
|
+
{
|
|
1226
|
+
url: source.kind === "github" ? `https://github.com/${source.repo}.git` : source.url,
|
|
1227
|
+
...source.ref !== void 0 ? { ref: source.ref } : {},
|
|
1228
|
+
...source.sha !== void 0 ? { sha: source.sha } : {},
|
|
1229
|
+
...source.kind === "git-subdir" ? { sparsePaths: [source.path] } : {},
|
|
1230
|
+
dest
|
|
1231
|
+
},
|
|
1232
|
+
options
|
|
1233
|
+
);
|
|
1234
|
+
let dir = dest;
|
|
1235
|
+
if (source.kind === "git-subdir") {
|
|
1236
|
+
try {
|
|
1237
|
+
dir = await resolveWithinReal(dest, source.path);
|
|
1238
|
+
if (!lstatSync2(dir).isDirectory()) throw new Error("not a folder");
|
|
1239
|
+
} catch {
|
|
1240
|
+
throw new FetchError(
|
|
1241
|
+
EXIT_DATAERR,
|
|
1242
|
+
`The repository has no folder "${source.path}", or it leaves the repository.`,
|
|
1243
|
+
"path"
|
|
1244
|
+
);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
return {
|
|
1248
|
+
dir,
|
|
1249
|
+
commit: result.commit,
|
|
1250
|
+
lfsPointers: result.lfsPointers,
|
|
1251
|
+
submodules: result.submodules
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
__name(fetchPlugin, "fetchPlugin");
|
|
1255
|
+
|
|
1256
|
+
// src/integrations/plugins/install-plan.ts
|
|
1257
|
+
import { randomUUID } from "node:crypto";
|
|
1258
|
+
import {
|
|
1259
|
+
chmodSync,
|
|
1260
|
+
copyFileSync,
|
|
1261
|
+
existsSync as existsSync2,
|
|
1262
|
+
lstatSync as lstatSync5,
|
|
1263
|
+
mkdirSync as mkdirSync4,
|
|
1264
|
+
readFileSync as readFileSync4,
|
|
1265
|
+
readdirSync as readdirSync3,
|
|
1266
|
+
realpathSync as realpathSync2,
|
|
1267
|
+
renameSync,
|
|
1268
|
+
rmSync as rmSync2,
|
|
1269
|
+
statSync,
|
|
1270
|
+
writeFileSync as writeFileSync3
|
|
1271
|
+
} from "node:fs";
|
|
1272
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join6, relative, resolve as resolve2 } from "node:path";
|
|
1273
|
+
|
|
1274
|
+
// src/integrations/plugins/marketplace.ts
|
|
1275
|
+
import { lstatSync as lstatSync3, readFileSync as readFileSync2, realpathSync } from "node:fs";
|
|
1276
|
+
import { basename, dirname as dirname2, isAbsolute, join as join4, resolve } from "node:path";
|
|
1277
|
+
var LOCAL_UPLOADS_MARKETPLACE = "local-uploads";
|
|
1278
|
+
var RESERVED_MARKETPLACE_NAMES = [
|
|
1279
|
+
LOCAL_UPLOADS_MARKETPLACE,
|
|
1280
|
+
"inline",
|
|
1281
|
+
"builtin",
|
|
1282
|
+
"synced"
|
|
1283
|
+
];
|
|
1284
|
+
var MAX_CATALOG_PLUGINS = 500;
|
|
1285
|
+
var MAX_CATALOG_BYTES = 10 * 1024 * 1024;
|
|
1286
|
+
var NAME_RULE = /^[a-z0-9][a-z0-9._-]{0,63}$/;
|
|
1287
|
+
function marketplaceNameProblem(name) {
|
|
1288
|
+
if (!NAME_RULE.test(name) || name.includes(".."))
|
|
1289
|
+
return `"${name}" is not a marketplace name. Use lowercase letters, digits, dots, dashes and underscores, starting with a letter or digit, at most 64 characters.`;
|
|
1290
|
+
const lower = name.toLowerCase();
|
|
1291
|
+
if (RESERVED_MARKETPLACE_NAMES.includes(lower) || lower === "namzu" || lower.startsWith("namzu-"))
|
|
1292
|
+
return `The marketplace name "${name}" is reserved.`;
|
|
1293
|
+
if (isOfficialLookingMarketplaceName(name))
|
|
1294
|
+
return `The marketplace name "${name}" looks like an official catalog's name, which another marketplace may not use.`;
|
|
1295
|
+
return void 0;
|
|
1296
|
+
}
|
|
1297
|
+
__name(marketplaceNameProblem, "marketplaceNameProblem");
|
|
1298
|
+
var ENTRY_COMPONENT_FIELDS = [
|
|
1299
|
+
"skills",
|
|
1300
|
+
"commands",
|
|
1301
|
+
"agents",
|
|
1302
|
+
"hooks",
|
|
1303
|
+
"mcpServers"
|
|
1304
|
+
];
|
|
1305
|
+
var ENTRY_SIDECAR_KEEPS = [
|
|
1306
|
+
"name",
|
|
1307
|
+
"description",
|
|
1308
|
+
"version",
|
|
1309
|
+
"author",
|
|
1310
|
+
"strict",
|
|
1311
|
+
"platforms",
|
|
1312
|
+
"engines",
|
|
1313
|
+
...ENTRY_COMPONENT_FIELDS
|
|
1314
|
+
];
|
|
1315
|
+
function catalogLocation(location, kind) {
|
|
1316
|
+
if (kind === "file") {
|
|
1317
|
+
const dir = dirname2(location);
|
|
1318
|
+
return { file: location, root: basename(dir) === COMMON_MANIFEST_DIR ? dirname2(dir) : dir };
|
|
1319
|
+
}
|
|
1320
|
+
const inside2 = join4(location, COMMON_MANIFEST_DIR, COMMON_MARKETPLACE_FILE);
|
|
1321
|
+
let file = inside2;
|
|
1322
|
+
try {
|
|
1323
|
+
lstatSync3(inside2);
|
|
1324
|
+
} catch {
|
|
1325
|
+
const plain = join4(location, COMMON_MARKETPLACE_FILE);
|
|
1326
|
+
try {
|
|
1327
|
+
lstatSync3(plain);
|
|
1328
|
+
file = plain;
|
|
1329
|
+
} catch {
|
|
1330
|
+
file = inside2;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
return { file, root: location };
|
|
1334
|
+
}
|
|
1335
|
+
__name(catalogLocation, "catalogLocation");
|
|
1336
|
+
function text(value, max = 1024) {
|
|
1337
|
+
return typeof value === "string" && value.trim() !== "" ? value.trim().slice(0, max) : void 0;
|
|
1338
|
+
}
|
|
1339
|
+
__name(text, "text");
|
|
1340
|
+
function readCatalog(location, kind) {
|
|
1341
|
+
const { file, root } = catalogLocation(location, kind);
|
|
1342
|
+
let stat2;
|
|
1343
|
+
try {
|
|
1344
|
+
stat2 = lstatSync3(file);
|
|
1345
|
+
} catch {
|
|
1346
|
+
return {
|
|
1347
|
+
ok: false,
|
|
1348
|
+
missing: true,
|
|
1349
|
+
reason: `There is no catalog at ${file}. A marketplace folder holds ${COMMON_MANIFEST_DIR}/${COMMON_MARKETPLACE_FILE}.`
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
if (!stat2.isFile())
|
|
1353
|
+
return { ok: false, reason: `${file} is a link or not a regular file, so it is not read.` };
|
|
1354
|
+
if (stat2.size > MAX_CATALOG_BYTES)
|
|
1355
|
+
return { ok: false, reason: `${file} is larger than ${MAX_CATALOG_BYTES / (1024 * 1024)} MiB.` };
|
|
1356
|
+
let parsed;
|
|
1357
|
+
try {
|
|
1358
|
+
parsed = JSON.parse(readFileSync2(file, "utf8"));
|
|
1359
|
+
} catch (error) {
|
|
1360
|
+
return {
|
|
1361
|
+
ok: false,
|
|
1362
|
+
reason: `${file} is not valid JSON (${error instanceof Error ? error.message : String(error)}).`
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
if (!isRecord(parsed))
|
|
1366
|
+
return { ok: false, reason: `${file} is not a catalog: it is not a mapping.` };
|
|
1367
|
+
const name = text(parsed.name, 200);
|
|
1368
|
+
if (name === void 0) return { ok: false, reason: `${file} has no "name".` };
|
|
1369
|
+
if (!Array.isArray(parsed.plugins)) return { ok: false, reason: `${file} has no "plugins" list.` };
|
|
1370
|
+
if (parsed.plugins.length > MAX_CATALOG_PLUGINS)
|
|
1371
|
+
return {
|
|
1372
|
+
ok: false,
|
|
1373
|
+
reason: `${file} lists ${parsed.plugins.length} plugins; at most ${MAX_CATALOG_PLUGINS} are read.`
|
|
1374
|
+
};
|
|
1375
|
+
const warnings = [];
|
|
1376
|
+
const owner = isRecord(parsed.owner) ? text(parsed.owner.name, 200) : void 0;
|
|
1377
|
+
if (owner === void 0) warnings.push("The catalog names no owner.");
|
|
1378
|
+
const metadata = isRecord(parsed.metadata) ? parsed.metadata : {};
|
|
1379
|
+
const pluginRoot = text(metadata.pluginRoot, 512);
|
|
1380
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1381
|
+
const entries = [];
|
|
1382
|
+
for (const [index, item] of parsed.plugins.entries()) {
|
|
1383
|
+
if (!isRecord(item)) {
|
|
1384
|
+
warnings.push(`Entry ${index + 1} is not a mapping and was left out.`);
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1387
|
+
const entryName = text(item.name, 64);
|
|
1388
|
+
if (entryName === void 0 || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(entryName)) {
|
|
1389
|
+
warnings.push(`Entry ${index + 1} has no usable name and was left out.`);
|
|
1390
|
+
continue;
|
|
1391
|
+
}
|
|
1392
|
+
if (item.source === void 0 || typeof item.source !== "string" && !isRecord(item.source) || item.source === "") {
|
|
1393
|
+
warnings.push(`${entryName} has no source and was left out.`);
|
|
1394
|
+
continue;
|
|
1395
|
+
}
|
|
1396
|
+
if (seen.has(entryName)) {
|
|
1397
|
+
warnings.push(`${entryName} is listed twice; the first entry is used.`);
|
|
1398
|
+
continue;
|
|
1399
|
+
}
|
|
1400
|
+
seen.add(entryName);
|
|
1401
|
+
const description = text(item.description);
|
|
1402
|
+
const version = text(item.version, 64);
|
|
1403
|
+
const author = typeof item.author === "string" ? text(item.author, 200) : void 0;
|
|
1404
|
+
entries.push({
|
|
1405
|
+
name: entryName,
|
|
1406
|
+
source: item.source,
|
|
1407
|
+
...description !== void 0 ? { description } : {},
|
|
1408
|
+
...version !== void 0 ? { version } : {},
|
|
1409
|
+
...author !== void 0 ? { author } : {},
|
|
1410
|
+
strict: item.strict !== false,
|
|
1411
|
+
raw: item
|
|
1412
|
+
});
|
|
1413
|
+
if (item.strict !== false && ENTRY_COMPONENT_FIELDS.some((field) => field in item))
|
|
1414
|
+
warnings.push(
|
|
1415
|
+
`${entryName} sets components inline without "strict": false, so they are ignored.`
|
|
1416
|
+
);
|
|
1417
|
+
}
|
|
1418
|
+
return {
|
|
1419
|
+
ok: true,
|
|
1420
|
+
catalog: {
|
|
1421
|
+
name,
|
|
1422
|
+
...owner !== void 0 ? { owner } : {},
|
|
1423
|
+
...pluginRoot !== void 0 ? { pluginRoot } : {},
|
|
1424
|
+
entries,
|
|
1425
|
+
warnings,
|
|
1426
|
+
file,
|
|
1427
|
+
root
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
__name(readCatalog, "readCatalog");
|
|
1432
|
+
async function resolveEntrySource(entry, catalog, options = {}) {
|
|
1433
|
+
const source = entry.source;
|
|
1434
|
+
if (typeof source === "string") {
|
|
1435
|
+
if (options.hosted === true)
|
|
1436
|
+
return {
|
|
1437
|
+
kind: "unsupported",
|
|
1438
|
+
reason: `${entry.name} is a folder inside the marketplace, and a hosted catalog file has no folders behind it. Add the marketplace as a repository instead.`
|
|
1439
|
+
};
|
|
1440
|
+
let relative3;
|
|
1441
|
+
if (source.startsWith("./") || source.startsWith("../") || source === ".") relative3 = source;
|
|
1442
|
+
else if (catalog.pluginRoot !== void 0 && !isAbsolute(source) && !/^[A-Za-z]:/.test(source))
|
|
1443
|
+
relative3 = join4(catalog.pluginRoot, source);
|
|
1444
|
+
else
|
|
1445
|
+
return {
|
|
1446
|
+
kind: "invalid",
|
|
1447
|
+
reason: `The source "${source}" is not a folder path starting with ./, and the catalog sets no metadata.pluginRoot for a bare name.`
|
|
1448
|
+
};
|
|
1449
|
+
if (isAbsolute(relative3) || /^[A-Za-z]:/.test(relative3))
|
|
1450
|
+
return { kind: "invalid", reason: `The source "${source}" is an absolute path.` };
|
|
1451
|
+
try {
|
|
1452
|
+
const dir = await resolveWithinReal(catalog.root, relative3);
|
|
1453
|
+
if (!lstatSync3(dir).isDirectory())
|
|
1454
|
+
return { kind: "invalid", reason: `The source "${source}" is not a folder.` };
|
|
1455
|
+
return { kind: "local", dir };
|
|
1456
|
+
} catch (error) {
|
|
1457
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1458
|
+
const leaves = /^Path escapes the working directory/.test(message);
|
|
1459
|
+
return {
|
|
1460
|
+
kind: "invalid",
|
|
1461
|
+
reason: leaves ? `The source "${source}" leaves the marketplace folder, which is not allowed.` : `The source "${source}" cannot be used: ${message}`
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
if (isRecord(source)) {
|
|
1466
|
+
const read = parseEntrySource(
|
|
1467
|
+
entry.name,
|
|
1468
|
+
source,
|
|
1469
|
+
entry.raw,
|
|
1470
|
+
options.allowFileProtocol === true
|
|
1471
|
+
);
|
|
1472
|
+
if (read.ok) return { kind: "remote", remote: read.source };
|
|
1473
|
+
return read.unsupported ? { kind: "unsupported", reason: read.reason } : { kind: "invalid", reason: read.reason };
|
|
1474
|
+
}
|
|
1475
|
+
return { kind: "invalid", reason: "The entry has no usable source." };
|
|
1476
|
+
}
|
|
1477
|
+
__name(resolveEntrySource, "resolveEntrySource");
|
|
1478
|
+
var NOT_AN_ADDRESS2 = "Not a marketplace address. Use owner/repo, an https:// address, or a folder path.";
|
|
1479
|
+
function parseMarketplaceAddress(input, cwd) {
|
|
1480
|
+
const value = input.trim();
|
|
1481
|
+
if (value === "") return { kind: "refused", message: NOT_AN_ADDRESS2 };
|
|
1482
|
+
if (/^http:\/\//i.test(value))
|
|
1483
|
+
return { kind: "refused", message: "Only https:// addresses are accepted, not http://." };
|
|
1484
|
+
if (/^file:\/\//i.test(value))
|
|
1485
|
+
return { kind: "refused", message: "Use a folder path, not a file:// address." };
|
|
1486
|
+
if (/^\\\\/.test(value) || /^\/\/[^/]/.test(value))
|
|
1487
|
+
return {
|
|
1488
|
+
kind: "refused",
|
|
1489
|
+
message: "A network share is not accepted. Copy the marketplace to this computer first."
|
|
1490
|
+
};
|
|
1491
|
+
if (/^(\.{1,2}([\\/]|$)|\/|~|[A-Za-z]:[\\/])/.test(value)) {
|
|
1492
|
+
const home = process.env.HOME ?? process.env.USERPROFILE ?? "";
|
|
1493
|
+
const expanded = value === "~" || /^~[\\/]/.test(value) ? join4(home, value.slice(1)) : value;
|
|
1494
|
+
return { kind: "path", path: resolve(cwd, expanded) };
|
|
1495
|
+
}
|
|
1496
|
+
const remote = parseRemoteAddress(value);
|
|
1497
|
+
if (!remote.ok) return { kind: "refused", message: remote.message };
|
|
1498
|
+
return { kind: "remote", form: remote.form, text: value, source: remote.source };
|
|
1499
|
+
}
|
|
1500
|
+
__name(parseMarketplaceAddress, "parseMarketplaceAddress");
|
|
1501
|
+
function realPathOf(path) {
|
|
1502
|
+
try {
|
|
1503
|
+
return realpathSync.native(path);
|
|
1504
|
+
} catch {
|
|
1505
|
+
return void 0;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
__name(realPathOf, "realPathOf");
|
|
1509
|
+
|
|
1510
|
+
// src/integrations/plugins/surface.ts
|
|
1511
|
+
import { lstatSync as lstatSync4, readFileSync as readFileSync3, readdirSync as readdirSync2 } from "node:fs";
|
|
1512
|
+
import { join as join5 } from "node:path";
|
|
1513
|
+
function hashExecutableFiles(root) {
|
|
1514
|
+
const executable = [];
|
|
1515
|
+
const files = {};
|
|
1516
|
+
const scripts = [];
|
|
1517
|
+
const walk = /* @__PURE__ */ __name((dir, prefix) => {
|
|
1518
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
1519
|
+
const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
1520
|
+
const full = join5(dir, entry.name);
|
|
1521
|
+
if (entry.isDirectory()) walk(full, rel);
|
|
1522
|
+
else if (entry.isFile()) {
|
|
1523
|
+
const stat2 = lstatSync4(full);
|
|
1524
|
+
executable.push(rel);
|
|
1525
|
+
files[rel] = sha256Hex(readFileSync3(full));
|
|
1526
|
+
if (isExecutablePath(rel, stat2.mode) && !isConfigFile(rel))
|
|
1527
|
+
scripts.push({ path: rel, bytes: stat2.size, exec: (stat2.mode & 73) !== 0 });
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
}, "walk");
|
|
1531
|
+
walk(root, "");
|
|
1532
|
+
executable.sort();
|
|
1533
|
+
scripts.sort((a, b) => a.path.localeCompare(b.path));
|
|
1534
|
+
return { executable, files, scripts };
|
|
1535
|
+
}
|
|
1536
|
+
__name(hashExecutableFiles, "hashExecutableFiles");
|
|
1537
|
+
var ENV_REF = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
1538
|
+
function envNamesIn(values) {
|
|
1539
|
+
const names = /* @__PURE__ */ new Set();
|
|
1540
|
+
for (const value of values)
|
|
1541
|
+
for (const match of value.matchAll(ENV_REF)) names.add(match[1]);
|
|
1542
|
+
return [...names].sort();
|
|
1543
|
+
}
|
|
1544
|
+
__name(envNamesIn, "envNamesIn");
|
|
1545
|
+
function unexpandWith(un) {
|
|
1546
|
+
if (un === void 0) return (text2) => text2;
|
|
1547
|
+
const pairs = [
|
|
1548
|
+
[un.root, "${NAMZU_PLUGIN_ROOT}"],
|
|
1549
|
+
[un.dataSentinel, "${NAMZU_PLUGIN_DATA}"],
|
|
1550
|
+
[un.projectSentinel, "${NAMZU_PROJECT_DIR}"]
|
|
1551
|
+
];
|
|
1552
|
+
return (text2) => {
|
|
1553
|
+
let out = text2;
|
|
1554
|
+
for (const [folder, name] of pairs) if (folder.length > 1) out = out.split(folder).join(name);
|
|
1555
|
+
return out;
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
__name(unexpandWith, "unexpandWith");
|
|
1559
|
+
function remoteRow(server, unexpand) {
|
|
1560
|
+
const url = unexpand(server.url);
|
|
1561
|
+
let origin = url;
|
|
1562
|
+
try {
|
|
1563
|
+
origin = new URL(server.url).origin;
|
|
1564
|
+
} catch {
|
|
1565
|
+
}
|
|
1566
|
+
const headers = server.headers ?? {};
|
|
1567
|
+
return {
|
|
1568
|
+
name: server.name,
|
|
1569
|
+
origin,
|
|
1570
|
+
url,
|
|
1571
|
+
transport: server.transport ?? "http",
|
|
1572
|
+
sendsEnv: envNamesIn([server.url, ...Object.values(headers)]),
|
|
1573
|
+
headers: Object.keys(headers).sort()
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
__name(remoteRow, "remoteRow");
|
|
1577
|
+
function splitAllowedTools(written) {
|
|
1578
|
+
const out = [];
|
|
1579
|
+
let depth = 0;
|
|
1580
|
+
let current = "";
|
|
1581
|
+
const flush = /* @__PURE__ */ __name(() => {
|
|
1582
|
+
if (current !== "") out.push(current);
|
|
1583
|
+
current = "";
|
|
1584
|
+
}, "flush");
|
|
1585
|
+
for (const char of written) {
|
|
1586
|
+
if (char === "(") depth++;
|
|
1587
|
+
else if (char === ")" && depth > 0) depth--;
|
|
1588
|
+
if (depth === 0 && (char === "," || /\s/.test(char))) flush();
|
|
1589
|
+
else current += char;
|
|
1590
|
+
}
|
|
1591
|
+
flush();
|
|
1592
|
+
return out;
|
|
1593
|
+
}
|
|
1594
|
+
__name(splitAllowedTools, "splitAllowedTools");
|
|
1595
|
+
function inside(root, rel) {
|
|
1596
|
+
if (rel.split(/[\\/]/).includes("..") || /^([A-Za-z]:|[\\/])/.test(rel)) return void 0;
|
|
1597
|
+
return join5(root, rel);
|
|
1598
|
+
}
|
|
1599
|
+
__name(inside, "inside");
|
|
1600
|
+
function readText(path) {
|
|
1601
|
+
try {
|
|
1602
|
+
const stat2 = lstatSync4(path);
|
|
1603
|
+
if (!stat2.isFile() || stat2.size > 1024 * 1024) return void 0;
|
|
1604
|
+
return readFileSync3(path, "utf8");
|
|
1605
|
+
} catch {
|
|
1606
|
+
return void 0;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
__name(readText, "readText");
|
|
1610
|
+
function hookRows(hooks) {
|
|
1611
|
+
const rows = [];
|
|
1612
|
+
for (const [event, entries] of Object.entries(hooks)) {
|
|
1613
|
+
for (const entry of entries ?? []) {
|
|
1614
|
+
rows.push(entryRow(event, entry));
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
return rows;
|
|
1618
|
+
}
|
|
1619
|
+
__name(hookRows, "hookRows");
|
|
1620
|
+
function entryRow(event, entry) {
|
|
1621
|
+
const matcher = typeof entry.matcher === "string" && entry.matcher !== "" ? entry.matcher : void 0;
|
|
1622
|
+
const base = matcher !== void 0 ? { event, matcher } : { event };
|
|
1623
|
+
if (entry.type === "http") return { ...base, type: "http", run: String(entry.url ?? "") };
|
|
1624
|
+
if (entry.type === "prompt")
|
|
1625
|
+
return {
|
|
1626
|
+
...base,
|
|
1627
|
+
type: "prompt",
|
|
1628
|
+
run: String(entry.prompt ?? "").replace(/\s+/g, " ").slice(0, 200)
|
|
1629
|
+
};
|
|
1630
|
+
const args = Array.isArray(entry.args) ? entry.args.map(String) : [];
|
|
1631
|
+
return { ...base, type: "command", run: [String(entry.command ?? ""), ...args].join(" ") };
|
|
1632
|
+
}
|
|
1633
|
+
__name(entryRow, "entryRow");
|
|
1634
|
+
function readSurface(input) {
|
|
1635
|
+
const { root, manifest } = input;
|
|
1636
|
+
const unexpand = unexpandWith(input.unexpander);
|
|
1637
|
+
const problems = [];
|
|
1638
|
+
const read = readPluginHookEntriesOf({ rootDir: root, manifest });
|
|
1639
|
+
for (const problem of read.problems)
|
|
1640
|
+
problems.push({ code: problem.code, file: problem.file, message: problem.message });
|
|
1641
|
+
const hooks = hookRows(read.hooks).map((row) => ({ ...row }));
|
|
1642
|
+
const modules = (manifest.hooks ?? []).filter((path) => !isHookEntriesPath(path)).map((path) => ({ path }));
|
|
1643
|
+
const isolated = isolatedModuleRow(root, manifest.name);
|
|
1644
|
+
if (isolated !== void 0) modules.push(isolated);
|
|
1645
|
+
const mcpLocal = (manifest.mcpServers ?? []).map((server) => ({
|
|
1646
|
+
name: server.name,
|
|
1647
|
+
command: unexpand(server.command),
|
|
1648
|
+
args: (server.args ?? []).map(unexpand),
|
|
1649
|
+
env: Object.fromEntries(
|
|
1650
|
+
Object.entries(server.env ?? {}).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => [key, unexpand(value)])
|
|
1651
|
+
)
|
|
1652
|
+
}));
|
|
1653
|
+
const mcpRemote = input.remoteServers.map((server) => remoteRow(server, unexpand));
|
|
1654
|
+
for (const server of input.setupServers ?? []) {
|
|
1655
|
+
if (server.kind === "remote") {
|
|
1656
|
+
mcpRemote.push({
|
|
1657
|
+
...remoteRow(
|
|
1658
|
+
{
|
|
1659
|
+
name: server.name,
|
|
1660
|
+
url: server.target,
|
|
1661
|
+
transport: server.transport ?? "http",
|
|
1662
|
+
...Object.keys(server.values).length > 0 ? { headers: { ...server.values } } : {}
|
|
1663
|
+
},
|
|
1664
|
+
unexpand
|
|
1665
|
+
),
|
|
1666
|
+
needsSetup: true
|
|
1667
|
+
});
|
|
1668
|
+
} else {
|
|
1669
|
+
mcpLocal.push({
|
|
1670
|
+
name: server.name,
|
|
1671
|
+
command: unexpand(server.target),
|
|
1672
|
+
args: (server.args ?? []).map(unexpand),
|
|
1673
|
+
env: Object.fromEntries(
|
|
1674
|
+
Object.entries(server.values).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => [key, unexpand(value)])
|
|
1675
|
+
),
|
|
1676
|
+
needsSetup: true
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
const fileHooks = [];
|
|
1681
|
+
const allowedTools = [];
|
|
1682
|
+
const considerFile = /* @__PURE__ */ __name((kind, fallbackName, path) => {
|
|
1683
|
+
const raw = readText(path);
|
|
1684
|
+
if (raw === void 0) return;
|
|
1685
|
+
let parsed;
|
|
1686
|
+
try {
|
|
1687
|
+
parsed = parseSkillMarkdown(raw, path);
|
|
1688
|
+
} catch (error) {
|
|
1689
|
+
problems.push({
|
|
1690
|
+
code: `${kind}-front-matter`,
|
|
1691
|
+
file: path.slice(root.length + 1).replace(/\\/g, "/"),
|
|
1692
|
+
message: `The front matter could not be read (${error instanceof Error ? error.message : String(error)}), so what it declares is not listed.`
|
|
1693
|
+
});
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
const name = parsed.name ?? fallbackName;
|
|
1697
|
+
if (kind !== "agent" && parsed.allowedTools !== void 0) {
|
|
1698
|
+
const tools = splitAllowedTools(parsed.allowedTools);
|
|
1699
|
+
if (tools.length > 0) allowedTools.push({ kind, name, tools });
|
|
1700
|
+
}
|
|
1701
|
+
if (parsed.hooksSource !== void 0) {
|
|
1702
|
+
const hookRead = readSkillHooks(parsed.hooksSource, `${kind} ${name}`);
|
|
1703
|
+
for (const row of hookRows(hookRead.hooks))
|
|
1704
|
+
fileHooks.push({ kind, name, event: row.event, type: row.type, run: row.run });
|
|
1705
|
+
for (const problem of hookRead.problems)
|
|
1706
|
+
problems.push({
|
|
1707
|
+
code: `${kind}-hooks-${problem.severity}`,
|
|
1708
|
+
file: path.slice(root.length + 1).replace(/\\/g, "/"),
|
|
1709
|
+
message: `${problem.event} ${problem.message}`
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
}, "considerFile");
|
|
1713
|
+
for (const dir of manifest.skills ?? []) {
|
|
1714
|
+
const folder = inside(root, dir);
|
|
1715
|
+
if (folder !== void 0)
|
|
1716
|
+
considerFile("skill", dir.split(/[\\/]/).pop() ?? dir, join5(folder, "SKILL.md"));
|
|
1717
|
+
}
|
|
1718
|
+
for (const [kind, declared] of [
|
|
1719
|
+
["command", manifest.commands],
|
|
1720
|
+
["agent", manifest.agents]
|
|
1721
|
+
]) {
|
|
1722
|
+
for (const source of resolvePluginFileDirs(manifest.name, root, declared, manifest.layout).dirs)
|
|
1723
|
+
for (const file of listMarkdownNames(source.dir, source.only))
|
|
1724
|
+
considerFile(kind, file, join5(source.dir, `${file}.md`));
|
|
1725
|
+
}
|
|
1726
|
+
const byName = /* @__PURE__ */ __name((a, b) => `${a.kind ?? ""} ${a.name ?? ""} ${a.event ?? ""}`.localeCompare(
|
|
1727
|
+
`${b.kind ?? ""} ${b.name ?? ""} ${b.event ?? ""}`
|
|
1728
|
+
), "byName");
|
|
1729
|
+
return {
|
|
1730
|
+
surface: {
|
|
1731
|
+
hooks,
|
|
1732
|
+
fileHooks: fileHooks.sort(byName),
|
|
1733
|
+
mcpLocal: mcpLocal.sort((a, b) => a.name.localeCompare(b.name)),
|
|
1734
|
+
mcpRemote: mcpRemote.sort((a, b) => a.name.localeCompare(b.name)),
|
|
1735
|
+
modules: modules.sort((a, b) => a.path.localeCompare(b.path)),
|
|
1736
|
+
allowedTools: allowedTools.sort(byName),
|
|
1737
|
+
scripts: input.scripts,
|
|
1738
|
+
unpinnedDownload: false
|
|
1739
|
+
},
|
|
1740
|
+
problems
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
__name(readSurface, "readSurface");
|
|
1744
|
+
function same(a, b) {
|
|
1745
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
1746
|
+
}
|
|
1747
|
+
__name(same, "same");
|
|
1748
|
+
function rowIdentity(json) {
|
|
1749
|
+
try {
|
|
1750
|
+
const row = JSON.parse(json);
|
|
1751
|
+
if (typeof row.path === "string") return `path:${row.path}`;
|
|
1752
|
+
if (typeof row.name === "string") return `name:${String(row.kind ?? "")}:${row.name}`;
|
|
1753
|
+
} catch {
|
|
1754
|
+
}
|
|
1755
|
+
return void 0;
|
|
1756
|
+
}
|
|
1757
|
+
__name(rowIdentity, "rowIdentity");
|
|
1758
|
+
function surfaceChanges(before, after) {
|
|
1759
|
+
const out = [];
|
|
1760
|
+
const label = {
|
|
1761
|
+
hooks: "hook",
|
|
1762
|
+
fileHooks: "hook in a skill, command or agent file",
|
|
1763
|
+
mcpLocal: "local server",
|
|
1764
|
+
mcpRemote: "remote server",
|
|
1765
|
+
modules: "module",
|
|
1766
|
+
allowedTools: "pre-approved tools",
|
|
1767
|
+
scripts: "script"
|
|
1768
|
+
};
|
|
1769
|
+
for (const key of Object.keys(label)) {
|
|
1770
|
+
const a = before[key].map((item) => JSON.stringify(item));
|
|
1771
|
+
const b = after[key].map((item) => JSON.stringify(item));
|
|
1772
|
+
const added = b.filter((item) => !a.includes(item));
|
|
1773
|
+
const removed = a.filter((item) => !b.includes(item));
|
|
1774
|
+
const ids = /* @__PURE__ */ __name((items) => new Set(items.map(rowIdentity).filter((id) => id !== void 0)), "ids");
|
|
1775
|
+
const addedIds = ids(added);
|
|
1776
|
+
const removedIds = ids(removed);
|
|
1777
|
+
const changed = added.filter((item) => {
|
|
1778
|
+
const id = rowIdentity(item);
|
|
1779
|
+
return id !== void 0 && removedIds.has(id);
|
|
1780
|
+
}).length;
|
|
1781
|
+
const fresh = added.length - changed;
|
|
1782
|
+
const gone = removed.filter((item) => {
|
|
1783
|
+
const id = rowIdentity(item);
|
|
1784
|
+
return id === void 0 || !addedIds.has(id);
|
|
1785
|
+
}).length;
|
|
1786
|
+
const noun = /* @__PURE__ */ __name((count) => `${label[key]}${count === 1 ? "" : "s"}`, "noun");
|
|
1787
|
+
if (fresh > 0) out.push(`${fresh} new ${noun(fresh)}`);
|
|
1788
|
+
if (changed > 0) out.push(`${changed} ${noun(changed)} changed`);
|
|
1789
|
+
if (gone > 0) out.push(`${gone} ${noun(gone)} removed`);
|
|
1790
|
+
}
|
|
1791
|
+
if (!same(before.unpinnedDownload, after.unpinnedDownload)) out.push("download pinning changed");
|
|
1792
|
+
return out;
|
|
1793
|
+
}
|
|
1794
|
+
__name(surfaceChanges, "surfaceChanges");
|
|
1795
|
+
function isolatedModuleRow(root, plugin) {
|
|
1796
|
+
const located = locateHookModule(root);
|
|
1797
|
+
if (located.kind === "refused")
|
|
1798
|
+
return { path: located.hooksFile, isolated: true, refused: located.message };
|
|
1799
|
+
if (located.kind !== "found") return void 0;
|
|
1800
|
+
const scan = scanHookModule(root, located.entry);
|
|
1801
|
+
if (scan.refusals.length > 0)
|
|
1802
|
+
return { path: located.entry, isolated: true, refused: scan.refusals[0]?.message ?? "refused" };
|
|
1803
|
+
return {
|
|
1804
|
+
path: located.entry,
|
|
1805
|
+
isolated: true,
|
|
1806
|
+
declares: hookModuleConsentEntry(plugin, scan).lines
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
__name(isolatedModuleRow, "isolatedModuleRow");
|
|
1810
|
+
|
|
1811
|
+
// src/integrations/plugins/install-plan.ts
|
|
1812
|
+
var PLUGIN_COPY_MAX_FILES = 2e4;
|
|
1813
|
+
var PLUGIN_COPY_MAX_BYTES = 256 * 1024 * 1024;
|
|
1814
|
+
var PLUGIN_ARCHIVE_MAX_BYTES = 200 * 1024 * 1024;
|
|
1815
|
+
var PLUGIN_ARCHIVE_LIMITS = {
|
|
1816
|
+
maxEntries: 5e3,
|
|
1817
|
+
maxUnpackedBytes: PLUGIN_COPY_MAX_BYTES,
|
|
1818
|
+
maxRatio: 100,
|
|
1819
|
+
allowExecutable: true,
|
|
1820
|
+
subject: "plugin archive"
|
|
1821
|
+
};
|
|
1822
|
+
var PlanRefusal = class extends Error {
|
|
1823
|
+
constructor(code, message) {
|
|
1824
|
+
super(message);
|
|
1825
|
+
this.code = code;
|
|
1826
|
+
}
|
|
1827
|
+
code;
|
|
1828
|
+
static {
|
|
1829
|
+
__name(this, "PlanRefusal");
|
|
1830
|
+
}
|
|
1831
|
+
name = "PlanRefusal";
|
|
1832
|
+
};
|
|
1833
|
+
function stagingFolder(home) {
|
|
1834
|
+
return join6(pluginsFolder(home), ".staging");
|
|
1835
|
+
}
|
|
1836
|
+
__name(stagingFolder, "stagingFolder");
|
|
1837
|
+
var SKIPPED_NAMES = /* @__PURE__ */ new Set([".git", "__MACOSX", ".DS_Store"]);
|
|
1838
|
+
var REFUSED = 65;
|
|
1839
|
+
function within(outer, inner) {
|
|
1840
|
+
const rel = relative(outer, inner);
|
|
1841
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
|
|
1842
|
+
}
|
|
1843
|
+
__name(within, "within");
|
|
1844
|
+
function copyPluginTree(src, dest, findings) {
|
|
1845
|
+
const counter = { files: 0, bytes: 0 };
|
|
1846
|
+
const walk = /* @__PURE__ */ __name((from, to, prefix) => {
|
|
1847
|
+
mkdirSync4(to, { recursive: true, mode: 493 });
|
|
1848
|
+
for (const entry of readdirSync3(from, { withFileTypes: true }).sort(
|
|
1849
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
1850
|
+
)) {
|
|
1851
|
+
if (SKIPPED_NAMES.has(entry.name)) continue;
|
|
1852
|
+
const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
1853
|
+
const source = join6(from, entry.name);
|
|
1854
|
+
const stat2 = lstatSync5(source);
|
|
1855
|
+
if (stat2.isSymbolicLink()) {
|
|
1856
|
+
findings.push({
|
|
1857
|
+
level: "ignored",
|
|
1858
|
+
code: "symlink",
|
|
1859
|
+
field: rel,
|
|
1860
|
+
message: `${rel} is a link and was not copied.`
|
|
1861
|
+
});
|
|
1862
|
+
} else if (stat2.isDirectory()) walk(source, join6(to, entry.name), rel);
|
|
1863
|
+
else if (stat2.isFile()) {
|
|
1864
|
+
counter.files += 1;
|
|
1865
|
+
counter.bytes += stat2.size;
|
|
1866
|
+
if (counter.files > PLUGIN_COPY_MAX_FILES)
|
|
1867
|
+
throw new PlanRefusal(
|
|
1868
|
+
REFUSED,
|
|
1869
|
+
`The plugin has more than ${PLUGIN_COPY_MAX_FILES} files, which is more than Namzu installs.`
|
|
1870
|
+
);
|
|
1871
|
+
if (counter.bytes > PLUGIN_COPY_MAX_BYTES)
|
|
1872
|
+
throw new PlanRefusal(
|
|
1873
|
+
REFUSED,
|
|
1874
|
+
`The plugin is larger than ${PLUGIN_COPY_MAX_BYTES / (1024 * 1024)} MiB, which is more than Namzu installs.`
|
|
1875
|
+
);
|
|
1876
|
+
const target = join6(to, entry.name);
|
|
1877
|
+
copyFileSync(source, target);
|
|
1878
|
+
chmodSync(target, (stat2.mode & 64) !== 0 ? 493 : 420);
|
|
1879
|
+
} else
|
|
1880
|
+
findings.push({
|
|
1881
|
+
level: "ignored",
|
|
1882
|
+
code: "special-file",
|
|
1883
|
+
field: rel,
|
|
1884
|
+
message: `${rel} is not a regular file and was not copied.`
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
}, "walk");
|
|
1888
|
+
walk(src, dest, "");
|
|
1889
|
+
return counter;
|
|
1890
|
+
}
|
|
1891
|
+
__name(copyPluginTree, "copyPluginTree");
|
|
1892
|
+
function unpackPluginArchive(file, dest) {
|
|
1893
|
+
let size;
|
|
1894
|
+
try {
|
|
1895
|
+
size = statSync(file).size;
|
|
1896
|
+
} catch {
|
|
1897
|
+
throw new PlanRefusal(66, `${file} could not be read.`);
|
|
1898
|
+
}
|
|
1899
|
+
if (size > PLUGIN_ARCHIVE_MAX_BYTES)
|
|
1900
|
+
throw new PlanRefusal(
|
|
1901
|
+
REFUSED,
|
|
1902
|
+
`The archive is larger than ${PLUGIN_ARCHIVE_MAX_BYTES / (1024 * 1024)} MiB.`
|
|
1903
|
+
);
|
|
1904
|
+
let files;
|
|
1905
|
+
try {
|
|
1906
|
+
files = openArchive(readFileSync4(file), PLUGIN_ARCHIVE_LIMITS);
|
|
1907
|
+
} catch (error) {
|
|
1908
|
+
if (error instanceof ArchiveError) throw new PlanRefusal(REFUSED, error.message);
|
|
1909
|
+
throw error;
|
|
1910
|
+
}
|
|
1911
|
+
let count = 0;
|
|
1912
|
+
for (const [name, entry] of files) {
|
|
1913
|
+
if (name.split("/").some((part) => SKIPPED_NAMES.has(part))) continue;
|
|
1914
|
+
if (++count > PLUGIN_COPY_MAX_FILES)
|
|
1915
|
+
throw new PlanRefusal(REFUSED, `The archive has more than ${PLUGIN_COPY_MAX_FILES} files.`);
|
|
1916
|
+
const target = join6(dest, ...name.split("/"));
|
|
1917
|
+
if (!within(dest, target)) throw new PlanRefusal(REFUSED, `${name} climbs out of the archive.`);
|
|
1918
|
+
mkdirSync4(dirname3(target), { recursive: true, mode: 493 });
|
|
1919
|
+
writeFileSync3(target, entry.bytes, { mode: entry.executable ? 493 : 420 });
|
|
1920
|
+
chmodSync(target, entry.executable ? 493 : 420);
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
__name(unpackPluginArchive, "unpackPluginArchive");
|
|
1924
|
+
function discardStaging(dir) {
|
|
1925
|
+
try {
|
|
1926
|
+
rmSync2(dir, { recursive: true, force: true });
|
|
1927
|
+
} catch {
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
__name(discardStaging, "discardStaging");
|
|
1931
|
+
var DATA_SENTINEL = "/namzu-sentinel/plugin-data";
|
|
1932
|
+
var PROJECT_SENTINEL = "/namzu-sentinel/project";
|
|
1933
|
+
var VERSION_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/;
|
|
1934
|
+
async function usedPluginNames(options) {
|
|
1935
|
+
const used = /* @__PURE__ */ new Map();
|
|
1936
|
+
const read = readInstalledPlugins(options.home);
|
|
1937
|
+
if (read.state !== "unreadable")
|
|
1938
|
+
for (const id of read.plugins.keys()) used.set(splitPluginId(id).name, id);
|
|
1939
|
+
try {
|
|
1940
|
+
const discovered = await discoverAllPluginDirs(options.cwd, {
|
|
1941
|
+
enabled: true,
|
|
1942
|
+
autoDiscovery: true,
|
|
1943
|
+
allowedScopes: ["project", "user"],
|
|
1944
|
+
userRoot: options.home
|
|
1945
|
+
});
|
|
1946
|
+
for (const scope of ["project", "user"])
|
|
1947
|
+
for (const dir of discovered[scope]) {
|
|
1948
|
+
if (scope === "user" && isReservedPluginDir(options.home, dir)) continue;
|
|
1949
|
+
try {
|
|
1950
|
+
const name = (await loadPluginManifest(dir, { skillsSupported: true })).name;
|
|
1951
|
+
if (!used.has(name)) used.set(name, `the plugin folder ${dir}`);
|
|
1952
|
+
} catch {
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
} catch {
|
|
1956
|
+
}
|
|
1957
|
+
return used;
|
|
1958
|
+
}
|
|
1959
|
+
__name(usedPluginNames, "usedPluginNames");
|
|
1960
|
+
async function nameClash(options, name, id) {
|
|
1961
|
+
const holder = (await usedPluginNames(options)).get(name);
|
|
1962
|
+
if (holder === void 0 || holder === id) return void 0;
|
|
1963
|
+
return `The name "${name}" is already used by ${holder}. Remove it first, or ask the author to rename this plugin.`;
|
|
1964
|
+
}
|
|
1965
|
+
__name(nameClash, "nameClash");
|
|
1966
|
+
function sidecarFor(entry) {
|
|
1967
|
+
if (entry.strict) return void 0;
|
|
1968
|
+
const kept = {};
|
|
1969
|
+
for (const key of ENTRY_SIDECAR_KEEPS) if (key in entry.raw) kept[key] = entry.raw[key];
|
|
1970
|
+
return `${JSON.stringify(kept, null, 2)}
|
|
1971
|
+
`;
|
|
1972
|
+
}
|
|
1973
|
+
__name(sidecarFor, "sidecarFor");
|
|
1974
|
+
var SIDECAR_FILE = ".namzu-entry.json";
|
|
1975
|
+
async function planInstall(source, options) {
|
|
1976
|
+
const staging = join6(stagingFolder(options.home), randomUUID());
|
|
1977
|
+
mkdirSync4(staging, { recursive: true, mode: 448 });
|
|
1978
|
+
try {
|
|
1979
|
+
return await build(source, options, staging);
|
|
1980
|
+
} catch (error) {
|
|
1981
|
+
discardStaging(staging);
|
|
1982
|
+
throw error;
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
__name(planInstall, "planInstall");
|
|
1986
|
+
async function build(source, options, staging) {
|
|
1987
|
+
const findings = [];
|
|
1988
|
+
const root = join6(staging, "plugin");
|
|
1989
|
+
let installedFrom;
|
|
1990
|
+
let marketplace;
|
|
1991
|
+
let entry;
|
|
1992
|
+
let commit;
|
|
1993
|
+
let unpinnedDownload = false;
|
|
1994
|
+
const notes = [];
|
|
1995
|
+
if (source.kind === "remote-catalog") {
|
|
1996
|
+
marketplace = source.marketplace;
|
|
1997
|
+
entry = source.entry;
|
|
1998
|
+
installedFrom = { marketplace, source: entry.source, kind: "catalog" };
|
|
1999
|
+
let fetched;
|
|
2000
|
+
try {
|
|
2001
|
+
fetched = await fetchPlugin(source.remote, staging, options.fetch);
|
|
2002
|
+
} catch (error) {
|
|
2003
|
+
if (error instanceof FetchError) throw new PlanRefusal(error.code, error.message);
|
|
2004
|
+
throw error;
|
|
2005
|
+
}
|
|
2006
|
+
commit = fetched.commit;
|
|
2007
|
+
if (fetched.lfsPointers > 0)
|
|
2008
|
+
notes.push(
|
|
2009
|
+
`${fetched.lfsPointers} ${fetched.lfsPointers === 1 ? "file is" : "files are"} stored with Git LFS and was not downloaded; ${fetched.lfsPointers === 1 ? "it stays" : "they stay"} a small pointer file.`
|
|
2010
|
+
);
|
|
2011
|
+
if (fetched.submodules > 0)
|
|
2012
|
+
notes.push(
|
|
2013
|
+
`The repository lists ${fetched.submodules} ${fetched.submodules === 1 ? "submodule" : "submodules"}; none was downloaded.`
|
|
2014
|
+
);
|
|
2015
|
+
if (fetched.archive !== void 0) {
|
|
2016
|
+
if (source.remote.kind === "archive" && source.remote.sha256 === void 0)
|
|
2017
|
+
unpinnedDownload = true;
|
|
2018
|
+
const unpacked = join6(staging, "unpacked");
|
|
2019
|
+
mkdirSync4(unpacked, { recursive: true, mode: 493 });
|
|
2020
|
+
unpackPluginArchive(fetched.archive.file, unpacked);
|
|
2021
|
+
const inner = await findCommonLayoutRoot(unpacked);
|
|
2022
|
+
renameSync(inner, root);
|
|
2023
|
+
} else if (fetched.dir !== void 0) copyFolderSource(fetched.dir, root, options, findings);
|
|
2024
|
+
} else if (source.kind === "catalog") {
|
|
2025
|
+
marketplace = source.marketplace;
|
|
2026
|
+
entry = source.entry;
|
|
2027
|
+
installedFrom = {
|
|
2028
|
+
marketplace,
|
|
2029
|
+
source: entry.source,
|
|
2030
|
+
kind: "catalog"
|
|
2031
|
+
};
|
|
2032
|
+
commit = source.commit;
|
|
2033
|
+
copyFolderSource(source.dir, root, options, findings);
|
|
2034
|
+
} else {
|
|
2035
|
+
marketplace = LOCAL_UPLOADS_MARKETPLACE;
|
|
2036
|
+
let stat2;
|
|
2037
|
+
try {
|
|
2038
|
+
stat2 = lstatSync5(source.path);
|
|
2039
|
+
} catch {
|
|
2040
|
+
throw new PlanRefusal(66, `${source.path} was not found.`);
|
|
2041
|
+
}
|
|
2042
|
+
if (stat2.isDirectory()) {
|
|
2043
|
+
installedFrom = { marketplace, source: realpathSync2.native(source.path), kind: "folder" };
|
|
2044
|
+
copyFolderSource(source.path, root, options, findings);
|
|
2045
|
+
} else if (stat2.isFile()) {
|
|
2046
|
+
installedFrom = { marketplace, source: resolve2(source.path), kind: "archive" };
|
|
2047
|
+
const unpacked = join6(staging, "unpacked");
|
|
2048
|
+
mkdirSync4(unpacked, { recursive: true, mode: 493 });
|
|
2049
|
+
unpackPluginArchive(source.path, unpacked);
|
|
2050
|
+
const inner = await findCommonLayoutRoot(unpacked);
|
|
2051
|
+
renameSync(inner, root);
|
|
2052
|
+
} else throw new PlanRefusal(66, `${source.path} is neither a folder nor an archive.`);
|
|
2053
|
+
}
|
|
2054
|
+
const sidecarPath = join6(root, SIDECAR_FILE);
|
|
2055
|
+
if (existsSync2(sidecarPath)) {
|
|
2056
|
+
rmSync2(sidecarPath, { force: true });
|
|
2057
|
+
findings.push({
|
|
2058
|
+
level: "ignored",
|
|
2059
|
+
code: "sidecar-shipped",
|
|
2060
|
+
field: SIDECAR_FILE,
|
|
2061
|
+
message: `${SIDECAR_FILE} came with the files and was removed; Namzu writes it itself.`
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
const sidecar = entry !== void 0 ? sidecarFor(entry) : void 0;
|
|
2065
|
+
if (sidecar !== void 0) writeFileSync3(sidecarPath, sidecar, { mode: 420 });
|
|
2066
|
+
const installed = readInstalledPlugins(options.home);
|
|
2067
|
+
const installedIds = /* @__PURE__ */ new Set();
|
|
2068
|
+
if (installed.state !== "unreadable")
|
|
2069
|
+
for (const id2 of installed.plugins.keys()) {
|
|
2070
|
+
installedIds.add(id2);
|
|
2071
|
+
installedIds.add(splitPluginId(id2).name);
|
|
2072
|
+
}
|
|
2073
|
+
const layoutOptions = {
|
|
2074
|
+
entrySidecar: true,
|
|
2075
|
+
// Every `${NAME}` a server's environment or headers refer to reads as itself, so a server
|
|
2076
|
+
// that needs a variable that is unset here is still read and listed, not dropped from what is shown.
|
|
2077
|
+
environment: new Proxy(
|
|
2078
|
+
{},
|
|
2079
|
+
{ get: /* @__PURE__ */ __name((_, name2) => typeof name2 === "string" ? `\${${name2}}` : void 0, "get") }
|
|
2080
|
+
),
|
|
2081
|
+
installedIds,
|
|
2082
|
+
paths: /* @__PURE__ */ __name(() => ({ project: PROJECT_SENTINEL, data: DATA_SENTINEL }), "paths"),
|
|
2083
|
+
...entry?.version !== void 0 ? { version: entry.version } : {}
|
|
2084
|
+
};
|
|
2085
|
+
const layout = await readCommonLayout(root, layoutOptions);
|
|
2086
|
+
if (layout.refusal !== void 0) throw new PlanRefusal(REFUSED, layout.refusal.message);
|
|
2087
|
+
let manifest;
|
|
2088
|
+
try {
|
|
2089
|
+
manifest = (await loadPluginManifestWithFindings(root, {
|
|
2090
|
+
skillsSupported: true,
|
|
2091
|
+
commonLayout: layoutOptions
|
|
2092
|
+
})).manifest;
|
|
2093
|
+
} catch (error) {
|
|
2094
|
+
throw new PlanRefusal(REFUSED, error instanceof Error ? error.message : String(error));
|
|
2095
|
+
}
|
|
2096
|
+
const layoutKind = layout.source === "namzu" ? "namzu" : "common";
|
|
2097
|
+
for (const finding of layout.findings) {
|
|
2098
|
+
if (finding.level === "used") continue;
|
|
2099
|
+
findings.push({
|
|
2100
|
+
level: finding.level,
|
|
2101
|
+
code: finding.code,
|
|
2102
|
+
field: finding.path ?? finding.field,
|
|
2103
|
+
message: finding.message
|
|
2104
|
+
});
|
|
2105
|
+
}
|
|
2106
|
+
const name = manifest.name;
|
|
2107
|
+
if (entry !== void 0 && entry.name !== name)
|
|
2108
|
+
throw new PlanRefusal(
|
|
2109
|
+
REFUSED,
|
|
2110
|
+
`The catalog calls this plugin "${entry.name}" but the plugin calls itself "${name}". Ask the marketplace's owner to fix the entry.`
|
|
2111
|
+
);
|
|
2112
|
+
const id = `${name}@${marketplace}`;
|
|
2113
|
+
if (!PLUGIN_ID_PATTERN.test(id))
|
|
2114
|
+
throw new PlanRefusal(REFUSED, `"${id}" cannot be a plugin id (name@marketplace).`);
|
|
2115
|
+
const version = manifest.version;
|
|
2116
|
+
if (!VERSION_PATTERN.test(version))
|
|
2117
|
+
throw new PlanRefusal(
|
|
2118
|
+
REFUSED,
|
|
2119
|
+
`The version "${version}" has characters that cannot be in a folder name.`
|
|
2120
|
+
);
|
|
2121
|
+
const clash = await nameClash(options, name, id);
|
|
2122
|
+
if (clash !== void 0) throw new PlanRefusal(REFUSED, clash);
|
|
2123
|
+
const hashed = hashExecutableFiles(root);
|
|
2124
|
+
const read = readSurface({
|
|
2125
|
+
root,
|
|
2126
|
+
manifest,
|
|
2127
|
+
remoteServers: layoutKind === "namzu" ? manifest.remoteMcpServers ?? [] : layout.remoteServers,
|
|
2128
|
+
setupServers: layout.findings.flatMap(
|
|
2129
|
+
(finding) => finding.code === "mcp-needs-setup" && finding.server !== void 0 ? [finding.server] : []
|
|
2130
|
+
),
|
|
2131
|
+
scripts: hashed.scripts,
|
|
2132
|
+
unexpander: { root, dataSentinel: DATA_SENTINEL, projectSentinel: PROJECT_SENTINEL }
|
|
2133
|
+
});
|
|
2134
|
+
for (const problem of read.problems)
|
|
2135
|
+
findings.push({
|
|
2136
|
+
level: "refused",
|
|
2137
|
+
code: problem.code,
|
|
2138
|
+
field: problem.file,
|
|
2139
|
+
message: problem.message
|
|
2140
|
+
});
|
|
2141
|
+
const details = await readPluginManifestDetails(root, manifest);
|
|
2142
|
+
const named = /* @__PURE__ */ __name((declared) => resolvePluginFileDirs(name, root, declared, manifest.layout).dirs.flatMap(
|
|
2143
|
+
(dir) => listMarkdownNames(dir.dir, dir.only).map((file) => `${name}__${file}`)
|
|
2144
|
+
), "named");
|
|
2145
|
+
const warnings = [...notes];
|
|
2146
|
+
if (manifest.remoteMcpServers !== void 0 || layout.remoteServers.length > 0)
|
|
2147
|
+
warnings.push("Remote servers ask you before they connect; nothing connects at install.");
|
|
2148
|
+
const surface = unpinnedDownload ? { ...read.surface, unpinnedDownload: true } : read.surface;
|
|
2149
|
+
const digest = surfaceDigest(surface, hashed.files, hashed.executable);
|
|
2150
|
+
return {
|
|
2151
|
+
id,
|
|
2152
|
+
name,
|
|
2153
|
+
marketplace,
|
|
2154
|
+
version,
|
|
2155
|
+
...commit !== void 0 ? { commit } : {},
|
|
2156
|
+
layout: layoutKind,
|
|
2157
|
+
stagingDir: staging,
|
|
2158
|
+
root,
|
|
2159
|
+
manifest,
|
|
2160
|
+
findings,
|
|
2161
|
+
surface,
|
|
2162
|
+
executable: hashed.executable,
|
|
2163
|
+
files: hashed.files,
|
|
2164
|
+
digest,
|
|
2165
|
+
inventory: {
|
|
2166
|
+
skills: (details.skills ?? []).map((skill) => skill.name),
|
|
2167
|
+
commands: named(manifest.commands),
|
|
2168
|
+
agents: named(manifest.agents)
|
|
2169
|
+
},
|
|
2170
|
+
installedFrom,
|
|
2171
|
+
warnings
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
__name(build, "build");
|
|
2175
|
+
function copyFolderSource(dir, root, options, findings) {
|
|
2176
|
+
let real;
|
|
2177
|
+
try {
|
|
2178
|
+
real = realpathSync2.native(dir);
|
|
2179
|
+
} catch {
|
|
2180
|
+
throw new PlanRefusal(66, `${dir} was not found.`);
|
|
2181
|
+
}
|
|
2182
|
+
if (!lstatSync5(real).isDirectory()) throw new PlanRefusal(66, `${dir} is not a folder.`);
|
|
2183
|
+
if (within(real, pluginsFolder(options.home)) || within(real, options.home))
|
|
2184
|
+
throw new PlanRefusal(
|
|
2185
|
+
REFUSED,
|
|
2186
|
+
`${dir} holds Namzu's own folder, so it cannot be installed from. Pick the plugin's folder.`
|
|
2187
|
+
);
|
|
2188
|
+
copyPluginTree(real, root, findings);
|
|
2189
|
+
}
|
|
2190
|
+
__name(copyFolderSource, "copyFolderSource");
|
|
2191
|
+
function recordFields(plan, where) {
|
|
2192
|
+
return {
|
|
2193
|
+
scope: where.scope,
|
|
2194
|
+
installPath: where.installPath,
|
|
2195
|
+
...where.projectPath !== void 0 ? { projectPath: where.projectPath } : {},
|
|
2196
|
+
version: plan.version,
|
|
2197
|
+
...plan.commit !== void 0 ? { gitCommitSha: plan.commit } : {},
|
|
2198
|
+
installedAt: where.now,
|
|
2199
|
+
lastUpdated: where.now,
|
|
2200
|
+
layout: plan.layout,
|
|
2201
|
+
surfaceSha256: plan.digest,
|
|
2202
|
+
findings: plan.findings.filter((f) => f.level !== "used")
|
|
2203
|
+
};
|
|
2204
|
+
}
|
|
2205
|
+
__name(recordFields, "recordFields");
|
|
2206
|
+
|
|
2207
|
+
// src/integrations/plugins/install.ts
|
|
2208
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
2209
|
+
import {
|
|
2210
|
+
existsSync as existsSync3,
|
|
2211
|
+
mkdirSync as mkdirSync5,
|
|
2212
|
+
readFileSync as readFileSync5,
|
|
2213
|
+
readdirSync as readdirSync4,
|
|
2214
|
+
renameSync as renameSync2,
|
|
2215
|
+
rmSync as rmSync3,
|
|
2216
|
+
rmdirSync,
|
|
2217
|
+
statSync as statSync2,
|
|
2218
|
+
writeFileSync as writeFileSync4
|
|
2219
|
+
} from "node:fs";
|
|
2220
|
+
import { dirname as dirname4, join as join7 } from "node:path";
|
|
2221
|
+
var SimulatedCrash = class extends Error {
|
|
2222
|
+
static {
|
|
2223
|
+
__name(this, "SimulatedCrash");
|
|
2224
|
+
}
|
|
2225
|
+
name = "SimulatedCrash";
|
|
2226
|
+
};
|
|
2227
|
+
var InstallConflict = class extends Error {
|
|
2228
|
+
constructor(message, code = 65) {
|
|
2229
|
+
super(message);
|
|
2230
|
+
this.code = code;
|
|
2231
|
+
}
|
|
2232
|
+
code;
|
|
2233
|
+
static {
|
|
2234
|
+
__name(this, "InstallConflict");
|
|
2235
|
+
}
|
|
2236
|
+
name = "InstallConflict";
|
|
2237
|
+
};
|
|
2238
|
+
function readRecords(home) {
|
|
2239
|
+
const read = readInstalledPlugins(home);
|
|
2240
|
+
if (read.state === "unreadable")
|
|
2241
|
+
throw unreadableStateFile(
|
|
2242
|
+
installedPluginsPath(home),
|
|
2243
|
+
read.reason,
|
|
2244
|
+
home,
|
|
2245
|
+
"Fix or remove the file, then try again. The install record stays as it is until then."
|
|
2246
|
+
);
|
|
2247
|
+
return read.plugins;
|
|
2248
|
+
}
|
|
2249
|
+
__name(readRecords, "readRecords");
|
|
2250
|
+
function writeJsonAtomic(path, value) {
|
|
2251
|
+
mkdirSync5(dirname4(path), { recursive: true, mode: 448 });
|
|
2252
|
+
const tmp = `${path}.${process.pid}.${randomUUID2().slice(0, 8)}.tmp`;
|
|
2253
|
+
writeFileSync4(tmp, `${JSON.stringify(value, null, 2)}
|
|
2254
|
+
`, { mode: 384 });
|
|
2255
|
+
renameSync2(tmp, path);
|
|
2256
|
+
}
|
|
2257
|
+
__name(writeJsonAtomic, "writeJsonAtomic");
|
|
2258
|
+
function trashFolder(home, path) {
|
|
2259
|
+
const bin = join7(stagingFolder(home), `trash-${Date.now()}-${randomUUID2().slice(0, 8)}`);
|
|
2260
|
+
try {
|
|
2261
|
+
mkdirSync5(dirname4(bin), { recursive: true, mode: 448 });
|
|
2262
|
+
renameSync2(path, bin);
|
|
2263
|
+
rmSync3(bin, { recursive: true, force: true });
|
|
2264
|
+
} catch {
|
|
2265
|
+
try {
|
|
2266
|
+
rmSync3(path, { recursive: true, force: true });
|
|
2267
|
+
} catch {
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
__name(trashFolder, "trashFolder");
|
|
2272
|
+
function cacheFolderOf(home, plan) {
|
|
2273
|
+
return join7(pluginCacheFolder(home), plan.marketplace, plan.name, plan.version);
|
|
2274
|
+
}
|
|
2275
|
+
__name(cacheFolderOf, "cacheFolderOf");
|
|
2276
|
+
function layerOf(scope) {
|
|
2277
|
+
return scope;
|
|
2278
|
+
}
|
|
2279
|
+
__name(layerOf, "layerOf");
|
|
2280
|
+
function manifestFile(plan, where) {
|
|
2281
|
+
return {
|
|
2282
|
+
version: INSTALL_MANIFEST_VERSION,
|
|
2283
|
+
id: plan.id,
|
|
2284
|
+
installedFrom: plan.installedFrom,
|
|
2285
|
+
executable: plan.executable,
|
|
2286
|
+
files: plan.files,
|
|
2287
|
+
surface: plan.surface,
|
|
2288
|
+
surfaceSha256: plan.digest,
|
|
2289
|
+
consent: {
|
|
2290
|
+
at: where.now.toISOString(),
|
|
2291
|
+
scope: where.scope,
|
|
2292
|
+
by: where.consent.by,
|
|
2293
|
+
nonInteractive: where.consent.nonInteractive
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
__name(manifestFile, "manifestFile");
|
|
2298
|
+
var SAME_VERSION_OTHER_CONTENTS = "This version already exists with other contents; nothing was changed.";
|
|
2299
|
+
function commitInstall(plan, where) {
|
|
2300
|
+
const { home } = where;
|
|
2301
|
+
const dest = cacheFolderOf(home, plan);
|
|
2302
|
+
const projectPath = where.scope === "user" ? void 0 : where.cwd;
|
|
2303
|
+
return withStateFileLock(installedPluginsPath(home), () => {
|
|
2304
|
+
const existing = readRecords(home).get(plan.id) ?? [];
|
|
2305
|
+
const sameScope = existing.find(
|
|
2306
|
+
(record) => record.scope === where.scope && (projectPath === void 0 || record.projectPath !== void 0 && samePath(record.projectPath, projectPath))
|
|
2307
|
+
);
|
|
2308
|
+
const otherVersion = existing.find((record) => record.version !== plan.version);
|
|
2309
|
+
if (otherVersion !== void 0)
|
|
2310
|
+
throw new InstallConflict(
|
|
2311
|
+
`${plan.id} ${otherVersion.version ?? ""} is already installed (scope: ${otherVersion.scope}). Its scopes share one copy; to change its version run: namzu plugin update ${plan.id}`.replace(
|
|
2312
|
+
/\s+/g,
|
|
2313
|
+
" "
|
|
2314
|
+
)
|
|
2315
|
+
);
|
|
2316
|
+
const recorded = readInstallManifest(home, plan.id);
|
|
2317
|
+
const sameContents = recorded.state === "ok" && recorded.manifest.surfaceSha256 === plan.digest;
|
|
2318
|
+
if (existing.length > 0) {
|
|
2319
|
+
if (!sameContents) throw new InstallConflict(SAME_VERSION_OTHER_CONTENTS);
|
|
2320
|
+
if (sameScope !== void 0) {
|
|
2321
|
+
const layerPath = recordLayerPath(layerOf(where.scope), { home, cwd: where.cwd });
|
|
2322
|
+
const own = readRecordLayer(layerPath);
|
|
2323
|
+
if (own.state !== "unreadable" && !own.enabledPlugins.has(plan.id))
|
|
2324
|
+
setEnabledPlugin(layerPath, home, plan.id, true);
|
|
2325
|
+
return { outcome: "already-installed", installPath: sameScope.installPath };
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
let moved = false;
|
|
2329
|
+
let wroteManifest = false;
|
|
2330
|
+
let wroteRecord = false;
|
|
2331
|
+
try {
|
|
2332
|
+
if (existing.length === 0) {
|
|
2333
|
+
if (existsSync3(dest)) trashFolder(home, dest);
|
|
2334
|
+
where.faults?.("before-move");
|
|
2335
|
+
mkdirSync5(dirname4(dest), { recursive: true, mode: 493 });
|
|
2336
|
+
renameSync2(plan.root, dest);
|
|
2337
|
+
moved = true;
|
|
2338
|
+
where.faults?.("after-move");
|
|
2339
|
+
writeJsonAtomic(installManifestPath(home, plan.id), manifestFile(plan, where));
|
|
2340
|
+
wroteManifest = true;
|
|
2341
|
+
where.faults?.("after-manifest");
|
|
2342
|
+
}
|
|
2343
|
+
const installPath = existing.length > 0 ? existing[0].installPath : dest;
|
|
2344
|
+
putInstallRecord(
|
|
2345
|
+
home,
|
|
2346
|
+
plan.id,
|
|
2347
|
+
recordFields(plan, {
|
|
2348
|
+
scope: where.scope,
|
|
2349
|
+
installPath,
|
|
2350
|
+
...projectPath !== void 0 ? { projectPath } : {},
|
|
2351
|
+
now: where.now.toISOString()
|
|
2352
|
+
})
|
|
2353
|
+
);
|
|
2354
|
+
wroteRecord = true;
|
|
2355
|
+
where.faults?.("after-record");
|
|
2356
|
+
setEnabledPlugin(
|
|
2357
|
+
recordLayerPath(layerOf(where.scope), { home, cwd: where.cwd }),
|
|
2358
|
+
home,
|
|
2359
|
+
plan.id,
|
|
2360
|
+
true
|
|
2361
|
+
);
|
|
2362
|
+
where.faults?.("after-enabled");
|
|
2363
|
+
return { outcome: "installed", installPath };
|
|
2364
|
+
} catch (error) {
|
|
2365
|
+
if (!(error instanceof SimulatedCrash) && !wroteRecord) {
|
|
2366
|
+
if (wroteManifest) rmSync3(installManifestPath(home, plan.id), { force: true });
|
|
2367
|
+
if (moved) trashFolder(home, dest);
|
|
2368
|
+
}
|
|
2369
|
+
throw error;
|
|
2370
|
+
}
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
__name(commitInstall, "commitInstall");
|
|
2374
|
+
function commitUpdate(plan, where) {
|
|
2375
|
+
const { home } = where;
|
|
2376
|
+
const dest = cacheFolderOf(home, plan);
|
|
2377
|
+
return withStateFileLock(installedPluginsPath(home), () => {
|
|
2378
|
+
const existing = readRecords(home).get(plan.id) ?? [];
|
|
2379
|
+
if (existing.length === 0) throw new InstallConflict(`${plan.id} is not installed.`, 66);
|
|
2380
|
+
const current = existing[0];
|
|
2381
|
+
const recorded = readInstallManifest(home, plan.id);
|
|
2382
|
+
const sameContents = recorded.state === "ok" && recorded.manifest.surfaceSha256 === plan.digest;
|
|
2383
|
+
if (current.version === plan.version) {
|
|
2384
|
+
if (sameContents) return { outcome: "up-to-date", to: plan.version };
|
|
2385
|
+
throw new InstallConflict(
|
|
2386
|
+
`${plan.id} still says version ${plan.version} but its files changed. Ask its author to raise the version, or remove it and install it again.`
|
|
2387
|
+
);
|
|
2388
|
+
}
|
|
2389
|
+
const oldPaths = new Set(existing.map((record) => realPathOrResolved(record.installPath)));
|
|
2390
|
+
let moved = false;
|
|
2391
|
+
let wroteRecord = false;
|
|
2392
|
+
const previousManifest = existsSync3(installManifestPath(home, plan.id)) ? readFileSync5(installManifestPath(home, plan.id)) : void 0;
|
|
2393
|
+
try {
|
|
2394
|
+
if (existsSync3(dest)) trashFolder(home, dest);
|
|
2395
|
+
where.faults?.("before-move");
|
|
2396
|
+
mkdirSync5(dirname4(dest), { recursive: true, mode: 493 });
|
|
2397
|
+
renameSync2(plan.root, dest);
|
|
2398
|
+
moved = true;
|
|
2399
|
+
where.faults?.("after-move");
|
|
2400
|
+
const first = existing[0];
|
|
2401
|
+
writeJsonAtomic(installManifestPath(home, plan.id), {
|
|
2402
|
+
...manifestFile(plan, {
|
|
2403
|
+
...where,
|
|
2404
|
+
scope: first.scope,
|
|
2405
|
+
cwd: first.projectPath ?? ""
|
|
2406
|
+
})
|
|
2407
|
+
});
|
|
2408
|
+
where.faults?.("after-manifest");
|
|
2409
|
+
for (const record of existing) {
|
|
2410
|
+
putInstallRecord(home, plan.id, {
|
|
2411
|
+
...recordFields(plan, {
|
|
2412
|
+
scope: record.scope,
|
|
2413
|
+
installPath: dest,
|
|
2414
|
+
...record.projectPath !== void 0 ? { projectPath: record.projectPath } : {},
|
|
2415
|
+
now: where.now.toISOString()
|
|
2416
|
+
}),
|
|
2417
|
+
installedAt: record.installedAt ?? where.now.toISOString()
|
|
2418
|
+
});
|
|
2419
|
+
wroteRecord = true;
|
|
2420
|
+
}
|
|
2421
|
+
where.faults?.("after-record");
|
|
2422
|
+
} catch (error) {
|
|
2423
|
+
if (!(error instanceof SimulatedCrash) && !wroteRecord) {
|
|
2424
|
+
if (previousManifest !== void 0)
|
|
2425
|
+
writeFileSync4(installManifestPath(home, plan.id), previousManifest, { mode: 384 });
|
|
2426
|
+
if (moved) trashFolder(home, dest);
|
|
2427
|
+
}
|
|
2428
|
+
throw error;
|
|
2429
|
+
}
|
|
2430
|
+
for (const old of oldPaths) {
|
|
2431
|
+
if (samePath(old, dest) || !isInsidePluginCache(home, old)) continue;
|
|
2432
|
+
try {
|
|
2433
|
+
writeFileSync4(join7(old, ".orphaned_at"), `${where.now.toISOString()}
|
|
2434
|
+
`, { mode: 384 });
|
|
2435
|
+
} catch {
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
return {
|
|
2439
|
+
outcome: "updated",
|
|
2440
|
+
...current.version !== void 0 ? { from: current.version } : {},
|
|
2441
|
+
to: plan.version
|
|
2442
|
+
};
|
|
2443
|
+
});
|
|
2444
|
+
}
|
|
2445
|
+
__name(commitUpdate, "commitUpdate");
|
|
2446
|
+
function removeInstall(id, which, options) {
|
|
2447
|
+
const { home } = options;
|
|
2448
|
+
return withStateFileLock(installedPluginsPath(home), () => {
|
|
2449
|
+
const before = (readRecords(home).get(id) ?? []).find(
|
|
2450
|
+
(record) => record.scope === which.scope && (which.projectPath === void 0 || record.projectPath !== void 0 && samePath(record.projectPath, which.projectPath))
|
|
2451
|
+
);
|
|
2452
|
+
if (before === void 0)
|
|
2453
|
+
return {
|
|
2454
|
+
removedRecord: false,
|
|
2455
|
+
folderRemoved: false,
|
|
2456
|
+
manifestRemoved: false,
|
|
2457
|
+
dataKept: false,
|
|
2458
|
+
dataDeleted: false,
|
|
2459
|
+
remaining: 0
|
|
2460
|
+
};
|
|
2461
|
+
removeInstallRecord(home, id, {
|
|
2462
|
+
scope: which.scope,
|
|
2463
|
+
...which.projectPath !== void 0 ? { projectPath: which.projectPath } : {}
|
|
2464
|
+
});
|
|
2465
|
+
try {
|
|
2466
|
+
setEnabledPlugin(
|
|
2467
|
+
recordLayerPath(layerOf(which.scope), { home, cwd: which.projectPath ?? home }),
|
|
2468
|
+
home,
|
|
2469
|
+
id,
|
|
2470
|
+
void 0
|
|
2471
|
+
);
|
|
2472
|
+
} catch {
|
|
2473
|
+
}
|
|
2474
|
+
const remaining = readRecords(home);
|
|
2475
|
+
const left = remaining.get(id) ?? [];
|
|
2476
|
+
let manifestRemoved = false;
|
|
2477
|
+
const prior = readInstallManifest(home, id);
|
|
2478
|
+
const originSource = prior.state === "ok" ? prior.manifest.installedFrom ?? null : null;
|
|
2479
|
+
if (left.length === 0 && existsSync3(installManifestPath(home, id))) {
|
|
2480
|
+
rmSync3(installManifestPath(home, id), { force: true });
|
|
2481
|
+
manifestRemoved = true;
|
|
2482
|
+
}
|
|
2483
|
+
const usedElsewhere = [...remaining.values()].flat().some((record) => samePath(record.installPath, before.installPath));
|
|
2484
|
+
let folderRemoved = false;
|
|
2485
|
+
if (!usedElsewhere && existsSync3(before.installPath) && isInsidePluginCache(home, before.installPath)) {
|
|
2486
|
+
trashFolder(home, before.installPath);
|
|
2487
|
+
folderRemoved = true;
|
|
2488
|
+
removeEmptyParents(before.installPath, pluginCacheFolder(home));
|
|
2489
|
+
}
|
|
2490
|
+
const data = installedPluginDataFolder(home, id);
|
|
2491
|
+
let dataKept = false;
|
|
2492
|
+
let dataDeleted = false;
|
|
2493
|
+
if (left.length === 0 && existsSync3(data)) {
|
|
2494
|
+
if (options.deleteData) {
|
|
2495
|
+
trashFolder(home, data);
|
|
2496
|
+
dataDeleted = true;
|
|
2497
|
+
} else {
|
|
2498
|
+
dataKept = true;
|
|
2499
|
+
try {
|
|
2500
|
+
writeFileSync4(
|
|
2501
|
+
join7(data, ".origin.json"),
|
|
2502
|
+
`${JSON.stringify({ id, removedAt: options.now.toISOString(), source: originSource }, null, 2)}
|
|
2503
|
+
`,
|
|
2504
|
+
{ mode: 384 }
|
|
2505
|
+
);
|
|
2506
|
+
} catch {
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
return {
|
|
2511
|
+
removedRecord: true,
|
|
2512
|
+
folderRemoved,
|
|
2513
|
+
manifestRemoved,
|
|
2514
|
+
dataKept,
|
|
2515
|
+
dataDeleted,
|
|
2516
|
+
remaining: left.length
|
|
2517
|
+
};
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
__name(removeInstall, "removeInstall");
|
|
2521
|
+
function removeIfEmpty(dir) {
|
|
2522
|
+
try {
|
|
2523
|
+
if (readdirSync4(dir).length === 0) rmdirSync(dir);
|
|
2524
|
+
} catch {
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
__name(removeIfEmpty, "removeIfEmpty");
|
|
2528
|
+
function removeEmptyParents(from, stop) {
|
|
2529
|
+
let dir = dirname4(from);
|
|
2530
|
+
while (dir.length > stop.length && dir.startsWith(stop)) {
|
|
2531
|
+
try {
|
|
2532
|
+
if (readdirSync4(dir).length > 0) return;
|
|
2533
|
+
rmdirSync(dir);
|
|
2534
|
+
} catch {
|
|
2535
|
+
return;
|
|
2536
|
+
}
|
|
2537
|
+
dir = dirname4(dir);
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
__name(removeEmptyParents, "removeEmptyParents");
|
|
2541
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
2542
|
+
var STAGING_GRACE_MS = 60 * 60 * 1e3;
|
|
2543
|
+
function readMarker(dir) {
|
|
2544
|
+
try {
|
|
2545
|
+
const at = Date.parse(readFileSync5(join7(dir, ".orphaned_at"), "utf8").trim());
|
|
2546
|
+
return Number.isNaN(at) ? void 0 : at;
|
|
2547
|
+
} catch {
|
|
2548
|
+
return void 0;
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
__name(readMarker, "readMarker");
|
|
2552
|
+
function listDirs(path) {
|
|
2553
|
+
try {
|
|
2554
|
+
return readdirSync4(path, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join7(path, entry.name));
|
|
2555
|
+
} catch {
|
|
2556
|
+
return [];
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
__name(listDirs, "listDirs");
|
|
2560
|
+
function findPrunable(home, now) {
|
|
2561
|
+
const records = readRecords(home);
|
|
2562
|
+
const used = /* @__PURE__ */ new Set();
|
|
2563
|
+
for (const list2 of records.values())
|
|
2564
|
+
for (const r of list2) used.add(realPathOrResolved(r.installPath));
|
|
2565
|
+
const items = [];
|
|
2566
|
+
const kept = [];
|
|
2567
|
+
for (const market of listDirs(pluginCacheFolder(home)))
|
|
2568
|
+
for (const plugin of listDirs(market))
|
|
2569
|
+
for (const version of listDirs(plugin)) {
|
|
2570
|
+
if (used.has(realPathOrResolved(version))) continue;
|
|
2571
|
+
const marked = readMarker(version);
|
|
2572
|
+
if (marked === void 0)
|
|
2573
|
+
items.push({ path: version, kind: "cache-version", reason: "no install record names it" });
|
|
2574
|
+
else if (now.getTime() - marked >= DAY_MS)
|
|
2575
|
+
items.push({
|
|
2576
|
+
path: version,
|
|
2577
|
+
kind: "cache-version",
|
|
2578
|
+
reason: "an older version that was replaced more than a day ago"
|
|
2579
|
+
});
|
|
2580
|
+
else kept.push({ path: version, reason: "an older version replaced less than a day ago" });
|
|
2581
|
+
}
|
|
2582
|
+
try {
|
|
2583
|
+
for (const file of readdirSync4(installManifestsFolder(home))) {
|
|
2584
|
+
if (!file.endsWith(".json")) continue;
|
|
2585
|
+
const id = file.slice(0, -".json".length);
|
|
2586
|
+
if (!records.has(id))
|
|
2587
|
+
items.push({
|
|
2588
|
+
path: join7(installManifestsFolder(home), file),
|
|
2589
|
+
kind: "install-manifest",
|
|
2590
|
+
reason: "no install record names it"
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
} catch {
|
|
2594
|
+
}
|
|
2595
|
+
for (const entry of listAll(stagingFolder(home))) {
|
|
2596
|
+
try {
|
|
2597
|
+
if (now.getTime() - statSync2(entry).mtimeMs >= STAGING_GRACE_MS)
|
|
2598
|
+
items.push({
|
|
2599
|
+
path: entry,
|
|
2600
|
+
kind: "staging",
|
|
2601
|
+
reason: "left over from an install that did not finish"
|
|
2602
|
+
});
|
|
2603
|
+
} catch {
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
return { items, kept };
|
|
2607
|
+
}
|
|
2608
|
+
__name(findPrunable, "findPrunable");
|
|
2609
|
+
function listAll(path) {
|
|
2610
|
+
try {
|
|
2611
|
+
return readdirSync4(path).map((name) => join7(path, name));
|
|
2612
|
+
} catch {
|
|
2613
|
+
return [];
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
__name(listAll, "listAll");
|
|
2617
|
+
function prune(home, now, apply) {
|
|
2618
|
+
if (!apply) return findPrunable(home, now);
|
|
2619
|
+
return withStateFileLock(installedPluginsPath(home), () => {
|
|
2620
|
+
const result = findPrunable(home, now);
|
|
2621
|
+
for (const item of result.items) {
|
|
2622
|
+
if (item.kind === "install-manifest") rmSync3(item.path, { force: true });
|
|
2623
|
+
else trashFolder(home, item.path);
|
|
2624
|
+
}
|
|
2625
|
+
for (const market of listDirs(pluginCacheFolder(home))) {
|
|
2626
|
+
for (const plugin of listDirs(market)) removeIfEmpty(plugin);
|
|
2627
|
+
removeIfEmpty(market);
|
|
2628
|
+
}
|
|
2629
|
+
return result;
|
|
2630
|
+
});
|
|
2631
|
+
}
|
|
2632
|
+
__name(prune, "prune");
|
|
2633
|
+
|
|
2634
|
+
// src/integrations/plugins/remote-marketplace.ts
|
|
2635
|
+
var oneLine = /* @__PURE__ */ __name((value) => terminalDisplayText(value).replace(/[\t\n\r]+/g, " "), "oneLine");
|
|
2636
|
+
var MARKETPLACE_NOTICE = [
|
|
2637
|
+
"Plugins from a marketplace can run programs on this computer, with access to",
|
|
2638
|
+
"your files. Namzu does not control this marketplace or its plugins, and its",
|
|
2639
|
+
"owner can change them later. Add only marketplaces you trust."
|
|
2640
|
+
].join("\n");
|
|
2641
|
+
var MARKETPLACE_BLOCKED = "Adding this marketplace is turned off in your settings.";
|
|
2642
|
+
var DOWNLOAD_BLOCKED = "Downloading from this marketplace is turned off in your settings.";
|
|
2643
|
+
function sameVersionChanged(id, version) {
|
|
2644
|
+
return `${id} still says version ${version} but its files changed. Ask its author to raise the version, or remove it and install it again.`;
|
|
2645
|
+
}
|
|
2646
|
+
__name(sameVersionChanged, "sameVersionChanged");
|
|
2647
|
+
function describeAddition(source) {
|
|
2648
|
+
const where = describeSource(source);
|
|
2649
|
+
if (source.source === "url") return `Will add the marketplace file at ${where}`;
|
|
2650
|
+
return `Will add ${where}${source.ref !== void 0 ? ` (${isCommitId(source.ref) ? "commit" : "branch or tag"} ${source.ref})` : " (default branch)"}`;
|
|
2651
|
+
}
|
|
2652
|
+
__name(describeAddition, "describeAddition");
|
|
2653
|
+
function sameSource(a, b) {
|
|
2654
|
+
const norm = /* @__PURE__ */ __name((v) => JSON.stringify([
|
|
2655
|
+
v.source,
|
|
2656
|
+
v.repo ?? v.url ?? v.path ?? null,
|
|
2657
|
+
v.ref ?? null,
|
|
2658
|
+
[...v.sparsePaths ?? []].sort()
|
|
2659
|
+
]), "norm");
|
|
2660
|
+
return norm(a) === norm(b);
|
|
2661
|
+
}
|
|
2662
|
+
__name(sameSource, "sameSource");
|
|
2663
|
+
function anotherPlace(name, existing, wanted, remove = `Remove it first: namzu plugin marketplace remove ${name}`) {
|
|
2664
|
+
const sameRepo = existing.source === wanted.source && (existing.repo ?? existing.url ?? existing.path ?? null) === (wanted.repo ?? wanted.url ?? wanted.path ?? null) && wanted.source !== "directory";
|
|
2665
|
+
if (sameRepo) {
|
|
2666
|
+
const pin = /* @__PURE__ */ __name((v) => {
|
|
2667
|
+
const sparse = v.sparsePaths ?? [];
|
|
2668
|
+
return [
|
|
2669
|
+
v.ref !== void 0 ? `ref ${String(v.ref)}` : "default branch",
|
|
2670
|
+
...sparse.length > 0 ? [`folders ${sparse.join(", ")}`] : []
|
|
2671
|
+
].join(", ");
|
|
2672
|
+
}, "pin");
|
|
2673
|
+
return `A marketplace named "${name}" is already added from this repository at a different ref or folder set (added: ${oneLine(pin(existing))}; asked for: ${oneLine(pin(wanted))}). ${remove}`;
|
|
2674
|
+
}
|
|
2675
|
+
return `A marketplace named "${name}" is already added from another place (${oneLine(describeSource(existing))}). ${remove}`;
|
|
2676
|
+
}
|
|
2677
|
+
__name(anotherPlace, "anotherPlace");
|
|
2678
|
+
function marketplaceConsentText(name, display, catalog, notInstallable, commit, ref) {
|
|
2679
|
+
return [
|
|
2680
|
+
`Add marketplace "${oneLine(name)}" from ${oneLine(display)}?`,
|
|
2681
|
+
"",
|
|
2682
|
+
MARKETPLACE_NOTICE,
|
|
2683
|
+
"",
|
|
2684
|
+
` Owner: ${catalog.owner !== void 0 ? oneLine(catalog.owner) : "(not stated)"}`,
|
|
2685
|
+
` Plugins: ${catalog.entries.length}${notInstallable > 0 ? ` (${notInstallable} cannot be installed here)` : ""}`,
|
|
2686
|
+
...commit !== void 0 ? [` Commit: ${commit.slice(0, 7)}${ref !== void 0 ? ` (${oneLine(ref)})` : ""}`] : [],
|
|
2687
|
+
"",
|
|
2688
|
+
"You will see what a plugin does before you install it."
|
|
2689
|
+
].join("\n");
|
|
2690
|
+
}
|
|
2691
|
+
__name(marketplaceConsentText, "marketplaceConsentText");
|
|
2692
|
+
async function countNotInstallable(catalog, hosted, allowFileProtocol) {
|
|
2693
|
+
const kinds = await Promise.all(
|
|
2694
|
+
catalog.entries.map(
|
|
2695
|
+
async (entry) => (await resolveEntrySource(entry, catalog, {
|
|
2696
|
+
hosted,
|
|
2697
|
+
...allowFileProtocol ? { allowFileProtocol: true } : {}
|
|
2698
|
+
})).kind
|
|
2699
|
+
)
|
|
2700
|
+
);
|
|
2701
|
+
return kinds.filter((kind) => kind !== "local" && kind !== "remote").length;
|
|
2702
|
+
}
|
|
2703
|
+
__name(countNotInstallable, "countNotInstallable");
|
|
2704
|
+
function entryAddress(remote) {
|
|
2705
|
+
return remote.kind === "github" ? { source: "github", repo: remote.repo } : remote.kind === "archive" ? { source: "url", url: remote.url } : { source: "git", url: remote.url };
|
|
2706
|
+
}
|
|
2707
|
+
__name(entryAddress, "entryAddress");
|
|
2708
|
+
function downloadBlocked(market, remote, blocked) {
|
|
2709
|
+
return market !== void 0 && isBlockedSource(market.source, blocked) || isBlockedSource(entryAddress(remote), blocked);
|
|
2710
|
+
}
|
|
2711
|
+
__name(downloadBlocked, "downloadBlocked");
|
|
2712
|
+
function readFetchedCatalog(dir, display) {
|
|
2713
|
+
const read = readCatalog(dir, "directory");
|
|
2714
|
+
if (!read.ok)
|
|
2715
|
+
return {
|
|
2716
|
+
ok: false,
|
|
2717
|
+
message: read.missing ? `${oneLine(display)} is not a marketplace: it has no ${COMMON_MANIFEST_DIR}/${COMMON_MARKETPLACE_FILE}.` : `${oneLine(display)} is not a marketplace: ${read.reason}`
|
|
2718
|
+
};
|
|
2719
|
+
return { ok: true, catalog: read.catalog };
|
|
2720
|
+
}
|
|
2721
|
+
__name(readFetchedCatalog, "readFetchedCatalog");
|
|
2722
|
+
function fetchNotes(fetched) {
|
|
2723
|
+
return [
|
|
2724
|
+
...fetched.lfsPointers > 0 ? [
|
|
2725
|
+
`${fetched.lfsPointers} Git LFS ${fetched.lfsPointers === 1 ? "file was" : "files were"} not downloaded and stay as pointer files.`
|
|
2726
|
+
] : [],
|
|
2727
|
+
...fetched.submodules > 0 ? [
|
|
2728
|
+
`The repository lists ${fetched.submodules} ${fetched.submodules === 1 ? "submodule" : "submodules"}; none was downloaded.`
|
|
2729
|
+
] : []
|
|
2730
|
+
];
|
|
2731
|
+
}
|
|
2732
|
+
__name(fetchNotes, "fetchNotes");
|
|
2733
|
+
function placeMarketplace(catalog, source, fetched, options) {
|
|
2734
|
+
const dest = join8(marketplacesFolder(options.home), catalog.name);
|
|
2735
|
+
const at = options.now.toISOString();
|
|
2736
|
+
if (lstatExists(dest)) trashFolder(options.home, dest);
|
|
2737
|
+
mkdirSync6(marketplacesFolder(options.home), { recursive: true, mode: 448 });
|
|
2738
|
+
renameSync3(fetched.dir, dest);
|
|
2739
|
+
putKnownMarketplace(options.home, catalog.name, {
|
|
2740
|
+
source,
|
|
2741
|
+
installLocation: dest,
|
|
2742
|
+
lastUpdated: at,
|
|
2743
|
+
autoUpdate: false,
|
|
2744
|
+
...fetched.commit !== void 0 ? { commit: fetched.commit } : {},
|
|
2745
|
+
consent: { at, by: options.by, notice: "marketplace-v1" }
|
|
2746
|
+
});
|
|
2747
|
+
setExtraKnownMarketplace(options.layerPath, options.home, catalog.name, source);
|
|
2748
|
+
}
|
|
2749
|
+
__name(placeMarketplace, "placeMarketplace");
|
|
2750
|
+
function newStaging(home) {
|
|
2751
|
+
const staging = join8(stagingFolder(home), randomUUID3());
|
|
2752
|
+
mkdirSync6(staging, { recursive: true, mode: 448 });
|
|
2753
|
+
return staging;
|
|
2754
|
+
}
|
|
2755
|
+
__name(newStaging, "newStaging");
|
|
2756
|
+
function lstatExists(path) {
|
|
2757
|
+
try {
|
|
2758
|
+
lstatSync6(path);
|
|
2759
|
+
return true;
|
|
2760
|
+
} catch {
|
|
2761
|
+
return false;
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
__name(lstatExists, "lstatExists");
|
|
2765
|
+
function diffCatalogs(before, after) {
|
|
2766
|
+
const old = new Map(before.ok ? before.catalog.entries.map((e) => [e.name, e]) : []);
|
|
2767
|
+
const added = [];
|
|
2768
|
+
const changed = [];
|
|
2769
|
+
for (const entry of after.entries) {
|
|
2770
|
+
const prior = old.get(entry.name);
|
|
2771
|
+
if (prior === void 0) added.push(entry.name);
|
|
2772
|
+
else if (JSON.stringify(prior.raw) !== JSON.stringify(entry.raw)) changed.push(entry.name);
|
|
2773
|
+
}
|
|
2774
|
+
return { added, changed };
|
|
2775
|
+
}
|
|
2776
|
+
__name(diffCatalogs, "diffCatalogs");
|
|
2777
|
+
function newerVersions(home, name, catalog) {
|
|
2778
|
+
const installed = readInstalledPlugins(home);
|
|
2779
|
+
if (installed.state === "unreadable") return [];
|
|
2780
|
+
const out = [];
|
|
2781
|
+
for (const [id, records] of installed.plugins) {
|
|
2782
|
+
const parts = splitPluginId(id);
|
|
2783
|
+
if (parts.marketplace !== name) continue;
|
|
2784
|
+
const entry = catalog.entries.find((candidate) => candidate.name === parts.name);
|
|
2785
|
+
const have = records[0]?.version;
|
|
2786
|
+
if (entry?.version !== void 0 && have !== void 0 && entry.version !== have)
|
|
2787
|
+
out.push({ id, installed: have, available: entry.version });
|
|
2788
|
+
}
|
|
2789
|
+
return out;
|
|
2790
|
+
}
|
|
2791
|
+
__name(newerVersions, "newerVersions");
|
|
2792
|
+
function isInside(outer, inner) {
|
|
2793
|
+
const rel = relative2(outer, inner);
|
|
2794
|
+
return rel !== "" && !rel.startsWith("..") && !isAbsolute3(rel);
|
|
2795
|
+
}
|
|
2796
|
+
__name(isInside, "isInside");
|
|
2797
|
+
async function refreshRemoteMarketplace(market, options) {
|
|
2798
|
+
const { home } = options;
|
|
2799
|
+
const describe = options.describe ?? failureText;
|
|
2800
|
+
const name = market.name;
|
|
2801
|
+
const row = /* @__PURE__ */ __name((partial) => ({
|
|
2802
|
+
name,
|
|
2803
|
+
newPlugins: [],
|
|
2804
|
+
changedPlugins: [],
|
|
2805
|
+
newer: [],
|
|
2806
|
+
...partial
|
|
2807
|
+
}), "row");
|
|
2808
|
+
const kind = market.source.source;
|
|
2809
|
+
if (isBlockedSource(market.source, options.blockedMarketplaces))
|
|
2810
|
+
return row({ outcome: "failed", message: "refreshing it is turned off in your settings." });
|
|
2811
|
+
const ref = typeof market.source.ref === "string" ? market.source.ref : void 0;
|
|
2812
|
+
if ((kind === "github" || kind === "git") && ref !== void 0 && isCommitId(ref))
|
|
2813
|
+
return row({ outcome: "pinned", message: `pinned at ${ref.slice(0, 7)}` });
|
|
2814
|
+
if (!isInside(marketplacesFolder(home), market.installLocation))
|
|
2815
|
+
return row({
|
|
2816
|
+
outcome: "failed",
|
|
2817
|
+
message: "its folder is not under Namzu\u2019s marketplaces folder, so it is not replaced."
|
|
2818
|
+
});
|
|
2819
|
+
const staging = newStaging(home);
|
|
2820
|
+
try {
|
|
2821
|
+
let fetched;
|
|
2822
|
+
try {
|
|
2823
|
+
fetched = await fetchMarketplace(
|
|
2824
|
+
market.source,
|
|
2825
|
+
staging,
|
|
2826
|
+
options.fetch
|
|
2827
|
+
);
|
|
2828
|
+
} catch (error) {
|
|
2829
|
+
if (options.fetch?.signal?.aborted) throw error;
|
|
2830
|
+
return row({ outcome: "failed", message: describe(error) });
|
|
2831
|
+
}
|
|
2832
|
+
const read = readCatalog(fetched.dir, "directory");
|
|
2833
|
+
if (!read.ok)
|
|
2834
|
+
return row({ outcome: "failed", message: `it is no longer a marketplace: ${read.reason}` });
|
|
2835
|
+
if (read.catalog.name !== name)
|
|
2836
|
+
return row({
|
|
2837
|
+
outcome: "failed",
|
|
2838
|
+
message: `it now calls itself "${read.catalog.name}", so it was not updated.`
|
|
2839
|
+
});
|
|
2840
|
+
const before = readCatalog(market.installLocation, "directory");
|
|
2841
|
+
const diff = diffCatalogs(before, read.catalog);
|
|
2842
|
+
const unchanged = fetched.commit !== void 0 ? fetched.commit === market.commit : before.ok && diff.added.length === 0 && diff.changed.length === 0 && before.catalog.entries.length === read.catalog.entries.length;
|
|
2843
|
+
const newer = newerVersions(home, name, read.catalog);
|
|
2844
|
+
if (unchanged) return row({ outcome: "up-to-date", message: "already up to date", newer });
|
|
2845
|
+
try {
|
|
2846
|
+
if (lstatExists(market.installLocation)) trashFolder(home, market.installLocation);
|
|
2847
|
+
renameSync3(fetched.dir, market.installLocation);
|
|
2848
|
+
putKnownMarketplace(home, name, {
|
|
2849
|
+
source: market.source,
|
|
2850
|
+
installLocation: market.installLocation,
|
|
2851
|
+
lastUpdated: options.now.toISOString(),
|
|
2852
|
+
...fetched.commit !== void 0 ? { commit: fetched.commit } : {}
|
|
2853
|
+
});
|
|
2854
|
+
} catch (error) {
|
|
2855
|
+
return row({ outcome: "failed", message: describe(error) });
|
|
2856
|
+
}
|
|
2857
|
+
const counts = `${diff.added.length} new, ${diff.changed.length} changed`;
|
|
2858
|
+
return row({
|
|
2859
|
+
outcome: "updated",
|
|
2860
|
+
message: fetched.commit !== void 0 ? `updated ${(market.commit ?? "?").slice(0, 7)} to ${fetched.commit.slice(0, 7)} (${counts})` : `updated (${counts})`,
|
|
2861
|
+
from: market.commit ?? null,
|
|
2862
|
+
to: fetched.commit ?? null,
|
|
2863
|
+
newPlugins: diff.added,
|
|
2864
|
+
changedPlugins: diff.changed,
|
|
2865
|
+
newer
|
|
2866
|
+
});
|
|
2867
|
+
} finally {
|
|
2868
|
+
discardStaging(staging);
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
__name(refreshRemoteMarketplace, "refreshRemoteMarketplace");
|
|
2872
|
+
function failureText(error) {
|
|
2873
|
+
return error instanceof Error ? error.message : String(error);
|
|
2874
|
+
}
|
|
2875
|
+
__name(failureText, "failureText");
|
|
2876
|
+
|
|
2877
|
+
// src/commands/plugin-records.ts
|
|
2878
|
+
var PLUGIN_RECORD_VERBS = ["list", "details", "enable", "disable"];
|
|
2879
|
+
var PLUGIN_RECORD_HELP = [
|
|
2880
|
+
"Usage:",
|
|
2881
|
+
" namzu plugin list [--cwd <dir>] [--json]",
|
|
2882
|
+
" namzu plugin details <id> [--cwd <dir>] [--json]",
|
|
2883
|
+
" namzu plugin enable <id> [--scope user|project|local] [--cwd <dir>] [--json]",
|
|
2884
|
+
" namzu plugin disable <id> [--scope user|project|local] [--cwd <dir>] [--json]",
|
|
2885
|
+
"",
|
|
2886
|
+
"list The installed plugins that apply here: id, version, scope, on or off, and what needs attention.",
|
|
2887
|
+
"details One plugin: what it brings by its exact names, the record, who turned it on, where its data is.",
|
|
2888
|
+
"enable Record a yes for an installed plugin. It takes effect in new conversations.",
|
|
2889
|
+
"disable Record a no. Nothing is removed; the plugin stays installed.",
|
|
2890
|
+
"",
|
|
2891
|
+
"An id is <name>@<marketplace>; a bare name works when only one installed plugin has it.",
|
|
2892
|
+
"Without --scope a user plugin is changed in your own settings file, and a project plugin in",
|
|
2893
|
+
"this computer\u2019s file for the folder (.namzu/settings.local.json), so a shared file is not",
|
|
2894
|
+
"edited by a toggle. --scope project edits the shared .namzu/settings.json.",
|
|
2895
|
+
"",
|
|
2896
|
+
"Options:",
|
|
2897
|
+
" --scope user|project|local The record to act on, and the settings file it is written to",
|
|
2898
|
+
" --cwd <dir> The folder whose project plugins are meant (default: here)",
|
|
2899
|
+
" --json Print one JSON object on standard output",
|
|
2900
|
+
"",
|
|
2901
|
+
"Exit status: 0 done, 1 something failed, 64 the command line is wrong,",
|
|
2902
|
+
"66 not installed or a record could not be read, 77 the folder is not trusted."
|
|
2903
|
+
].join("\n");
|
|
2904
|
+
function parseFlags(args) {
|
|
2905
|
+
let json = false;
|
|
2906
|
+
let scope;
|
|
2907
|
+
let cwd;
|
|
2908
|
+
const positional = [];
|
|
2909
|
+
for (let i = 0; i < args.length; i++) {
|
|
2910
|
+
const arg = args[i];
|
|
2911
|
+
const value = /* @__PURE__ */ __name((name) => {
|
|
2912
|
+
if (arg === name) return args[++i];
|
|
2913
|
+
if (arg.startsWith(`${name}=`)) return arg.slice(name.length + 1);
|
|
2914
|
+
return void 0;
|
|
2915
|
+
}, "value");
|
|
2916
|
+
if (arg === "--json") json = true;
|
|
2917
|
+
else if (arg === "--scope" || arg.startsWith("--scope=")) {
|
|
2918
|
+
const v = value("--scope");
|
|
2919
|
+
if (v !== "user" && v !== "project" && v !== "local")
|
|
2920
|
+
return { json, positional, error: "--scope is user, project or local." };
|
|
2921
|
+
scope = v;
|
|
2922
|
+
} else if (arg === "--cwd" || arg.startsWith("--cwd=")) {
|
|
2923
|
+
const v = value("--cwd");
|
|
2924
|
+
if (v === void 0 || v === "") return { json, positional, error: "--cwd needs a folder." };
|
|
2925
|
+
cwd = v;
|
|
2926
|
+
} else if (arg.startsWith("-") && arg !== "-")
|
|
2927
|
+
return { json, positional, error: `unknown option: ${arg}` };
|
|
2928
|
+
else positional.push(arg);
|
|
2929
|
+
}
|
|
2930
|
+
return { json, ...scope ? { scope } : {}, ...cwd ? { cwd } : {}, positional };
|
|
2931
|
+
}
|
|
2932
|
+
__name(parseFlags, "parseFlags");
|
|
2933
|
+
function failure(deps, json, command, code, message, extra = {}) {
|
|
2934
|
+
if (json) deps.out(`${JSON.stringify({ command, outcome: "failed", message, ...extra })}
|
|
2935
|
+
`);
|
|
2936
|
+
else deps.err(`${message}
|
|
2937
|
+
`);
|
|
2938
|
+
return code;
|
|
2939
|
+
}
|
|
2940
|
+
__name(failure, "failure");
|
|
2941
|
+
function stateFailure(error) {
|
|
2942
|
+
if (error instanceof StateFileUnreadableError)
|
|
2943
|
+
return {
|
|
2944
|
+
code: EXIT_NOINPUT,
|
|
2945
|
+
message: `The install record could not be read, so nothing was changed: ${error.file}
|
|
2946
|
+
${error.sentence((p) => p)}`
|
|
2947
|
+
};
|
|
2948
|
+
if (error instanceof StateFileBusyError)
|
|
2949
|
+
return { code: EXIT_FAIL, message: error.sentence((p) => p) };
|
|
2950
|
+
return { code: EXIT_FAIL, message: error instanceof Error ? error.message : String(error) };
|
|
2951
|
+
}
|
|
2952
|
+
__name(stateFailure, "stateFailure");
|
|
2953
|
+
function resolveId(deps, json, command, arg) {
|
|
2954
|
+
const read = readInstalledPlugins(deps.namzuHome);
|
|
2955
|
+
if (read.state === "unreadable")
|
|
2956
|
+
return failure(
|
|
2957
|
+
deps,
|
|
2958
|
+
json,
|
|
2959
|
+
command,
|
|
2960
|
+
EXIT_NOINPUT,
|
|
2961
|
+
`The install record could not be read, so nothing was changed: ${installedPluginsPath(deps.namzuHome)} (${read.reason}). Fix or remove the file, then try again.`
|
|
2962
|
+
);
|
|
2963
|
+
if (isPluginId(arg)) {
|
|
2964
|
+
const records = read.plugins.get(arg);
|
|
2965
|
+
if (!records)
|
|
2966
|
+
return failure(
|
|
2967
|
+
deps,
|
|
2968
|
+
json,
|
|
2969
|
+
command,
|
|
2970
|
+
EXIT_NOINPUT,
|
|
2971
|
+
`${arg} is not installed on this computer.`,
|
|
2972
|
+
{
|
|
2973
|
+
id: arg
|
|
2974
|
+
}
|
|
2975
|
+
);
|
|
2976
|
+
return { id: arg, records };
|
|
2977
|
+
}
|
|
2978
|
+
if (arg.includes("@") || arg === "")
|
|
2979
|
+
return failure(
|
|
2980
|
+
deps,
|
|
2981
|
+
json,
|
|
2982
|
+
command,
|
|
2983
|
+
EXIT_USAGE,
|
|
2984
|
+
`"${arg}" is not a plugin id (name@marketplace).`
|
|
2985
|
+
);
|
|
2986
|
+
const matches = [...read.plugins.keys()].filter((id2) => splitPluginId(id2).name === arg);
|
|
2987
|
+
if (matches.length === 0)
|
|
2988
|
+
return failure(deps, json, command, EXIT_NOINPUT, `${arg} is not installed on this computer.`);
|
|
2989
|
+
if (matches.length > 1)
|
|
2990
|
+
return failure(
|
|
2991
|
+
deps,
|
|
2992
|
+
json,
|
|
2993
|
+
command,
|
|
2994
|
+
EXIT_USAGE,
|
|
2995
|
+
`More than one installed plugin is named ${arg}: ${matches.join(", ")}. Name one of them.`,
|
|
2996
|
+
{ matches }
|
|
2997
|
+
);
|
|
2998
|
+
const id = matches[0];
|
|
2999
|
+
return { id, records: read.plugins.get(id) };
|
|
3000
|
+
}
|
|
3001
|
+
__name(resolveId, "resolveId");
|
|
3002
|
+
function applicable(records, cwd, trusted) {
|
|
3003
|
+
const rank = { local: 3, project: 2, user: 1 };
|
|
3004
|
+
const here = [];
|
|
3005
|
+
let unread = 0;
|
|
3006
|
+
for (const record of records) {
|
|
3007
|
+
if (record.scope === "user") here.push(record);
|
|
3008
|
+
else if (record.projectPath !== void 0 && samePath(record.projectPath, cwd)) {
|
|
3009
|
+
if (trusted) here.push(record);
|
|
3010
|
+
else unread++;
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
here.sort((a, b) => rank[b.scope] - rank[a.scope]);
|
|
3014
|
+
return { here, unread };
|
|
3015
|
+
}
|
|
3016
|
+
__name(applicable, "applicable");
|
|
3017
|
+
function contextOf(deps, flags) {
|
|
3018
|
+
const cwd = resolve3(deps.cwd(), flags.cwd ?? ".");
|
|
3019
|
+
return { cwd: realPathOrResolved(cwd), trusted: deps.isTrusted(cwd) };
|
|
3020
|
+
}
|
|
3021
|
+
__name(contextOf, "contextOf");
|
|
3022
|
+
function layerSentence(by, answer) {
|
|
3023
|
+
if (by === void 0) return "no setting says so";
|
|
3024
|
+
return by === "user" ? `your settings say ${answer ? "yes" : "no"}` : by === "project" ? `the folder\u2019s shared settings say ${answer ? "yes" : "no"}` : `this computer\u2019s settings for the folder say ${answer ? "yes" : "no"}`;
|
|
3025
|
+
}
|
|
3026
|
+
__name(layerSentence, "layerSentence");
|
|
3027
|
+
function candidateFor(id, record, answer) {
|
|
3028
|
+
return {
|
|
3029
|
+
id,
|
|
3030
|
+
name: splitPluginId(id).name,
|
|
3031
|
+
record,
|
|
3032
|
+
scope: admissionScope(record.scope),
|
|
3033
|
+
installPath: realPathOrResolved(record.installPath),
|
|
3034
|
+
answer
|
|
3035
|
+
};
|
|
3036
|
+
}
|
|
3037
|
+
__name(candidateFor, "candidateFor");
|
|
3038
|
+
var CLASH_ALLOWED_SCOPES = ["project", "user"];
|
|
3039
|
+
async function nameClashes(deps, ctx, plugins) {
|
|
3040
|
+
const names = /* @__PURE__ */ new Set();
|
|
3041
|
+
try {
|
|
3042
|
+
const discovered = await discoverAllPluginDirs(ctx.cwd, {
|
|
3043
|
+
enabled: true,
|
|
3044
|
+
autoDiscovery: true,
|
|
3045
|
+
allowedScopes: CLASH_ALLOWED_SCOPES,
|
|
3046
|
+
userRoot: deps.namzuHome
|
|
3047
|
+
});
|
|
3048
|
+
for (const scope of CLASH_ALLOWED_SCOPES)
|
|
3049
|
+
for (const dir of discovered[scope]) {
|
|
3050
|
+
if (scope === "user" && isReservedPluginDir(deps.namzuHome, dir)) continue;
|
|
3051
|
+
try {
|
|
3052
|
+
names.add((await loadPluginManifest(dir, { skillsSupported: true })).name);
|
|
3053
|
+
} catch {
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
} catch {
|
|
3057
|
+
}
|
|
3058
|
+
const candidates = [];
|
|
3059
|
+
for (const [id, records] of plugins) {
|
|
3060
|
+
const chosen = applicable(records, ctx.cwd, ctx.trusted).here[0];
|
|
3061
|
+
if (chosen === void 0) continue;
|
|
3062
|
+
if (!verifyInstalledCopy(deps.namzuHome, id, chosen.installPath, chosen.surfaceSha256).ok)
|
|
3063
|
+
continue;
|
|
3064
|
+
candidates.push({ id, at: chosen.installedAt ?? "" });
|
|
3065
|
+
}
|
|
3066
|
+
candidates.sort((a, b) => a.at.localeCompare(b.at) || a.id.localeCompare(b.id));
|
|
3067
|
+
const clashes = /* @__PURE__ */ new Map();
|
|
3068
|
+
for (const { id } of candidates) {
|
|
3069
|
+
const { name } = splitPluginId(id);
|
|
3070
|
+
if (names.has(name))
|
|
3071
|
+
clashes.set(id, `${id} will not load: the name "${name}" is already used by another plugin.`);
|
|
3072
|
+
else names.add(name);
|
|
3073
|
+
}
|
|
3074
|
+
return clashes;
|
|
3075
|
+
}
|
|
3076
|
+
__name(nameClashes, "nameClashes");
|
|
3077
|
+
async function runList(deps, flags) {
|
|
3078
|
+
const command = "plugin list";
|
|
3079
|
+
if (flags.positional.length > 0)
|
|
3080
|
+
return failure(deps, flags.json, command, EXIT_USAGE, "plugin list takes no arguments.");
|
|
3081
|
+
const ctx = contextOf(deps, flags);
|
|
3082
|
+
const read = readInstalledPlugins(deps.namzuHome);
|
|
3083
|
+
if (read.state === "unreadable")
|
|
3084
|
+
return failure(
|
|
3085
|
+
deps,
|
|
3086
|
+
flags.json,
|
|
3087
|
+
command,
|
|
3088
|
+
EXIT_NOINPUT,
|
|
3089
|
+
`The install record could not be read: ${installedPluginsPath(deps.namzuHome)} (${read.reason}). Nothing was changed.`
|
|
3090
|
+
);
|
|
3091
|
+
const layers = readLayers(deps.namzuHome, ctx.cwd, ctx.trusted);
|
|
3092
|
+
const problems = read.invalid.map((bad) => `${bad.id}: ${bad.reason}`);
|
|
3093
|
+
for (const [layer, layerRead] of Object.entries(layers)) {
|
|
3094
|
+
if (layerRead?.state === "unreadable")
|
|
3095
|
+
problems.push(
|
|
3096
|
+
`${recordLayerPath(layer, { home: deps.namzuHome, cwd: ctx.cwd })} could not be read (${layerRead.reason}), so what it says was not used`
|
|
3097
|
+
);
|
|
3098
|
+
}
|
|
3099
|
+
const clashes = await nameClashes(deps, ctx, read.plugins);
|
|
3100
|
+
const known = readKnownMarketplaces(deps.namzuHome);
|
|
3101
|
+
const rows = [];
|
|
3102
|
+
let unread = 0;
|
|
3103
|
+
for (const [id, records] of [...read.plugins.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
3104
|
+
const found = applicable(records, ctx.cwd, ctx.trusted);
|
|
3105
|
+
unread += found.unread;
|
|
3106
|
+
if (found.here.length === 0) continue;
|
|
3107
|
+
const answer = currentEnabledAnswer(
|
|
3108
|
+
{ home: deps.namzuHome, cwd: ctx.cwd, projectTrusted: ctx.trusted },
|
|
3109
|
+
id
|
|
3110
|
+
);
|
|
3111
|
+
for (const record of found.here) {
|
|
3112
|
+
const verdict = verifyInstalledCopy(
|
|
3113
|
+
deps.namzuHome,
|
|
3114
|
+
id,
|
|
3115
|
+
record.installPath,
|
|
3116
|
+
record.surfaceSha256
|
|
3117
|
+
);
|
|
3118
|
+
const notes = record.findings.filter(
|
|
3119
|
+
(f) => f.level === "notUsed" || f.level === "refused"
|
|
3120
|
+
).length;
|
|
3121
|
+
const { name, marketplace } = splitPluginId(id);
|
|
3122
|
+
const clash = verdict.ok ? clashes.get(id) : void 0;
|
|
3123
|
+
const problem = verdict.ok ? clash : verdict.message;
|
|
3124
|
+
rows.push({
|
|
3125
|
+
id,
|
|
3126
|
+
name,
|
|
3127
|
+
marketplace,
|
|
3128
|
+
version: record.version ?? null,
|
|
3129
|
+
scope: record.scope,
|
|
3130
|
+
...record.projectPath ? { projectPath: record.projectPath } : {},
|
|
3131
|
+
enabled: answer.on,
|
|
3132
|
+
enabledBy: answer.by ?? null,
|
|
3133
|
+
state: problem !== void 0 ? "blocked" : answer.on ? "on" : "off",
|
|
3134
|
+
attention: notes + (problem !== void 0 ? 1 : 0),
|
|
3135
|
+
...problem !== void 0 ? { problem } : {},
|
|
3136
|
+
source: known.state !== "unreadable" ? known.marketplaces.get(marketplace)?.source ?? null : null,
|
|
3137
|
+
layout: record.layout ?? null,
|
|
3138
|
+
installPath: record.installPath
|
|
3139
|
+
});
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
const asked = [];
|
|
3143
|
+
for (const layer of ["project", "local"]) {
|
|
3144
|
+
const layerRead = layers[layer];
|
|
3145
|
+
if (layerRead === void 0 || layerRead.state === "unreadable") continue;
|
|
3146
|
+
for (const [id, value] of layerRead.enabledPlugins) {
|
|
3147
|
+
if (!value) continue;
|
|
3148
|
+
const have = rows.some((row) => row.id === id);
|
|
3149
|
+
if (!have) asked.push({ id, layer, installed: false });
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
const declared = [];
|
|
3153
|
+
for (const layer of ["project", "local"]) {
|
|
3154
|
+
const layerRead = layers[layer];
|
|
3155
|
+
if (layerRead === void 0 || layerRead.state === "unreadable") continue;
|
|
3156
|
+
for (const market of layerRead.marketplaces.values())
|
|
3157
|
+
declared.push({
|
|
3158
|
+
name: market.name,
|
|
3159
|
+
layer,
|
|
3160
|
+
source: market.source,
|
|
3161
|
+
added: known.state !== "unreadable" && known.marketplaces.has(market.name)
|
|
3162
|
+
});
|
|
3163
|
+
}
|
|
3164
|
+
const notice = unread > 0 ? `${unread} plugin ${unread === 1 ? "record" : "records"} for this folder ${unread === 1 ? "was" : "were"} not read because the folder is not trusted yet.` : void 0;
|
|
3165
|
+
if (flags.json) {
|
|
3166
|
+
deps.out(
|
|
3167
|
+
`${JSON.stringify({
|
|
3168
|
+
command,
|
|
3169
|
+
cwd: ctx.cwd,
|
|
3170
|
+
trusted: ctx.trusted,
|
|
3171
|
+
loading: deps.loadingOn ? "on" : "off",
|
|
3172
|
+
plugins: rows,
|
|
3173
|
+
asked,
|
|
3174
|
+
declaredMarketplaces: declared,
|
|
3175
|
+
problems,
|
|
3176
|
+
...notice ? { notice } : {}
|
|
3177
|
+
})}
|
|
3178
|
+
`
|
|
3179
|
+
);
|
|
3180
|
+
return EXIT_OK;
|
|
3181
|
+
}
|
|
3182
|
+
const lines = [];
|
|
3183
|
+
if (rows.length === 0) lines.push("No plugins are installed here.");
|
|
3184
|
+
else {
|
|
3185
|
+
const width = /* @__PURE__ */ __name((pick) => Math.max(...rows.map((row) => pick(row).length)), "width");
|
|
3186
|
+
const wId = width((r) => oneLine(r.id));
|
|
3187
|
+
const wVer = width((r) => oneLine(r.version ?? "-"));
|
|
3188
|
+
const wScope = width((r) => r.scope);
|
|
3189
|
+
for (const row of rows) {
|
|
3190
|
+
lines.push(
|
|
3191
|
+
`${oneLine(row.id).padEnd(wId)} ${oneLine(row.version ?? "-").padEnd(wVer)} ${row.scope.padEnd(wScope)} ${row.state}${row.attention > 0 ? ` (${row.attention} to look at)` : ""}`
|
|
3192
|
+
);
|
|
3193
|
+
if (row.problem) lines.push(` ${oneLine(row.problem)}`);
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
for (const ask of asked)
|
|
3197
|
+
lines.push(`${oneLine(ask.id)} is asked for here and is not installed on this computer.`);
|
|
3198
|
+
for (const market of declared)
|
|
3199
|
+
lines.push(
|
|
3200
|
+
`${oneLine(market.name)} is declared by this project, ${market.added ? "and added" : "not added"}.`
|
|
3201
|
+
);
|
|
3202
|
+
for (const problem of problems) lines.push(`Not used: ${oneLine(problem)}`);
|
|
3203
|
+
if (notice) lines.push(notice);
|
|
3204
|
+
if (!deps.loadingOn && rows.length > 0)
|
|
3205
|
+
lines.push(
|
|
3206
|
+
"Plugin loading is off, so none of these run. Turn it on: namzu config set plugins.enabled true"
|
|
3207
|
+
);
|
|
3208
|
+
deps.out(`${lines.join("\n")}
|
|
3209
|
+
`);
|
|
3210
|
+
return EXIT_OK;
|
|
3211
|
+
}
|
|
3212
|
+
__name(runList, "runList");
|
|
3213
|
+
function dataSize(path) {
|
|
3214
|
+
let total = 0;
|
|
3215
|
+
let seen = 0;
|
|
3216
|
+
const walk = /* @__PURE__ */ __name((dir) => {
|
|
3217
|
+
for (const entry of readdirSync5(dir)) {
|
|
3218
|
+
if (++seen > 2e4) return;
|
|
3219
|
+
const full = join9(dir, entry);
|
|
3220
|
+
const stat2 = lstatSync7(full);
|
|
3221
|
+
if (stat2.isDirectory()) walk(full);
|
|
3222
|
+
else total += stat2.size;
|
|
3223
|
+
}
|
|
3224
|
+
}, "walk");
|
|
3225
|
+
try {
|
|
3226
|
+
if (!lstatSync7(path).isDirectory()) return null;
|
|
3227
|
+
walk(path);
|
|
3228
|
+
return total;
|
|
3229
|
+
} catch {
|
|
3230
|
+
return null;
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
__name(dataSize, "dataSize");
|
|
3234
|
+
async function runDetails(deps, flags) {
|
|
3235
|
+
const command = "plugin details";
|
|
3236
|
+
if (flags.positional.length !== 1)
|
|
3237
|
+
return failure(deps, flags.json, command, EXIT_USAGE, "plugin details takes one plugin id.");
|
|
3238
|
+
const ctx = contextOf(deps, flags);
|
|
3239
|
+
const resolved = resolveId(deps, flags.json, command, flags.positional[0]);
|
|
3240
|
+
if (typeof resolved === "number") return resolved;
|
|
3241
|
+
const { id } = resolved;
|
|
3242
|
+
const found = applicable(resolved.records, ctx.cwd, ctx.trusted);
|
|
3243
|
+
if (found.here.length === 0)
|
|
3244
|
+
return failure(
|
|
3245
|
+
deps,
|
|
3246
|
+
flags.json,
|
|
3247
|
+
command,
|
|
3248
|
+
found.unread > 0 ? EXIT_UNTRUSTED : EXIT_NOINPUT,
|
|
3249
|
+
found.unread > 0 ? "This folder is not trusted yet. Open it with namzu once, or use --scope user." : `${id} is not installed for this folder or for you.`,
|
|
3250
|
+
{ id }
|
|
3251
|
+
);
|
|
3252
|
+
const record = found.here[0];
|
|
3253
|
+
const answer = currentEnabledAnswer(
|
|
3254
|
+
{ home: deps.namzuHome, cwd: ctx.cwd, projectTrusted: ctx.trusted },
|
|
3255
|
+
id
|
|
3256
|
+
);
|
|
3257
|
+
const verdict = verifyInstalledCopy(deps.namzuHome, id, record.installPath, record.surfaceSha256);
|
|
3258
|
+
const all = readInstalledPlugins(deps.namzuHome);
|
|
3259
|
+
const clash = verdict.ok && all.state !== "unreadable" ? (await nameClashes(deps, ctx, all.plugins)).get(id) : void 0;
|
|
3260
|
+
const blockedBy = verdict.ok ? clash : verdict.message;
|
|
3261
|
+
const manifestRead = readInstallManifest(deps.namzuHome, id);
|
|
3262
|
+
const { name, marketplace } = splitPluginId(id);
|
|
3263
|
+
const known = readKnownMarketplaces(deps.namzuHome);
|
|
3264
|
+
const source = known.state !== "unreadable" ? known.marketplaces.get(marketplace)?.source ?? null : null;
|
|
3265
|
+
const dataPath = installedPluginDataFolder(deps.namzuHome, id);
|
|
3266
|
+
let inventory;
|
|
3267
|
+
if (verdict.ok) {
|
|
3268
|
+
try {
|
|
3269
|
+
const candidate = candidateFor(id, record, answer);
|
|
3270
|
+
const manifest = await loadInstalledManifest(candidate, {
|
|
3271
|
+
home: deps.namzuHome,
|
|
3272
|
+
cwd: ctx.cwd,
|
|
3273
|
+
installedNames: /* @__PURE__ */ new Set()
|
|
3274
|
+
});
|
|
3275
|
+
const details = await readPluginManifestDetails(candidate.installPath, manifest);
|
|
3276
|
+
const prefix = `${manifest.name}__`;
|
|
3277
|
+
const files = /* @__PURE__ */ __name((declared) => resolvePluginFileDirs(
|
|
3278
|
+
manifest.name,
|
|
3279
|
+
candidate.installPath,
|
|
3280
|
+
declared,
|
|
3281
|
+
manifest.layout
|
|
3282
|
+
).dirs.flatMap(
|
|
3283
|
+
(source2) => listMarkdownNames(source2.dir, source2.only).map((file) => `${prefix}${file}`)
|
|
3284
|
+
), "files");
|
|
3285
|
+
const hookRead = readPluginHookEntriesOf({ rootDir: candidate.installPath, manifest });
|
|
3286
|
+
inventory = {
|
|
3287
|
+
description: manifest.description,
|
|
3288
|
+
hooks: Object.entries(hookRead.hooks).filter(([, entries]) => (entries?.length ?? 0) > 0).map(([event, entries]) => `${event} (${entries?.length ?? 0})`),
|
|
3289
|
+
skills: (details.skills ?? []).map((skill) => skill.name),
|
|
3290
|
+
commands: files(manifest.commands),
|
|
3291
|
+
agents: files(manifest.agents),
|
|
3292
|
+
servers: (manifest.mcpServers ?? []).map((server) => server.name),
|
|
3293
|
+
...details.author ? { author: details.author } : {}
|
|
3294
|
+
};
|
|
3295
|
+
} catch (error) {
|
|
3296
|
+
inventory = { error: error instanceof Error ? error.message : String(error) };
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
const surface = manifestRead.state === "ok" ? manifestRead.manifest.surface : null;
|
|
3300
|
+
const output = {
|
|
3301
|
+
command,
|
|
3302
|
+
id,
|
|
3303
|
+
name,
|
|
3304
|
+
marketplace,
|
|
3305
|
+
enabled: answer.on,
|
|
3306
|
+
enabledBy: answer.by ?? null,
|
|
3307
|
+
verification: verdict.ok ? clash !== void 0 ? { ok: false, code: "name-clash", message: clash } : { ok: true } : { ok: false, code: verdict.code, message: verdict.message },
|
|
3308
|
+
records: found.here.map((r) => ({
|
|
3309
|
+
scope: r.scope,
|
|
3310
|
+
...r.projectPath ? { projectPath: r.projectPath } : {},
|
|
3311
|
+
installPath: r.installPath,
|
|
3312
|
+
version: r.version ?? null,
|
|
3313
|
+
installedAt: r.installedAt ?? null,
|
|
3314
|
+
lastUpdated: r.lastUpdated ?? null,
|
|
3315
|
+
gitCommitSha: r.gitCommitSha ?? null,
|
|
3316
|
+
layout: r.layout ?? null,
|
|
3317
|
+
findings: r.findings
|
|
3318
|
+
})),
|
|
3319
|
+
origin: source ?? (manifestRead.state === "ok" ? manifestRead.manifest.installedFrom ?? null : null),
|
|
3320
|
+
surface,
|
|
3321
|
+
surfaceSha256: manifestRead.state === "ok" ? manifestRead.manifest.surfaceSha256 : null,
|
|
3322
|
+
executableFiles: manifestRead.state === "ok" ? manifestRead.manifest.executable : [],
|
|
3323
|
+
consent: manifestRead.state === "ok" ? manifestRead.manifest.consent ?? null : null,
|
|
3324
|
+
data: { path: dataPath, bytes: dataSize(dataPath) },
|
|
3325
|
+
inventory: inventory ?? null
|
|
3326
|
+
};
|
|
3327
|
+
if (flags.json) {
|
|
3328
|
+
deps.out(`${JSON.stringify(output)}
|
|
3329
|
+
`);
|
|
3330
|
+
return EXIT_OK;
|
|
3331
|
+
}
|
|
3332
|
+
const lines = [`${oneLine(id)}${record.version ? ` ${oneLine(record.version)}` : ""}`];
|
|
3333
|
+
const inv = inventory;
|
|
3334
|
+
if (inv?.description) lines.push(oneLine(inv.description));
|
|
3335
|
+
lines.push(
|
|
3336
|
+
` State: ${answer.on ? "on" : "off"} (${layerSentence(answer.by, answer.on)})`,
|
|
3337
|
+
` Scope: ${found.here.map((r) => r.scope).join(", ")}`,
|
|
3338
|
+
` Origin: ${source ? oneLine(JSON.stringify(source)) : `marketplace ${marketplace}`}`,
|
|
3339
|
+
` Folder: ${oneLine(record.installPath)}`,
|
|
3340
|
+
` Data: ${oneLine(dataPath)}${output.data.bytes === null ? " (none yet)" : ` (${output.data.bytes} bytes)`}`
|
|
3341
|
+
);
|
|
3342
|
+
if (blockedBy !== void 0) lines.push(` Blocked: ${oneLine(blockedBy)}`);
|
|
3343
|
+
const listed = /* @__PURE__ */ __name((label, items) => {
|
|
3344
|
+
if (Array.isArray(items) && items.length > 0)
|
|
3345
|
+
lines.push(` ${label}${items.map((item) => oneLine(String(item))).join(", ")}`);
|
|
3346
|
+
}, "listed");
|
|
3347
|
+
if (inventory) {
|
|
3348
|
+
listed("Skills: ", inventory.skills);
|
|
3349
|
+
listed("Commands: ", inventory.commands);
|
|
3350
|
+
listed("Agents: ", inventory.agents);
|
|
3351
|
+
listed("Hooks: ", inventory.hooks);
|
|
3352
|
+
listed("Servers: ", inventory.servers);
|
|
3353
|
+
}
|
|
3354
|
+
if (manifestRead.state === "ok") {
|
|
3355
|
+
lines.push(
|
|
3356
|
+
` Checked before it loads: ${manifestRead.manifest.executable.length} ${manifestRead.manifest.executable.length === 1 ? "file" : "files"}, surface sha256:${manifestRead.manifest.surfaceSha256.slice(0, 12)}`
|
|
3357
|
+
);
|
|
3358
|
+
const consent = manifestRead.manifest.consent;
|
|
3359
|
+
if (consent && typeof consent.at === "string")
|
|
3360
|
+
lines.push(
|
|
3361
|
+
` Accepted: ${oneLine(consent.at)}${typeof consent.by === "string" ? ` by ${oneLine(consent.by)}` : ""}`
|
|
3362
|
+
);
|
|
3363
|
+
}
|
|
3364
|
+
for (const finding of record.findings)
|
|
3365
|
+
if (finding.level === "notUsed" || finding.level === "refused")
|
|
3366
|
+
lines.push(
|
|
3367
|
+
` ${finding.level === "refused" ? "Refused" : "Not used"}: ${oneLine(finding.message)}`
|
|
3368
|
+
);
|
|
3369
|
+
deps.out(`${lines.join("\n")}
|
|
3370
|
+
`);
|
|
3371
|
+
return EXIT_OK;
|
|
3372
|
+
}
|
|
3373
|
+
__name(runDetails, "runDetails");
|
|
3374
|
+
async function runToggle(deps, flags, enable) {
|
|
3375
|
+
const command = enable ? "plugin enable" : "plugin disable";
|
|
3376
|
+
const verb = enable ? "on" : "off";
|
|
3377
|
+
if (flags.positional.length !== 1)
|
|
3378
|
+
return failure(deps, flags.json, command, EXIT_USAGE, `${command} takes one plugin id.`);
|
|
3379
|
+
const ctx = contextOf(deps, flags);
|
|
3380
|
+
const untrusted = "This folder is not trusted yet. Open it with namzu once, or use --scope user.";
|
|
3381
|
+
if (!ctx.trusted && (flags.scope === "project" || flags.scope === "local"))
|
|
3382
|
+
return failure(deps, flags.json, command, EXIT_UNTRUSTED, untrusted);
|
|
3383
|
+
const resolved = resolveId(deps, flags.json, command, flags.positional[0]);
|
|
3384
|
+
if (typeof resolved === "number") return resolved;
|
|
3385
|
+
const { id } = resolved;
|
|
3386
|
+
const found = applicable(resolved.records, ctx.cwd, ctx.trusted);
|
|
3387
|
+
const chosen = flags.scope ? found.here.find((r) => r.scope === flags.scope) : found.here[0];
|
|
3388
|
+
if (chosen === void 0) {
|
|
3389
|
+
if (!flags.scope && found.unread > 0)
|
|
3390
|
+
return failure(deps, flags.json, command, EXIT_UNTRUSTED, untrusted, { id });
|
|
3391
|
+
return failure(
|
|
3392
|
+
deps,
|
|
3393
|
+
flags.json,
|
|
3394
|
+
command,
|
|
3395
|
+
EXIT_NOINPUT,
|
|
3396
|
+
flags.scope ? `${id} is not installed at scope ${flags.scope} here.` : `${id} is not installed for this folder or for you.`,
|
|
3397
|
+
{ id }
|
|
3398
|
+
);
|
|
3399
|
+
}
|
|
3400
|
+
const layer = flags.scope ?? (chosen.scope === "user" ? "user" : "local");
|
|
3401
|
+
const path = recordLayerPath(layer, { home: deps.namzuHome, cwd: ctx.cwd });
|
|
3402
|
+
const own = readRecordLayer(path);
|
|
3403
|
+
if (own.state === "unreadable")
|
|
3404
|
+
return failure(
|
|
3405
|
+
deps,
|
|
3406
|
+
flags.json,
|
|
3407
|
+
command,
|
|
3408
|
+
EXIT_NOINPUT,
|
|
3409
|
+
`The plugin records in ${path} could not be read (${own.reason}), so nothing was changed.`,
|
|
3410
|
+
{ id }
|
|
3411
|
+
);
|
|
3412
|
+
let changed = false;
|
|
3413
|
+
if (own.enabledPlugins.get(id) !== enable) {
|
|
3414
|
+
try {
|
|
3415
|
+
setEnabledPlugin(path, deps.namzuHome, id, enable);
|
|
3416
|
+
changed = true;
|
|
3417
|
+
} catch (error) {
|
|
3418
|
+
const failed = stateFailure(error);
|
|
3419
|
+
return failure(deps, flags.json, command, failed.code, failed.message, { id });
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
const answer = currentEnabledAnswer(
|
|
3423
|
+
{ home: deps.namzuHome, cwd: ctx.cwd, projectTrusted: ctx.trusted },
|
|
3424
|
+
id
|
|
3425
|
+
);
|
|
3426
|
+
const notes = [];
|
|
3427
|
+
if (answer.on !== enable)
|
|
3428
|
+
notes.push(
|
|
3429
|
+
`It is still ${answer.on ? "on" : "off"} here: ${layerSentence(answer.by, answer.on)}.`
|
|
3430
|
+
);
|
|
3431
|
+
if (enable) {
|
|
3432
|
+
const verdict = verifyInstalledCopy(
|
|
3433
|
+
deps.namzuHome,
|
|
3434
|
+
id,
|
|
3435
|
+
chosen.installPath,
|
|
3436
|
+
chosen.surfaceSha256
|
|
3437
|
+
);
|
|
3438
|
+
const all = readInstalledPlugins(deps.namzuHome);
|
|
3439
|
+
const blocked = !verdict.ok ? verdict.message : all.state !== "unreadable" ? (await nameClashes(deps, ctx, all.plugins)).get(id) : void 0;
|
|
3440
|
+
if (blocked !== void 0) notes.push(`It is still blocked and will not load: ${blocked}`);
|
|
3441
|
+
}
|
|
3442
|
+
if (enable && !deps.loadingOn)
|
|
3443
|
+
notes.push(
|
|
3444
|
+
"Plugin loading is off, so it will not run until you run: namzu config set plugins.enabled true"
|
|
3445
|
+
);
|
|
3446
|
+
const message = changed ? `Turned ${verb} ${id} (scope: ${layer}). It takes effect in new conversations.` : `${id} is already ${verb} at scope ${layer}.`;
|
|
3447
|
+
if (flags.json)
|
|
3448
|
+
deps.out(
|
|
3449
|
+
`${JSON.stringify({
|
|
3450
|
+
command,
|
|
3451
|
+
outcome: changed ? enable ? "enabled" : "disabled" : "unchanged",
|
|
3452
|
+
id,
|
|
3453
|
+
scope: layer,
|
|
3454
|
+
message,
|
|
3455
|
+
effective: { enabled: answer.on, by: answer.by ?? null },
|
|
3456
|
+
loading: deps.loadingOn ? "on" : "off",
|
|
3457
|
+
...notes.length > 0 ? { notes } : {}
|
|
3458
|
+
})}
|
|
3459
|
+
`
|
|
3460
|
+
);
|
|
3461
|
+
else deps.out(`${[message, ...notes].join("\n")}
|
|
3462
|
+
`);
|
|
3463
|
+
return EXIT_OK;
|
|
3464
|
+
}
|
|
3465
|
+
__name(runToggle, "runToggle");
|
|
3466
|
+
async function runPluginRecords(verb, args, deps) {
|
|
3467
|
+
const flags = parseFlags(args);
|
|
3468
|
+
if (flags.error) return failure(deps, flags.json, `plugin ${verb}`, EXIT_USAGE, flags.error);
|
|
3469
|
+
switch (verb) {
|
|
3470
|
+
case "list":
|
|
3471
|
+
return runList(deps, flags);
|
|
3472
|
+
case "details":
|
|
3473
|
+
return runDetails(deps, flags);
|
|
3474
|
+
case "enable":
|
|
3475
|
+
return runToggle(deps, flags, true);
|
|
3476
|
+
case "disable":
|
|
3477
|
+
return runToggle(deps, flags, false);
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
__name(runPluginRecords, "runPluginRecords");
|
|
3481
|
+
|
|
3482
|
+
// src/integrations/plugins/install-preview.ts
|
|
3483
|
+
var one = /* @__PURE__ */ __name((value) => terminalDisplayText(value).replace(/[\t\n\r]+/g, " "), "one");
|
|
3484
|
+
var SCRIPTS_SHOWN = 12;
|
|
3485
|
+
function list(items) {
|
|
3486
|
+
return items.map(one).join(", ");
|
|
3487
|
+
}
|
|
3488
|
+
__name(list, "list");
|
|
3489
|
+
function bytes(count) {
|
|
3490
|
+
return count < 1024 ? `${count} B` : `${(count / 1024).toFixed(1)} KB`;
|
|
3491
|
+
}
|
|
3492
|
+
__name(bytes, "bytes");
|
|
3493
|
+
function runsLines(surface) {
|
|
3494
|
+
const lines = [];
|
|
3495
|
+
for (const hook2 of surface.hooks)
|
|
3496
|
+
lines.push(
|
|
3497
|
+
` hook ${one(hook2.event)}${hook2.matcher !== void 0 ? ` ${one(hook2.matcher)}` : ""} -> ${hook2.type === "command" ? "" : `${hook2.type}: `}${one(hook2.run)}`
|
|
3498
|
+
);
|
|
3499
|
+
for (const hook2 of surface.fileHooks)
|
|
3500
|
+
lines.push(
|
|
3501
|
+
` hook ${one(hook2.event)} in ${hook2.kind} ${one(hook2.name)} -> ${hook2.type === "command" ? "" : `${hook2.type}: `}${one(hook2.run)}`
|
|
3502
|
+
);
|
|
3503
|
+
for (const server of surface.mcpLocal)
|
|
3504
|
+
lines.push(
|
|
3505
|
+
` server ${one(server.name)} -> ${one([server.command, ...server.args].join(" "))}${Object.keys(server.env).length > 0 ? ` (environment: ${list(Object.keys(server.env))})` : ""}${server.needsSetup === true ? " (needs setup: not started until its variables are set)" : ""}`
|
|
3506
|
+
);
|
|
3507
|
+
for (const server of surface.mcpRemote)
|
|
3508
|
+
lines.push(
|
|
3509
|
+
` server ${one(server.name)} -> ${one(server.origin)} (asks you before it connects${server.sendsEnv.length > 0 ? `; would send ${server.sendsEnv.map((name) => `$${one(name)}`).join(", ")}` : ""}${server.headers.length > 0 ? `; headers: ${list(server.headers)}` : ""}${server.needsSetup === true ? "; needs setup" : ""})`
|
|
3510
|
+
);
|
|
3511
|
+
for (const module of surface.modules)
|
|
3512
|
+
lines.push(
|
|
3513
|
+
module.refused !== void 0 ? ` module ${one(module.path)} (not run: ${one(module.refused)})` : module.isolated === true ? ` module ${one(module.path)} (runs in an isolated worker${module.declares !== void 0 && module.declares.length > 0 ? `; ${list(module.declares)}` : ""})` : ` module ${one(module.path)} (JavaScript that runs inside the session; what it declares is not read before it runs)`
|
|
3514
|
+
);
|
|
3515
|
+
for (const script of surface.scripts.slice(0, SCRIPTS_SHOWN))
|
|
3516
|
+
lines.push(
|
|
3517
|
+
` script ${one(script.path)} (${bytes(script.bytes)}${script.exec ? ", executable" : ""})`
|
|
3518
|
+
);
|
|
3519
|
+
if (surface.scripts.length > SCRIPTS_SHOWN)
|
|
3520
|
+
lines.push(
|
|
3521
|
+
` script and ${surface.scripts.length - SCRIPTS_SHOWN} more (all of them in --json)`
|
|
3522
|
+
);
|
|
3523
|
+
return lines;
|
|
3524
|
+
}
|
|
3525
|
+
__name(runsLines, "runsLines");
|
|
3526
|
+
function renderInstallPreview(plan, options) {
|
|
3527
|
+
const lines = [
|
|
3528
|
+
options.headline ?? `Install ${one(plan.name)} ${one(plan.version)} from ${one(plan.marketplace)}${plan.commit !== void 0 ? ` (commit ${plan.commit.slice(0, 7)})` : ""}? ${options.scopeLine}`,
|
|
3529
|
+
""
|
|
3530
|
+
];
|
|
3531
|
+
if (options.changes !== void 0 && options.changes.length > 0) {
|
|
3532
|
+
lines.push(" What changed since the version you have:");
|
|
3533
|
+
for (const change of options.changes) lines.push(` ${one(change)}`);
|
|
3534
|
+
lines.push("");
|
|
3535
|
+
}
|
|
3536
|
+
const { inventory, surface } = plan;
|
|
3537
|
+
if (inventory.skills.length > 0)
|
|
3538
|
+
lines.push(` Skills (${inventory.skills.length}): ${list(inventory.skills)}`);
|
|
3539
|
+
if (inventory.commands.length > 0)
|
|
3540
|
+
lines.push(
|
|
3541
|
+
` Commands (${inventory.commands.length}): ${inventory.commands.map((name) => `/${one(name)}`).join(", ")}`
|
|
3542
|
+
);
|
|
3543
|
+
if (inventory.agents.length > 0)
|
|
3544
|
+
lines.push(` Agents (${inventory.agents.length}): ${list(inventory.agents)}`);
|
|
3545
|
+
const runs = runsLines(surface);
|
|
3546
|
+
lines.push(
|
|
3547
|
+
runs.length > 0 ? " Runs on this computer:" : " Runs on this computer: nothing found."
|
|
3548
|
+
);
|
|
3549
|
+
lines.push(...runs);
|
|
3550
|
+
if (surface.unpinnedDownload) lines.push(" This download is not pinned to a digest.");
|
|
3551
|
+
for (const tools of surface.allowedTools)
|
|
3552
|
+
lines.push(` Pre-approves tools: ${tools.kind} ${one(tools.name)} allows ${list(tools.tools)}`);
|
|
3553
|
+
const listedElsewhere = /* @__PURE__ */ new Set(["mcp-server-remote", "mcp-needs-setup"]);
|
|
3554
|
+
const notUsed = plan.findings.filter((f) => f.level === "notUsed" && !listedElsewhere.has(f.code));
|
|
3555
|
+
if (notUsed.length > 0)
|
|
3556
|
+
lines.push(
|
|
3557
|
+
` Not used by Namzu: ${[...new Set(notUsed.map((f) => f.field ?? f.code))].map(one).join(", ")}`
|
|
3558
|
+
);
|
|
3559
|
+
for (const finding of plan.findings.filter((f) => f.level === "refused"))
|
|
3560
|
+
lines.push(` Left out: ${one(finding.message)}`);
|
|
3561
|
+
for (const warning of plan.warnings) lines.push(` Note: ${one(warning)}`);
|
|
3562
|
+
lines.push(
|
|
3563
|
+
"",
|
|
3564
|
+
"This plugin runs programs on your computer with your permissions. Namzu cannot",
|
|
3565
|
+
"check what they do. Install only plugins you trust.",
|
|
3566
|
+
`Surface: sha256:${plan.digest}`
|
|
3567
|
+
);
|
|
3568
|
+
return lines.join("\n");
|
|
3569
|
+
}
|
|
3570
|
+
__name(renderInstallPreview, "renderInstallPreview");
|
|
3571
|
+
|
|
3572
|
+
// src/integrations/plugins/update-compare.ts
|
|
3573
|
+
function compareUpdate(recorded, plan) {
|
|
3574
|
+
const before = recorded.surface;
|
|
3575
|
+
const changes = surfaceChanges(before, plan.surface);
|
|
3576
|
+
const nothingRunsDifferently = JSON.stringify(before) === JSON.stringify(plan.surface) && [.../* @__PURE__ */ new Set([...Object.keys(plan.files), ...Object.keys(recorded.files)])].filter((path) => plan.files[path] !== recorded.files[path]).every((path) => {
|
|
3577
|
+
const base = path.split("/").pop() ?? path;
|
|
3578
|
+
if (base === "plugin.json") return true;
|
|
3579
|
+
return !isExecutablePath(path, 0) && !plan.surface.scripts.some((script) => script.path === path);
|
|
3580
|
+
});
|
|
3581
|
+
return {
|
|
3582
|
+
changes,
|
|
3583
|
+
unchangedSurface: recorded.surfaceSha256 === plan.digest || nothingRunsDifferently
|
|
3584
|
+
};
|
|
3585
|
+
}
|
|
3586
|
+
__name(compareUpdate, "compareUpdate");
|
|
3587
|
+
|
|
3588
|
+
export {
|
|
3589
|
+
readPluginManifestDetails,
|
|
3590
|
+
refProblem,
|
|
3591
|
+
repoPathProblem,
|
|
3592
|
+
describeSource,
|
|
3593
|
+
isBlockedSource,
|
|
3594
|
+
FetchError,
|
|
3595
|
+
fetchMarketplace,
|
|
3596
|
+
LOCAL_UPLOADS_MARKETPLACE,
|
|
3597
|
+
MAX_CATALOG_PLUGINS,
|
|
3598
|
+
marketplaceNameProblem,
|
|
3599
|
+
readCatalog,
|
|
3600
|
+
resolveEntrySource,
|
|
3601
|
+
parseMarketplaceAddress,
|
|
3602
|
+
realPathOf,
|
|
3603
|
+
hashExecutableFiles,
|
|
3604
|
+
PlanRefusal,
|
|
3605
|
+
discardStaging,
|
|
3606
|
+
usedPluginNames,
|
|
3607
|
+
planInstall,
|
|
3608
|
+
renderInstallPreview,
|
|
3609
|
+
SimulatedCrash,
|
|
3610
|
+
InstallConflict,
|
|
3611
|
+
trashFolder,
|
|
3612
|
+
commitInstall,
|
|
3613
|
+
commitUpdate,
|
|
3614
|
+
removeInstall,
|
|
3615
|
+
prune,
|
|
3616
|
+
oneLine,
|
|
3617
|
+
MARKETPLACE_NOTICE,
|
|
3618
|
+
MARKETPLACE_BLOCKED,
|
|
3619
|
+
DOWNLOAD_BLOCKED,
|
|
3620
|
+
sameVersionChanged,
|
|
3621
|
+
describeAddition,
|
|
3622
|
+
sameSource,
|
|
3623
|
+
anotherPlace,
|
|
3624
|
+
marketplaceConsentText,
|
|
3625
|
+
countNotInstallable,
|
|
3626
|
+
downloadBlocked,
|
|
3627
|
+
readFetchedCatalog,
|
|
3628
|
+
fetchNotes,
|
|
3629
|
+
placeMarketplace,
|
|
3630
|
+
newStaging,
|
|
3631
|
+
lstatExists,
|
|
3632
|
+
newerVersions,
|
|
3633
|
+
isInside,
|
|
3634
|
+
refreshRemoteMarketplace,
|
|
3635
|
+
compareUpdate,
|
|
3636
|
+
PLUGIN_RECORD_VERBS,
|
|
3637
|
+
PLUGIN_RECORD_HELP,
|
|
3638
|
+
failure,
|
|
3639
|
+
stateFailure,
|
|
3640
|
+
resolveId,
|
|
3641
|
+
applicable,
|
|
3642
|
+
runPluginRecords
|
|
3643
|
+
};
|
|
3644
|
+
//# sourceMappingURL=chunk-BJT37HR4.js.map
|