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
@@ -1,35 +1,19 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import {
3
- ROUTER_PATH
4
- } from "./chunk-UKY4CHNC.js";
5
2
  import {
6
3
  NUDGE_OPT_OUT,
7
4
  channelTag,
8
5
  fetchDistTags,
9
- isNewer,
10
6
  resolveTarget
11
- } from "./chunk-KXVP2VKA.js";
12
- import {
13
- MOD_FILES,
14
- OWNER_MARKER,
15
- PLUGIN_DIR,
16
- PLUGIN_FILES,
17
- renderPluginFiles
18
- } from "./chunk-GA7JETVM.js";
7
+ } from "./chunk-I5TDIUKM.js";
19
8
  import {
20
9
  underAgentHarness
21
10
  } from "./chunk-KOGZDMHO.js";
22
11
  import {
23
- CLAUDE_CODE_FLOOR,
24
- claudeConfigDir,
25
- findClaudeBinary,
26
- jsonList,
27
- jsonResult,
28
- readClaudeCode,
29
- runClaude,
30
- userMcpFile,
31
- userSettingsPath
32
- } from "./chunk-QXP3Z3JN.js";
12
+ ROUTER_PATH
13
+ } from "./chunk-PKHI276N.js";
14
+ import {
15
+ readMcpServers
16
+ } from "./chunk-B7EM4GGF.js";
33
17
  import {
34
18
  CLI_SKILL_NAMES,
35
19
  FEE_APPROVAL,
@@ -47,238 +31,133 @@ import {
47
31
  skillsDirsFor,
48
32
  spendChoiceQuestion,
49
33
  spendOptions
50
- } from "./chunk-5MARFNSB.js";
51
- import {
52
- LEGACY_HOOK_TOOL,
53
- LEGACY_MCP_SERVER_NAME,
54
- LEGACY_REQUEST_TOOL,
55
- MARKETPLACE_NAME,
56
- PLUGIN_ID,
57
- PLUGIN_NAME,
58
- SKILLS_DIR_PLUGIN_ID
59
- } from "./chunk-WJXLQXJY.js";
60
- import {
61
- SUGGESTED_FUND_USD
62
- } from "./chunk-4ZZO6ULA.js";
34
+ } from "./chunk-AD226HDR.js";
63
35
  import {
64
36
  emitWriteNotice,
65
37
  paint,
66
38
  sanitizeForTerminal
67
- } from "./chunk-K72RURN3.js";
39
+ } from "./chunk-VJUVFZ2D.js";
40
+ import {
41
+ SUGGESTED_FUND_USD
42
+ } from "./chunk-HDPUXS3Z.js";
68
43
  import {
69
44
  askText,
70
45
  selectOne
71
46
  } from "./chunk-DOQGNFHM.js";
72
47
  import {
73
- readAliveStamp
74
- } from "./chunk-I3EQFHCD.js";
48
+ MANAGERS,
49
+ classifyManager,
50
+ inspectPluginFolder,
51
+ pluginFolderPath,
52
+ readModSources,
53
+ refuse,
54
+ removePluginFolder,
55
+ resolveManagerScript,
56
+ writePluginFolder
57
+ } from "./chunk-TAW4UFFF.js";
58
+ import {
59
+ PLUGIN_DIR,
60
+ renderPluginFiles
61
+ } from "./chunk-E7LGOMH6.js";
62
+ import {
63
+ LEGACY_HOOK_TOOL,
64
+ LEGACY_MCP_SERVER_NAME,
65
+ LEGACY_REQUEST_TOOL,
66
+ MARKETPLACE_NAME,
67
+ MCP_SERVER_NAME,
68
+ PLUGIN_ID,
69
+ PLUGIN_NAME,
70
+ SKILLS_DIR_PLUGIN_ID
71
+ } from "./chunk-MPZUYCAP.js";
75
72
  import {
76
73
  envProxySupported,
74
+ proxyNodeStep,
75
+ proxySkipped,
77
76
  proxyVariable
78
- } from "./chunk-S4SAZ7OD.js";
77
+ } from "./chunk-3FMZGI7I.js";
79
78
  import {
80
79
  httpRequest
81
- } from "./chunk-AGZ7PJKY.js";
80
+ } from "./chunk-OTWLERSW.js";
82
81
  import {
83
- hasCode
84
- } from "./chunk-2I4QTOLB.js";
82
+ CLAUDE_CODE_FLOOR,
83
+ claudeConfigDir,
84
+ findClaudeBinary,
85
+ jsonList,
86
+ jsonResult,
87
+ readClaudeCode,
88
+ runClaude,
89
+ userMcpFile,
90
+ userSettingsPath
91
+ } from "./chunk-QXP3Z3JN.js";
92
+ import {
93
+ package_default
94
+ } from "./chunk-YUY4SAGM.js";
85
95
  import {
86
96
  resolveContextSettings
87
- } from "./chunk-7WU4OPLP.js";
97
+ } from "./chunk-AV5NZMYO.js";
88
98
  import {
89
99
  parseUsdToAtomic,
90
100
  toMoney
91
101
  } from "./chunk-Y527D4TV.js";
102
+ import {
103
+ readAliveStamp
104
+ } from "./chunk-WOM257PW.js";
105
+ import {
106
+ WALLET_REASONS,
107
+ agentFixFor
108
+ } from "./chunk-BFDQ4WNW.js";
109
+ import {
110
+ REPAIR_CLAUSE
111
+ } from "./chunk-X5ZBP3IY.js";
112
+ import {
113
+ hasCode
114
+ } from "./chunk-2I4QTOLB.js";
92
115
  import {
93
116
  MAX_AUTO_SPEND_FLOOR_ATOMIC,
94
117
  MAX_AUTO_SPEND_FLOOR_WHY,
95
118
  loadRawConfig
96
- } from "./chunk-YVFXE7RR.js";
119
+ } from "./chunk-2GNOFONN.js";
97
120
  import {
98
121
  PRODUCTION_ORIGIN,
99
122
  isSameDeployment
100
123
  } from "./chunk-XQJXNMSB.js";
124
+ import {
125
+ writeFileAtomic
126
+ } from "./chunk-7WEQQJLG.js";
101
127
  import {
102
128
  CliError
103
129
  } from "./chunk-3UCIG4TG.js";
104
130
  import {
105
- writeFileAtomic
106
- } from "./chunk-7WEQQJLG.js";
131
+ runtimeBuild,
132
+ runtimeStatePath
133
+ } from "./chunk-G75OPGAK.js";
107
134
  import {
108
- defaultDataDir
109
- } from "./chunk-SJLTEINJ.js";
135
+ isNewer
136
+ } from "./chunk-EDJWHDDL.js";
110
137
  import {
111
- package_default
112
- } from "./chunk-5C32RLTA.js";
138
+ defaultDataDir,
139
+ runtimeDir
140
+ } from "./chunk-OJNTCYQQ.js";
113
141
 
114
142
  // src/commands/update.ts
115
143
  import { spawn } from "node:child_process";
116
- import { existsSync as existsSync2, statSync as statSync2 } from "node:fs";
144
+ import { existsSync as existsSync2, statSync } from "node:fs";
145
+ import { rm as rm2 } from "node:fs/promises";
117
146
  import { homedir as homedir2 } from "node:os";
118
- import { resolve, sep as sep3 } from "node:path";
147
+ import { resolve as resolve2, sep as sep2 } from "node:path";
119
148
  import { fileURLToPath as fileURLToPath3 } from "node:url";
120
149
 
