tenjin-cli 0.1.0-alpha.31 → 0.1.0-alpha.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/README.md +5 -5
  2. package/dist/{_esm-MEXZI5DL.js → _esm-RLLC72MS.js} +128 -132
  3. package/dist/{alive-J64H46HI.js → alive-MROUMFH3.js} +13 -6
  4. package/dist/auto-update-OPWMRZLS.js +22 -0
  5. package/dist/{ccip-7RMRLAGV.js → ccip-DHDFKTQV.js} +2 -2
  6. package/dist/chunk-2GNOFONN.js +560 -0
  7. package/dist/chunk-2GNOFONN.js.map +1 -0
  8. package/dist/{chunk-TTNESUPQ.js → chunk-2GP3HRYK.js} +2120 -193
  9. package/dist/chunk-2GP3HRYK.js.map +1 -0
  10. package/dist/chunk-3AIHRXKO.js +72 -0
  11. package/dist/chunk-3AIHRXKO.js.map +1 -0
  12. package/dist/{chunk-LEFIX6RS.js → chunk-3DIL66VX.js} +31 -11
  13. package/dist/chunk-3DIL66VX.js.map +1 -0
  14. package/dist/{chunk-S4SAZ7OD.js → chunk-3FMZGI7I.js} +12 -2
  15. package/dist/{chunk-S4SAZ7OD.js.map → chunk-3FMZGI7I.js.map} +1 -1
  16. package/dist/{chunk-7Q5FDF65.js → chunk-445VQTVM.js} +3 -3
  17. package/dist/{chunk-A36LQPHV.js → chunk-4LMUQMBH.js} +1 -1
  18. package/dist/{chunk-A36LQPHV.js.map → chunk-4LMUQMBH.js.map} +1 -1
  19. package/dist/{chunk-KXQ4UIP7.js → chunk-4USCZ2NI.js} +2 -2
  20. package/dist/chunk-62KNUYWD.js +111 -0
  21. package/dist/chunk-62KNUYWD.js.map +1 -0
  22. package/dist/{chunk-POUWHWID.js → chunk-6CMM6YCB.js} +3 -3
  23. package/dist/{chunk-POUWHWID.js.map → chunk-6CMM6YCB.js.map} +1 -1
  24. package/dist/{chunk-5MARFNSB.js → chunk-AD226HDR.js} +49 -30
  25. package/dist/chunk-AD226HDR.js.map +1 -0
  26. package/dist/chunk-ADV4LDTB.js +106 -0
  27. package/dist/chunk-ADV4LDTB.js.map +1 -0
  28. package/dist/{chunk-7WU4OPLP.js → chunk-AV5NZMYO.js} +5 -3
  29. package/dist/{chunk-7WU4OPLP.js.map → chunk-AV5NZMYO.js.map} +1 -1
  30. package/dist/chunk-B7EM4GGF.js +198 -0
  31. package/dist/chunk-B7EM4GGF.js.map +1 -0
  32. package/dist/chunk-BFDQ4WNW.js +119 -0
  33. package/dist/chunk-BFDQ4WNW.js.map +1 -0
  34. package/dist/{chunk-2XLC3AEX.js → chunk-BI673VEJ.js} +536 -510
  35. package/dist/chunk-BI673VEJ.js.map +1 -0
  36. package/dist/chunk-CEXSOI5R.js +808 -0
  37. package/dist/chunk-CEXSOI5R.js.map +1 -0
  38. package/dist/{chunk-FW75G2W4.js → chunk-CISYM4EO.js} +5 -5
  39. package/dist/{chunk-B7HUUJOK.js → chunk-D3ZURCG7.js} +3 -3
  40. package/dist/chunk-D5TOQSO4.js +474 -0
  41. package/dist/chunk-D5TOQSO4.js.map +1 -0
  42. package/dist/{chunk-UQUOVWBG.js → chunk-DRDUIZIA.js} +7 -7
  43. package/dist/{chunk-27EPWVOY.js → chunk-DW4YTVR3.js} +2 -2
  44. package/dist/chunk-E7LGOMH6.js +449 -0
  45. package/dist/chunk-E7LGOMH6.js.map +1 -0
  46. package/dist/{chunk-QSCPK4F5.js → chunk-E7SW44LM.js} +4 -11
  47. package/dist/chunk-E7SW44LM.js.map +1 -0
  48. package/dist/chunk-EDJWHDDL.js +33 -0
  49. package/dist/chunk-EDJWHDDL.js.map +1 -0
  50. package/dist/chunk-F3ED5WTR.js +13 -0
  51. package/dist/chunk-F3ED5WTR.js.map +1 -0
  52. package/dist/chunk-G75OPGAK.js +111 -0
  53. package/dist/chunk-G75OPGAK.js.map +1 -0
  54. package/dist/{chunk-R5LCN54M.js → chunk-GAKUQHKA.js} +13 -17
  55. package/dist/{chunk-R5LCN54M.js.map → chunk-GAKUQHKA.js.map} +1 -1
  56. package/dist/{chunk-4ZZO6ULA.js → chunk-HDPUXS3Z.js} +19 -48
  57. package/dist/chunk-HDPUXS3Z.js.map +1 -0
  58. package/dist/{chunk-ORWL5BSN.js → chunk-HGZEPQUT.js} +2 -2
  59. package/dist/{chunk-6E5R45ZO.js → chunk-HREHWL32.js} +4 -4
  60. package/dist/{chunk-6E5R45ZO.js.map → chunk-HREHWL32.js.map} +1 -1
  61. package/dist/{chunk-KXVP2VKA.js → chunk-I5TDIUKM.js} +15 -34
  62. package/dist/chunk-I5TDIUKM.js.map +1 -0
  63. package/dist/{chunk-7QKHZQKW.js → chunk-IADZOXKN.js} +39 -6
  64. package/dist/chunk-IADZOXKN.js.map +1 -0
  65. package/dist/{chunk-P4NH7OUK.js → chunk-IDTRSAHE.js} +2 -2
  66. package/dist/{chunk-YFPY4ONH.js → chunk-JEVQ5LKO.js} +4 -4
  67. package/dist/chunk-JNJWBTU2.js +3497 -0
  68. package/dist/chunk-JNJWBTU2.js.map +1 -0
  69. package/dist/{chunk-MNXS2U45.js → chunk-JRZBBPO6.js} +167 -86
  70. package/dist/chunk-JRZBBPO6.js.map +1 -0
  71. package/dist/{chunk-WJXLQXJY.js → chunk-MPZUYCAP.js} +4 -1
  72. package/dist/{chunk-WJXLQXJY.js.map → chunk-MPZUYCAP.js.map} +1 -1
  73. package/dist/{chunk-SJLTEINJ.js → chunk-OJNTCYQQ.js} +17 -1
  74. package/dist/chunk-OJNTCYQQ.js.map +1 -0
  75. package/dist/{chunk-AGZ7PJKY.js → chunk-OTWLERSW.js} +22 -5
  76. package/dist/chunk-OTWLERSW.js.map +1 -0
  77. package/dist/{chunk-NEFNKLBE.js → chunk-PJNENX2A.js} +1535 -422
  78. package/dist/chunk-PJNENX2A.js.map +1 -0
  79. package/dist/{chunk-UKY4CHNC.js → chunk-PKHI276N.js} +8 -4
  80. package/dist/chunk-PKHI276N.js.map +1 -0
  81. package/dist/{chunk-5K5W4S66.js → chunk-QF3LSMGS.js} +2 -2
  82. package/dist/{chunk-XZKD7DIF.js → chunk-RL5UUDT4.js} +3 -3
  83. package/dist/{chunk-XZKD7DIF.js.map → chunk-RL5UUDT4.js.map} +1 -1
  84. package/dist/{chunk-OHRR5OYM.js → chunk-SFASB5FL.js} +10 -4
  85. package/dist/chunk-SFASB5FL.js.map +1 -0
  86. package/dist/{chunk-YVFXE7RR.js → chunk-SNNSAGMT.js} +7279 -2627
  87. package/dist/chunk-SNNSAGMT.js.map +1 -0
  88. package/dist/{chunk-WK7F3B2E.js → chunk-SO3XRZPX.js} +3 -3
  89. package/dist/chunk-SYOS5CAC.js +176 -0
  90. package/dist/chunk-SYOS5CAC.js.map +1 -0
  91. package/dist/chunk-TAW4UFFF.js +293 -0
  92. package/dist/chunk-TAW4UFFF.js.map +1 -0
  93. package/dist/{hosts-FWZOV26H.js → chunk-TF5HCP33.js} +79 -24
  94. package/dist/chunk-TF5HCP33.js.map +1 -0
  95. package/dist/{chunk-AKWGE6JQ.js → chunk-UUGOUOVT.js} +37 -2
  96. package/dist/chunk-UUGOUOVT.js.map +1 -0
  97. package/dist/{chunk-7ZRL2LBQ.js → chunk-V2LQLN5H.js} +6 -6
  98. package/dist/{chunk-K72RURN3.js → chunk-VJUVFZ2D.js} +2 -2
  99. package/dist/{chunk-77TCKDEC.js → chunk-VOZA6O7K.js} +663 -477
  100. package/dist/chunk-VOZA6O7K.js.map +1 -0
  101. package/dist/{chunk-D65GNPS3.js → chunk-VUGQTZ2L.js} +208 -84
  102. package/dist/chunk-VUGQTZ2L.js.map +1 -0
  103. package/dist/chunk-WOM257PW.js +393 -0
  104. package/dist/chunk-WOM257PW.js.map +1 -0
  105. package/dist/chunk-WYXUQGOL.js +191 -0
  106. package/dist/chunk-WYXUQGOL.js.map +1 -0
  107. package/dist/chunk-X5ZBP3IY.js +97 -0
  108. package/dist/chunk-X5ZBP3IY.js.map +1 -0
  109. package/dist/{chunk-5C32RLTA.js → chunk-YUY4SAGM.js} +17 -2
  110. package/dist/chunk-YUY4SAGM.js.map +1 -0
  111. package/dist/{cli-D5OE3URZ.js → cli-FB4LOA5A.js} +144 -63
  112. package/dist/{cli-D5OE3URZ.js.map → cli-FB4LOA5A.js.map} +1 -1
  113. package/dist/{codex-event-PPNVRRDH.js → codex-event-TYVES3UX.js} +2 -2
  114. package/dist/{codex-host-2RJOJW2B.js → codex-host-WW4H2SKT.js} +7 -6
  115. package/dist/codex-install-2C623HPW.js +393 -0
  116. package/dist/codex-install-2C623HPW.js.map +1 -0
  117. package/dist/{config-ZD4OB2DO.js → config-HOVJFEKD.js} +21 -17
  118. package/dist/doctor-NKU4V5OV.js +1312 -0
  119. package/dist/doctor-NKU4V5OV.js.map +1 -0
  120. package/dist/{env-proxy-XL4P73MZ.js → env-proxy-R6ZMLQTT.js} +6 -2
  121. package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js → ethersCompat-Df4a6QIZ-X6YZWAML.js} +3 -3
  122. package/dist/{fund-5ITKQGYF.js → fund-WEBHTZGN.js} +37 -36
  123. package/dist/{fund-5ITKQGYF.js.map → fund-WEBHTZGN.js.map} +1 -1
  124. package/dist/hook-command-ZA2PNKS6.js +44 -0
  125. package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
  126. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
  127. package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +82 -0
  128. package/dist/hosts/codex/tenjin/.mcp.json +3 -0
  129. package/dist/hosts/codex/tenjin/hooks/hooks.json +51 -5
  130. package/dist/hosts-AV5MHBAU.js +38 -0
  131. package/dist/index.js +28 -8
  132. package/dist/index.js.map +1 -1
  133. package/dist/{install-XWGE4Q7L.js → install-PT4EZS4R.js} +53 -30
  134. package/dist/{install-identity-K7EJIQFP.js → install-identity-5A4OE6YC.js} +11 -10
  135. package/dist/install-wallet-SAAPKB73.js +281 -0
  136. package/dist/install-wallet-SAAPKB73.js.map +1 -0
  137. package/dist/{mcp-3LIJSSJB.js → mcp-HAWKCTPQ.js} +785 -210
  138. package/dist/mcp-HAWKCTPQ.js.map +1 -0
  139. package/dist/{mine.wasm-6PIT3DK6.js → mine.wasm-QFAHIFPY.js} +2 -2
  140. package/dist/{mine.wasm-6PIT3DK6.js.map → mine.wasm-QFAHIFPY.js.map} +1 -1
  141. package/dist/{package-ZKQFDWLE.js → package-SR2WB6MK.js} +4 -2
  142. package/dist/passphrase-IFTDS3CU.js +44 -0
  143. package/dist/{paths-POPTXJO6.js → paths-XCSAKISU.js} +10 -2
  144. package/dist/{pay-WHBERZ3W.js → pay-OXC3WKYV.js} +29 -29
  145. package/dist/{payments-KVICEKD2.js → payments-3KHMP2MG.js} +15 -14
  146. package/dist/{payments-KVICEKD2.js.map → payments-3KHMP2MG.js.map} +1 -1
  147. package/dist/plugin-registration-N3GRIZVM.js +67 -0
  148. package/dist/{redact-6W23GGJC.js → redact-D7ASVWKL.js} +2 -2
  149. package/dist/runtime-UVNUA3AS.js +1203 -0
  150. package/dist/runtime-UVNUA3AS.js.map +1 -0
  151. package/dist/runtime-fetch-EKFRNR6Z.js +20 -0
  152. package/dist/runtime-layout-BDWZG2TQ.js +25 -0
  153. package/dist/{send-7G7Y7DLN.js → send-HMKJLT34.js} +24 -22
  154. package/dist/{send-7G7Y7DLN.js.map → send-HMKJLT34.js.map} +1 -1
  155. package/dist/{status-OF7RH5HM.js → status-RWXIIWYS.js} +55 -25
  156. package/dist/status-RWXIIWYS.js.map +1 -0
  157. package/dist/{status-line-XOUE6MPL.js → status-line-77XYZP7E.js} +10 -9
  158. package/dist/{status-line-XOUE6MPL.js.map → status-line-77XYZP7E.js.map} +1 -1
  159. package/dist/uninstall-D5G67UJH.js +480 -0
  160. package/dist/uninstall-D5G67UJH.js.map +1 -0
  161. package/dist/update-LRNOEGSB.js +53 -0
  162. package/dist/update-LRNOEGSB.js.map +1 -0
  163. package/dist/{usdc-OGOGEHV2.js → usdc-D6X7EIQ2.js} +6 -8
  164. package/dist/usdc-D6X7EIQ2.js.map +1 -0
  165. package/dist/{viemAdapter-By13KInL-S3DA7DFW.js → viemAdapter-By13KInL-RL742ETX.js} +3 -3
  166. package/dist/viemAdapter-By13KInL-RL742ETX.js.map +1 -0
  167. package/dist/wallet-XFYC27BR.js +55 -0
  168. package/dist/wallet-XFYC27BR.js.map +1 -0
  169. package/dist/wallet-kdf-worker.mjs +8 -8
  170. package/docs/agent-permissions.md +40 -22
  171. package/docs/safety-model.md +1 -1
  172. package/docs/troubleshooting.md +72 -1
  173. package/package.json +14 -1
  174. package/dist/ccip-NLCSCHKI.js +0 -19
  175. package/dist/chunk-2XLC3AEX.js.map +0 -1
  176. package/dist/chunk-4ZZO6ULA.js.map +0 -1
  177. package/dist/chunk-5C32RLTA.js.map +0 -1
  178. package/dist/chunk-5IEP5EGE.js +0 -5332
  179. package/dist/chunk-5IEP5EGE.js.map +0 -1
  180. package/dist/chunk-5MARFNSB.js.map +0 -1
  181. package/dist/chunk-77TCKDEC.js.map +0 -1
  182. package/dist/chunk-7EKYXMUO.js +0 -7536
  183. package/dist/chunk-7EKYXMUO.js.map +0 -1
  184. package/dist/chunk-7QKHZQKW.js.map +0 -1
  185. package/dist/chunk-AGZ7PJKY.js.map +0 -1
  186. package/dist/chunk-AKWGE6JQ.js.map +0 -1
  187. package/dist/chunk-BL3332HQ.js +0 -7611
  188. package/dist/chunk-BL3332HQ.js.map +0 -1
  189. package/dist/chunk-D65GNPS3.js.map +0 -1
  190. package/dist/chunk-EGELTSPU.js +0 -2865
  191. package/dist/chunk-EGELTSPU.js.map +0 -1
  192. package/dist/chunk-GA7JETVM.js +0 -150
  193. package/dist/chunk-GA7JETVM.js.map +0 -1
  194. package/dist/chunk-I3EQFHCD.js +0 -175
  195. package/dist/chunk-I3EQFHCD.js.map +0 -1
  196. package/dist/chunk-K3I7C2MO.js +0 -1185
  197. package/dist/chunk-K3I7C2MO.js.map +0 -1
  198. package/dist/chunk-KXVP2VKA.js.map +0 -1
  199. package/dist/chunk-LEFIX6RS.js.map +0 -1
  200. package/dist/chunk-MNXS2U45.js.map +0 -1
  201. package/dist/chunk-NEFNKLBE.js.map +0 -1
  202. package/dist/chunk-OHRR5OYM.js.map +0 -1
  203. package/dist/chunk-QSCPK4F5.js.map +0 -1
  204. package/dist/chunk-SJLTEINJ.js.map +0 -1
  205. package/dist/chunk-TTNESUPQ.js.map +0 -1
  206. package/dist/chunk-UKY4CHNC.js.map +0 -1
  207. package/dist/chunk-V6BSF6OC.js +0 -260
  208. package/dist/chunk-V6BSF6OC.js.map +0 -1
  209. package/dist/chunk-YVFXE7RR.js.map +0 -1
  210. package/dist/codex-install-UUZ6QMBQ.js +0 -221
  211. package/dist/codex-install-UUZ6QMBQ.js.map +0 -1
  212. package/dist/doctor-KBR34Q4B.js +0 -601
  213. package/dist/doctor-KBR34Q4B.js.map +0 -1
  214. package/dist/hook-command-4TYCHHRL.js +0 -39
  215. package/dist/hosts-FWZOV26H.js.map +0 -1
  216. package/dist/install-wallet-XQ6XFZV4.js +0 -117
  217. package/dist/install-wallet-XQ6XFZV4.js.map +0 -1
  218. package/dist/mcp-3LIJSSJB.js.map +0 -1
  219. package/dist/plugin-registration-5TIA564H.js +0 -54
  220. package/dist/status-OF7RH5HM.js.map +0 -1
  221. package/dist/uninstall-JXUAFNDB.js +0 -158
  222. package/dist/uninstall-JXUAFNDB.js.map +0 -1
  223. package/dist/update-ZKUERSO2.js +0 -44
  224. package/dist/wallet-2HA6W4R4.js +0 -43
  225. /package/dist/{_esm-MEXZI5DL.js.map → _esm-RLLC72MS.js.map} +0 -0
  226. /package/dist/{alive-J64H46HI.js.map → alive-MROUMFH3.js.map} +0 -0
  227. /package/dist/{ccip-7RMRLAGV.js.map → auto-update-OPWMRZLS.js.map} +0 -0
  228. /package/dist/{ccip-NLCSCHKI.js.map → ccip-DHDFKTQV.js.map} +0 -0
  229. /package/dist/{chunk-7Q5FDF65.js.map → chunk-445VQTVM.js.map} +0 -0
  230. /package/dist/{chunk-KXQ4UIP7.js.map → chunk-4USCZ2NI.js.map} +0 -0
  231. /package/dist/{chunk-FW75G2W4.js.map → chunk-CISYM4EO.js.map} +0 -0
  232. /package/dist/{chunk-B7HUUJOK.js.map → chunk-D3ZURCG7.js.map} +0 -0
  233. /package/dist/{chunk-UQUOVWBG.js.map → chunk-DRDUIZIA.js.map} +0 -0
  234. /package/dist/{chunk-27EPWVOY.js.map → chunk-DW4YTVR3.js.map} +0 -0
  235. /package/dist/{chunk-ORWL5BSN.js.map → chunk-HGZEPQUT.js.map} +0 -0
  236. /package/dist/{chunk-P4NH7OUK.js.map → chunk-IDTRSAHE.js.map} +0 -0
  237. /package/dist/{chunk-YFPY4ONH.js.map → chunk-JEVQ5LKO.js.map} +0 -0
  238. /package/dist/{chunk-5K5W4S66.js.map → chunk-QF3LSMGS.js.map} +0 -0
  239. /package/dist/{chunk-WK7F3B2E.js.map → chunk-SO3XRZPX.js.map} +0 -0
  240. /package/dist/{chunk-7ZRL2LBQ.js.map → chunk-V2LQLN5H.js.map} +0 -0
  241. /package/dist/{chunk-K72RURN3.js.map → chunk-VJUVFZ2D.js.map} +0 -0
  242. /package/dist/{codex-event-PPNVRRDH.js.map → codex-event-TYVES3UX.js.map} +0 -0
  243. /package/dist/{codex-host-2RJOJW2B.js.map → codex-host-WW4H2SKT.js.map} +0 -0
  244. /package/dist/{config-ZD4OB2DO.js.map → config-HOVJFEKD.js.map} +0 -0
  245. /package/dist/{env-proxy-XL4P73MZ.js.map → env-proxy-R6ZMLQTT.js.map} +0 -0
  246. /package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js.map → ethersCompat-Df4a6QIZ-X6YZWAML.js.map} +0 -0
  247. /package/dist/{hook-command-4TYCHHRL.js.map → hook-command-ZA2PNKS6.js.map} +0 -0
  248. /package/dist/{install-XWGE4Q7L.js.map → hosts-AV5MHBAU.js.map} +0 -0
  249. /package/dist/{install-identity-K7EJIQFP.js.map → install-PT4EZS4R.js.map} +0 -0
  250. /package/dist/{package-ZKQFDWLE.js.map → install-identity-5A4OE6YC.js.map} +0 -0
  251. /package/dist/{paths-POPTXJO6.js.map → package-SR2WB6MK.js.map} +0 -0
  252. /package/dist/{pay-WHBERZ3W.js.map → passphrase-IFTDS3CU.js.map} +0 -0
  253. /package/dist/{plugin-registration-5TIA564H.js.map → paths-XCSAKISU.js.map} +0 -0
  254. /package/dist/{redact-6W23GGJC.js.map → pay-OXC3WKYV.js.map} +0 -0
  255. /package/dist/{update-ZKUERSO2.js.map → plugin-registration-N3GRIZVM.js.map} +0 -0
  256. /package/dist/{usdc-OGOGEHV2.js.map → redact-D7ASVWKL.js.map} +0 -0
  257. /package/dist/{viemAdapter-By13KInL-S3DA7DFW.js.map → runtime-fetch-EKFRNR6Z.js.map} +0 -0
  258. /package/dist/{wallet-2HA6W4R4.js.map → runtime-layout-BDWZG2TQ.js.map} +0 -0
