tenjin-cli 0.1.0-alpha.14 → 0.1.0-alpha.16

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 (253) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +41 -295
  3. package/dist/{_esm-N4KAVXQR.js → _esm-CE7KNONL.js} +9 -10
  4. package/dist/{ccip-ZGGWQN4X.js → ccip-7RMRLAGV.js} +4 -4
  5. package/dist/{ccip-RPPPKTJR.js → ccip-NLCSCHKI.js} +5 -5
  6. package/dist/chunk-25TJPVBF.js +353 -0
  7. package/dist/chunk-25TJPVBF.js.map +1 -0
  8. package/dist/chunk-2BKS2FVE.js +93 -0
  9. package/dist/chunk-2BKS2FVE.js.map +1 -0
  10. package/dist/chunk-2QYORQBF.js +55 -0
  11. package/dist/chunk-2QYORQBF.js.map +1 -0
  12. package/dist/{chunk-ACBEHJAH.js → chunk-2U5ZVEV3.js} +14 -16
  13. package/dist/chunk-2U5ZVEV3.js.map +1 -0
  14. package/dist/{chunk-MJSXP4LW.js → chunk-3AJS6LLN.js} +11 -8
  15. package/dist/chunk-3AJS6LLN.js.map +1 -0
  16. package/dist/{chunk-OWVVI4VQ.js → chunk-3AUDA53C.js} +7650 -7361
  17. package/dist/chunk-3AUDA53C.js.map +1 -0
  18. package/dist/{chunk-MJZZTKCC.js → chunk-56MOAIP5.js} +5 -10
  19. package/dist/chunk-56MOAIP5.js.map +1 -0
  20. package/dist/{chunk-U5S527PP.js → chunk-5IEP5EGE.js} +3 -3
  21. package/dist/chunk-5X4SZ5BF.js +227 -0
  22. package/dist/chunk-5X4SZ5BF.js.map +1 -0
  23. package/dist/chunk-7WEQQJLG.js +68 -0
  24. package/dist/chunk-7WEQQJLG.js.map +1 -0
  25. package/dist/{chunk-7FK2UN2T.js → chunk-AWQPGIR6.js} +65 -67
  26. package/dist/{chunk-7FK2UN2T.js.map → chunk-AWQPGIR6.js.map} +1 -1
  27. package/dist/{chunk-PAOVPSP6.js → chunk-BBVUVBUO.js} +517 -138
  28. package/dist/chunk-BBVUVBUO.js.map +1 -0
  29. package/dist/{chunk-ETKZWJ4B.js → chunk-BFFM2WFK.js} +8 -8
  30. package/dist/chunk-BFFM2WFK.js.map +1 -0
  31. package/dist/{chunk-KYQVEKP5.js → chunk-BPMWXTFX.js} +8 -8
  32. package/dist/chunk-DMZZLPZN.js +205 -0
  33. package/dist/chunk-DMZZLPZN.js.map +1 -0
  34. package/dist/{chunk-47PP7TAG.js → chunk-EGELTSPU.js} +1356 -1356
  35. package/dist/chunk-EGELTSPU.js.map +1 -0
  36. package/dist/chunk-GULLJQXA.js +698 -0
  37. package/dist/chunk-GULLJQXA.js.map +1 -0
  38. package/dist/{chunk-S5RYMCV6.js → chunk-HPWO4O6S.js} +3 -3
  39. package/dist/chunk-HVRC33OL.js +174 -0
  40. package/dist/chunk-HVRC33OL.js.map +1 -0
  41. package/dist/{chunk-W6R3HAAG.js → chunk-JRGFKVAZ.js} +2 -2
  42. package/dist/{chunk-XJN5WUKL.js → chunk-KG3D7FIF.js} +2 -2
  43. package/dist/chunk-L3PVMIYQ.js +10328 -0
  44. package/dist/chunk-L3PVMIYQ.js.map +1 -0
  45. package/dist/{chunk-QW2Q2KAH.js → chunk-LHHMV4GU.js} +2 -2
  46. package/dist/{chunk-ZOBNS7CX.js → chunk-MEFB5KHA.js} +4 -18
  47. package/dist/chunk-MEFB5KHA.js.map +1 -0
  48. package/dist/{chunk-M2O56UK7.js → chunk-N35E6CM2.js} +293 -163
  49. package/dist/chunk-N35E6CM2.js.map +1 -0
  50. package/dist/chunk-OCBHUHWB.js +69 -0
  51. package/dist/chunk-OCBHUHWB.js.map +1 -0
  52. package/dist/chunk-OIM4HLN6.js +1405 -0
  53. package/dist/chunk-OIM4HLN6.js.map +1 -0
  54. package/dist/{chunk-PKW3H26Z.js → chunk-OJLYNM4Z.js} +56 -33
  55. package/dist/chunk-OJLYNM4Z.js.map +1 -0
  56. package/dist/{chunk-POJRB2AE.js → chunk-POUWHWID.js} +2 -2
  57. package/dist/chunk-PZEN5PHN.js +285 -0
  58. package/dist/chunk-PZEN5PHN.js.map +1 -0
  59. package/dist/chunk-SKAHDQH7.js +1785 -0
  60. package/dist/chunk-SKAHDQH7.js.map +1 -0
  61. package/dist/{chunk-KZAAWQNP.js → chunk-TTNESUPQ.js} +3 -3
  62. package/dist/{chunk-QWBUKIP2.js → chunk-U5DXNFJC.js} +23 -94
  63. package/dist/chunk-U5DXNFJC.js.map +1 -0
  64. package/dist/chunk-USS336NF.js +165 -0
  65. package/dist/chunk-USS336NF.js.map +1 -0
  66. package/dist/{chunk-UO22YNY4.js → chunk-WH7OWT6G.js} +49 -1
  67. package/dist/chunk-WH7OWT6G.js.map +1 -0
  68. package/dist/chunk-WXC57XGG.js +29 -0
  69. package/dist/chunk-WXC57XGG.js.map +1 -0
  70. package/dist/{chunk-YLYINX2H.js → chunk-XZKD7DIF.js} +3 -3
  71. package/dist/{chunk-7GJQ5RGA.js → chunk-YEETV6IW.js} +1077 -1039
  72. package/dist/chunk-YEETV6IW.js.map +1 -0
  73. package/dist/{chunk-B676GPS2.js → chunk-YJHHCWM3.js} +39 -16
  74. package/dist/chunk-YJHHCWM3.js.map +1 -0
  75. package/dist/{cli-U2BEUA55.js → cli-M3XCSOU6.js} +295 -349
  76. package/dist/cli-M3XCSOU6.js.map +1 -0
  77. package/dist/config-MXOX7XDR.js +41 -0
  78. package/dist/{dist-U4M6QCKE.js → dist-3LOO6M4U.js} +10 -10
  79. package/dist/doctor-LU4YIZWM.js +349 -0
  80. package/dist/doctor-LU4YIZWM.js.map +1 -0
  81. package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  82. package/dist/{chunk-3ZW7HPY5.js → fund-A54P2QFK.js} +81 -22
  83. package/dist/fund-A54P2QFK.js.map +1 -0
  84. package/dist/hook-command-U6KWPEDQ.js +377 -0
  85. package/dist/hook-command-U6KWPEDQ.js.map +1 -0
  86. package/dist/index.js +8 -3
  87. package/dist/index.js.map +1 -1
  88. package/dist/install-XUM2XSHW.js +53 -0
  89. package/dist/install-wallet-QIOFORTX.js +105 -0
  90. package/dist/install-wallet-QIOFORTX.js.map +1 -0
  91. package/dist/{run-CJWPGMIQ.js → mcp-HJC2PLRV.js} +3725 -10661
  92. package/dist/mcp-HJC2PLRV.js.map +1 -0
  93. package/dist/paths-P2N4JTDZ.js +49 -0
  94. package/dist/pay-SBXZEPEP.js +37 -0
  95. package/dist/redact-46ZHF2NH.js +17 -0
  96. package/dist/{secp256k1-XRPVBC6V.js → secp256k1-ZZZT2CAX.js} +3 -3
  97. package/dist/{send-C5EOKXOU.js → send-ASD2ZXJD.js} +28 -30
  98. package/dist/send-ASD2ZXJD.js.map +1 -0
  99. package/dist/{chunk-NAAMHWSI.js → skill-placement-NFVHY6A3.js} +159 -12
  100. package/dist/skill-placement-NFVHY6A3.js.map +1 -0
  101. package/dist/status-T2SDB57A.js +63 -0
  102. package/dist/status-T2SDB57A.js.map +1 -0
  103. package/dist/status-line-CGPUSDMC.js +71 -0
  104. package/dist/status-line-CGPUSDMC.js.map +1 -0
  105. package/dist/status-line-wiring-BYPHTYZE.js +30 -0
  106. package/dist/tenjin-daemon.mjs +20060 -0
  107. package/dist/tenjin-shim.mjs +251 -0
  108. package/dist/tenjin-vitest-reporter.mjs +49 -0
  109. package/dist/uninstall-FKYZHAM3.js +144 -0
  110. package/dist/uninstall-FKYZHAM3.js.map +1 -0
  111. package/dist/{update-24Y2CQTT.js → update-ANJ2AOTN.js} +133 -17
  112. package/dist/update-ANJ2AOTN.js.map +1 -0
  113. package/dist/{viemAdapter-By13KInL-TUQJBMHM.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
  114. package/dist/wallet-PWAHVKWW.js +31 -0
  115. package/dist/wallet-kdf-worker.mjs +980 -0
  116. package/docs/agent-permissions.md +68 -342
  117. package/docs/safety-model.md +25 -6
  118. package/package.json +8 -7
  119. package/LICENSE +0 -21
  120. package/dist/buy-2JBYPHAI.js +0 -46
  121. package/dist/chunk-3P3ES4XU.js +0 -144
  122. package/dist/chunk-3P3ES4XU.js.map +0 -1
  123. package/dist/chunk-3ZW7HPY5.js.map +0 -1
  124. package/dist/chunk-47PP7TAG.js.map +0 -1
  125. package/dist/chunk-4UHNXY6B.js +0 -786
  126. package/dist/chunk-4UHNXY6B.js.map +0 -1
  127. package/dist/chunk-4Y53PDH6.js +0 -213
  128. package/dist/chunk-4Y53PDH6.js.map +0 -1
  129. package/dist/chunk-54AJIO3E.js +0 -198
  130. package/dist/chunk-54AJIO3E.js.map +0 -1
  131. package/dist/chunk-736DW4V3.js +0 -65
  132. package/dist/chunk-736DW4V3.js.map +0 -1
  133. package/dist/chunk-7GJQ5RGA.js.map +0 -1
  134. package/dist/chunk-7NADDA2V.js +0 -161
  135. package/dist/chunk-7NADDA2V.js.map +0 -1
  136. package/dist/chunk-ACBEHJAH.js.map +0 -1
  137. package/dist/chunk-B676GPS2.js.map +0 -1
  138. package/dist/chunk-DAZAXFSF.js +0 -1357
  139. package/dist/chunk-DAZAXFSF.js.map +0 -1
  140. package/dist/chunk-DTCXO7HS.js +0 -791
  141. package/dist/chunk-DTCXO7HS.js.map +0 -1
  142. package/dist/chunk-ETKZWJ4B.js.map +0 -1
  143. package/dist/chunk-FDUD3W5V.js +0 -317
  144. package/dist/chunk-FDUD3W5V.js.map +0 -1
  145. package/dist/chunk-GEHL43VE.js +0 -711
  146. package/dist/chunk-GEHL43VE.js.map +0 -1
  147. package/dist/chunk-IU2HVT3Y.js +0 -313
  148. package/dist/chunk-IU2HVT3Y.js.map +0 -1
  149. package/dist/chunk-IUQZ4Z7M.js +0 -162
  150. package/dist/chunk-IUQZ4Z7M.js.map +0 -1
  151. package/dist/chunk-IXZJ3JOO.js +0 -614
  152. package/dist/chunk-IXZJ3JOO.js.map +0 -1
  153. package/dist/chunk-J6FUAIRR.js +0 -205
  154. package/dist/chunk-J6FUAIRR.js.map +0 -1
  155. package/dist/chunk-L6G35FU5.js +0 -105
  156. package/dist/chunk-L6G35FU5.js.map +0 -1
  157. package/dist/chunk-LSWP7MU2.js +0 -290
  158. package/dist/chunk-LSWP7MU2.js.map +0 -1
  159. package/dist/chunk-M2O56UK7.js.map +0 -1
  160. package/dist/chunk-MJSXP4LW.js.map +0 -1
  161. package/dist/chunk-MJZZTKCC.js.map +0 -1
  162. package/dist/chunk-NAAMHWSI.js.map +0 -1
  163. package/dist/chunk-O75FOHXS.js +0 -372
  164. package/dist/chunk-O75FOHXS.js.map +0 -1
  165. package/dist/chunk-OWVVI4VQ.js.map +0 -1
  166. package/dist/chunk-PAOVPSP6.js.map +0 -1
  167. package/dist/chunk-PCX2JQ2J.js +0 -233
  168. package/dist/chunk-PCX2JQ2J.js.map +0 -1
  169. package/dist/chunk-PKW3H26Z.js.map +0 -1
  170. package/dist/chunk-PQZVDCCA.js +0 -125
  171. package/dist/chunk-PQZVDCCA.js.map +0 -1
  172. package/dist/chunk-QWBUKIP2.js.map +0 -1
  173. package/dist/chunk-SGK2B724.js +0 -67
  174. package/dist/chunk-SGK2B724.js.map +0 -1
  175. package/dist/chunk-UHTVXQ2O.js +0 -140
  176. package/dist/chunk-UHTVXQ2O.js.map +0 -1
  177. package/dist/chunk-UO22YNY4.js.map +0 -1
  178. package/dist/chunk-VEAERJVJ.js +0 -43
  179. package/dist/chunk-VEAERJVJ.js.map +0 -1
  180. package/dist/chunk-VRPLZERE.js +0 -1421
  181. package/dist/chunk-VRPLZERE.js.map +0 -1
  182. package/dist/chunk-W4VW5XYB.js +0 -149
  183. package/dist/chunk-W4VW5XYB.js.map +0 -1
  184. package/dist/chunk-WU5CZPLD.js +0 -145
  185. package/dist/chunk-WU5CZPLD.js.map +0 -1
  186. package/dist/chunk-WYLMJQVH.js +0 -240
  187. package/dist/chunk-WYLMJQVH.js.map +0 -1
  188. package/dist/chunk-XGZ5EVMB.js +0 -35
  189. package/dist/chunk-XGZ5EVMB.js.map +0 -1
  190. package/dist/chunk-XVPQGCH4.js +0 -176
  191. package/dist/chunk-XVPQGCH4.js.map +0 -1
  192. package/dist/chunk-ZOBNS7CX.js.map +0 -1
  193. package/dist/chunk-ZQIQ55KK.js +0 -51
  194. package/dist/chunk-ZQIQ55KK.js.map +0 -1
  195. package/dist/cli-U2BEUA55.js.map +0 -1
  196. package/dist/config-CNUIX23Q.js +0 -32
  197. package/dist/doctor-QJJXRWTO.js +0 -31
  198. package/dist/edit-HJ44P44P.js +0 -40
  199. package/dist/fund-Y5IAHZ5D.js +0 -40
  200. package/dist/inspect-NFQ6SQQQ.js +0 -37
  201. package/dist/install-DXX7PVUP.js +0 -854
  202. package/dist/install-DXX7PVUP.js.map +0 -1
  203. package/dist/outcome-ANV4QIED.js +0 -24
  204. package/dist/publish-PCBTCXCZ.js +0 -42
  205. package/dist/read-W7QVRBVD.js +0 -160
  206. package/dist/read-W7QVRBVD.js.map +0 -1
  207. package/dist/run-CJWPGMIQ.js.map +0 -1
  208. package/dist/search-JGAVKTYJ.js +0 -25
  209. package/dist/secp256k1-XRPVBC6V.js.map +0 -1
  210. package/dist/send-C5EOKXOU.js.map +0 -1
  211. package/dist/session-OBCUUIFX.js +0 -89
  212. package/dist/session-OBCUUIFX.js.map +0 -1
  213. package/dist/skill-heal-D6EPLPS6.js +0 -84
  214. package/dist/skill-heal-D6EPLPS6.js.map +0 -1
  215. package/dist/uninstall-OWJNJ5LI.js +0 -73
  216. package/dist/uninstall-OWJNJ5LI.js.map +0 -1
  217. package/dist/update-24Y2CQTT.js.map +0 -1
  218. package/dist/usdc-4VCDHFWX.js +0 -38
  219. package/dist/usdc-4VCDHFWX.js.map +0 -1
  220. package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +0 -1
  221. package/dist/wallet-OFXDIIGP.js +0 -33
  222. package/dist/wallet-OFXDIIGP.js.map +0 -1
  223. package/dist/wallet-SLRIYJ2U.js +0 -42
  224. package/dist/wallet-SLRIYJ2U.js.map +0 -1
  225. package/docs/command-reference.md +0 -261
  226. package/skills/tenjin/SKILL.md +0 -364
  227. package/skills/tenjin-publish/SKILL.md +0 -224
  228. package/skills/tenjin-publish/references/maintain.md +0 -39
  229. package/skills/tenjin-search/SKILL.md +0 -149
  230. package/skills/tenjin-search/references/permissions.md +0 -106
  231. /package/dist/{_esm-N4KAVXQR.js.map → _esm-CE7KNONL.js.map} +0 -0
  232. /package/dist/{buy-2JBYPHAI.js.map → ccip-7RMRLAGV.js.map} +0 -0
  233. /package/dist/{ccip-RPPPKTJR.js.map → ccip-NLCSCHKI.js.map} +0 -0
  234. /package/dist/{chunk-U5S527PP.js.map → chunk-5IEP5EGE.js.map} +0 -0
  235. /package/dist/{chunk-KYQVEKP5.js.map → chunk-BPMWXTFX.js.map} +0 -0
  236. /package/dist/{chunk-S5RYMCV6.js.map → chunk-HPWO4O6S.js.map} +0 -0
  237. /package/dist/{chunk-W6R3HAAG.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  238. /package/dist/{chunk-XJN5WUKL.js.map → chunk-KG3D7FIF.js.map} +0 -0
  239. /package/dist/{chunk-QW2Q2KAH.js.map → chunk-LHHMV4GU.js.map} +0 -0
  240. /package/dist/{chunk-POJRB2AE.js.map → chunk-POUWHWID.js.map} +0 -0
  241. /package/dist/{chunk-KZAAWQNP.js.map → chunk-TTNESUPQ.js.map} +0 -0
  242. /package/dist/{chunk-YLYINX2H.js.map → chunk-XZKD7DIF.js.map} +0 -0
  243. /package/dist/{ccip-ZGGWQN4X.js.map → config-MXOX7XDR.js.map} +0 -0
  244. /package/dist/{dist-U4M6QCKE.js.map → dist-3LOO6M4U.js.map} +0 -0
  245. /package/dist/{config-CNUIX23Q.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  246. /package/dist/{doctor-QJJXRWTO.js.map → install-XUM2XSHW.js.map} +0 -0
  247. /package/dist/{edit-HJ44P44P.js.map → paths-P2N4JTDZ.js.map} +0 -0
  248. /package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js.map → pay-SBXZEPEP.js.map} +0 -0
  249. /package/dist/{fund-Y5IAHZ5D.js.map → redact-46ZHF2NH.js.map} +0 -0
  250. /package/dist/{inspect-NFQ6SQQQ.js.map → secp256k1-ZZZT2CAX.js.map} +0 -0
  251. /package/dist/{outcome-ANV4QIED.js.map → status-line-wiring-BYPHTYZE.js.map} +0 -0
  252. /package/dist/{publish-PCBTCXCZ.js.map → viemAdapter-By13KInL-X2VY6CY3.js.map} +0 -0
  253. /package/dist/{search-JGAVKTYJ.js.map → wallet-PWAHVKWW.js.map} +0 -0
@@ -1,854 +0,0 @@
1
- import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import {
3
- runWalletCreate
4
- } from "./chunk-ACBEHJAH.js";
5
- import "./chunk-MJZZTKCC.js";
6
- import {
7
- describeWallet,
8
- resolveWalletProvider
9
- } from "./chunk-7GJQ5RGA.js";
10
- import {
11
- collectDoctorChecks,
12
- isNoWalletCheck
13
- } from "./chunk-GEHL43VE.js";
14
- import "./chunk-J6FUAIRR.js";
15
- import "./chunk-54AJIO3E.js";
16
- import "./chunk-XGZ5EVMB.js";
17
- import {
18
- walletFileExists
19
- } from "./chunk-3P3ES4XU.js";
20
- import {
21
- removeMarkerLines
22
- } from "./chunk-WYLMJQVH.js";
23
- import {
24
- installSkill
25
- } from "./chunk-NAAMHWSI.js";
26
- import {
27
- sanitizeForTerminal
28
- } from "./chunk-B676GPS2.js";
29
- import {
30
- confirmChoice,
31
- hooksSkipped,
32
- hooksUndo,
33
- intro,
34
- outro,
35
- persistInstallHarness,
36
- persistPublishMode,
37
- persistSearchHookMode,
38
- selectOne,
39
- wireSearchHooks
40
- } from "./chunk-4UHNXY6B.js";
41
- import {
42
- ownsAnyLock,
43
- releaseOwnedLocks
44
- } from "./chunk-ZOBNS7CX.js";
45
- import {
46
- PERMISSIONS_DOC_URL,
47
- recommendedPermissions
48
- } from "./chunk-IUQZ4Z7M.js";
49
- import "./chunk-PKW3H26Z.js";
50
- import "./chunk-736DW4V3.js";
51
- import "./chunk-UO22YNY4.js";
52
- import "./chunk-DTCXO7HS.js";
53
- import {
54
- FREE_VERB_RULES,
55
- MODE_GATED_RULES,
56
- inspectFreeVerbRules,
57
- permissionsSkipped,
58
- planFreeVerbAllowlist,
59
- retractModeGatedRules,
60
- rulesForPublishMode,
61
- wireFreeVerbAllowlist
62
- } from "./chunk-IU2HVT3Y.js";
63
- import "./chunk-VEAERJVJ.js";
64
- import {
65
- CONFIG_DEFAULTS,
66
- PublishModeSchema,
67
- SearchHookModeSchema,
68
- loadRawConfig,
69
- parsePublishModeFlag,
70
- parseSearchHookModeFlag
71
- } from "./chunk-LSWP7MU2.js";
72
- import "./chunk-ETKZWJ4B.js";
73
- import {
74
- walletPath
75
- } from "./chunk-ZQIQ55KK.js";
76
- import {
77
- CLI_SKILL_NAMES,
78
- HARNESS_TARGETS,
79
- HOSTED_SKILL_NAME,
80
- SKILL_NAMES,
81
- harnessDetectedBy,
82
- harnessTargetDir,
83
- isModelInvocationDisabled,
84
- onPath,
85
- readSkillFile,
86
- resolveSkillsSource
87
- } from "./chunk-QWBUKIP2.js";
88
- import {
89
- CliError,
90
- external_exports,
91
- hasCode
92
- } from "./chunk-PAOVPSP6.js";
93
- import "./chunk-7FK2UN2T.js";
94
- import "./chunk-M2O56UK7.js";
95
- import "./chunk-UHTVXQ2O.js";
96
- import "./chunk-W6R3HAAG.js";
97
- import "./chunk-U5S527PP.js";
98
- import "./chunk-47PP7TAG.js";
99
- import "./chunk-XJN5WUKL.js";
100
- import "./chunk-RBJPAZFI.js";
101
- import "./chunk-KYQVEKP5.js";
102
- import "./chunk-ZXTAQYNA.js";
103
-
104
- // src/commands/install.ts
105
- import { existsSync } from "fs";
106
- import { readFile } from "fs/promises";
107
- import { fileURLToPath } from "url";
108
- import { dirname, isAbsolute, join } from "path";
109
- import { homedir } from "os";
110
- import { styleText } from "util";
111
- import { Stream } from "stream";
112
- var HARNESSES = HARNESS_TARGETS;
113
- var InstallInputSchema = external_exports.object({
114
- harness: external_exports.array(external_exports.string()).optional(),
115
- dryRun: external_exports.boolean().optional(),
116
- publishMode: external_exports.string().optional(),
117
- noWallet: external_exports.boolean().optional(),
118
- /**
119
- * ACCEPTED AND IGNORED. `install` writes no CLAUDE.md/AGENTS.md line any more —
120
- * a skill's own frontmatter description is the trigger surface the harness reads
121
- * at session start, so the line only duplicated it. Both spellings still parse so
122
- * a script or a released doc that passes one does not fail; neither does anything.
123
- */
124
- claudeMd: external_exports.boolean().optional(),
125
- /**
126
- * Tri-state. `true` (`--allow-free-verbs`) wires the free-verb
127
- * allowlist without asking, which is now also what an unanswered non-interactive
128
- * run does, so the flag is kept for compatibility and as an explicit statement of
129
- * intent. `false` (`--no-allow-free-verbs`) is the opt-out and is the only way to
130
- * get a run that writes no permission rule. `undefined` asks when it can, and
131
- * writes when it cannot ask.
132
- */
133
- allowFreeVerbs: external_exports.boolean().optional(),
134
- /** The harness search-hook behavior to install (`--search-hooks auto|remind|off`). */
135
- searchHooks: external_exports.string().optional(),
136
- /**
137
- * `--no-hooks`: register no hooks THIS RUN, changing nothing persistent. It is
138
- * deliberately not the same as `--search-hooks off`, which is a durable
139
- * statement about behavior and writes `hooks.searchMode: off` to config.
140
- */
141
- noHooks: external_exports.boolean().optional()
142
- });
143
- function walletFix(reason) {
144
- switch (reason) {
145
- case "no-passphrase-store":
146
- return "No OS credential store is available to hold the wallet passphrase. Set TENJIN_WALLET_PASSPHRASE and re-run `tenjin install`, or run `tenjin wallet create` in a terminal to enter one.";
147
- case "create-failed":
148
- return "Fix the reported problem, then run `tenjin wallet create`.";
149
- case "dry-run":
150
- case "flag":
151
- return "Create one with `tenjin wallet create`.";
152
- }
153
- }
154
- var CODEX_NETWORK_RULE = "[sandbox_workspace_write]\nnetwork_access = true";
155
- async function runInstall(input, ctx, deps = {}) {
156
- return withInterruptGuard((markPhase) => installBody(input, ctx, deps, markPhase));
157
- }
158
- async function withInterruptGuard(fn) {
159
- let phase;
160
- const onSignal = (signal) => {
161
- const wasWriting = ownsAnyLock() || phase === "writing-skills";
162
- releaseOwnedLocks();
163
- if (process.stdin.isTTY) process.stdin.setRawMode?.(false);
164
- if (process.stdout.isTTY) process.stdout.write("\x1B[?25h");
165
- process.stderr.write(
166
- wasWriting ? `
167
- Interrupted mid-write. Some files may be half-written; re-run \`tenjin install\` to finish.
168
- ` : phase === "wired" ? `
169
- Interrupted after the skills were written; later setup steps may not have finished. Re-run \`tenjin install\` to finish.
170
- ` : "\nInterrupted before anything was written; nothing changed.\n"
171
- );
172
- process.exit(signal === "SIGINT" ? 130 : 143);
173
- };
174
- process.on("SIGINT", onSignal);
175
- process.on("SIGTERM", onSignal);
176
- try {
177
- return await fn((p) => {
178
- phase = p;
179
- });
180
- } finally {
181
- process.off("SIGINT", onSignal);
182
- process.off("SIGTERM", onSignal);
183
- }
184
- }
185
- async function installBody(input, ctx, deps, markPhase) {
186
- const parsed = InstallInputSchema.safeParse(input);
187
- if (!parsed.success) {
188
- throw new CliError("USAGE", "Invalid install options", {
189
- fix: "Run `tenjin install --help`.",
190
- details: parsed.error.issues
191
- });
192
- }
193
- const dryRun = parsed.data.dryRun === true;
194
- const noWallet = parsed.data.noWallet === true;
195
- const noHooks = parsed.data.noHooks === true;
196
- const allowFreeVerbs = parsed.data.allowFreeVerbs;
197
- const publishModeFlag = parsed.data.publishMode !== void 0 ? parseModeFlag(parsed.data.publishMode) : void 0;
198
- const searchHooksFlag = parsed.data.searchHooks !== void 0 ? parseSearchHookModeFlag(parsed.data.searchHooks, "--search-hooks") : void 0;
199
- const env = deps.env ?? process.env;
200
- const home = deps.homeDir ?? homedir();
201
- if (!isAbsolute(home)) {
202
- throw new CliError(
203
- "INTERNAL",
204
- "The home directory did not resolve to an absolute path, so nothing was installed.",
205
- {
206
- fix: "Set HOME to your home directory (`export HOME=...`), then re-run `tenjin install`."
207
- }
208
- );
209
- }
210
- const which = deps.which ?? ((bin) => onPath(bin, env));
211
- const humanOutput = ctx.flags.json === true ? false : deps.isInteractive ?? ctx.io.isTTY;
212
- const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));
213
- const skillsSource = deps.skillsSourceDir ?? resolveSkillsSource(fileURLToPath(new URL(".", import.meta.url)));
214
- await assertSkillsSource(skillsSource);
215
- const plans = resolvePlans(parsed.data.harness, home, which);
216
- const explicitHarness = parsed.data.harness !== void 0 && parsed.data.harness.length > 0;
217
- const harnesses = [];
218
- if (!dryRun) markPhase("writing-skills");
219
- for (const plan of plans) {
220
- harnesses.push(await applyPlan(plan, skillsSource, dryRun));
221
- }
222
- await assertSkillsLanded(plans, dryRun);
223
- if (!dryRun) markPhase("wired");
224
- if (explicitHarness && !dryRun) {
225
- await underDataDir(
226
- ctx.dataDir,
227
- () => persistInstallHarness(
228
- ctx.dataDir,
229
- plans.map((p) => p.harness)
230
- )
231
- );
232
- }
233
- const pointerCleanup = dryRun ? [] : await removeMarkerLines(home);
234
- if (canPrompt) await (deps.intro ?? intro)("tenjin install");
235
- const publishMode = await underDataDir(
236
- ctx.dataDir,
237
- () => resolvePublishMode(publishModeFlag, ctx, deps, dryRun, canPrompt)
238
- );
239
- const permissions = await resolvePermissions({
240
- plans,
241
- home,
242
- deps,
243
- flag: allowFreeVerbs,
244
- dryRun,
245
- canPrompt,
246
- publishMode: publishMode.value
247
- });
248
- const hooks = await underDataDir(
249
- ctx.dataDir,
250
- () => resolveHooks({ plans, home, ctx, deps, flag: searchHooksFlag, noHooks, dryRun, canPrompt })
251
- );
252
- const wallet = await underDataDir(
253
- ctx.dataDir,
254
- () => resolveWallet(ctx, deps, walletSkip(dryRun, noWallet), canPrompt)
255
- );
256
- const doctorDeps = { ...deps.doctorDeps ?? {} };
257
- doctorDeps.homeDir ??= home;
258
- doctorDeps.which ??= which;
259
- const collect = deps.collectChecks ?? ((c) => collectDoctorChecks(c, doctorDeps));
260
- const doctor = await collect(ctx);
261
- if (canPrompt) await (deps.outro ?? outro)("Setup complete.");
262
- const data = {
263
- dryRun,
264
- skillsSource,
265
- harnesses,
266
- // One-time cleanup, reported because it edits a file the operator owns. Older
267
- // versions wrote a pointer line into CLAUDE.md/AGENTS.md; nothing writes one
268
- // now, so an install that finds one removes it and says which file it touched.
269
- pointerCleanup,
270
- doctor: { status: doctor.failure !== void 0 ? "fail" : "pass", checks: doctor.checks },
271
- publishMode,
272
- // Shipped with the install rather than left for the operator to discover after
273
- // their first auto-mode denial (#33). Static constants, no config key: see
274
- // lib/permissions.ts for why this is deliberately not operator-editable state.
275
- // `wired` is the outcome of THIS run's settings.json write; the three
276
- // recommendation tiers beside it are unchanged, so a machine consumer that
277
- // read `alwaysSafe` / `optIn` / `neverAllowlisted` before still does.
278
- permissions: { ...recommendedPermissions(publishMode.value), wired: permissions },
279
- hooks,
280
- wallet
281
- };
282
- if (!humanOutput) return { data };
283
- const humanLines = buildWalkthrough(ctx.io, {
284
- pointerCleanup,
285
- dryRun,
286
- dataDir: ctx.dataDir,
287
- harnesses,
288
- publishMode,
289
- permissions,
290
- hooks,
291
- wallet,
292
- doctor
293
- });
294
- return { data, humanLines };
295
- }
296
- function walletSkip(dryRun, noWallet) {
297
- if (dryRun) return "dry-run";
298
- if (noWallet) return "flag";
299
- return void 0;
300
- }
301
- async function underDataDir(dataDir, fn) {
302
- try {
303
- return await fn();
304
- } catch (err) {
305
- if (!hasCode(err, "EACCES") && !hasCode(err, "EPERM")) throw err;
306
- throw new CliError("INTERNAL", `Could not use the Tenjin data directory ${dataDir}.`, {
307
- fix: `Permission denied. Check that you can write to it (\`ls -ld ${dataDir}\`), then re-run \`tenjin install\`.`,
308
- cause: err
309
- });
310
- }
311
- }
312
- var EXAMPLE_QUESTION = "what actually changed in <library> v3's public API";
313
- function buildWalkthrough(io, s) {
314
- const lines = [];
315
- if (s.dryRun) {
316
- lines.push(paint(io, "yellow", "Dry run: nothing was written."));
317
- lines.push("");
318
- }
319
- lines.push(...summaryLines(io, s));
320
- const notices = noticeLines(io, s);
321
- if (notices.length > 0) lines.push("", ...notices);
322
- return lines;
323
- }
324
- function noticeLines(io, s) {
325
- const lines = [];
326
- for (const h of s.harnesses) {
327
- if (h.hostedArrivedFirst) {
328
- lines.push(
329
- paint(
330
- io,
331
- "dim",
332
- `The hosted ${HOSTED_SKILL_NAME} skill was already in ${h.skillsDir}: kept as the zero-install fallback, and the CLI skills now take precedence.`
333
- )
334
- );
335
- }
336
- if (h.codexNetworkRule !== void 0) {
337
- lines.push(paint(io, "dim", "Codex blocks network by default; add to ~/.codex/config.toml:"));
338
- for (const rl of h.codexNetworkRule.split("\n")) lines.push(paint(io, "dim", ` ${rl}`));
339
- }
340
- for (const w of h.warnings) lines.push(paint(io, "yellow", `! ${w}`));
341
- }
342
- if (s.pointerCleanup.length > 0) {
343
- lines.push(
344
- `Removed the old Tenjin pointer line from ${s.pointerCleanup.join(" and ")}; the skills carry their own triggers now.`
345
- );
346
- }
347
- const stale = s.permissions.removed.filter((r) => !MODE_GATED_RULES.includes(r));
348
- if (stale.length > 0) {
349
- lines.push(
350
- `Removed ${stale.length} permission rule(s) an older tenjin left in ${s.permissions.path ?? "your settings"} for commands that no longer exist.`
351
- );
352
- }
353
- if (s.permissions.planned !== true && s.permissions.added.length > 0) {
354
- lines.push(paint(io, "dim", `Undo anytime: remove those lines from ${s.permissions.path}.`));
355
- }
356
- if (s.hooks.added.length > 0 || s.hooks.updated.length > 0) {
357
- lines.push(paint(io, "dim", hooksDisclosure(s.hooks)));
358
- lines.push(
359
- paint(io, "dim", hooksUndo(s.hooks.path ?? "~/.claude/settings.json", s.hooks.scriptsDir))
360
- );
361
- lines.push(
362
- `${paint(io, "bold", "Restart Claude Code")} to load them; hooks are read once at session start.`
363
- );
364
- }
365
- if (s.hooks.warning !== void 0) {
366
- lines.push(paint(io, "yellow", `! ${sanitizeForTerminal(s.hooks.warning)}`));
367
- }
368
- for (const line of walletDisclosure(s.wallet, s.dataDir)) lines.push(paint(io, "dim", line));
369
- if (s.wallet.warning !== void 0) {
370
- lines.push(paint(io, "yellow", `! ${sanitizeForTerminal(s.wallet.warning)}`));
371
- }
372
- if (s.permissions.warning !== void 0) {
373
- lines.push(paint(io, "yellow", `! ${sanitizeForTerminal(s.permissions.warning)}`));
374
- }
375
- lines.push(...doctorNotices(io, s.doctor, s.wallet));
376
- return lines;
377
- }
378
- function summaryLines(io, s) {
379
- return [
380
- ...s.harnesses.map((h) => skillsLine(io, h, s.dryRun)),
381
- publishingLine(io, s.publishMode.value, s.permissions),
382
- permissionsLine(io, s.permissions),
383
- hooksLine(io, s.hooks),
384
- walletLine(io, s.wallet),
385
- `${paint(io, "bold", "Next:")} tenjin search "${EXAMPLE_QUESTION}"`
386
- ];
387
- }
388
- function hooksDisclosure(h) {
389
- const shared = "A Stop hook reminds you locally when a MISS you searched for is still unpublished; it makes no network call.";
390
- if (h.mode === "remind") {
391
- return `The WebSearch hook prints a one-line reminder that Tenjin may have an answer; it sends nothing off-machine. ${shared}`;
392
- }
393
- return `Before a web search, the WebSearch hook asks tenjin.blog the same question (free and anonymous, ~2s budget, 5s harness kill) and mentions a tested answer if one exists; the query text leaves the machine. It can never block or change the search. ${shared}`;
394
- }
395
- function hooksLine(io, h) {
396
- const label = paint(io, "bold", "Search hooks:");
397
- const wrote = h.added.length + h.updated.length;
398
- if (wrote > 0) {
399
- return `${paint(io, "green", "\u2713")} ${label} ${h.mode} mode, ${wrote} hook(s) registered in ${h.path}. Change: tenjin config set hooks.searchMode <auto|remind|off>`;
400
- }
401
- if (h.skipped === void 0) {
402
- return `${paint(io, "green", "\u2713")} ${label} ${h.mode} mode, already registered in ${h.path}`;
403
- }
404
- if (h.skipped === "harness-not-claude") {
405
- return `${paint(io, "dim", "-")} ${label} not wired (Claude Code only).`;
406
- }
407
- if (h.skipped === "dry-run") {
408
- return `${paint(io, "dim", "-")} ${label} unchanged (dry run).`;
409
- }
410
- if (h.skipped === "mode-off") {
411
- return `${paint(io, "dim", "-")} ${label} off (hooks.searchMode). Turn them on: tenjin config set hooks.searchMode auto, then tenjin install`;
412
- }
413
- if (h.skipped === "declined") {
414
- return `${paint(io, "dim", "-")} ${label} not registered this run; nothing was configured. Register them: tenjin install`;
415
- }
416
- if (h.skipped === "changed-since-read") {
417
- return `${paint(io, "yellow", "!")} ${label} ${h.path} changed while it was being updated, so nothing was written. Re-run: tenjin install`;
418
- }
419
- return `${paint(io, "yellow", "!")} ${label} ${h.path} was left untouched. Fix it, then: tenjin install`;
420
- }
421
- function harnessLabel(h) {
422
- return h === "claude" ? "Claude Code" : h === "codex" ? "Codex" : "Agent Skills";
423
- }
424
- function skillsLine(io, h, dryRun) {
425
- const changed = h.skills.some((s) => s.status !== "up-to-date");
426
- const verb = dryRun ? "would install" : changed ? "installed" : "up to date";
427
- const head = `${harnessLabel(h.harness)}: ${h.skills.length} skills ${verb}`;
428
- return `${paint(io, "green", "\u2713")} ${paint(io, "bold", head)} in ${h.skillsDir}. ${skillRoster(h)}.`;
429
- }
430
- function publishingLine(io, mode, wired) {
431
- const undo = wired.modeGrant === void 0 ? "" : ` ${paint(io, "dim", wired.planned === true ? "Would turn off:" : "Turn off:")} tenjin config set publish.mode review`;
432
- return `${paint(io, "green", "\u2713")} ${paint(io, "bold", `Publishing: ${mode}`)}. ${modeBlurb(mode)}${undo}`;
433
- }
434
- function permissionsLine(io, p) {
435
- const label = paint(io, "bold", "Permissions:");
436
- const allowed = p.added.length + p.alreadyPresent.length;
437
- const retracted = p.removed.filter((r) => MODE_GATED_RULES.includes(r));
438
- const gaveBack = retracted.length === 0 ? "" : p.planned === true ? ` A real run would remove ${retracted.length} rule(s) for publish and edit from ${p.path ?? "your settings"}.` : ` Publishing is back to asking first, so ${retracted.length} rule(s) for publish and edit were removed from ${p.path ?? "your settings"}.`;
439
- const unchanged = retracted.length === 0 || p.planned === true ? "unchanged" : "otherwise unchanged";
440
- if (p.planned === true && p.added.length > 0) {
441
- return `${paint(io, "dim", "-")} ${label} would allow ${allowed} tenjin commands in ${p.path}. Details: ${PERMISSIONS_DOC_URL}`;
442
- }
443
- if (p.added.length > 0) {
444
- return `${paint(io, "green", "\u2713")} ${label} ${allowed} tenjin commands allowed in ${p.path}.${gaveBack} Details: ${PERMISSIONS_DOC_URL}`;
445
- }
446
- if (p.skipped === void 0) {
447
- return `${paint(io, "green", "\u2713")} ${label} the ${FREE_VERB_RULES.length} free tenjin commands were already allowed in ${p.path}.${gaveBack}`;
448
- }
449
- if (p.skipped === "harness-not-claude") {
450
- return `${paint(io, "dim", "-")} ${label} not wired for this harness (Claude Code only).${gaveBack} The lines your harness needs: ${PERMISSIONS_DOC_URL}`;
451
- }
452
- if (p.skipped === "dry-run") {
453
- return `${paint(io, "dim", "-")} ${label} ${unchanged} (dry run); the ${FREE_VERB_RULES.length} rules a real run needs are already there.${gaveBack}`;
454
- }
455
- if (p.skipped === "declined" || p.skipped === "not-requested") {
456
- return `${paint(io, "dim", "-")} ${label} ${unchanged}.${gaveBack} Allow the ${FREE_VERB_RULES.length} free tenjin commands with: tenjin install --allow-free-verbs`;
457
- }
458
- if (p.skipped === "changed-since-read") {
459
- return `${paint(io, "yellow", "!")} ${label} ${p.path} changed while it was being updated, so nothing was written.${gaveBack} Re-run: tenjin install`;
460
- }
461
- return `${paint(io, "yellow", "!")} ${label} ${p.path} was left untouched.${gaveBack} Fix it, then: tenjin install --allow-free-verbs`;
462
- }
463
- function walletLine(io, w) {
464
- const label = paint(io, "bold", "Wallet:");
465
- if (w.status === "existing") {
466
- return `${paint(io, "green", "\u2713")} ${label} ${w.address} (existing). Check funds with: tenjin wallet balance`;
467
- }
468
- if (w.status === "created") {
469
- return `${paint(io, "green", "\u2713")} ${label} ${w.address}, holding $0. Fund it with a few dollars of USDC on Base, then: tenjin wallet balance`;
470
- }
471
- if (w.status === "skipped") {
472
- const icon = w.reason === "no-passphrase-store" || w.reason === "create-failed" ? "!" : "-";
473
- const color = icon === "!" ? "yellow" : "dim";
474
- return `${paint(io, color, icon)} ${label} none (${w.reason}). ${w.fix}`;
475
- }
476
- return `${paint(io, "dim", "-")} ${label} none. Create one later with: tenjin wallet create`;
477
- }
478
- function walletDisclosure(w, dataDir) {
479
- if (w.status !== "created") return [];
480
- return [
481
- `A wallet was created at ${walletPath(dataDir)}: the key is encrypted at rest (keystore v3, scrypt, mode 0600) and never leaves this machine.`,
482
- "It holds $0. Funding it is a human step: run `tenjin fund` (card checkout via Coinbase, opened in your browser), or send USDC on Base to that address."
483
- ];
484
- }
485
- function skillRoster(h) {
486
- const cli = h.skills.filter((s) => s.cli).map((s) => s.name);
487
- const hosted = h.skills.filter((s) => !s.cli).map((s) => s.name);
488
- const parts = [];
489
- if (cli.length > 0) parts.push(`${cli.join(", ")} (CLI)`);
490
- if (hosted.length > 0) parts.push(`${hosted.join(", ")} (hosted, zero-install fallback)`);
491
- return parts.join("; ");
492
- }
493
- function modeBlurb(v) {
494
- return v === "auto" ? "Your agent publishes and updates pieces on its own, under your identity." : v === "review" ? "Your agent asks you in chat before every publish." : "Your agent publishes on its own, under your identity, and only a hard block stops it.";
495
- }
496
- async function resolveWallet(ctx, deps, skipReason, canPrompt) {
497
- const exists = await (deps.walletExists ?? walletFileExists)(ctx.dataDir);
498
- if (exists) {
499
- return {
500
- status: "existing",
501
- address: await (deps.walletAddress ?? existingWalletAddress)(ctx)
502
- };
503
- }
504
- if (skipReason !== void 0) {
505
- return { status: "skipped", reason: skipReason, fix: walletFix(skipReason) };
506
- }
507
- if (canPrompt) {
508
- const confirm = deps.confirmWallet ?? defaultConfirm;
509
- if (!await confirm(WALLET_QUESTION)) return { status: "declined" };
510
- }
511
- try {
512
- const create = deps.createWallet ?? ((c) => defaultCreateWallet(c, deps.walletPassphrase, deps.env));
513
- return { status: "created", address: await create(ctx) };
514
- } catch (err) {
515
- const reason = isNoPassphraseError(err) ? "no-passphrase-store" : "create-failed";
516
- return {
517
- status: "skipped",
518
- reason,
519
- fix: walletFix(reason),
520
- ...reason === "create-failed" ? { warning: `The wallet could not be created: ${errorText(err)}` } : {}
521
- };
522
- }
523
- }
524
- function isNoPassphraseError(err) {
525
- return err instanceof CliError && err.code === "USAGE" && err.message.includes("No wallet passphrase is available");
526
- }
527
- function errorText(err) {
528
- return err instanceof Error ? err.message : String(err);
529
- }
530
- async function existingWalletAddress(ctx) {
531
- return (await describeWallet(resolveWalletProvider(ctx))).address;
532
- }
533
- async function defaultCreateWallet(ctx, passphrase, env) {
534
- const result = await runWalletCreate(ctx, {
535
- ...passphrase !== void 0 ? { passphrase } : {},
536
- ...env !== void 0 ? { env } : {}
537
- });
538
- return result.data.address;
539
- }
540
- function defaultConfirm(label) {
541
- return confirmChoice(label, true);
542
- }
543
- function summaryAlreadySaysNoWallet(wallet) {
544
- return wallet.status === "declined" || wallet.status === "skipped";
545
- }
546
- function doctorNotices(io, doctor, wallet) {
547
- const problems = doctor.checks.filter(
548
- (c) => c.status !== "ok" && !(summaryAlreadySaysNoWallet(wallet) && isNoWalletCheck(c))
549
- );
550
- if (problems.length === 0) return [];
551
- const lines = [paint(io, "yellow", "Some checks need attention:")];
552
- for (const c of problems) {
553
- const icon = c.status === "fail" ? paint(io, "red", "\u2717") : paint(io, "yellow", "!");
554
- lines.push(` ${icon} ${c.name}: ${sanitizeForTerminal(c.detail)}`);
555
- if (c.fix !== void 0) {
556
- lines.push(paint(io, "dim", ` fix: ${sanitizeForTerminal(c.fix)}`));
557
- }
558
- }
559
- return lines;
560
- }
561
- var DEFAULT_MODE = CONFIG_DEFAULTS.publish.mode;
562
- var RECOMMENDED_MODE = "auto";
563
- var PUBLISH_MODE_CHOICES = [
564
- {
565
- value: "auto",
566
- label: "Auto (recommended)",
567
- hint: "your agent publishes and updates pieces on its own, under your identity"
568
- },
569
- { value: "review", label: "Ask me in chat first" },
570
- { value: "full-auto", label: "Fully unattended", hint: "only a hard block stops it" }
571
- ];
572
- var PUBLISH_MODE_QUESTION = "When your agent has something worth publishing:";
573
- async function resolvePublishMode(flag, ctx, deps, dryRun, interactive) {
574
- if (flag !== void 0) {
575
- if (!dryRun) await persistPublishMode(ctx.dataDir, flag);
576
- return { value: flag, source: "flag" };
577
- }
578
- const config = await loadRawConfig(ctx.dataDir);
579
- if (config.publish?.mode !== void 0) {
580
- return { value: config.publish.mode, source: "existing" };
581
- }
582
- if (dryRun) return { value: DEFAULT_MODE, source: "default-skipped" };
583
- if (!interactive) {
584
- await persistPublishMode(ctx.dataDir, RECOMMENDED_MODE);
585
- return { value: RECOMMENDED_MODE, source: "headless-default" };
586
- }
587
- const answer = await (deps.promptPublishMode ?? defaultPromptPublishMode)();
588
- if (answer === null) return { value: DEFAULT_MODE, source: "default-skipped" };
589
- const parsed = PublishModeSchema.safeParse(answer);
590
- if (!parsed.success) return { value: DEFAULT_MODE, source: "default-skipped" };
591
- await persistPublishMode(ctx.dataDir, parsed.data);
592
- return { value: parsed.data, source: "prompt" };
593
- }
594
- function defaultPromptPublishMode() {
595
- return selectOne({
596
- message: PUBLISH_MODE_QUESTION,
597
- choices: PUBLISH_MODE_CHOICES.map((c) => ({ ...c })),
598
- initialValue: "auto"
599
- });
600
- }
601
- function parseModeFlag(value) {
602
- return parsePublishModeFlag(value, "--publish-mode");
603
- }
604
- function permissionsQuestionHead(mode) {
605
- const count = rulesForPublishMode(mode).length;
606
- return `Let your agent use tenjin without permission popups? Adds ${count} command rules to ~/.claude/settings.json.`;
607
- }
608
- var PERMISSIONS_QUESTION = `${permissionsQuestionHead("review")} None of them can spend your money. Details: ${PERMISSIONS_DOC_URL}`;
609
- function permissionsQuestion(mode) {
610
- if (mode === "review") return PERMISSIONS_QUESTION;
611
- return `${permissionsQuestionHead(mode)} None of them can spend your money, and on publish.mode ${mode} your agent will publish under your identity on its own. Details: ${PERMISSIONS_DOC_URL}`;
612
- }
613
- var WALLET_QUESTION = "Create a wallet now?";
614
- async function resolvePermissions(args) {
615
- const { plans, home, deps, flag, dryRun, canPrompt, publishMode } = args;
616
- if (dryRun) return (deps.planPermissions ?? planFreeVerbAllowlist)(home, publishMode);
617
- let retractedRules = [];
618
- let retractedFrom;
619
- if (publishMode === "review") {
620
- const retracted = await (deps.retractModeGated ?? retractModeGatedRules)(home);
621
- if (retracted.skipped !== void 0) return retracted;
622
- retractedRules = retracted.removed;
623
- retractedFrom = retracted.path;
624
- }
625
- const withRetraction = (result) => retractedRules.length === 0 ? result : {
626
- ...result,
627
- removed: [...retractedRules, ...result.removed],
628
- // A non-Claude skip carries no `path`, deliberately: naming a Claude
629
- // file to a Codex-only operator points them at a file that is nothing
630
- // to do with their harness. Once we have RETRACTED from that file, the
631
- // reverse is true, and the operator needs to know which file changed.
632
- ...result.path === void 0 ? { path: retractedFrom } : {}
633
- };
634
- if (!plans.some((p) => p.harness === "claude")) {
635
- return withRetraction(
636
- permissionsSkipped(plans[0]?.harness ?? "shared", home, "harness-not-claude")
637
- );
638
- }
639
- if (flag === false) return withRetraction(permissionsSkipped("claude", home, "declined"));
640
- const probe = await (deps.inspectPermissions ?? inspectFreeVerbRules)(home, publishMode);
641
- if (probe.satisfied !== void 0) return withRetraction(probe.satisfied);
642
- if (probe.pending !== null && probe.pending.length === 0) {
643
- return withRetraction(await wireFreeVerbAllowlist(home, publishMode));
644
- }
645
- if (flag === true || !canPrompt) {
646
- return withRetraction(await wireFreeVerbAllowlist(home, publishMode));
647
- }
648
- const confirm = deps.confirmPermissions ?? defaultConfirm;
649
- if (!await confirm(permissionsQuestion(publishMode))) {
650
- return withRetraction(permissionsSkipped("claude", home, "declined"));
651
- }
652
- return withRetraction(await wireFreeVerbAllowlist(home, publishMode));
653
- }
654
- var SEARCH_HOOKS_QUESTION = "Let Tenjin ride along with your web searches?";
655
- var SEARCH_HOOKS_CHOICES = [
656
- {
657
- value: "auto",
658
- label: "Yes, check Tenjin first (recommended)",
659
- hint: "before a WebSearch, ask tenjin.blog the same question (free, anonymous, 2s budget) and mention a tested answer; the query text leaves the machine"
660
- },
661
- {
662
- value: "remind",
663
- label: "Just remind me",
664
- hint: "a one-line reminder, nothing sent off-machine"
665
- },
666
- { value: "off", label: "No hooks", hint: "nothing is registered" }
667
- ];
668
- async function resolveHooks(args) {
669
- const { plans, home, ctx, deps, flag, noHooks, dryRun, canPrompt } = args;
670
- const dataDir = ctx.dataDir;
671
- const stored = (await loadRawConfig(dataDir)).hooks?.searchMode;
672
- if (!plans.some((p) => p.harness === "claude")) {
673
- const harness = plans[0]?.harness ?? "shared";
674
- return hooksSkipped(
675
- harness,
676
- home,
677
- dataDir,
678
- flag ?? stored ?? DEFAULT_HOOK_MODE,
679
- "harness-not-claude"
680
- );
681
- }
682
- if (noHooks) {
683
- return hooksSkipped("claude", home, dataDir, stored ?? DEFAULT_HOOK_MODE, "declined");
684
- }
685
- const mode = await chooseHookMode(flag, stored, deps, dryRun, canPrompt);
686
- if (mode === null) {
687
- return hooksSkipped("claude", home, dataDir, stored ?? DEFAULT_HOOK_MODE, "declined");
688
- }
689
- if (dryRun) return hooksSkipped("claude", home, dataDir, mode, "dry-run");
690
- if (mode !== (stored ?? DEFAULT_HOOK_MODE) || stored === void 0) {
691
- await persistSearchHookMode(dataDir, mode);
692
- }
693
- if (mode === "off") return hooksSkipped("claude", home, dataDir, mode, "mode-off");
694
- return wireSearchHooks({ homeDir: home, dataDir, mode });
695
- }
696
- var DEFAULT_HOOK_MODE = CONFIG_DEFAULTS.hooks.searchMode;
697
- async function chooseHookMode(flag, stored, deps, dryRun, canPrompt) {
698
- if (flag !== void 0) return flag;
699
- if (dryRun || !canPrompt) return stored ?? DEFAULT_HOOK_MODE;
700
- const answer = await (deps.promptSearchHooks ?? defaultPromptSearchHooks)();
701
- if (answer === null) return null;
702
- const parsed = SearchHookModeSchema.safeParse(answer);
703
- return parsed.success ? parsed.data : null;
704
- }
705
- function defaultPromptSearchHooks() {
706
- return selectOne({
707
- message: SEARCH_HOOKS_QUESTION,
708
- choices: SEARCH_HOOKS_CHOICES.map((c) => ({ ...c })),
709
- initialValue: "auto"
710
- });
711
- }
712
- function resolvePlans(override, home, which) {
713
- if (override !== void 0 && override.length > 0) {
714
- const plans2 = override.map((v) => planFor(validateHarness(v), ["override"], true, home));
715
- return dedupeBySkillsDir(plans2);
716
- }
717
- const plans = [];
718
- const claudeBy = harnessDetectedBy(home, "claude", which);
719
- const codexBy = harnessDetectedBy(home, "codex", which);
720
- if (claudeBy.length > 0) plans.push(planFor("claude", claudeBy, true, home));
721
- if (codexBy.length > 0) plans.push(planFor("codex", codexBy, true, home));
722
- if (plans.length === 0) {
723
- plans.push(planFor("shared", ["fallback"], false, home));
724
- }
725
- return dedupeBySkillsDir(plans);
726
- }
727
- function planFor(harness, detectedBy, detected, home) {
728
- const skillsDir = harnessTargetDir(home, harness);
729
- return { harness, detected, detectedBy, skillsDir, wiresAgentsMd: harness !== "claude", home };
730
- }
731
- function dedupeBySkillsDir(plans) {
732
- const seen = /* @__PURE__ */ new Set();
733
- const out = [];
734
- for (const p of plans) {
735
- if (seen.has(p.skillsDir)) continue;
736
- seen.add(p.skillsDir);
737
- out.push(p);
738
- }
739
- return out;
740
- }
741
- function validateHarness(value) {
742
- if (HARNESSES.includes(value)) return value;
743
- throw new CliError("USAGE", `Unknown harness "${value}"`, {
744
- fix: `--harness must be one of: ${HARNESSES.join(", ")}.`
745
- });
746
- }
747
- async function applyPlan(plan, skillsSource, dryRun) {
748
- const skills = [];
749
- const warnings = [];
750
- for (const name of SKILL_NAMES) {
751
- const { status, warning, preexisting } = await installSkill(
752
- join(skillsSource, name),
753
- join(plan.skillsDir, name),
754
- dryRun,
755
- name
756
- );
757
- skills.push({
758
- name,
759
- status,
760
- preexisting,
761
- cli: CLI_SKILL_NAMES.includes(name),
762
- modelInvocable: await landedInvocable(plan.skillsDir, skillsSource, name, dryRun)
763
- });
764
- if (warning !== void 0) warnings.push(warning);
765
- }
766
- const hostedPreexisting = skills.some((s) => s.name === HOSTED_SKILL_NAME && s.preexisting);
767
- const hostedArrivedFirst = hostedPreexisting && !skills.some((s) => s.cli && s.preexisting);
768
- const result = {
769
- harness: plan.harness,
770
- detected: plan.detected,
771
- detectedBy: plan.detectedBy,
772
- skillsDir: plan.skillsDir,
773
- skills,
774
- hostedPreexisting,
775
- hostedArrivedFirst,
776
- notes: notesFor(plan, hostedArrivedFirst),
777
- warnings
778
- };
779
- if (plan.wiresAgentsMd) result.codexNetworkRule = CODEX_NETWORK_RULE;
780
- return result;
781
- }
782
- function notesFor(plan, hostedArrivedFirst) {
783
- const notes = plan.harness === "claude" ? [
784
- "Installed at the user level (~/.claude/skills). A Claude Code plugin will later make this automatic."
785
- ] : [
786
- "Copied into the shared Agent Skills location (~/.agents/skills). Codex and any Agent-Skills-compatible harness read it there."
787
- ];
788
- if (hostedArrivedFirst) {
789
- notes.push(
790
- `The hosted ${HOSTED_SKILL_NAME} skill was already here; the skill stays as the zero-install fallback (its file is replaced by this package's mirror) and the CLI skills (${CLI_SKILL_NAMES.join(", ")}) take precedence while the CLI is installed.`
791
- );
792
- }
793
- return notes;
794
- }
795
- async function landedInvocable(skillsDir, skillsSource, name, dryRun) {
796
- const read = await readSkillFile(join(dryRun ? skillsSource : skillsDir, name, "SKILL.md"));
797
- if (read.kind !== "ok") return false;
798
- return !isModelInvocationDisabled(read.bytes.toString("utf8"));
799
- }
800
- async function assertSkillsLanded(plans, dryRun) {
801
- if (dryRun) return;
802
- const missing = [];
803
- for (const plan of plans) {
804
- for (const name of SKILL_NAMES) {
805
- if (!existsSync(join(plan.skillsDir, name, "SKILL.md"))) {
806
- missing.push(join(plan.skillsDir, name));
807
- }
808
- }
809
- }
810
- if (missing.length === 0) return;
811
- throw new CliError("INTERNAL", `Skills were not written: ${missing.join(", ")}`, {
812
- // Safe to point at permissions because nothing removes a landed file any more:
813
- // each shipped file arrives by its own atomic rename. When this was a
814
- // rm-then-write it also fired on a lost race, and sent people to chmod a
815
- // directory that was fine.
816
- fix: `Check that you can write to the skills directory (\`ls -ld ${dirname(missing[0] ?? "")}\`), then re-run \`tenjin install\`.`
817
- });
818
- }
819
- function paint(io, format, text) {
820
- if (io.stdout instanceof Stream) return styleText(format, text, { stream: io.stdout });
821
- return styleText(format, text);
822
- }
823
- async function assertSkillsSource(dir) {
824
- for (const name of SKILL_NAMES) {
825
- if (!existsSync(join(dir, name, "SKILL.md"))) {
826
- throw new CliError("INTERNAL", `Packaged skill "${name}" is missing under ${dir}`, {
827
- fix: "Reinstall tenjin-cli; the published package must ship every skill under skills/."
828
- });
829
- }
830
- }
831
- for (const name of CLI_SKILL_NAMES) {
832
- const text = await readFile(join(dir, name, "SKILL.md"), "utf8");
833
- if (isModelInvocationDisabled(text)) {
834
- throw new CliError(
835
- "INTERNAL",
836
- `Packaged skill "${name}" carries disable-model-invocation: true, so no harness would surface it`,
837
- {
838
- fix: "Reinstall tenjin-cli; the published CLI skills must be model-invocable."
839
- }
840
- );
841
- }
842
- }
843
- }
844
- export {
845
- PERMISSIONS_QUESTION,
846
- PUBLISH_MODE_CHOICES,
847
- PUBLISH_MODE_QUESTION,
848
- SEARCH_HOOKS_CHOICES,
849
- SEARCH_HOOKS_QUESTION,
850
- WALLET_QUESTION,
851
- permissionsQuestion,
852
- runInstall
853
- };
854
- //# sourceMappingURL=install-DXX7PVUP.js.map