121
- // src/lib/install-location.ts
122
- import { existsSync, realpathSync, statSync } from "node:fs";
123
- import { delimiter, dirname, join, sep } from "node:path";
124
- var REFUSALS = [
125
- {
126
- test: isSourceCheckout,
127
- error: () => new CliError("REFUSED", "tenjin-cli is running from a source checkout, not an install", {
128
- fix: "Update the checkout instead: git pull && pnpm install"
129
- }),
130
- needsVersion: false,
131
- appliesToCheck: false
132
- },
133
- {
134
- test: (moduleDir) => moduleDir.split(sep).includes("_npx"),
135
- error: (spec) => new CliError("REFUSED", "tenjin-cli is running from the npx cache, not an install", {
136
- // Writing a global here would "succeed" and change nothing: the next
137
- // `npx tenjin` still resolves its own cached copy.
138
- fix: `npx fetches its own copy every time. To keep one: npm i -g ${spec}`
139
- }),
140
- needsVersion: true,
141
- appliesToCheck: false
142
- },
143
- {
144
- // The ONLY manager still refused. `yarn global add` is yarn-1 only, and
145
- // berry dropped global installs altogether, so there is no one command this
146
- // can drive across the versions a user might have. Every other manager is
147
- // delegated to rather than refused (see MANAGERS).
148
- test: (moduleDir) => classifyManager(moduleDir) === "yarn",
149
- error: (spec) => new CliError(
150
- "REFUSED",
151
- "This tenjin-cli was installed with yarn, whose global install exists only in yarn 1",
152
- { fix: `yarn global add ${spec}` }
153
- ),
154
- needsVersion: true,
155
- appliesToCheck: false
156
- },
157
- {
158
- // Scoped to npm on purpose: the prefix-vs-project-root test is written for
159
- // npm's layout. pnpm's global store and bun's global dir both keep a
160
- // package.json beside `node_modules`, so an unscoped test would read either
161
- // as a project-local install and refuse the very case we now delegate.
162
- test: (moduleDir) => classifyManager(moduleDir) === "npm" && !isGlobalTree(moduleDir),
163
- error: (spec) => new CliError(
164
- "REFUSED",
165
- "This tenjin-cli is a project-local dependency, not a global install",
166
- {
167
- fix: `Update it where it is declared: npm i ${spec}`
168
- }
169
- ),
170
- needsVersion: true,
171
- appliesToCheck: false
172
- }
173
- ];
174
- function refuse(moduleDir, opts) {
175
- for (const entry of REFUSALS) {
176
- if (opts.check && !entry.appliesToCheck) continue;
177
- if (entry.needsVersion !== (opts.spec !== null)) continue;
178
- if (entry.test(moduleDir)) throw entry.error(opts.spec ?? "", moduleDir);
179
- }
180
- }
181
- function isSourceCheckout(moduleDir) {
182
- let dir = moduleDir;
183
- for (let i = 0; i < 8; i += 1) {
184
- if (existsSync(join(dir, "package.json"))) return existsSync(join(dir, "src"));
185
- const parent = dirname(dir);
186
- if (parent === dir) break;
187
- dir = parent;
188
- }
189
- return false;
190
- }
191
- function isGlobalTree(moduleDir) {
192
- const segs = moduleDir.split(sep);
193
- const i = segs.lastIndexOf("node_modules");
194
- if (i <= 0) return false;
195
- return !existsSync(join(segs.slice(0, i).join(sep), "package.json"));
196
- }
197
- function classifyManager(moduleDir) {
198
- const segs = moduleDir.split(sep);
199
- const pair = (a, b) => segs.includes(a) && segs.includes(b);
200
- if (segs.includes(".pnpm") || pair("pnpm", "global")) return "pnpm";
201
- if (segs.includes(".bun")) return "bun";
202
- if (segs.includes(".yarn") || pair("yarn", "global")) return "yarn";
203
- return "npm";
204
- }
205
- var MANAGERS = {
206
- npm: {
207
- bin: "npm",
208
- scriptSuffixes: ["npm-cli.js"],
209
- besideNode: true,
210
- args: (spec) => ["install", "-g", "--ignore-scripts", spec],
211
- manual: (spec) => `npm i -g ${spec}`
212
- },
213
- pnpm: {
214
- bin: "pnpm",
215
- // corepack's shim resolves to `pnpm.js`, a standalone install to `pnpm.cjs`.
216
- scriptSuffixes: [".cjs", ".js"],
217
- besideNode: false,
218
- args: (spec) => ["add", "-g", "--ignore-scripts", spec],
219
- manual: (spec) => `pnpm add -g ${spec}`
220
- },
221
- bun: {
222
- bin: "bun",
223
- scriptSuffixes: [],
224
- besideNode: false,
225
- // No --ignore-scripts: bun's flag surface for it is not stable across the
226
- // versions in the wild, and an unknown flag would fail the install outright.
227
- args: (spec) => ["add", "-g", spec],
228
- manual: (spec) => `bun add -g ${spec}`
229
- }
230
- };
231
- function resolveManagerScript(manager, execPath, env = process.env) {
232
- const plan = MANAGERS[manager];
233
- if (plan.scriptSuffixes.length === 0) return null;
234
- const beside = plan.besideNode ? scriptNear(dirname(execPath), plan.bin) : null;
235
- return beside ?? scriptOnPath(plan.bin, plan.scriptSuffixes, env);
236
- }
237
- function scriptNear(dir, bin) {
238
- const candidates = [
239
- join(dir, "node_modules", bin, "bin", `${bin}-cli.js`),
240
- join(dir, "..", "lib", "node_modules", bin, "bin", `${bin}-cli.js`)
241
- ];
242
- return candidates.find(isFile) ?? null;
243
- }
244
- function scriptOnPath(bin, suffixes, env) {
245
- const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter((e) => e.length > 0)] : [""];
246
- for (const part of (env.PATH ?? "").split(delimiter)) {
247
- if (part.length === 0) continue;
248
- for (const ext of exts) {
249
- if (!isFile(join(part, `${bin}${ext}`))) continue;
250
- const real = realpathOrNull(join(part, `${bin}${ext}`));
251
- if (real !== null && suffixes.some((suffix) => real.endsWith(suffix))) return real;
252
- const near = scriptNear(part, bin);
253
- if (near !== null) return near;
254
- }
255
- }
256
- return null;
257
- }
258
- function isFile(p) {
259
- try {
260
- return statSync(p).isFile();
261
- } catch {
262
- return false;
263
- }
264
- }
265
- function realpathOrNull(p) {
266
- try {
267
- return realpathSync(p);
268
- } catch {
269
- return null;
270
- }
271
- }
272
-
273
150
  // src/router/install.ts
274
- import { readFile as readFile4, realpath } from "node:fs/promises";
151
+ import { existsSync } from "node:fs";
152
+ import { readFile as readFile3, realpath, stat as stat3 } from "node:fs/promises";
275
153
  import { homedir } from "node:os";
276
- import { isAbsolute, join as join7 } from "node:path";
154
+ import { dirname as dirname3, isAbsolute, join as join4, relative, resolve, sep } from "node:path";
155
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
277
156
 
278
157
  // src/lib/skill-placement.ts
279
158
  import { lstatSync } from "node:fs";
280
159
  import { readdir, rm, rmdir } from "node:fs/promises";