@@ -4,10 +4,10 @@ import {
4
4
  } from "./chunk-2I4QTOLB.js";
5
5
  import {
6
6
  external_exports
7
- } from "./chunk-YVFXE7RR.js";
7
+ } from "./chunk-SNNSAGMT.js";
8
8
  import {
9
9
  spendLedgerPath
10
- } from "./chunk-SJLTEINJ.js";
10
+ } from "./chunk-OJNTCYQQ.js";
11
11
 
12
12
  // src/lib/spend-ledger.ts
13
13
  import { readFile } from "node:fs/promises";
@@ -111,4 +111,4 @@ export {
111
111
  readLedger,
112
112
  readSpendSummary
113
113
  };
114
- //# sourceMappingURL=chunk-WK7F3B2E.js.map
114
+ //# sourceMappingURL=chunk-SO3XRZPX.js.map
@@ -0,0 +1,176 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ CliError
4
+ } from "./chunk-3UCIG4TG.js";
5
+
6
+ // src/lib/runtime-fetch.ts
7
+ import { spawn } from "node:child_process";
8
+ import { createHash, randomBytes } from "node:crypto";
9
+ import { open, rm } from "node:fs/promises";
10
+ import { join, posix, win32 } from "node:path";
11
+ var MIN_GLIBC = [2, 28];
12
+ var KEYS = /* @__PURE__ */ new Set([
13
+ "darwin-arm64",
14
+ "darwin-x64",
15
+ "linux-x64",
16
+ "linux-arm64",
17
+ "win-x64",
18
+ "win-arm64"
19
+ ]);
20
+ function glibcAtLeast(glibc, min) {
21
+ const m = /^(\d+)\.(\d+)/.exec(glibc);
22
+ if (m === null) return false;
23
+ const major = Number(m[1]);
24
+ const minor = Number(m[2]);
25
+ return major > min[0] || major === min[0] && minor >= min[1];
26
+ }
27
+ function nodeKey(platform, arch, glibc) {
28
+ const os = platform === "win32" ? "win" : platform;
29
+ const key = `${os}-${arch}`;
30
+ if (!KEYS.has(key)) return null;
31
+ if (platform === "linux" && (typeof glibc !== "string" || !glibcAtLeast(glibc, MIN_GLIBC))) {
32
+ return null;
33
+ }
34
+ return key;
35
+ }
36
+ function unpinnedPlatform(platform, arch, glibc) {
37
+ if (nodeKey(platform, arch, glibc) !== null) return null;
38
+ const key = `${platform === "win32" ? "win" : platform}-${arch}`;
39
+ if (platform !== "linux" || !KEYS.has(key)) return key;
40
+ return typeof glibc === "string" ? `${key} with glibc ${glibc}, older than ${MIN_GLIBC.join(".")}` : `${key} with musl, not glibc`;
41
+ }
42
+ function runningGlibc() {
43
+ try {
44
+ const report = process.report.getReport();
45
+ return report.header?.glibcVersionRuntime ?? null;
46
+ } catch {
47
+ return null;
48
+ }
49
+ }
50
+ function nodeArtifact(version, key) {
51
+ const base = `node-v${version}-${key}`;
52
+ const windows = key.startsWith("win-");
53
+ const file = `${base}.${windows ? "zip" : "tar.gz"}`;
54
+ return {
55
+ key,
56
+ url: `https://nodejs.org/dist/v${version}/${file}`,
57
+ file,
58
+ member: windows ? `${base}/node.exe` : `${base}/bin/node`
59
+ };
60
+ }
61
+ function isHttps(url) {
62
+ try {
63
+ return new URL(url).protocol === "https:";
64
+ } catch {
65
+ return false;
66
+ }
67
+ }
68
+ async function download(url, o) {
69
+ if (!isHttps(url)) {
70
+ throw new CliError("UPDATE_FAILED", `refused to download ${url}: only https is allowed`);
71
+ }
72
+ const file = join(o.dir, `dl-${randomBytes(6).toString("hex")}`);
73
+ const handle = await open(file, "wx", 384);
74
+ let closed = false;
75
+ try {
76
+ let res;
77
+ try {
78
+ res = await (o.fetchImpl ?? fetch)(url, { signal: AbortSignal.timeout(o.timeoutMs) });
79
+ } catch (err) {
80
+ throw new CliError("NETWORK_ERROR", `could not download ${url}: ${messageOf(err)}`, {
81
+ cause: err
82
+ });
83
+ }
84
+ if (res.url !== "" && !isHttps(res.url)) {
85
+ throw new CliError("UPDATE_FAILED", `refused ${url}: it redirected to ${res.url}`);
86
+ }
87
+ if (!res.ok || res.body === null) {
88
+ throw new CliError("NETWORK_ERROR", `could not download ${url}: HTTP ${res.status}`);
89
+ }
90
+ const tooLarge = () => new CliError("UPDATE_FAILED", `the download from ${url} is larger than ${o.maxBytes} bytes`);
91
+ if (Number(res.headers.get("content-length") ?? 0) > o.maxBytes) throw tooLarge();
92
+ const hash = createHash(o.hash);
93
+ let size = 0;
94
+ try {
95
+ for await (const chunk of res.body) {
96
+ size += chunk.byteLength;
97
+ if (size > o.maxBytes) throw tooLarge();
98
+ hash.update(chunk);
99
+ try {
100
+ await handle.write(chunk);
101
+ } catch (err) {
102
+ throw new CliError("UPDATE_FAILED", `could not write ${file}: ${codeOf(err)}`, {
103
+ cause: err
104
+ });
105
+ }
106
+ }
107
+ } catch (err) {
108
+ if (err instanceof CliError) throw err;
109
+ throw new CliError("NETWORK_ERROR", `could not download ${url}: ${messageOf(err)}`, {
110
+ cause: err
111
+ });
112
+ }
113
+ await handle.close();
114
+ closed = true;
115
+ return { file, digest: hash.digest() };
116
+ } catch (err) {
117
+ if (!closed) await handle.close().catch(() => void 0);
118
+ await rm(file, { force: true }).catch(() => void 0);
119
+ throw err;
120
+ }
121
+ }
122
+ function codeOf(err) {
123
+ const code = err?.code;
124
+ return typeof code === "string" ? code : messageOf(err);
125
+ }
126
+ function messageOf(err) {
127
+ if (err instanceof Error) {
128
+ return err.name === "TimeoutError" ? "it timed out" : err.message;
129
+ }
130
+ return String(err);
131
+ }
132
+ var spawnTar = (command, args, o) => new Promise((resolve, reject) => {
133
+ const child = spawn(command, args, {
134
+ cwd: o.cwd,
135
+ shell: false,
136
+ stdio: ["ignore", "ignore", "pipe"],
137
+ windowsHide: true
138
+ });
139
+ let stderr = "";
140
+ child.stderr.setEncoding("utf8");
141
+ child.stderr.on("data", (chunk) => {
142
+ if (stderr.length < 4096) stderr += chunk;
143
+ });
144
+ child.on("error", reject);
145
+ child.on("close", (code) => resolve({ code, stderr }));
146
+ });
147
+ async function extract(archive, dest, o = {}) {
148
+ const windows = (o.platform ?? process.platform) === "win32";
149
+ const command = windows ? win32.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe") : "tar";
150
+ const path = windows ? win32 : posix;
151
+ const cwd = path.dirname(archive);
152
+ const into = path.relative(cwd, dest);
153
+ const args = [
154
+ windows ? "-xf" : "-xzf",
155
+ path.basename(archive),
156
+ "-C",
157
+ into === "" ? "." : into.startsWith("..") || path.isAbsolute(into) ? dest : into,
158
+ ...o.strip !== void 0 && o.strip > 0 ? [`--strip-components=${o.strip}`] : [],
159
+ ...o.member !== void 0 ? [o.member] : []
160
+ ];
161
+ const run = await (o.spawnImpl ?? spawnTar)(command, args, { cwd });
162
+ if (run.code !== 0) {
163
+ const said = run.stderr.trim().slice(0, 300);
164
+ throw new Error(`tar could not unpack ${archive} (exit ${run.code})${said ? `: ${said}` : ""}`);
165
+ }
166
+ }
167
+
168
+ export {
169
+ nodeKey,
170
+ unpinnedPlatform,
171
+ runningGlibc,
172
+ nodeArtifact,
173
+ download,
174
+ extract
175
+ };
176
+ //# sourceMappingURL=chunk-SYOS5CAC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/runtime-fetch.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { createHash, randomBytes } from 'node:crypto';\nimport { open, rm } from 'node:fs/promises';\nimport { join, posix, win32 } from 'node:path';\nimport { CliError } from './errors';\n\n/**\n * WHAT THE RUNTIME DOWNLOADS, AND HOW: Node's own release archive and the npm\n * tarball of a tenjin-cli version, over https only, streamed to disk while\n * hashed, capped in size and time, and unpacked by the system's `tar` in exec\n * form. The checksums themselves are the caller's: the pin in `package.json`\n * for Node, the registry's `dist.integrity` for a tarball.\n */\n\n/** The oldest glibc Node 24's prebuilt Linux binaries run on. */\nconst MIN_GLIBC = [2, 28] as const;\n\n/** Node's release archives, by `nodeKey`. Anything else has no pinned build. */\nconst KEYS = new Set([\n 'darwin-arm64',\n 'darwin-x64',\n 'linux-x64',\n 'linux-arm64',\n 'win-x64',\n 'win-arm64',\n]);\n\nfunction glibcAtLeast(glibc: string, min: readonly [number, number]): boolean {\n const m = /^(\\d+)\\.(\\d+)/.exec(glibc);\n if (m === null) return false;\n const major = Number(m[1]);\n const minor = Number(m[2]);\n return major > min[0] || (major === min[0] && minor >= min[1]);\n}\n\n/**\n * The release-archive key for this machine, or null where Tenjin pins no Node:\n * musl (no glibc version at all), a glibc older than 2.28, and every platform\n * and architecture outside the six keys. A Rosetta x64 Node asks for\n * `darwin-x64`, which runs under Rosetta too.\n */\nexport function nodeKey(\n platform: NodeJS.Platform,\n arch: string,\n glibc: string | null | undefined,\n): string | null {\n const os = platform === 'win32' ? 'win' : platform;\n const key = `${os}-${arch}`;\n if (!KEYS.has(key)) return null;\n if (platform === 'linux' && (typeof glibc !== 'string' || !glibcAtLeast(glibc, MIN_GLIBC))) {\n return null;\n }\n return key;\n}\n\n/**\n * Why Tenjin pins no Node for this machine, or null when it pins one: the\n * platform and architecture, and on Linux the C library that rules it out.\n * Said by install and doctor so the cause is named, never a pinned key.\n */\nexport function unpinnedPlatform(\n platform: NodeJS.Platform,\n arch: string,\n glibc: string | null | undefined,\n): string | null {\n if (nodeKey(platform, arch, glibc) !== null) return null;\n const key = `${platform === 'win32' ? 'win' : platform}-${arch}`;\n if (platform !== 'linux' || !KEYS.has(key)) return key;\n return typeof glibc === 'string'\n ? `${key} with glibc ${glibc}, older than ${MIN_GLIBC.join('.')}`\n : `${key} with musl, not glibc`;\n}\n\n/** The glibc this Node runs on, or null: musl, or a report that cannot be read. */\nexport function runningGlibc(): string | null {\n try {\n const report = process.report.getReport() as { header?: { glibcVersionRuntime?: string } };\n return report.header?.glibcVersionRuntime ?? null;\n } catch {\n return null;\n }\n}\n\nexport interface NodeArtifact {\n key: string;\n url: string;\n /** The archive's name in the release, the name `SHASUMS256.txt` lists. */\n file: string;\n /** The one archive member the runtime keeps: the `node` binary. */\n member: string;\n}\n\nexport function nodeArtifact(version: string, key: string): NodeArtifact {\n const base = `node-v${version}-${key}`;\n const windows = key.startsWith('win-');\n const file = `${base}.${windows ? 'zip' : 'tar.gz'}`;\n return {\n key,\n url: `https://nodejs.org/dist/v${version}/${file}`,\n file,\n member: windows ? `${base}/node.exe` : `${base}/bin/node`,\n };\n}\n\nfunction isHttps(url: string): boolean {\n try {\n return new URL(url).protocol === 'https:';\n } catch {\n return false;\n }\n}\n\n/**\n * Stream `url` into a fresh file under `dir`, hashing as it goes. Refuses a URL\n * (or a redirect's final URL) that is not https, aborts past `maxBytes` or\n * `timeoutMs`, and unlinks the file on any failure, so a caller never finds a\n * half download. A transport failure (the fetch, or reading the body) is\n * `NETWORK_ERROR`, and the caller adds its fix; a write to disk that fails\n * (ENOSPC, EACCES) is not the network's, and says which file and why.\n */\nexport async function download(\n url: string,\n o: {\n dir: string;\n maxBytes: number;\n timeoutMs: number;\n hash: 'sha256' | 'sha512';\n fetchImpl?: typeof fetch;\n },\n): Promise<{ file: string; digest: Buffer }> {\n if (!isHttps(url)) {\n throw new CliError('UPDATE_FAILED', `refused to download ${url}: only https is allowed`);\n }\n const file = join(o.dir, `dl-${randomBytes(6).toString('hex')}`);\n const handle = await open(file, 'wx', 0o600);\n let closed = false;\n try {\n let res: Response;\n try {\n res = await (o.fetchImpl ?? fetch)(url, { signal: AbortSignal.timeout(o.timeoutMs) });\n } catch (err) {\n throw new CliError('NETWORK_ERROR', `could not download ${url}: ${messageOf(err)}`, {\n cause: err,\n });\n }\n if (res.url !== '' && !isHttps(res.url)) {\n throw new CliError('UPDATE_FAILED', `refused ${url}: it redirected to ${res.url}`);\n }\n if (!res.ok || res.body === null) {\n throw new CliError('NETWORK_ERROR', `could not download ${url}: HTTP ${res.status}`);\n }\n const tooLarge = () =>\n new CliError('UPDATE_FAILED', `the download from ${url} is larger than ${o.maxBytes} bytes`);\n if (Number(res.headers.get('content-length') ?? 0) > o.maxBytes) throw tooLarge();\n const hash = createHash(o.hash);\n let size = 0;\n try {\n for await (const chunk of res.body as AsyncIterable<Uint8Array>) {\n size += chunk.byteLength;\n if (size > o.maxBytes) throw tooLarge();\n hash.update(chunk);\n try {\n await handle.write(chunk);\n } catch (err) {\n throw new CliError('UPDATE_FAILED', `could not write ${file}: ${codeOf(err)}`, {\n cause: err,\n });\n }\n }\n } catch (err) {\n if (err instanceof CliError) throw err;\n throw new CliError('NETWORK_ERROR', `could not download ${url}: ${messageOf(err)}`, {\n cause: err,\n });\n }\n await handle.close();\n closed = true;\n return { file, digest: hash.digest() };\n } catch (err) {\n if (!closed) await handle.close().catch(() => undefined);\n await rm(file, { force: true }).catch(() => undefined);\n throw err;\n }\n}\n\n/** A file-system error's errno code (ENOSPC, EACCES), or its message when it has none. */\nfunction codeOf(err: unknown): string {\n const code = (err as { code?: unknown } | null)?.code;\n return typeof code === 'string' ? code : messageOf(err);\n}\n\nfunction messageOf(err: unknown): string {\n if (err instanceof Error) {\n return err.name === 'TimeoutError' ? 'it timed out' : err.message;\n }\n return String(err);\n}\n\n/** How `extract` runs `tar`: exec form, no shell, in `cwd`. A seam for tests. */\nexport type ExtractSpawn = (\n command: string,\n args: string[],\n o: { cwd: string },\n) => Promise<{ code: number | null; stderr: string }>;\n\nconst spawnTar: ExtractSpawn = (command, args, o) =>\n new Promise((resolve, reject) => {\n const child = spawn(command, args, {\n cwd: o.cwd,\n shell: false,\n stdio: ['ignore', 'ignore', 'pipe'],\n windowsHide: true,\n });\n let stderr = '';\n child.stderr.setEncoding('utf8');\n child.stderr.on('data', (chunk: string) => {\n if (stderr.length < 4096) stderr += chunk;\n });\n child.on('error', reject);\n child.on('close', (code) => resolve({ code, stderr }));\n });\n\n/**\n * Unpack `archive` into `dest` with the system's `tar`: `tar -xzf` on POSIX,\n * and on Windows `System32\\tar.exe -xf`, which is bsdtar and reads a `.zip`\n * (Git's GNU tar, earlier on many PATHs, does not). `member` limits it to one\n * file, `strip` drops leading folders. A non-zero exit throws with what tar said.\n *\n * TAR RUNS IN THE ARCHIVE'S FOLDER and is given names relative to it. bsdtar\n * reads its argv in the ANSI code page, so a user folder named outside it\n * (Cyrillic on cp1252, an emoji) would reach it as `?`; the working directory\n * goes to Windows as a wide string, and the names it is given are the\n * runtime's own ASCII ones.\n */\nexport async function extract(\n archive: string,\n dest: string,\n o: { member?: string; strip?: number; platform?: NodeJS.Platform; spawnImpl?: ExtractSpawn } = {},\n): Promise<void> {\n const windows = (o.platform ?? process.platform) === 'win32';\n const command = windows\n ? win32.join(process.env.SystemRoot ?? 'C:\\\\Windows', 'System32', 'tar.exe')\n : 'tar';\n const path = windows ? win32 : posix;\n const cwd = path.dirname(archive);\n const into = path.relative(cwd, dest);\n const args = [\n windows ? '-xf' : '-xzf',\n path.basename(archive),\n '-C',\n into === '' ? '.' : into.startsWith('..') || path.isAbsolute(into) ? dest : into,\n ...(o.strip !== undefined && o.strip > 0 ? [`--strip-components=${o.strip}`] : []),\n ...(o.member !== undefined ? [o.member] : []),\n ];\n const run = await (o.spawnImpl ?? spawnTar)(command, args, { cwd });\n if (run.code !== 0) {\n const said = run.stderr.trim().slice(0, 300);\n throw new Error(`tar could not unpack ${archive} (exit ${run.code})${said ? `: ${said}` : ''}`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,YAAY,mBAAmB;AACxC,SAAS,MAAM,UAAU;AACzB,SAAS,MAAM,OAAO,aAAa;AAYnC,IAAM,YAAY,CA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AK,EAAE,MAAM,GAAG,GAAG;AAC3C,UAAM,IAAI,MAAM,wBAAwB,OAAO,UAAU,IAAI,IAAI,IAAI,OAAO,KAAK,IAAI,KAAK,EAAE,EAAE;AAAA,EAChG;AACF;","names":[]}
@@ -0,0 +1,293 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ MOD_FILES,
4
+ OWNER_MARKER,
5
+ PLUGIN_FILES
6
+ } from "./chunk-E7LGOMH6.js";
7
+ import {
8
+ PLUGIN_NAME
9
+ } from "./chunk-MPZUYCAP.js";
10
+ import {
11
+ writeFileAtomic
12
+ } from "./chunk-7WEQQJLG.js";
13
+ import {
14
+ CliError
15
+ } from "./chunk-3UCIG4TG.js";
16
+
17
+ // src/router/plugin-folder.ts
18
+ import { lstat, readdir, readFile, rm, rmdir } from "node:fs/promises";
19
+ import { dirname, join, relative, sep } from "node:path";
20
+ var FOLDER_NAME = "tenjin-router";
21
+ async function readModSources(pluginDir) {
22
+ const entries = await Promise.all(
23
+ MOD_FILES.map(async (path) => [path, await readFile(join(pluginDir, path), "utf8")])
24
+ ).catch(() => null);
25
+ return entries === null ? void 0 : Object.fromEntries(entries);
26
+ }
27
+ function pluginFolderPath(base) {
28
+ return join(base, "skills", FOLDER_NAME);
29
+ }
30
+ async function inspectPluginFolder(dir) {
31
+ const entry = await lstat(dir).catch(() => null);
32
+ if (entry === null) return "absent";
33
+ if (!entry.isDirectory() || entry.isSymbolicLink()) return "foreign";
34
+ try {
35
+ const manifest = JSON.parse(
36
+ await readFile(join(dir, ".claude-plugin", "plugin.json"), "utf8")
37
+ );
38
+ const marked = manifest.metadata !== null && typeof manifest.metadata === "object" && OWNER_MARKER in manifest.metadata;
39
+ return manifest.name === PLUGIN_NAME && marked ? "ours" : "foreign";
40
+ } catch {
41
+ return "foreign";
42
+ }
43
+ }
44
+ async function linkedParent(dir, path) {
45
+ const parents = [];
46
+ for (let d = dirname(path); d !== "."; d = dirname(d)) parents.unshift(d);
47
+ for (const parent of parents) {
48
+ const entry = await lstat(join(dir, parent)).catch(() => null);
49
+ if (entry === null) return null;
50
+ if (entry.isSymbolicLink() || !entry.isDirectory()) return parent;
51
+ }
52
+ return null;
53
+ }
54
+ async function writePluginFolder(dir, files) {
55
+ const state = await inspectPluginFolder(dir);
56
+ if (state === "foreign") {
57
+ return {
58
+ path: dir,
59
+ state: "refused",
60
+ reason: `${dir} exists and is not a folder this CLI wrote, so it was left as it is`
61
+ };
62
+ }
63
+ for (const path of PLUGIN_FILES) {
64
+ const linked = await linkedParent(dir, path);
65
+ if (linked !== null) {
66
+ return {
67
+ path: dir,
68
+ state: "refused",
69
+ reason: `${join(dir, linked)} is a link or not a folder, so nothing in ${dir} was written`
70
+ };
71
+ }
72
+ }
73
+ try {
74
+ for (const path of PLUGIN_FILES) {
75
+ const body = files[path];
76
+ if (body === void 0) continue;
77
+ await writeFileAtomic(join(dir, path), body);
78
+ }
79
+ } catch (err) {
80
+ return {
81
+ path: dir,
82
+ state: "refused",
83
+ reason: err instanceof Error ? err.message : String(err)
84
+ };
85
+ }
86
+ return { path: dir, state: "written" };
87
+ }
88
+ async function removePluginFolder(dir) {
89
+ const state = await inspectPluginFolder(dir);
90
+ if (state === "absent") return { path: dir, removed: false, left: [] };
91
+ if (state === "foreign") {
92
+ return {
93
+ path: dir,
94
+ removed: false,
95
+ left: [],
96
+ reason: `${dir} is not a folder this CLI wrote, so nothing in it was removed`
97
+ };
98
+ }
99
+ for (const path of PLUGIN_FILES) {
100
+ if (await linkedParent(dir, path) === null) await rm(join(dir, path), { force: true });
101
+ }
102
+ const subdirs = [
103
+ ...new Set(
104
+ PLUGIN_FILES.flatMap((p) => {
105
+ const out = [];
106
+ for (let d = dirname(p); d !== "."; d = dirname(d)) out.push(d);
107
+ return out;
108
+ })
109
+ )
110
+ ].sort((a, b) => b.split("/").length - a.split("/").length);
111
+ for (const sub of subdirs) await rmdir(join(dir, sub)).catch(() => void 0);
112
+ const left = await listFiles(dir);
113
+ if (left.length === 0) await rmdir(dir).catch(() => void 0);
114
+ return { path: dir, removed: true, left };
115
+ }
116
+ async function listFiles(dir) {
117
+ const out = [];
118
+ const walk = async (current) => {
119
+ for (const entry of await readdir(current, { withFileTypes: true }).catch(() => [])) {
120
+ const path = join(current, entry.name);
121
+ if (entry.isDirectory()) await walk(path);
122
+ else out.push(relative(dir, path).split(sep).join("/"));
123
+ }
124
+ };
125
+ await walk(dir);
126
+ return out.sort();
127
+ }
128
+
129
+ // src/lib/install-location.ts
130
+ import { existsSync, realpathSync, statSync } from "node:fs";
131
+ import { delimiter, dirname as dirname2, join as join2, sep as sep2 } from "node:path";
132
+ var REFUSALS = [
133
+ {
134
+ test: isSourceCheckout,
135
+ error: () => new CliError("REFUSED", "tenjin-cli is running from a source checkout, not an install", {
136
+ fix: "Update the checkout instead: git pull && pnpm install"
137
+ }),
138
+ needsVersion: false,
139
+ appliesToCheck: false
140
+ },
141
+ {
142
+ test: (moduleDir) => moduleDir.split(sep2).includes("_npx"),
143
+ error: (spec) => new CliError("REFUSED", "tenjin-cli is running from the npx cache, not an install", {
144
+ // Writing a global here would "succeed" and change nothing: the next
145
+ // `npx tenjin` still resolves its own cached copy.
146
+ fix: `npx fetches its own copy every time. To keep one: npm i -g ${spec}`
147
+ }),
148
+ needsVersion: true,
149
+ appliesToCheck: false
150
+ },
151
+ {
152
+ // The ONLY manager still refused. `yarn global add` is yarn-1 only, and
153
+ // berry dropped global installs altogether, so there is no one command this
154
+ // can drive across the versions a user might have. Every other manager is
155
+ // delegated to rather than refused (see MANAGERS).
156
+ test: (moduleDir) => classifyManager(moduleDir) === "yarn",
157
+ error: (spec) => new CliError(
158
+ "REFUSED",
159
+ "This tenjin-cli was installed with yarn, whose global install exists only in yarn 1",
160
+ { fix: `yarn global add ${spec}` }
161
+ ),
162
+ needsVersion: true,
163
+ appliesToCheck: false
164
+ },
165
+ {
166
+ // Scoped to npm on purpose: the prefix-vs-project-root test is written for
167
+ // npm's layout. pnpm's global store and bun's global dir both keep a
168
+ // package.json beside `node_modules`, so an unscoped test would read either
169
+ // as a project-local install and refuse the very case we now delegate.
170
+ test: (moduleDir) => classifyManager(moduleDir) === "npm" && !isGlobalTree(moduleDir),
171
+ error: (spec) => new CliError(
172
+ "REFUSED",
173
+ "This tenjin-cli is a project-local dependency, not a global install",
174
+ {
175
+ fix: `Update it where it is declared: npm i ${spec}`
176
+ }
177
+ ),
178
+ needsVersion: true,
179
+ appliesToCheck: false
180
+ }
181
+ ];
182
+ function refuse(moduleDir, opts) {
183
+ for (const entry of REFUSALS) {
184
+ if (opts.check && !entry.appliesToCheck) continue;
185
+ if (entry.needsVersion !== (opts.spec !== null)) continue;
186
+ if (entry.test(moduleDir)) throw entry.error(opts.spec ?? "", moduleDir);
187
+ }
188
+ }
189
+ function isSourceCheckout(moduleDir) {
190
+ let dir = moduleDir;
191
+ for (let i = 0; i < 8; i += 1) {
192
+ if (existsSync(join2(dir, "package.json"))) return existsSync(join2(dir, "src"));
193
+ const parent = dirname2(dir);
194
+ if (parent === dir) break;
195
+ dir = parent;
196
+ }
197
+ return false;
198
+ }
199
+ function isGlobalTree(moduleDir) {
200
+ const segs = moduleDir.split(sep2);
201
+ const i = segs.lastIndexOf("node_modules");
202
+ if (i <= 0) return false;
203
+ return !existsSync(join2(segs.slice(0, i).join(sep2), "package.json"));
204
+ }
205
+ function classifyManager(moduleDir) {
206
+ const segs = moduleDir.split(sep2);
207
+ const pair = (a, b) => segs.includes(a) && segs.includes(b);
208
+ if (segs.includes(".pnpm") || pair("pnpm", "global")) return "pnpm";
209
+ if (segs.includes(".bun")) return "bun";
210
+ if (segs.includes(".yarn") || pair("yarn", "global")) return "yarn";
211
+ return "npm";
212
+ }
213
+ var MANAGERS = {
214
+ npm: {
215
+ bin: "npm",
216
+ scriptSuffixes: ["npm-cli.js"],
217
+ besideNode: true,
218
+ args: (spec) => ["install", "-g", "--ignore-scripts", spec],
219
+ manual: (spec) => `npm i -g ${spec}`
220
+ },
221
+ pnpm: {
222
+ bin: "pnpm",
223
+ // corepack's shim resolves to `pnpm.js`, a standalone install to `pnpm.cjs`.
224
+ scriptSuffixes: [".cjs", ".js"],
225
+ besideNode: false,
226
+ args: (spec) => ["add", "-g", "--ignore-scripts", spec],
227
+ manual: (spec) => `pnpm add -g ${spec}`
228
+ },
229
+ bun: {
230
+ bin: "bun",
231
+ scriptSuffixes: [],
232
+ besideNode: false,
233
+ // No --ignore-scripts: bun's flag surface for it is not stable across the
234
+ // versions in the wild, and an unknown flag would fail the install outright.
235
+ args: (spec) => ["add", "-g", spec],
236
+ manual: (spec) => `bun add -g ${spec}`
237
+ }
238
+ };
239
+ function resolveManagerScript(manager, execPath, env = process.env) {
240
+ const plan = MANAGERS[manager];
241
+ if (plan.scriptSuffixes.length === 0) return null;
242
+ const beside = plan.besideNode ? scriptNear(dirname2(execPath), plan.bin) : null;
243
+ return beside ?? scriptOnPath(plan.bin, plan.scriptSuffixes, env);
244
+ }
245
+ function scriptNear(dir, bin) {
246
+ const candidates = [
247
+ join2(dir, "node_modules", bin, "bin", `${bin}-cli.js`),
248
+ join2(dir, "..", "lib", "node_modules", bin, "bin", `${bin}-cli.js`)
249
+ ];
250
+ return candidates.find(isFile) ?? null;
251
+ }
252
+ function scriptOnPath(bin, suffixes, env) {
253
+ const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter((e) => e.length > 0)] : [""];
254
+ for (const part of (env.PATH ?? "").split(delimiter)) {
255
+ if (part.length === 0) continue;
256
+ for (const ext of exts) {
257
+ if (!isFile(join2(part, `${bin}${ext}`))) continue;
258
+ const real = realpathOrNull(join2(part, `${bin}${ext}`));
259
+ if (real !== null && suffixes.some((suffix) => real.endsWith(suffix))) return real;
260
+ const near = scriptNear(part, bin);
261
+ if (near !== null) return near;
262
+ }
263
+ }
264
+ return null;
265
+ }
266
+ function isFile(p) {
267
+ try {
268
+ return statSync(p).isFile();
269
+ } catch {
270
+ return false;
271
+ }
272
+ }
273
+ function realpathOrNull(p) {
274
+ try {
275
+ return realpathSync(p);
276
+ } catch {
277
+ return null;
278
+ }
279
+ }
280
+
281
+ export {
282
+ readModSources,
283
+ pluginFolderPath,
284
+ inspectPluginFolder,
285
+ writePluginFolder,
286
+ removePluginFolder,
287
+ refuse,
288
+ isSourceCheckout,
289
+ classifyManager,
290
+ MANAGERS,
291
+ resolveManagerScript
292
+ };
293
+ //# sourceMappingURL=chunk-TAW4UFFF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/plugin-folder.ts","../src/lib/install-location.ts"],"sourcesContent":["import { lstat, readdir, readFile, rm, rmdir } from 'node:fs/promises';\nimport { dirname, join, relative, sep } from 'node:path';\nimport { writeFileAtomic } from '../lib/atomic-json';\nimport { PLUGIN_NAME } from './names';\nimport { MOD_FILES, OWNER_MARKER, PLUGIN_FILES, type ModSources } from './plugin-files';\n\n/**\n * THE FOLDER FALLBACK: the plugin as a folder under a config dir's `skills/`,\n * which Claude Code loads in place as `tenjin@skills-dir` with no `claude`\n * command at all (lab, 2026-10-09: the manifest's name wins over the folder's).\n * `install` writes it only where it cannot run `claude plugin`.\n *\n * OWNERSHIP RULES. Only `tenjin-router/` is ever touched, never `skills/tenjin`,\n * where tenjin.sh tells readers to drop its hosted skill. The folder is ours\n * only when it is a real directory (never followed through a link) whose\n * manifest names `tenjin` and carries the `tenjin-cli` marker. Inside it, only\n * the paths in {@link PLUGIN_FILES} are written or unlinked, so a user's own\n * `skills/` or `commands/` there survive every update and uninstall, and a\n * listed path whose parent inside the folder is a link is never written or\n * unlinked, so a linked `skills/tenjin-pay` keeps the user's file behind it.\n */\n\nexport const FOLDER_NAME = 'tenjin-router';\n\n/**\n * The mod's files from a plugin folder that carries them (the package's own\n * `dist/hosts/claude/tenjin`), or undefined when any is missing: the folder\n * fallback then writes the legs and the server without the mod.\n */\nexport async function readModSources(pluginDir: string): Promise<ModSources | undefined> {\n const entries = await Promise.all(\n MOD_FILES.map(async (path) => [path, await readFile(join(pluginDir, path), 'utf8')] as const),\n ).catch(() => null);\n return entries === null ? undefined : (Object.fromEntries(entries) as ModSources);\n}\n\n/** `<base>/skills/tenjin-router`, for a config dir or a project's `.claude`. */\nexport function pluginFolderPath(base: string): string {\n return join(base, 'skills', FOLDER_NAME);\n}\n\nexport type FolderState = 'absent' | 'ours' | 'foreign';\n\nexport async function inspectPluginFolder(dir: string): Promise<FolderState> {\n const entry = await lstat(dir).catch(() => null);\n if (entry === null) return 'absent';\n if (!entry.isDirectory() || entry.isSymbolicLink()) return 'foreign';\n try {\n const manifest = JSON.parse(\n await readFile(join(dir, '.claude-plugin', 'plugin.json'), 'utf8'),\n ) as { name?: unknown; metadata?: Record<string, unknown> };\n const marked =\n manifest.metadata !== null &&\n typeof manifest.metadata === 'object' &&\n OWNER_MARKER in manifest.metadata;\n return manifest.name === PLUGIN_NAME && marked ? 'ours' : 'foreign';\n } catch {\n return 'foreign';\n }\n}\n\n/**\n * The first parent of `path` inside `dir` that exists and is not a real\n * directory, relative to `dir`, or null when every parent is real or absent.\n */\nasync function linkedParent(dir: string, path: string): Promise<string | null> {\n const parents: string[] = [];\n for (let d = dirname(path); d !== '.'; d = dirname(d)) parents.unshift(d);\n for (const parent of parents) {\n const entry = await lstat(join(dir, parent)).catch(() => null);\n if (entry === null) return null;\n if (entry.isSymbolicLink() || !entry.isDirectory()) return parent;\n }\n return null;\n}\n\nexport interface FolderWrite {\n path: string;\n state: 'written' | 'refused';\n reason?: string;\n}\n\n/**\n * Write the listed files, each atomically (a temp file in its own directory,\n * renamed over the file), the manifest last. A folder that exists and is not\n * ours is refused and reported, never overwritten.\n */\nexport async function writePluginFolder(\n dir: string,\n files: Record<string, string>,\n): Promise<FolderWrite> {\n const state = await inspectPluginFolder(dir);\n if (state === 'foreign') {\n return {\n path: dir,\n state: 'refused',\n reason: `${dir} exists and is not a folder this CLI wrote, so it was left as it is`,\n };\n }\n for (const path of PLUGIN_FILES) {\n const linked = await linkedParent(dir, path);\n if (linked !== null) {\n return {\n path: dir,\n state: 'refused',\n reason: `${join(dir, linked)} is a link or not a folder, so nothing in ${dir} was written`,\n };\n }\n }\n try {\n for (const path of PLUGIN_FILES) {\n const body = files[path];\n if (body === undefined) continue;\n await writeFileAtomic(join(dir, path), body);\n }\n } catch (err) {\n return {\n path: dir,\n state: 'refused',\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n return { path: dir, state: 'written' };\n}\n\nexport interface FolderRemoval {\n path: string;\n /** False when there was no folder of ours to remove. */\n removed: boolean;\n /** What is left in the folder that is not ours, relative to it. */\n left: string[];\n reason?: string;\n}\n\n/**\n * Unlink the listed files, remove the subfolders they leave empty, deepest\n * first, and the folder itself only when it is then empty. Never recursive.\n */\nexport async function removePluginFolder(dir: string): Promise<FolderRemoval> {\n const state = await inspectPluginFolder(dir);\n if (state === 'absent') return { path: dir, removed: false, left: [] };\n if (state === 'foreign') {\n return {\n path: dir,\n removed: false,\n left: [],\n reason: `${dir} is not a folder this CLI wrote, so nothing in it was removed`,\n };\n }\n for (const path of PLUGIN_FILES) {\n if ((await linkedParent(dir, path)) === null) await rm(join(dir, path), { force: true });\n }\n // Every ancestor of every file, deepest first: a nested skill directory\n // leaves its parent behind otherwise.\n const subdirs = [\n ...new Set(\n PLUGIN_FILES.flatMap((p) => {\n const out: string[] = [];\n for (let d = dirname(p); d !== '.'; d = dirname(d)) out.push(d);\n return out;\n }),\n ),\n ].sort((a, b) => b.split('/').length - a.split('/').length);\n for (const sub of subdirs) await rmdir(join(dir, sub)).catch(() => undefined);\n const left = await listFiles(dir);\n if (left.length === 0) await rmdir(dir).catch(() => undefined);\n return { path: dir, removed: true, left };\n}\n\nasync function listFiles(dir: string): Promise<string[]> {\n const out: string[] = [];\n const walk = async (current: string): Promise<void> => {\n for (const entry of await readdir(current, { withFileTypes: true }).catch(() => [])) {\n const path = join(current, entry.name);\n if (entry.isDirectory()) await walk(path);\n else out.push(relative(dir, path).split(sep).join('/'));\n }\n };\n await walk(dir);\n return out.sort();\n}\n","import { existsSync, realpathSync, statSync } from 'node:fs';\nimport { delimiter, dirname, join, sep } from 'node:path';\nimport { CliError } from './errors';\n\n/**\n * WHERE this build is installed, and what that implies about replacing it.\n *\n * Its own module because it answers a different question from the command that\n * uses it: \"what IS this install\" rather than \"how do I replace it\". The\n * refusal set is the load-bearing part, and it got re-cut in three consecutive\n * reviews while it was expressed positionally inside the command body.\n */\n\n/** Managers a global install can be handed back to. yarn is deliberately absent\n * from the delegable set: see the yarn entry in REFUSALS. */\nexport type Delegable = 'npm' | 'pnpm' | 'bun';\n\n/**\n * One reason `npm install -g` would not actually replace THIS build.\n *\n * Each entry carries the three properties that decide WHEN it is evaluated,\n * because expressing them by where the line sat is what made this set get\n * re-cut three times: a missing entry, then a copy on the wrong side of the\n * fetch, then a duplicate that could not run. Declaring them means adding a\n * refusal is a matter of answering three questions, not of guessing a position.\n */\ninterface Refusal {\n /** Does this install location refuse? Pure filesystem, never the network. */\n test: (moduleDir: string) => boolean;\n error: (spec: string, moduleDir: string) => CliError;\n /**\n * Does the fix string name the version the registry just resolved? This is\n * also what decides whether the entry may run BEFORE the fetch: one that does\n * not need a version is evaluated first, so an offline user in a checkout is\n * told they are in a checkout rather than told to go debug their network.\n */\n needsVersion: boolean;\n /**\n * Does it apply to `--check`? Everything here is a reason not to WRITE, and\n * `--check` only reports, so today nothing does. An entry that ever answers\n * yes is one whose test says the REPORT would be wrong, not the install.\n */\n appliesToCheck: boolean;\n}\n\n/**\n * Ordered most-specific first: a checkout and an npx cache are recognizable\n * before any question of which manager or which tree, and the manager entry\n * precedes the global/local one because a pnpm or bun store has its own layout\n * that `isGlobalTree` is not written for.\n */\nexport const REFUSALS: readonly Refusal[] = [\n {\n test: isSourceCheckout,\n error: () =>\n new CliError('REFUSED', 'tenjin-cli is running from a source checkout, not an install', {\n fix: 'Update the checkout instead: git pull && pnpm install',\n }),\n needsVersion: false,\n appliesToCheck: false,\n },\n {\n test: (moduleDir) => moduleDir.split(sep).includes('_npx'),\n error: (spec) =>\n new CliError('REFUSED', 'tenjin-cli is running from the npx cache, not an install', {\n // Writing a global here would \"succeed\" and change nothing: the next\n // `npx tenjin` still resolves its own cached copy.\n fix: `npx fetches its own copy every time. To keep one: npm i -g ${spec}`,\n }),\n needsVersion: true,\n appliesToCheck: false,\n },\n {\n // The ONLY manager still refused. `yarn global add` is yarn-1 only, and\n // berry dropped global installs altogether, so there is no one command this\n // can drive across the versions a user might have. Every other manager is\n // delegated to rather than refused (see MANAGERS).\n test: (moduleDir) => classifyManager(moduleDir) === 'yarn',\n error: (spec) =>\n new CliError(\n 'REFUSED',\n 'This tenjin-cli was installed with yarn, whose global install exists only in yarn 1',\n { fix: `yarn global add ${spec}` },\n ),\n needsVersion: true,\n appliesToCheck: false,\n },\n {\n // Scoped to npm on purpose: the prefix-vs-project-root test is written for\n // npm's layout. pnpm's global store and bun's global dir both keep a\n // package.json beside `node_modules`, so an unscoped test would read either\n // as a project-local install and refuse the very case we now delegate.\n test: (moduleDir) => classifyManager(moduleDir) === 'npm' && !isGlobalTree(moduleDir),\n error: (spec) =>\n new CliError(\n 'REFUSED',\n 'This tenjin-cli is a project-local dependency, not a global install',\n {\n fix: `Update it where it is declared: npm i ${spec}`,\n },\n ),\n needsVersion: true,\n appliesToCheck: false,\n },\n];\n\n/**\n * Evaluate the refusal set, once per stage. `spec` is null before the registry\n * has been asked and the resolved `tenjin-cli@<version>` after, which is what\n * selects the eligible entries: every entry runs in exactly one stage, so no\n * refusal can be reached twice or, as in round three, be written twice and\n * reached once.\n */\nexport function refuse(moduleDir: string, opts: { check: boolean; spec: string | null }): void {\n for (const entry of REFUSALS) {\n if (opts.check && !entry.appliesToCheck) continue;\n if (entry.needsVersion !== (opts.spec !== null)) continue;\n if (entry.test(moduleDir)) throw entry.error(opts.spec ?? '', moduleDir);\n }\n}\n\n/**\n * The published package ships `dist/`, `docs/`, and `skills/` with no `src/`\n * beside them (the `files` array), so a `src/` next to the nearest package.json\n * means a checkout, whose version number says nothing about what HEAD holds.\n * Same test skill-heal uses to keep its hands off working-tree skills.\n */\nexport function isSourceCheckout(moduleDir: string): boolean {\n let dir = moduleDir;\n for (let i = 0; i < 8; i += 1) {\n if (existsSync(join(dir, 'package.json'))) return existsSync(join(dir, 'src'));\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return false;\n}\n\n/**\n * Is this a GLOBAL npm tree? A global install sits under a prefix directory that\n * is not itself a package (`<prefix>/lib/node_modules/tenjin-cli` on POSIX,\n * `<prefix>\\node_modules\\tenjin-cli` on win32), while a project-local one sits\n * under the project root, which by definition has a package.json. That parent is\n * the whole test, which is why it holds for homebrew, nvm, volta and a\n * user-set `npm config prefix` alike without this code enumerating any of them.\n */\nexport function isGlobalTree(moduleDir: string): boolean {\n const segs = moduleDir.split(sep);\n const i = segs.lastIndexOf('node_modules');\n if (i <= 0) return false;\n return !existsSync(join(segs.slice(0, i).join(sep), 'package.json'));\n}\n\n/**\n * Which package manager owns this install, read off the on-disk path. Node\n * resolved the bin symlink before loading us, so the segments name the real\n * store: pnpm's virtual store keeps a literal `.pnpm` segment (or\n * `pnpm/global` for older layouts), bun installs under `.bun`, yarn under\n * `.yarn` or `yarn/global`. Everything else is treated as npm's tree; that\n * covers nvm and volta, both of which route `npm i -g` correctly.\n */\nexport function classifyManager(moduleDir: string): Delegable | 'yarn' {\n const segs = moduleDir.split(sep);\n const pair = (a: string, b: string): boolean => segs.includes(a) && segs.includes(b);\n if (segs.includes('.pnpm') || pair('pnpm', 'global')) return 'pnpm';\n if (segs.includes('.bun')) return 'bun';\n if (segs.includes('.yarn') || pair('yarn', 'global')) return 'yarn';\n return 'npm';\n}\n\n/**\n * How to perform a global install with each manager we delegate to.\n *\n * `scriptSuffixes` is what a PATH shim may resolve to that Node can run\n * directly, which is how win32 is served without a shell: npm and pnpm ship as\n * JS, so the child becomes `node <script>`. An empty list means the binary is\n * native (bun), where spawning it by name already works on every platform.\n */\nexport const MANAGERS: Record<\n Delegable,\n {\n bin: string;\n scriptSuffixes: readonly string[];\n /** Ships beside the running node, as npm does inside the Node distribution. */\n besideNode: boolean;\n args: (spec: string) => string[];\n manual: (spec: string) => string;\n }\n> = {\n npm: {\n bin: 'npm',\n scriptSuffixes: ['npm-cli.js'],\n besideNode: true,\n args: (spec) => ['install', '-g', '--ignore-scripts', spec],\n manual: (spec) => `npm i -g ${spec}`,\n },\n pnpm: {\n bin: 'pnpm',\n // corepack's shim resolves to `pnpm.js`, a standalone install to `pnpm.cjs`.\n scriptSuffixes: ['.cjs', '.js'],\n besideNode: false,\n args: (spec) => ['add', '-g', '--ignore-scripts', spec],\n manual: (spec) => `pnpm add -g ${spec}`,\n },\n bun: {\n bin: 'bun',\n scriptSuffixes: [],\n besideNode: false,\n // No --ignore-scripts: bun's flag surface for it is not stable across the\n // versions in the wild, and an unknown flag would fail the install outright.\n args: (spec) => ['add', '-g', spec],\n manual: (spec) => `bun add -g ${spec}`,\n },\n};\n\n/**\n * npm's own entry script, so the child can be `node npm-cli.js` rather than the\n * `npm` shim.\n *\n * On win32 the shim is `npm.cmd`, which Node refuses to spawn without\n * `shell: true`, and `shell: true` is exactly what this command must not do —\n * it would hand back the argv safety the pinned version buys.\n *\n * Deliberately NOT \"npm ships inside the Node distribution\". That is a property\n * of the installer, not of Node: Homebrew's plain `node` formula keeps only\n * corepack in the keg and puts npm at the brew prefix, so a probe relative to\n * `process.execPath` alone returns null on one of the most common macOS setups.\n * So the layout is searched, not assumed — beside the running binary first\n * (official tarball and installer, nvm, volta, versioned brew kegs), then off\n * PATH, where on POSIX the `npm` shim is itself a symlink to `npm-cli.js` and on\n * win32 `npm.cmd` has `node_modules` beside it. Still null when npm cannot be\n * found at all; the caller then falls back to the bare shim, which works\n * everywhere but win32 and fails closed there into UPDATE_FAILED carrying the\n * manual command.\n */\nexport function resolveNpmCli(\n execPath: string,\n env: NodeJS.ProcessEnv = process.env,\n): string | null {\n return resolveManagerScript('npm', execPath, env);\n}\n\n/**\n * The JS entry script for `manager`, or null when it has none to find (a native\n * binary, or a shim this cannot see through). Null means \"spawn the bare name\",\n * which works everywhere but win32 and fails closed there.\n */\nexport function resolveManagerScript(\n manager: Delegable,\n execPath: string,\n env: NodeJS.ProcessEnv = process.env,\n): string | null {\n const plan = MANAGERS[manager];\n if (plan.scriptSuffixes.length === 0) return null;\n const beside = plan.besideNode ? scriptNear(dirname(execPath), plan.bin) : null;\n return beside ?? scriptOnPath(plan.bin, plan.scriptSuffixes, env);\n}\n\n/** A manager's script relative to a directory holding `node` or its own shim. */\nfunction scriptNear(dir: string, bin: string): string | null {\n const candidates = [\n join(dir, 'node_modules', bin, 'bin', `${bin}-cli.js`),\n join(dir, '..', 'lib', 'node_modules', bin, 'bin', `${bin}-cli.js`),\n ];\n return candidates.find(isFile) ?? null;\n}\n\n/**\n * Walk PATH for the manager's shim and turn it into its script. Probes the\n * PATHEXT extensions on win32 for the same reason `onPath` in skill-wiring.ts\n * does: the real file there is `npm.cmd`, never a bare `npm`.\n */\nfunction scriptOnPath(\n bin: string,\n suffixes: readonly string[],\n env: NodeJS.ProcessEnv,\n): string | null {\n const exts =\n process.platform === 'win32'\n ? ['', ...(env.PATHEXT ?? '.EXE;.CMD;.BAT;.COM').split(';').filter((e) => e.length > 0)]\n : [''];\n for (const part of (env.PATH ?? '').split(delimiter)) {\n if (part.length === 0) continue;\n for (const ext of exts) {\n if (!isFile(join(part, `${bin}${ext}`))) continue;\n // POSIX package managers link the shim straight at the script, which is\n // what makes this layout-independent rather than a longer guess list.\n //\n // The endsWith is a CORRECTNESS check, not a security guard: it asks \"did\n // this symlink land on npm's script or on something else\", and a shim\n // pointed elsewhere returns null, which falls back to spawning that same\n // retargeted shim anyway. PATH poisoning is out of scope by construction —\n // an attacker ahead of npm on PATH owns every tool the user runs, and the\n // pre-existing fallback `spawn('npm', ...)` resolved through the same PATH.\n const real = realpathOrNull(join(part, `${bin}${ext}`));\n if (real !== null && suffixes.some((suffix) => real.endsWith(suffix))) return real;\n const near = scriptNear(part, bin);\n if (near !== null) return near;\n }\n }\n return null;\n}\n\nfunction isFile(p: string): boolean {\n try {\n return statSync(p).isFile();\n } catch {\n return false;\n }\n}\n\nfunction realpathOrNull(p: string): string | null {\n try {\n return realpathSync(p);\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,SAAS,UAAU,IAAI,aAAa;AACpD,SAAS,SAAS,MAAM,UAAU,WAAW;AAqBtC,IAAM,cAAc;AAO3B,eAAsB,eAAe,WAAoD;AACvF,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC5B,UAAU,IAAI,OAAO,SAAS,CAAC,MAAM,MAAM,SAAS,KAAK,WAAW,IAAI,GAAG,MAAM,CAAC,CAAU;AAAA,EAC9F,EAAE,MAAM,MAAM,IAAI;AAClB,SAAO,YAAY,OAAO,SAAa,OAAO,YAAY,OAAO;AACnE;AAGO,SAAS,iBAAiB,MAAsB;AACrD,SAAO,KAAK,MAAM,UAAU,WAAW;AACzC;AAIA,eAAsB,oBAAoB,KAAmC;AAC3E,QAAM,QAAQ,MAAM,MAAM,GAAG,EAAE,MAAM,MAAM,IAAI;AAC/C,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,CAAC,MAAM,YAAY,KAAK,MAAM,eAAe,EAAG,QAAO;AAC3D,MAAI;AACF,UAAM,WAAW,KAAK;AAAA,MACpB,MAAM,SAAS,KAAK,KAAK,kBAAkB,aAAa,GAAG,MAAM;AAAA,IACnE;AACA,UAAM,SACJ,SAAS,aAAa,QACtB,OAAO,SAAS,aAAa,YAC7B,gBAAgB,SAAS;AAC3B,WAAO,SAAS,SAAS,eAAe,SAAS,SAAS;AAAA,EAC5D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAMA,eAAe,aAAa,KAAa,MAAsC;AAC7E,QAAM,UAAoB,CAAC;AAC3B,WAAS,IAAI,QAAQ,IAAI,GAAG,MAAM,KAAK,IAAI,QAAQ,C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