281
- import { dirname as dirname2, join as join2 } from "node:path";
160
+ import { dirname, join } from "node:path";
282
161
  function isRealDirectory(path) {
283
162
  try {
284
163
  return lstatSync(path, { throwIfNoEntry: false })?.isDirectory() === true;
@@ -291,11 +170,11 @@ async function removeOwnedSkill(name, skillsDir) {
291
170
  if (!isRealDirectory(skillsDir)) {
292
171
  return { changed: false };
293
172
  }
294
- const skillDir = join2(skillsDir, name);
173
+ const skillDir = join(skillsDir, name);
295
174
  if (!isRealDirectory(skillDir)) {
296
175
  return { changed: false };
297
176
  }
298
- const path = join2(skillDir, "SKILL.md");
177
+ const path = join(skillDir, "SKILL.md");
299
178
  const read = await readSkillFile(path);
300
179
  if (read.kind === "absent") return { changed: false };
301
180
  if (read.kind !== "ok" || skillFrontmatterName(read.bytes.toString("utf8")) !== name) {
@@ -305,9 +184,9 @@ async function removeOwnedSkill(name, skillsDir) {
305
184
  const subdirs = /* @__PURE__ */ new Set();
306
185
  for (const rel of shipped) {
307
186
  if (rel === "SKILL.md") continue;
308
- const file = join2(skillDir, rel);
309
- if (!isRealDirectory(dirname2(file))) continue;
310
- subdirs.add(dirname2(file));
187
+ const file = join(skillDir, rel);
188
+ if (!isRealDirectory(dirname(file))) continue;
189
+ subdirs.add(dirname(file));
311
190
  if (lstatSync(file, { throwIfNoEntry: false })?.isFile() === true) await rm(file);
312
191
  }
313
192
  await rm(path, { force: true });
@@ -322,7 +201,7 @@ async function removeRetiredSkills(home, project) {
322
201
  const dirs = [...skillsDirsFor(home), ...project ? skillsDirsFor(project) : []];
323
202
  for (const dir of new Set(dirs)) {
324
203
  for (const name of [...RETIRED_SKILL_NAMES, ...CLI_SKILL_NAMES]) {
325
- if ((await removeOwnedSkill(name, dir)).changed) removed.push(join2(dir, name));
204
+ if ((await removeOwnedSkill(name, dir)).changed) removed.push(join(dir, name));
326
205
  }
327
206
  }
328
207
  return removed;
@@ -330,7 +209,7 @@ async function removeRetiredSkills(home, project) {
330
209
 
331
210
  // src/router/legacy-install.ts
332
211
  import { readFile, stat } from "node:fs/promises";
333
- import { join as join3 } from "node:path";
212
+ import { join as join2 } from "node:path";
334
213
 
335
214
  // src/router/status-line-wiring.ts
336
215
  var STATUS_LINE_COMMAND = "tenjin status-line";
@@ -562,101 +441,15 @@ async function removeMcpEntry(opts, out) {
562
441
  }
563
442
  }
564
443
  function projectMcpFile(cwd) {
565
- return join3(cwd, ".mcp.json");
444
+ return join2(cwd, ".mcp.json");
566
445
  }
567
446
 
568
447
  // src/router/plugin-registration.ts
569
- import { readFile as readFile3, stat as stat2 } from "node:fs/promises";
570
- import { dirname as dirname4, join as join5 } from "node:path";
448
+ import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
449
+ import { dirname as dirname2, join as join3 } from "node:path";
571
450
  import { fileURLToPath } from "node:url";
572
-
573
- // src/router/plugin-folder.ts
574
- import { lstat, readdir as readdir2, readFile as readFile2, rm as rm2, rmdir as rmdir2 } from "node:fs/promises";
575
- import { dirname as dirname3, join as join4, relative, sep as sep2 } from "node:path";
576
- var FOLDER_NAME = "tenjin-router";
577
- async function readModSources(pluginDir) {
578
- const entries = await Promise.all(
579
- MOD_FILES.map(async (path) => [path, await readFile2(join4(pluginDir, path), "utf8")])
580
- ).catch(() => null);
581
- return entries === null ? void 0 : Object.fromEntries(entries);
582
- }
583
- function pluginFolderPath(base) {
584
- return join4(base, "skills", FOLDER_NAME);
585
- }
586
- async function inspectPluginFolder(dir) {
587
- const entry = await lstat(dir).catch(() => null);
588
- if (entry === null) return "absent";
589
- if (!entry.isDirectory() || entry.isSymbolicLink()) return "foreign";
590
- try {
591
- const manifest = JSON.parse(
592
- await readFile2(join4(dir, ".claude-plugin", "plugin.json"), "utf8")
593
- );
594
- const marked = manifest.metadata !== null && typeof manifest.metadata === "object" && OWNER_MARKER in manifest.metadata;
595
- return manifest.name === PLUGIN_NAME && marked ? "ours" : "foreign";
596
- } catch {
597
- return "foreign";
598
- }
599
- }
600
- async function writePluginFolder(dir, files) {
601
- const state = await inspectPluginFolder(dir);
602
- if (state === "foreign") {
603
- return {
604
- path: dir,
605
- state: "refused",
606
- reason: `${dir} exists and is not a folder this CLI wrote, so it was left as it is`
607
- };
608
- }
609
- try {
610
- for (const path of PLUGIN_FILES) {
611
- const body = files[path];
612
- if (body === void 0) continue;
613
- await writeFileAtomic(join4(dir, path), body);
614
- }
615
- } catch (err) {
616
- return {
617
- path: dir,
618
- state: "refused",
619
- reason: err instanceof Error ? err.message : String(err)
620
- };
621
- }
622
- return { path: dir, state: "written" };
623
- }
624
- async function removePluginFolder(dir) {
625
- const state = await inspectPluginFolder(dir);
626
- if (state === "absent") return { path: dir, removed: false, left: [] };
627
- if (state === "foreign") {
628
- return {
629
- path: dir,
630
- removed: false,
631
- left: [],
632
- reason: `${dir} is not a folder this CLI wrote, so nothing in it was removed`
633
- };
634
- }
635
- for (const path of PLUGIN_FILES) await rm2(join4(dir, path), { force: true });
636
- const subdirs = [...new Set(PLUGIN_FILES.map((p) => dirname3(p)).filter((d) => d !== "."))].sort(
637
- (a, b) => b.split("/").length - a.split("/").length
638
- );
639
- for (const sub of subdirs) await rmdir2(join4(dir, sub)).catch(() => void 0);
640
- const left = await listFiles(dir);
641
- if (left.length === 0) await rmdir2(dir).catch(() => void 0);
642
- return { path: dir, removed: true, left };
643
- }
644
- async function listFiles(dir) {
645
- const out = [];
646
- const walk = async (current) => {
647
- for (const entry of await readdir2(current, { withFileTypes: true }).catch(() => [])) {
648
- const path = join4(current, entry.name);
649
- if (entry.isDirectory()) await walk(path);
650
- else out.push(relative(dir, path).split(sep2).join("/"));
651
- }
652
- };
653
- await walk(dir);
654
- return out.sort();
655
- }
656
-
657
- // src/router/plugin-registration.ts
658
451
  function folderFor(scope, env, home, cwd) {
659
- return pluginFolderPath(scope === "local" ? join5(cwd, ".claude") : claudeConfigDir(env, home));
452
+ return pluginFolderPath(scope === "local" ? join3(cwd, ".claude") : claudeConfigDir(env, home));
660
453
  }
661
454
  async function registerPlugin(opts) {
662
455
  const folder = folderFor(opts.scope, opts.env, opts.home, opts.cwd);
@@ -711,11 +504,10 @@ async function registerPlugin(opts) {
711
504
  }
712
505
  const written = await writePluginFolder(
713
506
  folder,
714
- renderPluginFiles(
715
- opts.version,
716
- opts.cliEntry ?? packageCliEntry(),
717
- await packageMod(opts.hostsDir)
718
- )
507
+ renderPluginFiles(opts.version, opts.cliEntry ?? packageCliEntry(), {
508
+ node: opts.node,
509
+ mod: await packageMod(opts.hostsDir)
510
+ })
719
511
  );
720
512
  if (written.state === "written") {
721
513
  return {
@@ -779,10 +571,14 @@ async function viaPluginCommands(binary, hosts, opts, steps) {
779
571
  return { ok: true, state: "installed" };
780
572
  }
781
573
  if (installed === available) return { ok: true, state: "current" };
782
- const update = await step(steps, ["plugin", "update", PLUGIN_ID, ...scopeArgs, "--json"], run);
783
- if (!update.ok) return { ok: false, reason: `claude plugin update failed: ${update.detail}` };
574
+ const update2 = await step(steps, ["plugin", "update", PLUGIN_ID, ...scopeArgs, "--json"], run);
575
+ if (!update2.ok) return { ok: false, reason: `claude plugin update failed: ${update2.detail}` };
784
576
  return { ok: true, state: "updated" };
785
577
  }
578
+ function marketplaceAdded(reg, hosts) {
579
+ const add = `claude plugin marketplace add ${hosts} `;
580
+ return reg.steps.some((s) => s.ok && s.command.startsWith(add));
581
+ }
786
582
  async function step(steps, args, run) {
787
583
  const out = await run(args);
788
584
  const result = jsonResult(out.stdout);
@@ -801,9 +597,9 @@ async function ownMarketplace(row) {
801
597
  const path = typeof row.path === "string" ? row.path : void 0;
802
598
  if (row.source !== "directory" || path === void 0) return false;
803
599
  if (await stat2(path).catch(() => null) === null) {
804
- return /tenjin-cli[\\/]dist[\\/]hosts[\\/]claude$/.test(path);
600
+ return /tenjin-cli[\\/]dist[\\/]hosts[\\/]claude$/.test(path) || /[\\/]runtime[\\/]claude$/.test(path);
805
601
  }
806
- return await inspectPluginFolder(join5(path, PLUGIN_DIR)) === "ours";
602
+ return await inspectPluginFolder(join3(path, PLUGIN_DIR)) === "ours";
807
603
  }
808
604
  async function existingCopy(binary, env, home, cwd) {
809
605
  const out = await runClaude(binary, ["plugin", "list", "--json"], { env, cwd });
@@ -814,10 +610,40 @@ async function existingCopy(binary, env, home, cwd) {
814
610
  );
815
611
  return typeof row?.id === "string" ? row.id : null;
816
612
  }
613
+ async function recordedInstalls(env, home) {
614
+ let raw;
615
+ try {
616
+ raw = await readFile2(
617
+ join3(claudeConfigDir(env, home), "plugins", "installed_plugins.json"),
618
+ "utf8"
619
+ );
620
+ } catch (err) {
621
+ return hasCode(err, "ENOENT") ? [] : null;
622
+ }
623
+ let plugins;
624
+ try {
625
+ plugins = JSON.parse(raw).plugins;
626
+ } catch {
627
+ return null;
628
+ }
629
+ if (typeof plugins !== "object" || plugins === null || Array.isArray(plugins)) return null;
630
+ const entries = plugins[PLUGIN_ID];
631
+ if (!Array.isArray(entries)) return [];
632
+ const records = [];
633
+ for (const entry of entries) {
634
+ if (typeof entry !== "object" || entry === null) continue;
635
+ const { scope, projectPath } = entry;
636
+ if (scope === "user") records.push({ scope, projectPath: null });
637
+ else if (scope === "local" && typeof projectPath === "string" && projectPath.length > 0) {
638
+ records.push({ scope, projectPath });
639
+ }
640
+ }
641
+ return records;
642
+ }
817
643
  async function installedThroughCommands(env, home) {
818
644
  try {
819
- const raw = await readFile3(
820
- join5(claudeConfigDir(env, home), "plugins", "installed_plugins.json"),
645
+ const raw = await readFile2(
646
+ join3(claudeConfigDir(env, home), "plugins", "installed_plugins.json"),
821
647
  "utf8"
822
648
  );
823
649
  const plugins = JSON.parse(raw).plugins;
@@ -826,31 +652,40 @@ async function installedThroughCommands(env, home) {
826
652
  return false;
827
653
  }
828
654
  }
829
- async function packageHostsDir(moduleDir = dirname4(fileURLToPath(import.meta.url))) {
830
- const catalog = join5(moduleDir, "hosts", "claude", ".claude-plugin", "marketplace.json");
655
+ async function packageHostsDir(moduleDir = dirname2(fileURLToPath(import.meta.url))) {
656
+ const catalog = join3(moduleDir, "hosts", "claude", ".claude-plugin", "marketplace.json");
831
657
  const stable = versionFreeEntry(catalog) ?? catalog;
832
658
  if ((await stat2(stable).catch(() => null))?.isFile() !== true) return null;
833
- return dirname4(dirname4(stable));
659
+ return dirname2(dirname2(stable));
834
660
  }
835
661
  async function packageMod(hostsDir) {
836
662
  const hosts = hostsDir === void 0 ? await packageHostsDir() : hostsDir;
837
- return hosts === null ? void 0 : readModSources(join5(hosts, PLUGIN_DIR));
663
+ return hosts === null ? void 0 : readModSources(join3(hosts, PLUGIN_DIR));
838
664
  }
839
- function packageCliEntry(moduleDir = dirname4(fileURLToPath(import.meta.url))) {
840
- const entry = join5(moduleDir, "index.js");
665
+ function packageCliEntry(moduleDir = dirname2(fileURLToPath(import.meta.url))) {
666
+ const entry = join3(moduleDir, "index.js");
841
667
  return versionFreeEntry(entry) ?? entry;
842
668
  }
843
669
  async function readPluginListing(binary, env, cwd) {
844
670
  const out = await runClaude(binary, ["plugin", "list", "--json"], { env, cwd });
845
671
  const rows = out.code === 0 ? jsonList(out.stdout) : null;
846
- if (rows === null) return { id: null, enabled: false, version: null, read: false };
672
+ if (rows === null) {
673
+ return { id: null, enabled: false, version: null, read: false, scope: null, projects: [] };
674
+ }
675
+ const projects = rows.filter(
676
+ (r) => r.id === PLUGIN_ID && r.enabled !== true && typeof r.projectPath === "string" && r.projectPath.length > 0
677
+ ).map((r) => r.projectPath);
847
678
  const row = rows.find((r) => r.id === PLUGIN_ID && r.enabled === true) ?? rows.find((r) => r.id === SKILLS_DIR_PLUGIN_ID && r.enabled === true) ?? rows.find((r) => r.id === PLUGIN_ID || r.id === SKILLS_DIR_PLUGIN_ID);
848
- if (row === void 0) return { id: null, enabled: false, version: null, read: true };
679
+ if (row === void 0) {
680
+ return { id: null, enabled: false, version: null, read: true, scope: null, projects };
681
+ }
849
682
  return {
850
683
  id: String(row.id),
851
684
  enabled: row.enabled === true,
852
685
  version: typeof row.version === "string" ? row.version : null,
853
- read: true
686
+ read: true,
687
+ scope: typeof row.scope === "string" ? row.scope : null,
688
+ projects
854
689
  };
855
690
  }
856
691
  async function folderState(scope, env, home, cwd) {
@@ -972,111 +807,20 @@ function proxyCredentialsFix(env) {
972
807
  return `Put the proxy's credentials in ${proxy} (\`http://user:password@proxy:port\`), then try again.`;
973
808
  }
974
809
 
975
- // src/router/mcp-processes.ts
976
- import { execFile } from "node:child_process";
977
- import { stat as stat3 } from "node:fs/promises";
978
- import { dirname as dirname5, join as join6 } from "node:path";
979
- import { fileURLToPath as fileURLToPath2 } from "node:url";
980
- import { promisify } from "node:util";
981
- var exec = promisify(execFile);
982
- var listMcpProcesses = async () => {
983
- if (process.platform === "win32" || typeof process.getuid !== "function") return null;
984
- try {
985
- const { stdout } = await exec(
986
- "ps",
987
- ["-U", String(process.getuid()), "-o", "pid=,lstart=,args="],
988
- { timeout: 5e3, env: { ...process.env, LC_ALL: "C" }, maxBuffer: 4 * 1024 * 1024 }
989
- );
990
- return parsePs(stdout, process.pid);
991
- } catch {
992
- return null;
993
- }
994
- };
995
- var PS_LINE = /^\s*(\d+)\s+(\w{3}\s+\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.*)$/;
996
- function parsePs(stdout, selfPid) {
997
- const found = [];
998
- for (const line of stdout.split("\n")) {
999
- const m = PS_LINE.exec(line);
1000
- if (m === null) continue;
1001
- const pid = Number(m[1]);
1002
- if (pid === selfPid || !isTenjinMcp(m[3])) continue;
1003
- const startedAt = Date.parse(m[2].replace(/\s+/g, " "));
1004
- found.push({ pid, startedAt: Number.isNaN(startedAt) ? null : startedAt });
1005
- }
1006
- return found;
1007
- }
1008
- function isTenjinMcp(args) {
1009
- const tokens = args.trim().split(/\s+/);
1010
- const bin = tokens.findIndex(
1011
- (t) => /(^|[/\\])tenjin(\.js|\.cmd)?$/.test(t) || /[/\\]tenjin-cli[/\\]/.test(t) || /[/\\]hosts[/\\]claude[/\\]tenjin[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]index\.js$/.test(t)
1012
- );
1013
- return bin >= 0 && tokens[bin + 1] === "mcp";
1014
- }
1015
- var installedAt = async () => {
1016
- let dir = dirname5(fileURLToPath2(import.meta.url));
1017
- for (let i = 0; i < 6; i += 1) {
1018
- try {
1019
- const st = await stat3(join6(dir, "package.json"));
1020
- return Math.max(st.ctimeMs, st.mtimeMs);
1021
- } catch {
1022
- dir = dirname5(dir);
1023
- }
1024
- }
1025
- return null;
1026
- };
1027
- var RECONNECT_FIX = "Type /reload-plugins in this Claude Code session, or start a new session.";
1028
- var NEW_SESSION_FIX = "Start a new Claude Code session: the earlier Tenjin setup is still in this one, and /reload-plugins would run both.";
1029
- function mcpServersState(procs, installed, version = package_default.version, fix = RECONNECT_FIX) {
1030
- const check = (detail) => ({
1031
- stale: 0,
1032
- check: { name: "mcp server", status: "ok", required: false, detail }
1033
- });
1034
- if (procs === null) {
1035
- return check("unknown: running `tenjin mcp` processes cannot be listed on this platform");
1036
- }
1037
- if (procs.length === 0) return check("none running (starts with the next session)");
1038
- if (installed === null) {
1039
- return check(`${procs.length} running; when this build was installed is unknown`);
1040
- }
1041
- const stale = procs.filter((p) => p.startedAt !== null && p.startedAt < installed).length;
1042
- if (stale === 0) {
1043
- return check(`${procs.length} running, all started after this install`);
1044
- }
1045
- const which = stale === 1 ? "process" : "processes";
1046
- return {
1047
- stale,
1048
- check: {
1049
- name: "mcp server",
1050
- status: "warn",
1051
- required: false,
1052
- detail: `${stale} running \`tenjin mcp\` ${which} started before this install (${version}), so ${stale === 1 ? "it runs" : "they run"} the older build, where the hooks can fail with "Tool hook not found"`,
1053
- fix
1054
- }
1055
- };
1056
- }
1057
- async function readMcpServers(deps = {}, opts = {}) {
1058
- const [procs, installed] = await Promise.all([
1059
- (deps.listMcpProcesses ?? listMcpProcesses)().catch(() => null),
1060
- (deps.installedAt ?? installedAt)().catch(() => null)
1061
- ]);
1062
- const fix = opts.settingsInstallPending === true ? NEW_SESSION_FIX : RECONNECT_FIX;
1063
- return mcpServersState(procs, installed, package_default.version, fix);
1064
- }
1065
-
1066
810
  // src/router/install.ts
1067
811
  var DISCLOSURE = [
1068
812
  "What leaves this machine: the bounded text of each prompt, each native search query or URL (and, when one came back short, its status, size or error), each task handed to a subagent, and each question your assistant asks you with your answers, sent to Tenjin for the free routing gate, beside this session's id. When the gate offers free library docs for a search, that search query also goes to Tenjin's docs lookup, which asks Context7.",
1069
813
  "What is kept when a lookup is paid: the capability chosen, a hash of the contract, a hash of the arguments, and your wallet address. No prompt text, no arguments, no hint text.",
1070
814
  "What never leaves: your private key. It is decrypted in this CLI to sign, and never sent anywhere."
1071
815
  ];
1072
- var RELOAD_STEP = "type /reload-plugins in this Claude Code session, or start a new session, so Tenjin loads";
1073
816
  var NEW_SESSION_STEP = "start a new Claude Code session so Tenjin loads";
1074
- function loadStep(settingsInstallPresent) {
1075
- return settingsInstallPresent ? NEW_SESSION_STEP : RELOAD_STEP;
817
+ var RELOAD_STEP = NEW_SESSION_STEP;
818
+ function loadStep(_settingsInstallPresent) {
819
+ return NEW_SESSION_STEP;
1076
820
  }
1077
821
  function settingsInstallPaths(project, env, home, cwd) {
1078
822
  return project ? {
1079
- settingsPath: join7(cwd, ".claude", "settings.json"),
823
+ settingsPath: join4(cwd, ".claude", "settings.json"),
1080
824
  mcpFile: projectMcpFile(cwd),
1081
825
  mcpScope: "project"
1082
826
  } : {
@@ -1125,7 +869,7 @@ async function projectInstallHere(cwd, home, env) {
1125
869
  return projectInstallAt(cwd, home, env);
1126
870
  }
1127
871
  async function projectInstallAt(dir, home, env) {
1128
- const local = await readFile4(join7(dir, ".claude", "settings.local.json"), "utf8").then((raw) => JSON.parse(raw)).catch(() => null);
872
+ const local = await readFile3(join4(dir, ".claude", "settings.local.json"), "utf8").then((raw) => JSON.parse(raw)).catch(() => null);
1129
873
  if (local?.enabledPlugins?.[PLUGIN_ID] === true) return true;
1130
874
  if (await isHome(dir, home)) return false;
1131
875
  if ((await folderState("local", env, home, dir)).state === "ours") return true;
@@ -1139,6 +883,7 @@ async function isHome(dir, home) {
1139
883
  ]);
1140
884
  return dirPath === homePath;
1141
885
  }
886
+ var NOTHING_TO_REFRESH = "Nothing to refresh";
1142
887
  async function somethingToRefresh(claude, scope, legacy, env, home, cwd) {
1143
888
  if (legacy.present) return true;
1144
889
  if ((await folderState(scope, env, home, cwd)).state === "ours") return true;
@@ -1164,10 +909,28 @@ async function runRouterInstall(args, ctx, deps = {}) {
1164
909
  const claude = await readClaudeCode(env, cwd, deps.findClaude ?? findClaudeBinary);
1165
910
  const paths = settingsInstallPaths(project, env, home, cwd);
1166
911
  const legacy = await inspectLegacyInstall(paths.settingsPath, paths.mcpFile);
912
+ if (!project) {
913
+ await recordClaudeProjects(ctx.dataDir, config.install?.routerProjects ?? [], env, home);
914
+ }
915
+ const setUpRuntime = () => (deps.runtime ?? defaultRuntime)({
916
+ dataDir: ctx.dataDir,
917
+ home,
918
+ env,
919
+ version: package_default.version,
920
+ moduleDir: dirname3(fileURLToPath2(import.meta.url)),
921
+ refresh: args.refresh === true
922
+ });
1167
923
  if (args.refresh === true && !await somethingToRefresh(claude, scope, legacy, env, home, cwd)) {
924
+ if (!project && hasRuntime(ctx.dataDir, home)) {
925
+ const rt2 = await setUpRuntime();
926
+ if (runtimeLaunch(rt2) !== null) {
927
+ await collectRuntime(rt2.root, await fallbackFolders(ctx.dataDir, env, home, cwd, false));
928
+ }
929
+ return runtimeOnlyRefresh(ctx, rt2, home);
930
+ }
1168
931
  throw new CliError(
1169
932
  "REFUSED",
1170
- `Nothing to refresh: neither the ${PLUGIN_ID} plugin nor a settings install of Tenjin is registered here.`,
933
+ `${NOTHING_TO_REFRESH}: neither the ${PLUGIN_ID} plugin nor a settings install of Tenjin is registered here.`,
1171
934
  { fix: "Run `tenjin install` to set this machine up." }
1172
935
  );
1173
936
  }
@@ -1181,16 +944,28 @@ async function runRouterInstall(args, ctx, deps = {}) {
1181
944
  `Removed retired settings: ${spend.removed.join(", ")}. Automatic router limits remain in effect; manual pay always requires consent.`
1182
945
  ] : [];
1183
946
  const removedSkills = await removeRetiredSkills(home, project ? cwd : void 0);
1184
- const plugin = !claude.meetsFloor && legacy.present ? deferredRegistration(scope, claude) : await registerPlugin({
947
+ const deferred = !claude.meetsFloor && legacy.present;
948
+ const rt = deferred ? null : await setUpRuntime();
949
+ const launch = runtimeLaunch(rt);
950
+ const plugin = deferred ? deferredRegistration(scope, claude) : await registerPlugin({
1185
951
  binary: claude.binary,
1186
952
  scope,
1187
- version: package_default.version,
953
+ version: launch?.version ?? package_default.version,
1188
954
  env,
1189
955
  home,
1190
956
  cwd,
1191
- ...deps.hostsDir !== void 0 ? { hostsDir: deps.hostsDir } : {},
1192
- ...deps.cliEntry !== void 0 ? { cliEntry: deps.cliEntry } : {}
957
+ ...launch !== null ? { hostsDir: launch.hostsDir, cliEntry: launch.cliEntry, node: launch.node } : {
958
+ ...deps.hostsDir !== void 0 ? { hostsDir: deps.hostsDir } : {},
959
+ ...deps.cliEntry !== void 0 ? { cliEntry: deps.cliEntry } : {}
960
+ }
1193
961
  });
962
+ if (rt !== null && launch !== null) {
963
+ if (plugin.state !== "failed") {
964
+ await collectRuntime(rt.root, await fallbackFolders(ctx.dataDir, env, home, cwd, project));
965
+ } else if (!marketplaceAdded(plugin, launch.hostsDir)) {
966
+ await rt.restore?.().catch(() => void 0);
967
+ }
968
+ }
1194
969
  if (project && plugin.state !== "failed") {
1195
970
  await persistRouterProject(ctx.dataDir, cwd).catch(() => void 0);
1196
971
  }
@@ -1201,10 +976,13 @@ async function runRouterInstall(args, ctx, deps = {}) {
1201
976
  mcpScope: paths.mcpScope
1202
977
  });
1203
978
  const pending = settingsInstallStays(migration);
1204
- const servers = await readMcpServers(deps, { settingsInstallPending: pending });
979
+ const servers = await readMcpServers(deps, {
980
+ settingsInstallPending: pending,
981
+ ...launch !== null ? { version: launch.version } : {}
982
+ });
1205
983
  const serverLines = servers.stale > 0 ? [paint(ctx.io, "yellow", `! ${servers.check.detail}. ${servers.check.fix ?? ""}`.trim())] : [];
1206
984
  const claudeCode = claudeCodeData(claude);
1207
- const notices = refreshNotices(plugin, claude, migration);
985
+ const notices = refreshNotices(plugin, claude, migration, rt, home);
1208
986
  if (args.refresh === true) {
1209
987
  if (plugin.state === "failed" && migration.state !== "pending") {
1210
988
  throw new CliError(
@@ -1223,16 +1001,18 @@ async function runRouterInstall(args, ctx, deps = {}) {
1223
1001
  spend,
1224
1002
  removedSkills,
1225
1003
  scope,
1226
- mcpServer: servers.check
1004
+ mcpServer: servers.check,
1005
+ runtime: runtimeData(rt),
1006
+ launcher: rt?.launcher ?? null
1227
1007
  },
1228
1008
  humanLines: [
1229
- ...refreshLines(ctx, plugin, claude, migration),
1009
+ ...refreshLines(ctx, plugin, claude, migration, rt, home),
1230
1010
  ...removedKeysLines,
1231
1011
  ...serverLines
1232
1012
  ]
1233
1013
  };
1234
1014
  }
1235
- const { resolveWallet } = await import("./install-wallet-XQ6XFZV4.js");
1015
+ const { resolveWallet } = await import("./install-wallet-SAAPKB73.js");
1236
1016
  const wallet = await resolveWallet(ctx, deps, args.noWallet === true ? "flag" : void 0, false);
1237
1017
  const effective = await resolveContextSettings(ctx);
1238
1018
  const spendAsk = !canPrompt && !answered && unasked ? spendStep(args) : void 0;
@@ -1255,7 +1035,14 @@ async function runRouterInstall(args, ctx, deps = {}) {
1255
1035
  plugin,
1256
1036
  claudeCode,
1257
1037
  migration,
1258
- next: nextStep(plugin, claude, wallet, migration, asksAgent && nextSteps.length > 0),
1038
+ next: nextStep(
1039
+ plugin,
1040
+ claude,
1041
+ wallet,
1042
+ migration,
1043
+ asksAgent && nextSteps.length > 0,
1044
+ ctx.io.isTTY
1045
+ ),
1259
1046
  nextSteps,
1260
1047
  // The check for this scope, said outright; a bare doctor in the project
1261
1048
  // also finds it from what the project holds.
@@ -1269,7 +1056,9 @@ async function runRouterInstall(args, ctx, deps = {}) {
1269
1056
  },
1270
1057
  disclosure: DISCLOSURE,
1271
1058
  removedSkills,
1272
- mcpServer: servers.check
1059
+ mcpServer: servers.check,
1060
+ runtime: runtimeData(rt),
1061
+ launcher: rt?.launcher ?? null
1273
1062
  };
1274
1063
  return {
1275
1064
  data,
@@ -1283,13 +1072,166 @@ async function runRouterInstall(args, ctx, deps = {}) {
1283
1072
  asks: asksAgent && nextSteps.length > 0,
1284
1073
  policy: effective.policy,
1285
1074
  ...spendAsk !== void 0 ? { spendAsk } : {},
1286
- router
1075
+ router,
1076
+ rt,
1077
+ home
1287
1078
  }),
1288
1079
  ...removedKeysLines,
1289
1080
  ...serverLines
1290
1081
  ]
1291
1082
  };
1292
1083
  }
1084
+ async function defaultRuntime(o) {
1085
+ const { setupRuntime } = await import("./runtime-UVNUA3AS.js");
1086
+ return setupRuntime(o);
1087
+ }
1088
+ var sharedResults = /* @__PURE__ */ new WeakSet();
1089
+ function runtimeOncePerRun(setup = defaultRuntime) {
1090
+ let first;
1091
+ return async (o) => {
1092
+ if (first === void 0) {
1093
+ first = setup(o);
1094
+ return first;
1095
+ }
1096
+ const rt = { ...await first };
1097
+ sharedResults.add(rt);
1098
+ return rt;
1099
+ };
1100
+ }
1101
+ function hasRuntime(dataDir, home) {
1102
+ return resolve(dataDir) === resolve(defaultDataDir(home)) && existsSync(runtimeStatePath(runtimeDir(dataDir)));
1103
+ }
1104
+ function runtimeOnlyRefresh(ctx, rt, home) {
1105
+ return {
1106
+ data: {
1107
+ plugin: null,
1108
+ refresh: true,
1109
+ scope: "user",
1110
+ notices: runtimeNotices(rt, home),
1111
+ runtime: runtimeData(rt),
1112
+ launcher: rt.launcher
1113
+ },
1114
+ humanLines: [
1115
+ `${paint(ctx.io, "green", "\u2713")} Tenjin's runtime is up to date; no Claude Code plugin is registered here, so none was refreshed`,
1116
+ ...runtimeLines(ctx, rt, home)
1117
+ ]
1118
+ };
1119
+ }
1120
+ async function collectRuntime(root, folders) {
1121
+ try {
1122
+ const { collect } = await import("./runtime-UVNUA3AS.js");
1123
+ await collect(root, { lockWaitMs: 5e3, keep: await folderPointers(root, folders) });
1124
+ } catch {
1125
+ }
1126
+ }
1127
+ async function fallbackFolders(dataDir, env, home, cwd, project) {
1128
+ const projects = (await loadRawConfig(dataDir).catch(() => null))?.install?.routerProjects ?? [];
1129
+ return [
1130
+ folderFor("user", env, home, cwd),
1131
+ ...[...projects, ...project ? [cwd] : []].map((dir) => folderFor("local", env, home, dir))
1132
+ ];
1133
+ }
1134
+ var NODE_DIR_RE = /^\d+\.\d+\.\d+$/;
1135
+ async function folderPointers(root, folders) {
1136
+ const pointers = [];
1137
+ for (const dir of folders) {
1138
+ if (await inspectPluginFolder(dir) !== "ours") continue;
1139
+ const server = await readFile3(join4(dir, ".mcp.json"), "utf8").then(
1140
+ (raw) => JSON.parse(raw).mcpServers?.[MCP_SERVER_NAME]
1141
+ ).catch(() => void 0);
1142
+ const entry = Array.isArray(server?.args) ? server.args[0] : void 0;
1143
+ const node = server?.command;
1144
+ if (typeof entry !== "string" || typeof node !== "string") continue;
1145
+ const build = runtimeBuild(dirname3(entry));
1146
+ const nodeVersion = relative(join4(root, "node"), node).split(sep)[0] ?? "";
1147
+ if (build !== null && resolve(build.root) === resolve(root) && NODE_DIR_RE.test(nodeVersion)) {
1148
+ pointers.push({ cli: build.cli, node: nodeVersion });
1149
+ }
1150
+ }
1151
+ return pointers;
1152
+ }
1153
+ function runtimeLaunch(rt) {
1154
+ if (rt === null || rt.state !== "active" && rt.state !== "current" && rt.state !== "kept") {
1155
+ return null;
1156
+ }
1157
+ if (rt.cli === void 0 || rt.hostsDir === void 0 || rt.entry === void 0 || rt.node === void 0) {
1158
+ return null;
1159
+ }
1160
+ return { version: rt.cli, hostsDir: rt.hostsDir, cliEntry: rt.entry, node: rt.node };
1161
+ }
1162
+ function runtimeData(rt) {
1163
+ if (rt === null) return null;
1164
+ return {
1165
+ state: rt.state,
1166
+ root: rt.root,
1167
+ ...rt.cli !== void 0 ? { cli: rt.cli } : {},
1168
+ ...rt.nodeVersion !== void 0 ? { nodeVersion: rt.nodeVersion } : {},
1169
+ ...rt.reason !== void 0 ? { reason: rt.reason } : {},
1170
+ ...rt.fix !== void 0 ? { fix: rt.fix } : {}
1171
+ };
1172
+ }
1173
+ async function recordClaudeProjects(dataDir, known, env, home) {
1174
+ const records = await recordedInstalls(env, home).catch(() => null);
1175
+ if (records === null || records.every((r) => r.projectPath === null)) return;
1176
+ const seen = /* @__PURE__ */ new Set([
1177
+ ...known,
1178
+ ...await Promise.all(known.map((dir) => realpath(dir).catch(() => dir)))
1179
+ ]);
1180
+ for (const { projectPath } of records) {
1181
+ if (projectPath === null || seen.has(projectPath)) continue;
1182
+ if ((await stat3(projectPath).catch(() => null))?.isDirectory() !== true) continue;
1183
+ seen.add(projectPath);
1184
+ await persistRouterProject(dataDir, projectPath).catch(() => void 0);
1185
+ }
1186
+ }
1187
+ function tilde(path, home) {
1188
+ return path === home || path.startsWith(`${home}${sep}`) ? `~${path.slice(home.length)}` : path;
1189
+ }
1190
+ function runtimeSentence(rt, home) {
1191
+ if (rt.state !== "active" || !rt.firstTime) return null;
1192
+ return `Runs from ${tilde(rt.root, home)} on its own Node ${rt.nodeVersion ?? ""}, so a Node upgrade or \`npm rm -g tenjin-cli\` no longer stops it.`;
1193
+ }
1194
+ function fallbackSentence(rt) {
1195
+ if (rt.state === "fallback" && rt.unpinned !== void 0) {
1196
+ return `Tenjin pins no Node for this platform (${rt.unpinned}), so the plugin runs from npm's copy on the Node on your PATH, as before.`;
1197
+ }
1198
+ const next = rt.fix ?? "run `tenjin install` again to retry";
1199
+ if (rt.state === "fallback") {
1200
+ return `Tenjin's own runtime could not be set up (${rt.reason ?? "unknown reason"}), so the plugin still runs on the Node on your PATH; ${next}.`;
1201
+ }
1202
+ if (rt.state === "kept" && rt.reason !== void 0 && rt.newer !== true) {
1203
+ const retry = rt.unpinned === void 0 ? `; ${next}` : "";
1204
+ return `tenjin-cli ${package_default.version} could not be set up (${rt.reason}), so Tenjin keeps running ${rt.cli ?? "the runtime it has"}${retry}.`;
1205
+ }
1206
+ return null;
1207
+ }
1208
+ function launcherSentence(launcher, home) {
1209
+ if (launcher === null) return null;
1210
+ if (launcher.state === "foreign") {
1211
+ const who = launcher.reason?.replace(/ is not Tenjin's$/, "") ?? launcher.paths[0] ?? "";
1212
+ return `${who} is not Tenjin's, so it was left as it is, and \`tenjin\` there runs that file instead of Tenjin's runtime. Move it aside and run \`tenjin install\` again to put Tenjin's there.`;
1213
+ }
1214
+ if (launcher.state === "failed") {
1215
+ const dir = launcher.paths[0] !== void 0 ? tilde(dirname3(launcher.paths[0]), home) : "";
1216
+ return `Tenjin's \`tenjin\` launcher could not be written to ${dir} (${launcher.reason ?? "unknown reason"}), so a terminal finds \`tenjin\` only through npm's copy; run \`tenjin install\` again to retry.`;
1217
+ }
1218
+ if ((launcher.state === "written" || launcher.state === "current") && !launcher.onPath) {
1219
+ return `~/.local/bin is not on your PATH, so a terminal will not find \`tenjin\` once npm's copy is gone (inside Claude Code the plugin's own \`tenjin\` is on the Bash tool's PATH). Add it: ${launcher.pathLine ?? ""}`;
1220
+ }
1221
+ return null;
1222
+ }
1223
+ function runtimeLines(ctx, rt, home) {
1224
+ if (rt === null || sharedResults.has(rt)) return [];
1225
+ const warn = (text) => paint(ctx.io, "yellow", `! ${text}`);
1226
+ const runs = runtimeSentence(rt, home);
1227
+ const fallback = fallbackSentence(rt);
1228
+ const launcher = launcherSentence(rt.launcher, home);
1229
+ return [
1230
+ ...runs !== null ? [` ${runs}`] : [],
1231
+ ...fallback !== null ? [warn(fallback)] : [],
1232
+ ...launcher !== null ? [warn(launcher)] : []
1233
+ ];
1234
+ }
1293
1235
  function claudeCodeData(claude) {
1294
1236
  return {
1295
1237
  binary: claude.binary?.path ?? null,
@@ -1309,8 +1251,24 @@ function registrationFix(plugin) {
1309
1251
  }
1310
1252
  return `Run \`tenjin doctor${flag}\` to see the cause, then run \`tenjin install${flag}\` again.`;
1311
1253
  }
1312
- function nextStep(plugin, claude, wallet, migration, asksQuestion) {
1254
+ var REPAIRABLE = /* @__PURE__ */ new Set([
1255
+ "passphrase_missing",
1256
+ "passphrase_wrong",
1257
+ "env_passphrase_wrong"
1258
+ ]);
1259
+ function repairStep(tty) {
1260
+ return tty ? `run \`tenjin wallet repair\` yourself ${REPAIR_CLAUSE}` : "ask the person to run `tenjin wallet repair` in their own terminal (never ask for the passphrase)";
1261
+ }
1262
+ function nextStep(plugin, claude, wallet, migration, asksQuestion, tty) {
1313
1263
  if (plugin.state === "failed") return registrationFix(plugin);
1264
+ const steps = todaysSteps(plugin, claude, wallet, migration, asksQuestion);
1265
+ const signing = wallet.signing;
1266
+ if (signing?.status === "blocked" && REPAIRABLE.has(signing.reason)) {
1267
+ steps.unshift(repairStep(tty));
1268
+ }
1269
+ return steps.join(", then ");
1270
+ }
1271
+ function todaysSteps(plugin, claude, wallet, migration, asksQuestion) {
1314
1272
  const steps = [];
1315
1273
  if (asksQuestion) {
1316
1274
  steps.push("ask the person the question in nextSteps, then run what the answer names");
@@ -1322,11 +1280,11 @@ function nextStep(plugin, claude, wallet, migration, asksQuestion) {
1322
1280
  steps.push(
1323
1281
  "run `tenjin install` again; until then the earlier Tenjin setup keeps routing as before"
1324
1282
  );
1325
- return steps.join(", then ");
1283
+ return steps;
1326
1284
  }
1327
1285
  if (!claude.meetsFloor) steps.unshift("run `claude update`");
1328
1286
  steps.push(loadStep(settingsInstallStays(migration)));
1329
- return steps.join(", then ");
1287
+ return steps;
1330
1288
  }
1331
1289
  function settingsInstallStays(migration) {
1332
1290
  return migration.state === "pending" || migration.state === "blocked";
@@ -1352,7 +1310,7 @@ function statusLineNotice(migration) {
1352
1310
  }
1353
1311
  return null;
1354
1312
  }
1355
- function refreshNotices(plugin, claude, migration) {
1313
+ function refreshNotices(plugin, claude, migration, rt, home) {
1356
1314
  const out = [];
1357
1315
  if (plugin.state === "deferred") {
1358
1316
  out.push(
@@ -1365,6 +1323,16 @@ function refreshNotices(plugin, claude, migration) {
1365
1323
  }
1366
1324
  const status = statusLineNotice(migration);
1367
1325
  if (status !== null) out.push(status);
1326
+ if (rt !== null) out.push(...runtimeNotices(rt, home));
1327
+ return out;
1328
+ }
1329
+ function runtimeNotices(rt, home) {
1330
+ const out = [];
1331
+ const runs = runtimeSentence(rt, home);
1332
+ if (runs !== null) out.push(`Tenjin ${runs.charAt(0).toLowerCase()}${runs.slice(1)}`);
1333
+ for (const sentence of [fallbackSentence(rt), launcherSentence(rt.launcher, home)]) {
1334
+ if (sentence !== null) out.push(sentence);
1335
+ }
1368
1336
  return out;
1369
1337
  }
1370
1338
  var SHOW_NOT_RUN = "Show the person addresses as written, and never ask them to run a command.";
@@ -1444,7 +1412,7 @@ async function fundStep(wallet, rpcUrl, deps) {
1444
1412
  };
1445
1413
  }
1446
1414
  async function defaultBalance(address, rpcUrl) {
1447
- const { getUsdcBalance } = await import("./usdc-OGOGEHV2.js");
1415
+ const { getUsdcBalance } = await import("./usdc-D6X7EIQ2.js");
1448
1416
  return getUsdcBalance(address, rpcUrl);
1449
1417
  }
1450
1418
  function fundLines(fund) {
@@ -1532,8 +1500,46 @@ function effectiveLimits(policy) {
1532
1500
  };
1533
1501
  }
1534
1502
  function walletLines(ctx, ok, w) {
1535
- if (w.status === "created") return [`${ok} Wallet created: ${w.address}`];
1536
- if (w.status === "existing") return [`${ok} Wallet: ${w.address}`];
1503
+ const warn = (text) => paint(ctx.io, "yellow", text);
1504
+ if (w.status === "created" || w.status === "existing") {
1505
+ const a = w.address ?? "";
1506
+ const signing = w.signing;
1507
+ const tty = ctx.io.isTTY;
1508
+ if (signing?.status === "blocked") {
1509
+ const wallet = Object.prototype.hasOwnProperty.call(WALLET_REASONS, signing.reason) ? WALLET_REASONS[signing.reason] : void 0;
1510
+ return [
1511
+ warn(`! Wallet ${a} cannot be unlocked by Claude Code: ${signing.detail}.`),
1512
+ ` ${tty ? wallet?.fix ?? signing.fix : agentFixFor(signing.reason, signing.fix)}`
1513
+ ];
1514
+ }
1515
+ if (signing?.status === "unknown") {
1516
+ return [
1517
+ warn(`! Wallet: ${a}; could not check that it unlocks (${signing.detail}).`),
1518
+ " Run `tenjin doctor` to check it again."
1519
+ ];
1520
+ }
1521
+ if (w.shellOnly === "key") {
1522
+ return [
1523
+ warn(
1524
+ `! Wallet: ${a} signs here only through TENJIN_WALLET_KEY in this shell; Claude Code must have the same variable.`
1525
+ )
1526
+ ];
1527
+ }
1528
+ if (w.shellOnly === "passphrase") {
1529
+ return [
1530
+ warn(
1531
+ tty ? `! Wallet: ${a} unlocks here only through TENJIN_WALLET_PASSPHRASE in this shell; Claude Code must have the same variable, or run \`tenjin wallet repair\` yourself to store the passphrase ${REPAIR_CLAUSE}.` : `! Wallet: ${a} unlocks here only through TENJIN_WALLET_PASSPHRASE in this shell; Claude Code must have the same variable, or ask the person to run \`tenjin wallet repair\` in their own terminal to store the passphrase. Never ask for the passphrase.`
1532
+ )
1533
+ ];
1534
+ }
1535
+ if (w.status === "created") {
1536
+ return [
1537
+ `${ok} Wallet created: ${a}`,
1538
+ ...w.passphrase !== void 0 ? [` ${w.passphrase.note}`] : []
1539
+ ];
1540
+ }
1541
+ return [`${ok} Wallet: ${a}`];
1542
+ }
1537
1543
  if (w.reason === "flag") return [" No wallet yet. Create one with: tenjin wallet create"];
1538
1544
  return [
1539
1545
  paint(ctx.io, "yellow", `! No wallet was created. ${w.warning ?? ""}`.trimEnd()),
@@ -1605,6 +1611,7 @@ function lines(ctx, s) {
1605
1611
  return [
1606
1612
  s.plugin.state === "failed" ? warn("Tenjin could not finish setting up Claude Code") : s.plugin.state === "deferred" ? warn("Tenjin keeps its earlier Claude Code setup until Claude Code is updated") : `${ok} Tenjin is set up for Claude Code (plugin ${s.plugin.id ?? PLUGIN_ID})`,
1607
1613
  ...s.plugin.scope === "local" && s.plugin.state !== "failed" ? [" For this project only; check it with: tenjin doctor --project"] : [],
1614
+ ...runtimeLines(ctx, s.rt, s.home),
1608
1615
  ...walletLines(ctx, ok, s.wallet),
1609
1616
  ...spend,
1610
1617
  ...s.fund !== void 0 ? fundLines(s.fund) : [],
@@ -1613,11 +1620,12 @@ function lines(ctx, s) {
1613
1620
  ...migrationLines(ctx, s.migration),
1614
1621
  ...router,
1615
1622
  "",
1616
- `Next: ${nextStep(s.plugin, s.claude, s.wallet, s.migration, s.asks)}`
1623
+ `Next: ${nextStep(s.plugin, s.claude, s.wallet, s.migration, s.asks, ctx.io.isTTY)}`
1617
1624
  ];
1618
1625
  }
1619
- function refreshLines(ctx, plugin, claude, migration) {
1626
+ function refreshLines(ctx, plugin, claude, migration, rt, home) {
1620
1627
  const issues = [
1628
+ ...runtimeLines(ctx, rt, home),
1621
1629
  ...pluginLines(ctx, plugin),
1622
1630
  ...claudeLines(ctx, claude),
1623
1631
  ...migrationLines(ctx, migration)
@@ -1628,11 +1636,45 @@ function refreshLines(ctx, plugin, claude, migration) {
1628
1636
 
1629
1637
  // src/commands/update.ts
1630
1638
  var INSTALL_TIMEOUT_MS = 3e5;
1639
+ var STAGE_TIMEOUT_MS = 12e4;
1640
+ var NODE_TIMEOUT_MS = 3e5;
1631
1641
  function resolveManager(manager, deps) {
1632
1642
  const script = deps.managerScript !== void 0 ? deps.managerScript : resolveManagerScript(manager, process.execPath);
1633
1643
  return script === null ? { cmd: MANAGERS[manager].bin, prefix: [] } : { cmd: process.execPath, prefix: [script] };
1634
1644
  }
1635
1645
  async function runUpdate(opts, ctx, deps = {}) {
1646
+ if (opts.background !== true) return update(opts, ctx, deps);
1647
+ const root = deps.runtimeRoot ?? runtimeDir(ctx.dataDir);
1648
+ const [{ recordAutoUpdate }, { readRuntimeState }] = await Promise.all([
1649
+ import("./auto-update-OPWMRZLS.js"),
1650
+ import("./runtime-layout-BDWZG2TQ.js")
1651
+ ]);
1652
+ const from = readRuntimeState(root)?.current.cli;
1653
+ const record = (r) => {
1654
+ if (!existsSync2(root)) return;
1655
+ try {
1656
+ recordAutoUpdate(root, { finishedAt: (/* @__PURE__ */ new Date()).toISOString(), ...r });
1657
+ } catch {
1658
+ }
1659
+ };
1660
+ try {
1661
+ const result = await update(opts, ctx, deps);
1662
+ const d = result.data;
1663
+ record(
1664
+ d.skipped !== void 0 ? { outcome: "skipped", reason: d.skipped } : d.updated === true ? { outcome: "updated", from: d.current, to: d.latest } : { outcome: "current", from: d.current, to: d.current }
1665
+ );
1666
+ return result;
1667
+ } catch (err) {
1668
+ const reason = sanitizeForTerminal(err instanceof Error ? err.message : String(err)).trim();
1669
+ record({
1670
+ outcome: "failed",
1671
+ ...from !== void 0 ? { from } : {},
1672
+ reason: reason.slice(0, REASON_LIMIT)
1673
+ });
1674
+ throw err;
1675
+ }
1676
+ }
1677
+ async function update(opts, ctx, deps) {
1636
1678
  const current = deps.currentVersion ?? package_default.version;
1637
1679
  const channel = channelTag(current);
1638
1680
  const moduleDir = deps.moduleDir ?? fileURLToPath3(new URL(".", import.meta.url));
@@ -1651,7 +1693,15 @@ async function runUpdate(opts, ctx, deps = {}) {
1651
1693
  fix: "Check access to registry.npmjs.org and retry"
1652
1694
  });
1653
1695
  }
1654
- const latest = resolveTarget(current, tags);
1696
+ const runtime = await runtimeHere(ctx, deps, moduleDir);
1697
+ if (opts.background === true && runtime === null) {
1698
+ return {
1699
+ data: { skipped: "no runtime" },
1700
+ humanLines: ["Nothing to update in the background: Tenjin's runtime is not set up here."]
1701
+ };
1702
+ }
1703
+ const base = runtime?.current ?? current;
1704
+ const latest = resolveTarget(base, tags);
1655
1705
  if (latest === null) {
1656
1706
  const raw = tags[channel];
1657
1707
  throw raw === void 0 ? new CliError("RESOURCE_NOT_FOUND", "npm has no published tenjin-cli on the latest tag", {
@@ -1665,28 +1715,32 @@ async function runUpdate(opts, ctx, deps = {}) {
1665
1715
  }
1666
1716
  );
1667
1717
  }
1668
- const updateAvailable = isNewer(latest, current);
1669
- const data = (updated) => ({
1670
- current,
1718
+ const updateAvailable = isNewer(latest, base);
1719
+ const data = (updated2) => ({
1720
+ current: base,
1671
1721
  latest,
1672
1722
  updateAvailable,
1673
- updated
1723
+ updated: updated2
1674
1724
  });
1675
1725
  if (!updateAvailable) {
1676
1726
  return {
1677
1727
  data: data(false),
1678
- humanLines: [`tenjin-cli ${current} is up to date`]
1728
+ humanLines: [`tenjin-cli ${base} is up to date`]
1679
1729
  };
1680
1730
  }
1681
1731
  if (opts.check) {
1682
1732
  return {
1683
1733
  data: data(false),
1684
1734
  humanLines: [
1685
- `tenjin-cli ${latest} is available (you have ${current}).`,
1735
+ `tenjin-cli ${latest} is available (you have ${base}).`,
1686
1736
  "Run tenjin update to install it."
1687
1737
  ]
1688
1738
  };
1689
1739
  }
1740
+ if (runtime !== null) {
1741
+ return runtimeUpdate(ctx, deps, { ...runtime, base, latest, current, moduleDir, data });
1742
+ }
1743
+ await refuseRuntimeElsewhere(ctx, moduleDir, deps.homeDir ?? homedir2());
1690
1744
  const spec = `tenjin-cli@${latest}`;
1691
1745
  refuse(moduleDir, { check: false, spec });
1692
1746
  const human = ctx.io.isTTY && !ctx.flags.json;
@@ -1731,14 +1785,18 @@ async function runUpdate(opts, ctx, deps = {}) {
1731
1785
  ctx.io,
1732
1786
  `tenjin update: replaced the global tenjin-cli with ${latest} via ${manager}`
1733
1787
  );
1734
- const refresh = await refreshProfiles(ctx, deps);
1788
+ const { refresh } = await refreshProfiles(ctx, deps, npmLaunch(deps));
1789
+ return updated(deps, data(true), refresh, [`Updated tenjin-cli ${current} -> ${latest}.`]);
1790
+ }
1791
+ async function updated(deps, data, refresh, head, version) {
1735
1792
  const servers = await readMcpServers(deps, {
1736
- settingsInstallPending: refresh.settingsInstallPending
1793
+ settingsInstallPending: refresh.settingsInstallPending,
1794
+ ...version !== void 0 ? { version } : {}
1737
1795
  });
1738
1796
  return {
1739
- data: { ...data(true), refresh, mcpServer: servers.check },
1797
+ data: { ...data, refresh, mcpServer: servers.check },
1740
1798
  humanLines: [
1741
- `Updated tenjin-cli ${current} -> ${latest}.`,
1799
+ ...head,
1742
1800
  ...refreshLines2(refresh),
1743
1801
  ...projectLines(refresh),
1744
1802
  ...refresh.notices,
@@ -1746,8 +1804,118 @@ async function runUpdate(opts, ctx, deps = {}) {
1746
1804
  ]
1747
1805
  };
1748
1806
  }
1807
+ async function runtimeHere(ctx, deps, moduleDir) {
1808
+ if (resolve2(ctx.dataDir) !== resolve2(defaultDataDir(deps.homeDir ?? homedir2()))) return null;
1809
+ const { readRuntimeState, runtimeBuild: runtimeBuild2 } = await import("./runtime-layout-BDWZG2TQ.js");
1810
+ const root = deps.runtimeRoot ?? runtimeDir(ctx.dataDir);
1811
+ const state = readRuntimeState(root);
1812
+ const inRuntime = runtimeBuild2(moduleDir) !== null;
1813
+ if (state === null && !inRuntime) return null;
1814
+ return { root, current: state?.current.cli ?? null, inRuntime };
1815
+ }
1816
+ async function refuseRuntimeElsewhere(ctx, moduleDir, home) {
1817
+ const { runtimeBuild: runtimeBuild2 } = await import("./runtime-layout-BDWZG2TQ.js");
1818
+ if (runtimeBuild2(moduleDir) === null) return;
1819
+ throw new CliError(
1820
+ "REFUSED",
1821
+ `This tenjin runs from Tenjin's runtime, which only the default data dir (${tilde2(defaultDataDir(home), home)}) uses, and TENJIN_DATA_DIR is ${tilde2(ctx.dataDir, home)}, so nothing was updated`,
1822
+ {
1823
+ fix: "Run `tenjin update` with TENJIN_DATA_DIR unset: the runtime belongs to the default data dir. Another data dir runs on an npm copy, updated with `npm i -g tenjin-cli@latest`."
1824
+ }
1825
+ );
1826
+ }
1827
+ async function runtimeUpdate(ctx, deps, o) {
1828
+ const { root, base, latest } = o;
1829
+ const [rt, layout] = await Promise.all([
1830
+ import("./runtime-UVNUA3AS.js"),
1831
+ import("./runtime-layout-BDWZG2TQ.js")
1832
+ ]);
1833
+ const stays = `so ${base} stays`;
1834
+ let stage;
1835
+ if (latest === o.current && !o.inRuntime) {
1836
+ const packageRoot = rt.packageRootOf(o.moduleDir);
1837
+ if (packageRoot === null) {
1838
+ throw new CliError(
1839
+ "UPDATE_FAILED",
1840
+ `tenjin-cli ${latest} cannot find its own package, ${stays}`,
1841
+ {
1842
+ fix: "Run `npx -y tenjin-cli@latest install`."
1843
+ }
1844
+ );
1845
+ }
1846
+ stage = await rt.stageSelf(root, packageRoot);
1847
+ } else {
1848
+ stage = await (deps.stage ?? rt.stageTarball)(root, latest, {
1849
+ timeoutMs: STAGE_TIMEOUT_MS,
1850
+ fetchImpl: deps.fetchImpl
1851
+ }).catch((err) => {
1852
+ throw proxyNamed(err, deps);
1853
+ });
1854
+ }
1855
+ let node;
1856
+ try {
1857
+ const pin = rt.readNodePin(stage);
1858
+ if (pin === null) {
1859
+ throw new CliError("UPDATE_FAILED", `tenjin-cli ${latest} carries no Node pin, ${stays}`, {
1860
+ fix: `Nothing to do: ${base} keeps running. Run \`tenjin update\` again after the next release.`
1861
+ });
1862
+ }
1863
+ node = await (deps.ensure ?? rt.ensureNode)(root, pin, {
1864
+ timeoutMs: NODE_TIMEOUT_MS,
1865
+ fetchImpl: deps.fetchImpl
1866
+ });
1867
+ await (deps.place ?? rt.placeVersion)(root, stage, latest);
1868
+ } catch (err) {
1869
+ await rm2(stage, { recursive: true, force: true }).catch(() => void 0);
1870
+ throw proxyNamed(err, deps);
1871
+ }
1872
+ const home = deps.homeDir ?? homedir2();
1873
+ emitWriteNotice(ctx.io, `tenjin update: staged tenjin-cli ${latest} in ${tilde2(root, home)}`);
1874
+ const { refresh, homeTail } = await refreshProfiles(ctx, deps, {
1875
+ node,
1876
+ entry: layout.versionEntry(root, latest)
1877
+ });
1878
+ if (layout.readRuntimeState(root)?.current.cli !== latest) {
1879
+ throw new CliError("UPDATE_FAILED", `tenjin-cli ${latest} did not pass its checks, ${stays}`, {
1880
+ fix: "Run `tenjin update` again; if it fails again, run `tenjin doctor`",
1881
+ details: {
1882
+ reason: refresh.failed[0]?.reason ?? runtimeReason(envelopeData(homeTail)) ?? "The new version did not switch the runtime to itself.",
1883
+ output: homeTail.slice(-2e3)
1884
+ }
1885
+ });
1886
+ }
1887
+ return updated(
1888
+ deps,
1889
+ o.data(true),
1890
+ refresh,
1891
+ [
1892
+ `Updated tenjin-cli ${base} -> ${latest}.`,
1893
+ `The previous version (${base}) stays as the fallback.`
1894
+ ],
1895
+ latest
1896
+ );
1897
+ }
1898
+ function proxyNamed(err, deps) {
1899
+ if (!(err instanceof CliError) || err.code !== "NETWORK_ERROR") return err;
1900
+ const skipped = proxySkipped(process.env, deps.proxySupported);
1901
+ if (skipped === null) return err;
1902
+ const step2 = proxyNodeStep("tenjin update");
1903
+ return new CliError("NETWORK_ERROR", `${err.message}: ${skipped}`, {
1904
+ fix: `${step2.charAt(0).toUpperCase()}${step2.slice(1)}.`,
1905
+ cause: err
1906
+ });
1907
+ }
1908
+ function runtimeReason(data) {
1909
+ const reason = data?.runtime?.reason;
1910
+ if (typeof reason !== "string") return void 0;
1911
+ const text = sanitizeForTerminal(reason).trim();
1912
+ return text.length > 0 ? text.slice(0, REASON_LIMIT) : void 0;
1913
+ }
1914
+ function tilde2(path, home) {
1915
+ return path === home || path.startsWith(`${home}${sep2}`) ? `~${path.slice(home.length)}` : path;
1916
+ }
1749
1917
  var REFRESH_TIMEOUT_MS = 6e4;
1750
- async function refreshProfiles(ctx, deps) {
1918
+ async function refreshProfiles(ctx, deps, launch) {
1751
1919
  const home = deps.homeDir ?? homedir2();
1752
1920
  const candidates = [ctx.dataDir];
1753
1921
  const fixFor = (dataDir) => manualFix(dataDir, home, ctx.dataDir);
@@ -1757,16 +1925,18 @@ async function refreshProfiles(ctx, deps) {
1757
1925
  if (isExistingDir(dataDir)) profiles.push(dataDir);
1758
1926
  else unrun.push({ dataDir, reason: "It is not a directory.", fix: fixFor(dataDir) });
1759
1927
  }
1760
- const entry = versionFreeEntry(deps.refreshCommand ?? process.argv[1]);
1761
- if (entry === null) {
1928
+ if (launch === null) {
1762
1929
  const reason = "This build has no entry the update could safely re-execute.";
1763
1930
  return {
1764
- profiles: [],
1765
- failed: candidates.map((d) => ({ dataDir: d, reason, fix: fixFor(d) })),
1766
- notices: [],
1767
- settingsInstallPending: false,
1768
- projects: [],
1769
- projectsFailed: []
1931
+ refresh: {
1932
+ profiles: [],
1933
+ failed: candidates.map((d) => ({ dataDir: d, reason, fix: fixFor(d) })),
1934
+ notices: [],
1935
+ settingsInstallPending: false,
1936
+ projects: [],
1937
+ projectsFailed: []
1938
+ },
1939
+ homeTail: ""
1770
1940
  };
1771
1941
  }
1772
1942
  const failed = [...unrun];
@@ -1779,8 +1949,10 @@ async function refreshProfiles(ctx, deps) {
1779
1949
  settingsInstallPending = true;
1780
1950
  }
1781
1951
  };
1952
+ let homeTail = "";
1782
1953
  for (const dataDir of profiles) {
1783
- const { outcome, tail } = await refreshChild(entry, homedir2(), dataDir, deps);
1954
+ const { outcome, tail } = await refreshChild(launch, homedir2(), dataDir, deps);
1955
+ homeTail = tail;
1784
1956
  if (outcome.kind !== "exit" || outcome.code !== 0) {
1785
1957
  failed.push({ dataDir, reason: refreshReason(outcome, tail), fix: fixFor(dataDir) });
1786
1958
  continue;
@@ -1796,7 +1968,7 @@ async function refreshProfiles(ctx, deps) {
1796
1968
  await forget();
1797
1969
  continue;
1798
1970
  }
1799
- const { outcome, tail } = await refreshChild(entry, project, ctx.dataDir, deps, ["--project"]);
1971
+ const { outcome, tail } = await refreshChild(launch, project, ctx.dataDir, deps, ["--project"]);
1800
1972
  if (outcome.kind !== "exit" || outcome.code !== 0) {
1801
1973
  projectsFailed.push({
1802
1974
  project,
@@ -1808,13 +1980,20 @@ async function refreshProfiles(ctx, deps) {
1808
1980
  projects.push(project);
1809
1981
  heard(envelopeData(tail));
1810
1982
  }
1811
- return { profiles, failed, notices, settingsInstallPending, projects, projectsFailed };
1983
+ return {
1984
+ refresh: { profiles, failed, notices, settingsInstallPending, projects, projectsFailed },
1985
+ homeTail
1986
+ };
1812
1987
  }
1813
- async function refreshChild(entry, cwd, dataDir, deps, flags = []) {
1988
+ function npmLaunch(deps) {
1989
+ const entry = versionFreeEntry(deps.refreshCommand ?? process.argv[1]);
1990
+ return entry === null ? null : { node: process.execPath, entry };
1991
+ }
1992
+ async function refreshChild(launch, cwd, dataDir, deps, flags = []) {
1814
1993
  let tail = "";
1815
1994
  const outcome = await (deps.spawnImpl ?? spawnCapture)(
1816
- process.execPath,
1817
- [entry, "install", "--refresh", ...flags],
1995
+ launch.node,
1996
+ [launch.entry, "install", "--refresh", ...flags],
1818
1997
  {
1819
1998
  cwd,
1820
1999
  timeoutMs: REFRESH_TIMEOUT_MS,
@@ -1875,21 +2054,21 @@ function envelopeMessage(output) {
1875
2054
  return void 0;
1876
2055
  }
1877
2056
  function isExistingDir(path) {
1878
- return statSync2(path, { throwIfNoEntry: false })?.isDirectory() === true;
2057
+ return statSync(path, { throwIfNoEntry: false })?.isDirectory() === true;
1879
2058
  }
1880
2059
  function manualFix(dataDir, home, invoking) {
1881
- const bare = resolve(dataDir) === resolve(defaultDataDir(home)) && resolve(dataDir) === resolve(invoking);
2060
+ const bare = resolve2(dataDir) === resolve2(defaultDataDir(home)) && resolve2(dataDir) === resolve2(invoking);
1882
2061
  const command = bare ? "tenjin install" : `TENJIN_DATA_DIR=${dataDir} tenjin install`;
1883
2062
  return `Run \`${command}\` to bring the Claude Code plugin up to this version.`;
1884
2063
  }
1885
2064
  function versionFreeEntry(entry) {
1886
2065
  if (entry === void 0 || entry.length === 0) return null;
1887
- const segs = entry.split(sep3);
2066
+ const segs = entry.split(sep2);
1888
2067
  const store = segs.indexOf(".pnpm");
1889
- if (store === -1) return segs.join(sep3);
2068
+ if (store === -1) return segs.join(sep2);
1890
2069
  const inner = segs.indexOf("node_modules", store);
1891
2070
  if (inner === -1) return null;
1892
- const derived = [...segs.slice(0, store), ...segs.slice(inner + 1)].join(sep3);
2071
+ const derived = [...segs.slice(0, store), ...segs.slice(inner + 1)].join(sep2);
1893
2072
  return existsSync2(derived) ? derived : null;
1894
2073
  }
1895
2074
  function refreshLines2(refresh) {
@@ -1952,14 +2131,14 @@ var spawnCapture = (cmd, args, opts, onOutput) => new Promise((res) => {
1952
2131
  export {
1953
2132
  inspectLegacyInstall,
1954
2133
  removeLegacyInstall,
1955
- readMcpServers,
1956
2134
  runUpdate,
1957
2135
  versionFreeEntry,
1958
2136
  spawnCapture,
1959
- removePluginFolder,
1960
2137
  folderFor,
1961
2138
  registerPlugin,
2139
+ marketplaceAdded,
1962
2140
  ownMarketplace,
2141
+ recordedInstalls,
1963
2142
  packageHostsDir,
1964
2143
  packageMod,
1965
2144
  packageCliEntry,
@@ -1967,15 +2146,22 @@ export {
1967
2146
  folderState,
1968
2147
  probeRouter,
1969
2148
  DISCLOSURE,
1970
- RELOAD_STEP,
1971
2149
  NEW_SESSION_STEP,
2150
+ RELOAD_STEP,
1972
2151
  loadStep,
1973
2152
  settingsInstallPaths,
1974
2153
  pluginProof,
1975
2154
  migrateSettingsInstall,
1976
2155
  projectInstallHere,
1977
2156
  projectInstallAt,
2157
+ NOTHING_TO_REFRESH,
1978
2158
  runRouterInstall,
2159
+ defaultRuntime,
2160
+ runtimeOncePerRun,
2161
+ hasRuntime,
2162
+ runtimeData,
2163
+ tilde,
2164
+ runtimeLines,
1979
2165
  SHOW_NOT_RUN,
1980
2166
  spendStepFor,
1981
2167
  namedLimits,
@@ -1984,4 +2170,4 @@ export {
1984
2170
  approveLimits,
1985
2171
  effectiveLimits
1986
2172
  };
1987
- //# sourceMappingURL=chunk-77TCKDEC.js.map
2173
+ //# sourceMappingURL=chunk-VOZA6O7K.js.map