tenjin-cli 0.1.0-alpha.13 → 0.1.0-alpha.15

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 (182) hide show
  1. package/README.md +51 -3
  2. package/dist/buy-VIRNSYGN.js +47 -0
  3. package/dist/{chunk-OC3EIDCP.js → chunk-2MYQN7HM.js} +71 -26
  4. package/dist/chunk-2MYQN7HM.js.map +1 -0
  5. package/dist/{chunk-XXY77EZJ.js → chunk-2RF2GIJQ.js} +57 -226
  6. package/dist/chunk-2RF2GIJQ.js.map +1 -0
  7. package/dist/chunk-3GL2Z5QK.js +57 -0
  8. package/dist/chunk-3GL2Z5QK.js.map +1 -0
  9. package/dist/{chunk-OXUJ3FXU.js → chunk-4CQIDQOT.js} +41 -8
  10. package/dist/chunk-4CQIDQOT.js.map +1 -0
  11. package/dist/{chunk-YMUJZWHB.js → chunk-4KG27W2S.js} +10 -10
  12. package/dist/chunk-4KG27W2S.js.map +1 -0
  13. package/dist/{chunk-SPUORKD7.js → chunk-5QQTYWEU.js} +13 -13
  14. package/dist/chunk-5QQTYWEU.js.map +1 -0
  15. package/dist/chunk-65DTCCJ7.js +21 -0
  16. package/dist/chunk-65DTCCJ7.js.map +1 -0
  17. package/dist/{chunk-BRAVLUGI.js → chunk-A5DKHMUN.js} +28 -13
  18. package/dist/chunk-A5DKHMUN.js.map +1 -0
  19. package/dist/chunk-B63XPWQ4.js +246 -0
  20. package/dist/chunk-B63XPWQ4.js.map +1 -0
  21. package/dist/{chunk-47YKYDOF.js → chunk-CAR6FHK6.js} +5 -5
  22. package/dist/{chunk-JVBMPU5G.js → chunk-CPCX67TI.js} +22 -22
  23. package/dist/{chunk-TXVC46SA.js → chunk-CQBVCYI2.js} +40 -53
  24. package/dist/chunk-CQBVCYI2.js.map +1 -0
  25. package/dist/chunk-DBU5CXBV.js +4731 -0
  26. package/dist/chunk-DBU5CXBV.js.map +1 -0
  27. package/dist/chunk-DHJD77OW.js +81 -0
  28. package/dist/chunk-DHJD77OW.js.map +1 -0
  29. package/dist/{chunk-XGZ5EVMB.js → chunk-EDZSNPE5.js} +2 -2
  30. package/dist/{chunk-736DW4V3.js → chunk-EFWZPUTC.js} +2 -2
  31. package/dist/chunk-EPFL6CTE.js +448 -0
  32. package/dist/chunk-EPFL6CTE.js.map +1 -0
  33. package/dist/{chunk-3P3ES4XU.js → chunk-GHLVXVZD.js} +3 -5
  34. package/dist/{chunk-3P3ES4XU.js.map → chunk-GHLVXVZD.js.map} +1 -1
  35. package/dist/{chunk-UUARTUY2.js → chunk-H3SOOJ2I.js} +264 -33
  36. package/dist/chunk-H3SOOJ2I.js.map +1 -0
  37. package/dist/{chunk-OUJDDY5L.js → chunk-HPJGOLTN.js} +32 -32
  38. package/dist/chunk-HPJGOLTN.js.map +1 -0
  39. package/dist/{chunk-J6FUAIRR.js → chunk-HRGBS2PA.js} +4 -6
  40. package/dist/{chunk-J6FUAIRR.js.map → chunk-HRGBS2PA.js.map} +1 -1
  41. package/dist/{chunk-NKN4YC5C.js → chunk-ITUXPJIS.js} +55 -58
  42. package/dist/chunk-ITUXPJIS.js.map +1 -0
  43. package/dist/{chunk-CA3JV7FX.js → chunk-JBIKAAT3.js} +2 -2
  44. package/dist/{chunk-CA3JV7FX.js.map → chunk-JBIKAAT3.js.map} +1 -1
  45. package/dist/{chunk-6JKD46OJ.js → chunk-KAJZHIQ4.js} +13 -10
  46. package/dist/chunk-KAJZHIQ4.js.map +1 -0
  47. package/dist/{chunk-OWVVI4VQ.js → chunk-KINZ23CV.js} +107 -4535
  48. package/dist/chunk-KINZ23CV.js.map +1 -0
  49. package/dist/{chunk-WMFRCSNC.js → chunk-LRYV3SK7.js} +9 -7
  50. package/dist/{chunk-WMFRCSNC.js.map → chunk-LRYV3SK7.js.map} +1 -1
  51. package/dist/{chunk-T4UWMVKV.js → chunk-NIKXHWOL.js} +11 -13
  52. package/dist/{chunk-T4UWMVKV.js.map → chunk-NIKXHWOL.js.map} +1 -1
  53. package/dist/chunk-OKDRDT74.js +209 -0
  54. package/dist/chunk-OKDRDT74.js.map +1 -0
  55. package/dist/chunk-OKYSNAS3.js +2144 -0
  56. package/dist/chunk-OKYSNAS3.js.map +1 -0
  57. package/dist/{chunk-B676GPS2.js → chunk-OLWTRUTS.js} +7 -3
  58. package/dist/{chunk-B676GPS2.js.map → chunk-OLWTRUTS.js.map} +1 -1
  59. package/dist/{chunk-WU5CZPLD.js → chunk-QQ6ELLSA.js} +6 -8
  60. package/dist/{chunk-WU5CZPLD.js.map → chunk-QQ6ELLSA.js.map} +1 -1
  61. package/dist/{chunk-WVHPGQH5.js → chunk-QZ6ROAJU.js} +8 -4
  62. package/dist/chunk-QZ6ROAJU.js.map +1 -0
  63. package/dist/{chunk-L4XNT3UW.js → chunk-R7RSCBI7.js} +167 -52
  64. package/dist/chunk-R7RSCBI7.js.map +1 -0
  65. package/dist/{chunk-ELVDOTU7.js → chunk-U6VPKMGC.js} +128 -28
  66. package/dist/chunk-U6VPKMGC.js.map +1 -0
  67. package/dist/{chunk-FKSAUOJU.js → chunk-UO22YNY4.js} +1 -69
  68. package/dist/chunk-UO22YNY4.js.map +1 -0
  69. package/dist/{chunk-IAR25V2E.js → chunk-US456VUI.js} +6 -6
  70. package/dist/{chunk-IKAJSA7E.js → chunk-V44J2MXV.js} +80 -34
  71. package/dist/chunk-V44J2MXV.js.map +1 -0
  72. package/dist/{chunk-IFPKA32J.js → chunk-VJQKL3YH.js} +10 -7
  73. package/dist/{chunk-IFPKA32J.js.map → chunk-VJQKL3YH.js.map} +1 -1
  74. package/dist/{chunk-GCGMXA2O.js → chunk-VJSQSLBM.js} +52 -20
  75. package/dist/chunk-VJSQSLBM.js.map +1 -0
  76. package/dist/{chunk-IGHSLJUF.js → chunk-VYOJOX4Z.js} +9 -7
  77. package/dist/chunk-VYOJOX4Z.js.map +1 -0
  78. package/dist/chunk-WY2K35OL.js +269 -0
  79. package/dist/chunk-WY2K35OL.js.map +1 -0
  80. package/dist/{chunk-PAOVPSP6.js → chunk-ZFJJ3EXC.js} +53 -5
  81. package/dist/chunk-ZFJJ3EXC.js.map +1 -0
  82. package/dist/chunk-ZOBNS7CX.js +73 -0
  83. package/dist/chunk-ZOBNS7CX.js.map +1 -0
  84. package/dist/{cli-XK5JZWU6.js → cli-KKRKBU5T.js} +76 -47
  85. package/dist/{cli-XK5JZWU6.js.map → cli-KKRKBU5T.js.map} +1 -1
  86. package/dist/config-JMRUNYE6.js +37 -0
  87. package/dist/discover-B5HF6SHM.js +102 -0
  88. package/dist/discover-B5HF6SHM.js.map +1 -0
  89. package/dist/doctor-ZBG7X66D.js +32 -0
  90. package/dist/edit-PZJIILQE.js +40 -0
  91. package/dist/{fund-JF6A76YS.js → fund-EUDH5KPA.js} +19 -17
  92. package/dist/index.js +1 -1
  93. package/dist/inspect-QC6WEQPN.js +37 -0
  94. package/dist/{install-YQVM3SUW.js → install-GNK2W3PI.js} +286 -447
  95. package/dist/install-GNK2W3PI.js.map +1 -0
  96. package/dist/outcome-KSGWZHUS.js +24 -0
  97. package/dist/pay-BC4UICPA.js +361 -0
  98. package/dist/pay-BC4UICPA.js.map +1 -0
  99. package/dist/publish-LXWFDIKF.js +42 -0
  100. package/dist/{read-UF7QVQOU.js → read-JMNUQ56P.js} +22 -20
  101. package/dist/{read-UF7QVQOU.js.map → read-JMNUQ56P.js.map} +1 -1
  102. package/dist/{run-GDZWHNWZ.js → run-XYTQ5TWQ.js} +54 -45
  103. package/dist/{run-GDZWHNWZ.js.map → run-XYTQ5TWQ.js.map} +1 -1
  104. package/dist/search-TSQAB45E.js +25 -0
  105. package/dist/{send-SI254H3R.js → send-G746D7PQ.js} +14 -14
  106. package/dist/{session-GJZJEXLJ.js → session-JBKWMJ24.js} +18 -17
  107. package/dist/{session-GJZJEXLJ.js.map → session-JBKWMJ24.js.map} +1 -1
  108. package/dist/{skill-heal-BPFT22XS.js → skill-heal-WKD67SLJ.js} +17 -9
  109. package/dist/skill-heal-WKD67SLJ.js.map +1 -0
  110. package/dist/skill-placement-RIU4AMC2.js +20 -0
  111. package/dist/{uninstall-7ZZG6WQ5.js → uninstall-5E263VTS.js} +15 -9
  112. package/dist/uninstall-5E263VTS.js.map +1 -0
  113. package/dist/{update-FPSBITLB.js → update-R76LHOZW.js} +18 -16
  114. package/dist/update-R76LHOZW.js.map +1 -0
  115. package/dist/{wallet-NS7TYWNN.js → wallet-TQ7D5EQ7.js} +7 -7
  116. package/dist/{wallet-TZVD2M4I.js → wallet-ZAVXWLWP.js} +11 -11
  117. package/dist/wallet-ZAVXWLWP.js.map +1 -0
  118. package/docs/agent-permissions.md +117 -18
  119. package/docs/command-reference.md +102 -50
  120. package/docs/safety-model.md +9 -0
  121. package/package.json +1 -1
  122. package/skills/tenjin/SKILL.md +38 -29
  123. package/skills/tenjin-pay/SKILL.md +76 -0
  124. package/skills/tenjin-publish/SKILL.md +184 -205
  125. package/skills/tenjin-publish/references/maintain.md +39 -0
  126. package/skills/tenjin-search/SKILL.md +92 -280
  127. package/skills/tenjin-search/references/permissions.md +112 -0
  128. package/dist/buy-X4VPHFUA.js +0 -44
  129. package/dist/chunk-3NZCU6SD.js +0 -125
  130. package/dist/chunk-3NZCU6SD.js.map +0 -1
  131. package/dist/chunk-6JKD46OJ.js.map +0 -1
  132. package/dist/chunk-BRAVLUGI.js.map +0 -1
  133. package/dist/chunk-ELVDOTU7.js.map +0 -1
  134. package/dist/chunk-FKSAUOJU.js.map +0 -1
  135. package/dist/chunk-GCGMXA2O.js.map +0 -1
  136. package/dist/chunk-IGHSLJUF.js.map +0 -1
  137. package/dist/chunk-IKAJSA7E.js.map +0 -1
  138. package/dist/chunk-L4XNT3UW.js.map +0 -1
  139. package/dist/chunk-NKN4YC5C.js.map +0 -1
  140. package/dist/chunk-OC3EIDCP.js.map +0 -1
  141. package/dist/chunk-OE36HRWG.js +0 -939
  142. package/dist/chunk-OE36HRWG.js.map +0 -1
  143. package/dist/chunk-OUJDDY5L.js.map +0 -1
  144. package/dist/chunk-OWVVI4VQ.js.map +0 -1
  145. package/dist/chunk-OXUJ3FXU.js.map +0 -1
  146. package/dist/chunk-PAOVPSP6.js.map +0 -1
  147. package/dist/chunk-SPUORKD7.js.map +0 -1
  148. package/dist/chunk-TXVC46SA.js.map +0 -1
  149. package/dist/chunk-UUARTUY2.js.map +0 -1
  150. package/dist/chunk-WVHPGQH5.js.map +0 -1
  151. package/dist/chunk-XXY77EZJ.js.map +0 -1
  152. package/dist/chunk-YMUJZWHB.js.map +0 -1
  153. package/dist/chunk-ZQIQ55KK.js +0 -51
  154. package/dist/chunk-ZQIQ55KK.js.map +0 -1
  155. package/dist/config-CNK7MYUR.js +0 -26
  156. package/dist/doctor-R7N7FUX5.js +0 -27
  157. package/dist/edit-QSUEG7CL.js +0 -38
  158. package/dist/inspect-NFNAA4LA.js +0 -35
  159. package/dist/install-YQVM3SUW.js.map +0 -1
  160. package/dist/outcome-IUSYFJTN.js +0 -22
  161. package/dist/publish-O2I6IAEL.js +0 -40
  162. package/dist/search-JVOHEF3E.js +0 -23
  163. package/dist/skill-heal-BPFT22XS.js.map +0 -1
  164. package/dist/uninstall-7ZZG6WQ5.js.map +0 -1
  165. package/dist/update-FPSBITLB.js.map +0 -1
  166. /package/dist/{buy-X4VPHFUA.js.map → buy-VIRNSYGN.js.map} +0 -0
  167. /package/dist/{chunk-47YKYDOF.js.map → chunk-CAR6FHK6.js.map} +0 -0
  168. /package/dist/{chunk-JVBMPU5G.js.map → chunk-CPCX67TI.js.map} +0 -0
  169. /package/dist/{chunk-XGZ5EVMB.js.map → chunk-EDZSNPE5.js.map} +0 -0
  170. /package/dist/{chunk-736DW4V3.js.map → chunk-EFWZPUTC.js.map} +0 -0
  171. /package/dist/{chunk-IAR25V2E.js.map → chunk-US456VUI.js.map} +0 -0
  172. /package/dist/{config-CNK7MYUR.js.map → config-JMRUNYE6.js.map} +0 -0
  173. /package/dist/{doctor-R7N7FUX5.js.map → doctor-ZBG7X66D.js.map} +0 -0
  174. /package/dist/{edit-QSUEG7CL.js.map → edit-PZJIILQE.js.map} +0 -0
  175. /package/dist/{fund-JF6A76YS.js.map → fund-EUDH5KPA.js.map} +0 -0
  176. /package/dist/{inspect-NFNAA4LA.js.map → inspect-QC6WEQPN.js.map} +0 -0
  177. /package/dist/{outcome-IUSYFJTN.js.map → outcome-KSGWZHUS.js.map} +0 -0
  178. /package/dist/{publish-O2I6IAEL.js.map → publish-LXWFDIKF.js.map} +0 -0
  179. /package/dist/{search-JVOHEF3E.js.map → search-TSQAB45E.js.map} +0 -0
  180. /package/dist/{send-SI254H3R.js.map → send-G746D7PQ.js.map} +0 -0
  181. /package/dist/{wallet-NS7TYWNN.js.map → skill-placement-RIU4AMC2.js.map} +0 -0
  182. /package/dist/{wallet-TZVD2M4I.js.map → wallet-TQ7D5EQ7.js.map} +0 -0
@@ -1,72 +1,88 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  runWalletCreate
4
- } from "./chunk-T4UWMVKV.js";
4
+ } from "./chunk-NIKXHWOL.js";
5
5
  import "./chunk-MJZZTKCC.js";
6
+ import "./chunk-7FK2UN2T.js";
6
7
  import {
7
8
  describeWallet,
8
9
  resolveWalletProvider
9
- } from "./chunk-JVBMPU5G.js";
10
+ } from "./chunk-CPCX67TI.js";
11
+ import "./chunk-M2O56UK7.js";
12
+ import "./chunk-UHTVXQ2O.js";
10
13
  import {
11
14
  collectDoctorChecks,
12
15
  isNoWalletCheck
13
- } from "./chunk-L4XNT3UW.js";
14
- import {
15
- PERMISSIONS_DOC_URL,
16
- recommendedPermissions
17
- } from "./chunk-OXUJ3FXU.js";
18
- import "./chunk-J6FUAIRR.js";
19
- import "./chunk-SPUORKD7.js";
20
- import "./chunk-XGZ5EVMB.js";
16
+ } from "./chunk-R7RSCBI7.js";
17
+ import "./chunk-HRGBS2PA.js";
18
+ import "./chunk-EDZSNPE5.js";
19
+ import "./chunk-5QQTYWEU.js";
21
20
  import {
22
21
  walletFileExists
23
- } from "./chunk-3P3ES4XU.js";
22
+ } from "./chunk-GHLVXVZD.js";
24
23
  import {
25
- FREE_VERB_RULES,
26
- STOP_HOOK_FILE,
27
- WEBSEARCH_HOOK_FILE,
28
- claudeSettingsPath,
29
- inspectFreeVerbRules,
30
- permissionsSkipped,
31
- removeMarkerLines,
32
- stopHookScript,
33
- websearchHookScript,
34
- wireFreeVerbAllowlist
35
- } from "./chunk-OE36HRWG.js";
36
- import "./chunk-CA3JV7FX.js";
24
+ removeMarkerLines
25
+ } from "./chunk-B63XPWQ4.js";
26
+ import {
27
+ placeOptionalSkill
28
+ } from "./chunk-DHJD77OW.js";
37
29
  import {
38
30
  installSkill
39
- } from "./chunk-WVHPGQH5.js";
31
+ } from "./chunk-QZ6ROAJU.js";
40
32
  import {
41
33
  sanitizeForTerminal
42
- } from "./chunk-B676GPS2.js";
34
+ } from "./chunk-OLWTRUTS.js";
43
35
  import {
36
+ confirmChoice,
37
+ intro,
38
+ outro,
39
+ persistAgentDispatchHookMode,
40
+ persistBazaarPay,
44
41
  persistInstallHarness,
45
42
  persistPublishMode,
46
- persistSearchHookMode
47
- } from "./chunk-UUARTUY2.js";
48
- import "./chunk-IGHSLJUF.js";
43
+ persistWebSearchHookMode,
44
+ selectOne
45
+ } from "./chunk-H3SOOJ2I.js";
49
46
  import {
50
- ownsAnyLock,
51
- releaseOwnedLocks
52
- } from "./chunk-FKSAUOJU.js";
53
- import "./chunk-736DW4V3.js";
47
+ PERMISSIONS_DOC_URL,
48
+ recommendedPermissions
49
+ } from "./chunk-4CQIDQOT.js";
50
+ import "./chunk-VYOJOX4Z.js";
51
+ import "./chunk-EFWZPUTC.js";
54
52
  import {
55
53
  CONFIG_DEFAULTS,
56
54
  PublishModeSchema,
57
- SearchHookModeSchema,
55
+ WebSearchModeSchema,
58
56
  loadRawConfig,
59
57
  parsePublishModeFlag,
60
- parseSearchHookModeFlag
61
- } from "./chunk-ELVDOTU7.js";
58
+ parseWebSearchHookModeFlag
59
+ } from "./chunk-U6VPKMGC.js";
60
+ import "./chunk-UO22YNY4.js";
62
61
  import {
63
- hooksDir,
64
- walletPath
65
- } from "./chunk-ZQIQ55KK.js";
62
+ FREE_VERB_RULES,
63
+ MODE_GATED_RULES,
64
+ hooksSkipped,
65
+ hooksUndo,
66
+ inspectFreeVerbRules,
67
+ permissionsSkipped,
68
+ planFreeVerbAllowlist,
69
+ resolveHermesHome,
70
+ resolveHermesHomeLenient,
71
+ retractModeGatedRules,
72
+ rulesForPublishMode,
73
+ wireFreeVerbAllowlist,
74
+ wireHermesIntegration,
75
+ wireSearchHooks
76
+ } from "./chunk-OKYSNAS3.js";
77
+ import "./chunk-A5DKHMUN.js";
78
+ import "./chunk-3GL2Z5QK.js";
79
+ import "./chunk-JBIKAAT3.js";
66
80
  import {
67
81
  CLI_SKILL_NAMES,
68
82
  HARNESS_TARGETS,
69
83
  HOSTED_SKILL_NAME,
84
+ OPTIONAL_PAY_SKILL,
85
+ PRODUCTION_HOST,
70
86
  SKILL_NAMES,
71
87
  harnessDetectedBy,
72
88
  harnessTargetDir,
@@ -74,16 +90,17 @@ import {
74
90
  onPath,
75
91
  readSkillFile,
76
92
  resolveSkillsSource
77
- } from "./chunk-OC3EIDCP.js";
93
+ } from "./chunk-2MYQN7HM.js";
94
+ import {
95
+ ownsAnyLock,
96
+ releaseOwnedLocks
97
+ } from "./chunk-ZOBNS7CX.js";
78
98
  import {
79
99
  CliError,
80
100
  external_exports,
81
101
  hasCode,
82
- writeFileAtomic
83
- } from "./chunk-PAOVPSP6.js";
84
- import "./chunk-7FK2UN2T.js";
85
- import "./chunk-M2O56UK7.js";
86
- import "./chunk-UHTVXQ2O.js";
102
+ walletPath
103
+ } from "./chunk-ZFJJ3EXC.js";
87
104
  import "./chunk-W6R3HAAG.js";
88
105
  import "./chunk-U5S527PP.js";
89
106
  import "./chunk-47PP7TAG.js";
@@ -94,329 +111,12 @@ import "./chunk-ZXTAQYNA.js";
94
111
 
95
112
  // src/commands/install.ts
96
113
  import { existsSync } from "fs";
97
- import { readFile as readFile2 } from "fs/promises";
114
+ import { readFile } from "fs/promises";
98
115
  import { fileURLToPath } from "url";
99
- import { dirname, isAbsolute, join as join2 } from "path";
116
+ import { dirname, isAbsolute, join } from "path";
100
117
  import { homedir } from "os";
101
118
  import { styleText } from "util";
102
119
  import { Stream } from "stream";
103
-
104
- // src/lib/harness-hooks.ts
105
- import { lstat, readFile, realpath } from "fs/promises";
106
- import { join } from "path";
107
- var WEBSEARCH_MATCHER = "WebSearch";
108
- var HOOK_TIMEOUT_SECONDS = 5;
109
- function hooksUndo(settingsPath, scriptsDir) {
110
- return `Undo anytime: \`tenjin config set hooks.searchMode off\` disarms them, or delete the tenjin hook entries from ${settingsPath} and the scripts in ${scriptsDir}.`;
111
- }
112
- function skip(reason, args) {
113
- return {
114
- harness: args.harness,
115
- ...args.path !== void 0 ? { path: args.path } : {},
116
- scriptsDir: args.scriptsDir,
117
- mode: args.mode,
118
- added: [],
119
- alreadyPresent: [],
120
- updated: [],
121
- scripts: [],
122
- skipped: reason,
123
- ...args.warning !== void 0 ? { warning: args.warning } : {},
124
- ...args.fix !== void 0 ? { fix: args.fix } : {}
125
- };
126
- }
127
- function hooksSkipped(harness, homeDir, dataDir, mode, reason) {
128
- return skip(reason, {
129
- harness,
130
- ...harness === "claude" ? { path: claudeSettingsPath(homeDir) } : {},
131
- scriptsDir: hooksDir(dataDir),
132
- mode,
133
- fix: fixFor(reason)
134
- });
135
- }
136
- function fixFor(reason) {
137
- switch (reason) {
138
- case "harness-not-claude":
139
- return "Hooks are wired for Claude Code only. Re-run `tenjin install --harness claude` on a machine with Claude Code.";
140
- case "mode-off":
141
- return "Enable them with `tenjin config set hooks.searchMode auto`, then re-run `tenjin install`.";
142
- case "declined":
143
- case "dry-run":
144
- return "Wire them with `tenjin install --search-hooks auto`.";
145
- case "changed-since-read":
146
- return "Another process changed the file mid-run; re-run `tenjin install`.";
147
- default:
148
- return "Fix the reported file, then re-run `tenjin install --search-hooks auto`.";
149
- }
150
- }
151
- function isPlainObject(value) {
152
- return typeof value === "object" && value !== null && !Array.isArray(value);
153
- }
154
- function quoteForShell(path, platform = process.platform) {
155
- if (platform === "win32") return `"${path}"`;
156
- return `'${path.replaceAll("'", `'\\''`)}'`;
157
- }
158
- function commandFor(scriptPath, platform) {
159
- return `node ${quoteForShell(scriptPath, platform)}`;
160
- }
161
- function handlerFor(scriptPath, platform) {
162
- return {
163
- type: "command",
164
- command: commandFor(scriptPath, platform),
165
- timeout: HOOK_TIMEOUT_SECONDS
166
- };
167
- }
168
- function ownsEntry(entry, scriptFile) {
169
- if (!isPlainObject(entry)) return false;
170
- const handlers = entry.hooks;
171
- if (!Array.isArray(handlers)) return false;
172
- return handlers.some(
173
- (h) => isPlainObject(h) && typeof h.command === "string" && h.command.includes(scriptFile)
174
- );
175
- }
176
- function specs(dataDir) {
177
- return [
178
- {
179
- event: "PreToolUse",
180
- scriptFile: WEBSEARCH_HOOK_FILE,
181
- script: websearchHookScript(dataDir),
182
- matcher: WEBSEARCH_MATCHER
183
- },
184
- { event: "Stop", scriptFile: STOP_HOOK_FILE, script: stopHookScript(dataDir) }
185
- ];
186
- }
187
- async function wireSearchHooks(opts) {
188
- const { homeDir, dataDir, mode, platform } = opts;
189
- const scriptsDir = hooksDir(dataDir);
190
- const plan = specs(dataDir);
191
- const found = await inspectSettings(homeDir, scriptsDir, mode);
192
- if ("result" in found) return found.result;
193
- const { path, raw, settings, hooks } = found;
194
- const added = [];
195
- const alreadyPresent = [];
196
- const updated = [];
197
- const nextHooks = { ...hooks };
198
- for (const spec of plan) {
199
- const existing = hooks[spec.event];
200
- if (existing !== void 0 && !Array.isArray(existing)) {
201
- return refuse(
202
- path,
203
- scriptsDir,
204
- mode,
205
- "unexpected-shape",
206
- `${path} has a "hooks.${spec.event}" key that is not an array; it was left exactly as it is.`
207
- );
208
- }
209
- const list = existing ?? [];
210
- const desired = {
211
- ...spec.matcher !== void 0 ? { matcher: spec.matcher } : {},
212
- hooks: [handlerFor(join(scriptsDir, spec.scriptFile), platform)]
213
- };
214
- const idx = list.findIndex((e) => ownsEntry(e, spec.scriptFile));
215
- if (idx === -1) {
216
- nextHooks[spec.event] = [...list, desired];
217
- added.push(spec.event);
218
- continue;
219
- }
220
- if (JSON.stringify(list[idx]) === JSON.stringify(desired)) {
221
- alreadyPresent.push(spec.event);
222
- continue;
223
- }
224
- nextHooks[spec.event] = list.map((e, i) => i === idx ? desired : e);
225
- updated.push(spec.event);
226
- }
227
- if (added.length === 0 && updated.length === 0) {
228
- const scripts2 = await writeScripts(plan, scriptsDir);
229
- return { harness: "claude", path, scriptsDir, mode, added, alreadyPresent, updated, scripts: scripts2 };
230
- }
231
- const next = { ...settings, hooks: nextHooks };
232
- const changed = async () => await readFile(path, "utf8").catch(() => null) !== raw;
233
- if (await changed()) return refuseChanged(path, scriptsDir, mode, []);
234
- const scripts = await writeScripts(plan, scriptsDir);
235
- if (await changed()) return refuseChanged(path, scriptsDir, mode, scripts);
236
- await writeFileAtomic(path, `${JSON.stringify(next, null, 2)}
237
- `);
238
- return { harness: "claude", path, scriptsDir, mode, added, alreadyPresent, updated, scripts };
239
- }
240
- function refuseChanged(path, scriptsDir, mode, scripts) {
241
- return {
242
- ...refuse(
243
- path,
244
- scriptsDir,
245
- mode,
246
- "changed-since-read",
247
- `${path} changed while it was being updated, so no hooks were registered. Re-run \`tenjin install\`.`
248
- ),
249
- scripts
250
- };
251
- }
252
- async function writeScripts(plan, scriptsDir) {
253
- const written = [];
254
- for (const spec of plan) {
255
- const target = join(scriptsDir, spec.scriptFile);
256
- const onDisk = await readFile(target, "utf8").catch(() => null);
257
- if (onDisk === spec.script) continue;
258
- await writeFileAtomic(target, spec.script, { mode: 493, dirMode: 448 });
259
- written.push(target);
260
- }
261
- return written;
262
- }
263
- function refuse(path, scriptsDir, mode, reason, warning) {
264
- return skip(reason, { harness: "claude", path, scriptsDir, mode, warning, fix: fixFor(reason) });
265
- }
266
- async function inspectSettings(homeDir, scriptsDir, mode) {
267
- const declaredPath = claudeSettingsPath(homeDir);
268
- const entry = await lstat(declaredPath).catch(() => null);
269
- let path = declaredPath;
270
- if (entry !== null) {
271
- try {
272
- path = await realpath(declaredPath);
273
- } catch (err) {
274
- return {
275
- result: refuse(
276
- declaredPath,
277
- scriptsDir,
278
- mode,
279
- "unresolvable",
280
- `${declaredPath} could not be resolved (${err.message}); it was left exactly as it is.`
281
- )
282
- };
283
- }
284
- }
285
- let settings = {};
286
- let raw = null;
287
- if (entry !== null) {
288
- try {
289
- raw = await readFile(path, "utf8");
290
- } catch (err) {
291
- return {
292
- result: refuse(
293
- path,
294
- scriptsDir,
295
- mode,
296
- "unreadable",
297
- `${path} could not be read (${err.message}); no hooks were registered.`
298
- )
299
- };
300
- }
301
- let parsed;
302
- try {
303
- parsed = JSON.parse(raw);
304
- } catch (err) {
305
- return {
306
- result: refuse(
307
- path,
308
- scriptsDir,
309
- mode,
310
- "unparsable",
311
- `${path} is not valid JSON (${err.message}); it was left exactly as it is.`
312
- )
313
- };
314
- }
315
- if (!isPlainObject(parsed)) {
316
- return {
317
- result: refuse(
318
- path,
319
- scriptsDir,
320
- mode,
321
- "unexpected-shape",
322
- `${path} is not a JSON object; it was left exactly as it is.`
323
- )
324
- };
325
- }
326
- settings = parsed;
327
- }
328
- const hooksValue = settings.hooks;
329
- if (hooksValue !== void 0 && !isPlainObject(hooksValue)) {
330
- return {
331
- result: refuse(
332
- path,
333
- scriptsDir,
334
- mode,
335
- "unexpected-shape",
336
- `${path} has a "hooks" key that is not an object; it was left exactly as it is.`
337
- )
338
- };
339
- }
340
- return { path, raw, settings, hooks: hooksValue ?? {} };
341
- }
342
-
343
- // src/lib/clack.ts
344
- var SHOW_CURSOR = "\x1B[?25h";
345
- function withInputEnd(streams, onEnd, run) {
346
- const controller = new AbortController();
347
- let settleEnd;
348
- const ended = new Promise((resolve) => {
349
- settleEnd = () => {
350
- streams.output.write(SHOW_CURSOR);
351
- resolve(onEnd);
352
- };
353
- });
354
- const end = () => {
355
- controller.abort();
356
- settleEnd?.();
357
- };
358
- const onKeypress = (_text, key) => {
359
- if (key?.ctrl === true && key.name === "d") end();
360
- };
361
- streams.input.on("keypress", onKeypress);
362
- if (streams.input.readableEnded) {
363
- queueMicrotask(end);
364
- } else {
365
- streams.input.once("end", end);
366
- streams.input.once("close", end);
367
- }
368
- return Promise.race([run(controller.signal), ended]).finally(() => {
369
- streams.input.off("keypress", onKeypress);
370
- streams.input.off("end", end);
371
- streams.input.off("close", end);
372
- });
373
- }
374
- function resolveStreams(streams) {
375
- return { input: streams.input ?? process.stdin, output: streams.output ?? process.stderr };
376
- }
377
- async function selectOne(opts) {
378
- const { select, isCancel } = await import("./dist-U4M6QCKE.js");
379
- const streams = resolveStreams(opts.streams ?? {});
380
- return withInputEnd(streams, null, async (signal) => {
381
- const answer = await select({
382
- message: opts.message,
383
- options: opts.choices.map((c) => ({
384
- value: c.value,
385
- label: c.label,
386
- ...c.hint !== void 0 ? { hint: c.hint } : {}
387
- })),
388
- initialValue: opts.initialValue,
389
- input: streams.input,
390
- output: streams.output,
391
- signal
392
- });
393
- return isCancel(answer) ? null : answer;
394
- });
395
- }
396
- async function confirmChoice(message, initialValue = true, streams = {}) {
397
- const { confirm, isCancel } = await import("./dist-U4M6QCKE.js");
398
- const resolved = resolveStreams(streams);
399
- return withInputEnd(resolved, false, async (signal) => {
400
- const answer = await confirm({
401
- message,
402
- initialValue,
403
- input: resolved.input,
404
- output: resolved.output,
405
- signal
406
- });
407
- return isCancel(answer) ? false : answer;
408
- });
409
- }
410
- async function intro(message) {
411
- const clack = await import("./dist-U4M6QCKE.js");
412
- clack.intro(message, { output: process.stderr });
413
- }
414
- async function outro(message) {
415
- const clack = await import("./dist-U4M6QCKE.js");
416
- clack.outro(message, { output: process.stderr });
417
- }
418
-
419
- // src/commands/install.ts
420
120
  var HARNESSES = HARNESS_TARGETS;
421
121
  var InstallInputSchema = external_exports.object({
422
122
  harness: external_exports.array(external_exports.string()).optional(),
@@ -444,7 +144,8 @@ var InstallInputSchema = external_exports.object({
444
144
  /**
445
145
  * `--no-hooks`: register no hooks THIS RUN, changing nothing persistent. It is
446
146
  * deliberately not the same as `--search-hooks off`, which is a durable
447
- * statement about behavior and writes `hooks.searchMode: off` to config.
147
+ * statement about behavior and writes `hooks.webSearch: off` (and
148
+ * `hooks.agentDispatch: off`) to config.
448
149
  */
449
150
  noHooks: external_exports.boolean().optional()
450
151
  });
@@ -503,7 +204,7 @@ async function installBody(input, ctx, deps, markPhase) {
503
204
  const noHooks = parsed.data.noHooks === true;
504
205
  const allowFreeVerbs = parsed.data.allowFreeVerbs;
505
206
  const publishModeFlag = parsed.data.publishMode !== void 0 ? parseModeFlag(parsed.data.publishMode) : void 0;
506
- const searchHooksFlag = parsed.data.searchHooks !== void 0 ? parseSearchHookModeFlag(parsed.data.searchHooks, "--search-hooks") : void 0;
207
+ const searchHooksFlag = parsed.data.searchHooks !== void 0 ? parseWebSearchHookModeFlag(parsed.data.searchHooks, "--search-hooks") : void 0;
507
208
  const env = deps.env ?? process.env;
508
209
  const home = deps.homeDir ?? homedir();
509
210
  if (!isAbsolute(home)) {
@@ -516,13 +217,17 @@ async function installBody(input, ctx, deps, markPhase) {
516
217
  );
517
218
  }
518
219
  const which = deps.which ?? ((bin) => onPath(bin, env));
220
+ const targetsHermes = parsed.data.harness?.includes("hermes") === true;
221
+ const hermesTarget = targetsHermes ? { home: resolveHermesHome(home, env), warning: void 0 } : resolveHermesHomeLenient(home, env);
222
+ const hermesHome = hermesTarget.home;
519
223
  const humanOutput = ctx.flags.json === true ? false : deps.isInteractive ?? ctx.io.isTTY;
520
224
  const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));
521
225
  const skillsSource = deps.skillsSourceDir ?? resolveSkillsSource(fileURLToPath(new URL(".", import.meta.url)));
522
226
  await assertSkillsSource(skillsSource);
523
- const plans = resolvePlans(parsed.data.harness, home, which);
227
+ const plans = resolvePlans(parsed.data.harness, home, hermesHome, which);
524
228
  const explicitHarness = parsed.data.harness !== void 0 && parsed.data.harness.length > 0;
525
229
  const harnesses = [];
230
+ const rawConfig = await loadRawConfig(ctx.dataDir);
526
231
  if (!dryRun) markPhase("writing-skills");
527
232
  for (const plan of plans) {
528
233
  harnesses.push(await applyPlan(plan, skillsSource, dryRun));
@@ -550,16 +255,67 @@ async function installBody(input, ctx, deps, markPhase) {
550
255
  deps,
551
256
  flag: allowFreeVerbs,
552
257
  dryRun,
553
- canPrompt
258
+ canPrompt,
259
+ publishMode: publishMode.value
554
260
  });
555
261
  const hooks = await underDataDir(
556
262
  ctx.dataDir,
557
263
  () => resolveHooks({ plans, home, ctx, deps, flag: searchHooksFlag, noHooks, dryRun, canPrompt })
558
264
  );
265
+ const hermesResult = harnesses.find((result) => result.harness === "hermes");
266
+ if (hermesResult !== void 0) {
267
+ const tenjinCommand = deps.tenjinCommand ?? process.argv[1];
268
+ const nodeCommand = deps.nodeCommand ?? process.execPath;
269
+ if (tenjinCommand === void 0 || !isAbsolute(tenjinCommand) || !isAbsolute(nodeCommand)) {
270
+ throw new CliError(
271
+ "INTERNAL",
272
+ "Hermes integration requires absolute Tenjin and Node executable paths.",
273
+ { fix: "Run `tenjin install --harness hermes` through the installed Tenjin CLI." }
274
+ );
275
+ }
276
+ hermesResult.hermes = await wireHermesIntegration({
277
+ hermesHome,
278
+ dataDir: ctx.dataDir,
279
+ tenjinCommand,
280
+ nodeCommand,
281
+ dryRun,
282
+ // Activation consent: the operator named Hermes on the command line.
283
+ explicit: explicitHarness && targetsHermes,
284
+ // Write consent, read off the SAME hooks decision that gates Claude's
285
+ // settings.json, because `--no-hooks` promises "writes no config" in the
286
+ // README and that promise cannot hold on only one of the two harnesses.
287
+ hooks: { enabled: hermesHooksEnabled(hooks), fix: hooks.fix, mode: hooks.mode }
288
+ });
289
+ for (const part of [
290
+ hermesResult.hermes.mcp,
291
+ hermesResult.hermes.plugin,
292
+ hermesResult.hermes.activation
293
+ ]) {
294
+ if (part.warning !== void 0) hermesResult.warnings.push(part.warning);
295
+ }
296
+ if (hermesTarget.warning !== void 0) hermesResult.warnings.push(hermesTarget.warning);
297
+ }
559
298
  const wallet = await underDataDir(
560
299
  ctx.dataDir,
561
300
  () => resolveWallet(ctx, deps, walletSkip(dryRun, noWallet), canPrompt)
562
301
  );
302
+ const bazaarPay = await underDataDir(
303
+ ctx.dataDir,
304
+ () => resolveBazaarPay(ctx, deps, dryRun, canPrompt, rawConfig.bazaarPay)
305
+ );
306
+ if (!dryRun) {
307
+ for (const plan of plans) {
308
+ try {
309
+ await placeOptionalSkill(
310
+ OPTIONAL_PAY_SKILL,
311
+ plan.skillsDir,
312
+ skillsSource,
313
+ bazaarPay.enabled
314
+ );
315
+ } catch {
316
+ }
317
+ }
318
+ }
563
319
  const doctorDeps = { ...deps.doctorDeps ?? {} };
564
320
  doctorDeps.homeDir ??= home;
565
321
  doctorDeps.which ??= which;
@@ -576,13 +332,14 @@ async function installBody(input, ctx, deps, markPhase) {
576
332
  pointerCleanup,
577
333
  doctor: { status: doctor.failure !== void 0 ? "fail" : "pass", checks: doctor.checks },
578
334
  publishMode,
335
+ bazaarPay,
579
336
  // Shipped with the install rather than left for the operator to discover after
580
337
  // their first auto-mode denial (#33). Static constants, no config key: see
581
338
  // lib/permissions.ts for why this is deliberately not operator-editable state.
582
339
  // `wired` is the outcome of THIS run's settings.json write; the three
583
340
  // recommendation tiers beside it are unchanged, so a machine consumer that
584
341
  // read `alwaysSafe` / `optIn` / `neverAllowlisted` before still does.
585
- permissions: { ...recommendedPermissions(), wired: permissions },
342
+ permissions: { ...recommendedPermissions(publishMode.value), wired: permissions },
586
343
  hooks,
587
344
  wallet
588
345
  };
@@ -651,19 +408,13 @@ function noticeLines(io, s) {
651
408
  `Removed the old Tenjin pointer line from ${s.pointerCleanup.join(" and ")}; the skills carry their own triggers now.`
652
409
  );
653
410
  }
654
- if (s.permissions.removed.length > 0) {
411
+ const stale = s.permissions.removed.filter((r) => !MODE_GATED_RULES.includes(r));
412
+ if (stale.length > 0) {
655
413
  lines.push(
656
- `Removed ${s.permissions.removed.length} permission rule(s) an older tenjin left in ${s.permissions.path ?? "your settings"} for commands that no longer exist.`
414
+ `Removed ${stale.length} permission rule(s) an older tenjin left in ${s.permissions.path ?? "your settings"} for commands that no longer exist.`
657
415
  );
658
416
  }
659
- if (s.permissions.added.length > 0) {
660
- lines.push(
661
- paint(
662
- io,
663
- "dim",
664
- `${s.permissions.added.length} free tenjin commands were allowed in ${s.permissions.path}. None can spend USDC or open your wallet keystore; see them with \`tenjin doctor\`.`
665
- )
666
- );
417
+ if (s.permissions.planned !== true && s.permissions.added.length > 0) {
667
418
  lines.push(paint(io, "dim", `Undo anytime: remove those lines from ${s.permissions.path}.`));
668
419
  }
669
420
  if (s.hooks.added.length > 0 || s.hooks.updated.length > 0) {
@@ -691,7 +442,7 @@ function noticeLines(io, s) {
691
442
  function summaryLines(io, s) {
692
443
  return [
693
444
  ...s.harnesses.map((h) => skillsLine(io, h, s.dryRun)),
694
- publishingLine(io, s.publishMode.value),
445
+ publishingLine(io, s.publishMode.value, s.permissions),
695
446
  permissionsLine(io, s.permissions),
696
447
  hooksLine(io, s.hooks),
697
448
  walletLine(io, s.wallet),
@@ -699,17 +450,17 @@ function summaryLines(io, s) {
699
450
  ];
700
451
  }
701
452
  function hooksDisclosure(h) {
702
- const shared = "A Stop hook reminds you locally when a MISS you searched for is still unpublished; it makes no network call.";
453
+ const shared = "A Stop hook reminds you locally when a MISS you searched for is still unpublished, and a SessionStart hook prints one paragraph on when to search first; neither makes a network call.";
703
454
  if (h.mode === "remind") {
704
- return `The WebSearch hook prints a one-line reminder that Tenjin may have an answer; it sends nothing off-machine. ${shared}`;
455
+ return `The WebSearch and dispatch hooks print a one-line reminder that Tenjin may have an answer; they send nothing off-machine. ${shared}`;
705
456
  }
706
- 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}`;
457
+ return `Before a web search or a subagent dispatch, the hooks ask ${PRODUCTION_HOST} the same question (free and anonymous, ~2s budget, 5s harness kill) and mention a tested answer if one exists; the query text, or at most 400 characters of the subagent prompt, leaves the machine. They can never block or change the tool call. ${shared}`;
707
458
  }
708
459
  function hooksLine(io, h) {
709
460
  const label = paint(io, "bold", "Search hooks:");
710
461
  const wrote = h.added.length + h.updated.length;
711
462
  if (wrote > 0) {
712
- 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>`;
463
+ return `${paint(io, "green", "\u2713")} ${label} ${h.mode} mode, ${wrote} hook event(s) registered in ${h.path}. Change: tenjin config set hooks.webSearch <auto|remind|off> (or hooks.agentDispatch)`;
713
464
  }
714
465
  if (h.skipped === void 0) {
715
466
  return `${paint(io, "green", "\u2713")} ${label} ${h.mode} mode, already registered in ${h.path}`;
@@ -717,11 +468,14 @@ function hooksLine(io, h) {
717
468
  if (h.skipped === "harness-not-claude") {
718
469
  return `${paint(io, "dim", "-")} ${label} not wired (Claude Code only).`;
719
470
  }
471
+ if (h.skipped === "native-harness") {
472
+ return `${paint(io, "green", "\u2713")} ${label} ${h.mode} mode through the native Hermes plugin. Change: tenjin config set hooks.webSearch <auto|remind|off> (or hooks.agentDispatch)`;
473
+ }
720
474
  if (h.skipped === "dry-run") {
721
475
  return `${paint(io, "dim", "-")} ${label} unchanged (dry run).`;
722
476
  }
723
477
  if (h.skipped === "mode-off") {
724
- return `${paint(io, "dim", "-")} ${label} off (hooks.searchMode). Turn them on: tenjin config set hooks.searchMode auto, then tenjin install`;
478
+ return `${paint(io, "dim", "-")} ${label} off (hooks.webSearch). Turn them on: tenjin config set hooks.webSearch auto, then tenjin install`;
725
479
  }
726
480
  if (h.skipped === "declined") {
727
481
  return `${paint(io, "dim", "-")} ${label} not registered this run; nothing was configured. Register them: tenjin install`;
@@ -732,7 +486,7 @@ function hooksLine(io, h) {
732
486
  return `${paint(io, "yellow", "!")} ${label} ${h.path} was left untouched. Fix it, then: tenjin install`;
733
487
  }
734
488
  function harnessLabel(h) {
735
- return h === "claude" ? "Claude Code" : h === "codex" ? "Codex" : "Agent Skills";
489
+ return h === "claude" ? "Claude Code" : h === "codex" ? "Codex" : h === "hermes" ? "Hermes" : "Agent Skills";
736
490
  }
737
491
  function skillsLine(io, h, dryRun) {
738
492
  const changed = h.skills.some((s) => s.status !== "up-to-date");
@@ -740,30 +494,38 @@ function skillsLine(io, h, dryRun) {
740
494
  const head = `${harnessLabel(h.harness)}: ${h.skills.length} skills ${verb}`;
741
495
  return `${paint(io, "green", "\u2713")} ${paint(io, "bold", head)} in ${h.skillsDir}. ${skillRoster(h)}.`;
742
496
  }
743
- function publishingLine(io, mode) {
744
- return `${paint(io, "green", "\u2713")} ${paint(io, "bold", `Publishing: ${mode}`)}. ${modeBlurb(mode)}`;
497
+ function publishingLine(io, mode, wired) {
498
+ const undo = wired.modeGrant === void 0 ? "" : ` ${paint(io, "dim", wired.planned === true ? "Would turn off:" : "Turn off:")} tenjin config set publish.mode review`;
499
+ return `${paint(io, "green", "\u2713")} ${paint(io, "bold", `Publishing: ${mode}`)}. ${modeBlurb(mode)}${undo}`;
745
500
  }
746
501
  function permissionsLine(io, p) {
747
502
  const label = paint(io, "bold", "Permissions:");
503
+ const allowed = p.added.length + p.alreadyPresent.length;
504
+ const retracted = p.removed.filter((r) => MODE_GATED_RULES.includes(r));
505
+ 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"}.`;
506
+ const unchanged = retracted.length === 0 || p.planned === true ? "unchanged" : "otherwise unchanged";
507
+ if (p.planned === true && p.added.length > 0) {
508
+ return `${paint(io, "dim", "-")} ${label} would allow ${allowed} tenjin commands in ${p.path}. Details: ${PERMISSIONS_DOC_URL}`;
509
+ }
748
510
  if (p.added.length > 0) {
749
- return `${paint(io, "green", "\u2713")} ${label} ${p.added.length} free tenjin commands added to ${p.path}. Full caveats: ${PERMISSIONS_DOC_URL}`;
511
+ return `${paint(io, "green", "\u2713")} ${label} ${allowed} tenjin commands allowed in ${p.path}.${gaveBack} Details: ${PERMISSIONS_DOC_URL}`;
750
512
  }
751
513
  if (p.skipped === void 0) {
752
- return `${paint(io, "green", "\u2713")} ${label} the ${FREE_VERB_RULES.length} free tenjin commands were already allowed in ${p.path}`;
514
+ return `${paint(io, "green", "\u2713")} ${label} the ${FREE_VERB_RULES.length} free tenjin commands were already allowed in ${p.path}.${gaveBack}`;
753
515
  }
754
516
  if (p.skipped === "harness-not-claude") {
755
- return `${paint(io, "dim", "-")} ${label} not wired (Claude Code only). The lines your harness needs: ${PERMISSIONS_DOC_URL}`;
517
+ return `${paint(io, "dim", "-")} ${label} not wired for this harness (Claude Code only).${gaveBack} The lines your harness needs: ${PERMISSIONS_DOC_URL}`;
756
518
  }
757
519
  if (p.skipped === "dry-run") {
758
- return `${paint(io, "dim", "-")} ${label} unchanged (dry run).`;
520
+ return `${paint(io, "dim", "-")} ${label} ${unchanged} (dry run); the ${FREE_VERB_RULES.length} rules a real run needs are already there.${gaveBack}`;
759
521
  }
760
522
  if (p.skipped === "declined" || p.skipped === "not-requested") {
761
- return `${paint(io, "dim", "-")} ${label} unchanged. Allow the ${FREE_VERB_RULES.length} free tenjin commands with: tenjin install --allow-free-verbs`;
523
+ return `${paint(io, "dim", "-")} ${label} ${unchanged}.${gaveBack} Allow the ${FREE_VERB_RULES.length} free tenjin commands with: tenjin install --allow-free-verbs`;
762
524
  }
763
525
  if (p.skipped === "changed-since-read") {
764
- return `${paint(io, "yellow", "!")} ${label} ${p.path} changed while it was being updated, so nothing was written. Re-run: tenjin install`;
526
+ return `${paint(io, "yellow", "!")} ${label} ${p.path} changed while it was being updated, so nothing was written.${gaveBack} Re-run: tenjin install`;
765
527
  }
766
- return `${paint(io, "yellow", "!")} ${label} ${p.path} was left untouched. Fix it, then: tenjin install --allow-free-verbs`;
528
+ return `${paint(io, "yellow", "!")} ${label} ${p.path} was left untouched.${gaveBack} Fix it, then: tenjin install --allow-free-verbs`;
767
529
  }
768
530
  function walletLine(io, w) {
769
531
  const label = paint(io, "bold", "Wallet:");
@@ -796,7 +558,7 @@ function skillRoster(h) {
796
558
  return parts.join("; ");
797
559
  }
798
560
  function modeBlurb(v) {
799
- return v === "auto" ? "Your agent publishes clean pieces on its own; your harness still shows each command for approval." : v === "review" ? "Your agent asks you in chat before every publish." : "Fully unattended; only hard blocks stop it.";
561
+ 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.";
800
562
  }
801
563
  async function resolveWallet(ctx, deps, skipReason, canPrompt) {
802
564
  const exists = await (deps.walletExists ?? walletFileExists)(ctx.dataDir);
@@ -845,6 +607,15 @@ async function defaultCreateWallet(ctx, passphrase, env) {
845
607
  function defaultConfirm(label) {
846
608
  return confirmChoice(label, true);
847
609
  }
610
+ var BAZAAR_QUESTION = "Enable the Bazaar pay lane? x402 lets this wallet pay HTTP endpoints that answer with a priced 402, and the Bazaar (https://docs.cdp.coinbase.com/x402/bazaar) is the public catalog of them. When on, `tenjin pay` may pay Bazaar-listed non-Tenjin endpoints under your spend policy. More: https://x402.org";
611
+ async function resolveBazaarPay(ctx, deps, dryRun, canPrompt, existing) {
612
+ if (existing !== void 0) return { enabled: existing, status: "kept" };
613
+ if (dryRun || !canPrompt) return { enabled: false, status: "not-asked" };
614
+ const confirm = deps.confirmBazaarPay ?? ((label) => confirmChoice(label, false));
615
+ const yes = await confirm(BAZAAR_QUESTION);
616
+ await persistBazaarPay(ctx.dataDir, yes);
617
+ return { enabled: yes, status: yes ? "enabled" : "declined" };
618
+ }
848
619
  function summaryAlreadySaysNoWallet(wallet) {
849
620
  return wallet.status === "declined" || wallet.status === "skipped";
850
621
  }
@@ -869,10 +640,10 @@ var PUBLISH_MODE_CHOICES = [
869
640
  {
870
641
  value: "auto",
871
642
  label: "Auto (recommended)",
872
- hint: "your agent publishes clean pieces on its own; your harness still shows each command for approval"
643
+ hint: "your agent publishes and updates pieces on its own, under your identity"
873
644
  },
874
645
  { value: "review", label: "Ask me in chat first" },
875
- { value: "full-auto", label: "Fully unattended", hint: "only hard blocks stop it" }
646
+ { value: "full-auto", label: "Fully unattended", hint: "only a hard block stops it" }
876
647
  ];
877
648
  var PUBLISH_MODE_QUESTION = "When your agent has something worth publishing:";
878
649
  async function resolvePublishMode(flag, ctx, deps, dryRun, interactive) {
@@ -906,37 +677,63 @@ function defaultPromptPublishMode() {
906
677
  function parseModeFlag(value) {
907
678
  return parsePublishModeFlag(value, "--publish-mode");
908
679
  }
909
- var PERMISSIONS_QUESTION = [
910
- "Let your agent search tenjin without permission popups?",
911
- `Adds ${FREE_VERB_RULES.length} free commands to ~/.claude/settings.json.`,
912
- "None can spend USDC or move your keys; doctor may check your wallet still opens.",
913
- "Three send or store data (search, outcome, read).",
914
- `Full caveats: ${PERMISSIONS_DOC_URL}`
915
- ].join(" ");
680
+ function permissionsQuestionHead(mode) {
681
+ const count = rulesForPublishMode(mode).length;
682
+ return `Let your agent use tenjin without permission popups? Adds ${count} command rules to ~/.claude/settings.json.`;
683
+ }
684
+ var PERMISSIONS_QUESTION = `${permissionsQuestionHead("review")} None of them can spend your money. Details: ${PERMISSIONS_DOC_URL}`;
685
+ function permissionsQuestion(mode) {
686
+ if (mode === "review") return PERMISSIONS_QUESTION;
687
+ 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}`;
688
+ }
916
689
  var WALLET_QUESTION = "Create a wallet now?";
917
690
  async function resolvePermissions(args) {
918
- const { plans, home, deps, flag, dryRun, canPrompt } = args;
919
- if (!plans.some((p) => p.harness === "claude")) {
920
- return permissionsSkipped(plans[0]?.harness ?? "shared", home, "harness-not-claude");
691
+ const { plans, home, deps, flag, dryRun, canPrompt, publishMode } = args;
692
+ if (dryRun) return (deps.planPermissions ?? planFreeVerbAllowlist)(home, publishMode);
693
+ let retractedRules = [];
694
+ let retractedFrom;
695
+ if (publishMode === "review") {
696
+ const retracted = await (deps.retractModeGated ?? retractModeGatedRules)(home);
697
+ if (retracted.skipped !== void 0) return retracted;
698
+ retractedRules = retracted.removed;
699
+ retractedFrom = retracted.path;
700
+ }
701
+ const withRetraction = (result) => retractedRules.length === 0 ? result : {
702
+ ...result,
703
+ removed: [...retractedRules, ...result.removed],
704
+ // A non-Claude skip carries no `path`, deliberately: naming a Claude
705
+ // file to a Codex-only operator points them at a file that is nothing
706
+ // to do with their harness. Once we have RETRACTED from that file, the
707
+ // reverse is true, and the operator needs to know which file changed.
708
+ ...result.path === void 0 ? { path: retractedFrom } : {}
709
+ };
710
+ const hasClaude = plans.some((p) => p.harness === "claude");
711
+ if (!hasClaude) {
712
+ return withRetraction(
713
+ permissionsSkipped(plans[0]?.harness ?? "shared", home, "harness-not-claude")
714
+ );
715
+ }
716
+ if (flag === false) return withRetraction(permissionsSkipped("claude", home, "declined"));
717
+ const probe = await (deps.inspectPermissions ?? inspectFreeVerbRules)(home, publishMode);
718
+ if (probe.satisfied !== void 0) return withRetraction(probe.satisfied);
719
+ if (probe.pending !== null && probe.pending.length === 0) {
720
+ return withRetraction(await wireFreeVerbAllowlist(home, publishMode));
721
+ }
722
+ if (flag === true || !canPrompt) {
723
+ return withRetraction(await wireFreeVerbAllowlist(home, publishMode));
921
724
  }
922
- if (dryRun) return permissionsSkipped("claude", home, "dry-run");
923
- if (flag === false) return permissionsSkipped("claude", home, "declined");
924
- const probe = await (deps.inspectPermissions ?? inspectFreeVerbRules)(home);
925
- if (probe.satisfied !== void 0) return probe.satisfied;
926
- if (probe.pending !== null && probe.pending.length === 0) return wireFreeVerbAllowlist(home);
927
- if (flag === true || !canPrompt) return wireFreeVerbAllowlist(home);
928
725
  const confirm = deps.confirmPermissions ?? defaultConfirm;
929
- if (!await confirm(PERMISSIONS_QUESTION)) {
930
- return permissionsSkipped("claude", home, "declined");
726
+ if (!await confirm(permissionsQuestion(publishMode))) {
727
+ return withRetraction(permissionsSkipped("claude", home, "declined"));
931
728
  }
932
- return wireFreeVerbAllowlist(home);
729
+ return withRetraction(await wireFreeVerbAllowlist(home, publishMode));
933
730
  }
934
- var SEARCH_HOOKS_QUESTION = "Let Tenjin ride along with your web searches? (Escape skips, registering nothing)";
731
+ var SEARCH_HOOKS_QUESTION = "Let Tenjin ride along with your web searches?";
935
732
  var SEARCH_HOOKS_CHOICES = [
936
733
  {
937
734
  value: "auto",
938
735
  label: "Yes, check Tenjin first (recommended)",
939
- 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"
736
+ hint: `before a WebSearch or a subagent dispatch, ask ${PRODUCTION_HOST} the same question (free, anonymous, 2s budget) and mention a tested answer; the query or the first 400 chars of the prompt leaves the machine`
940
737
  },
941
738
  {
942
739
  value: "remind",
@@ -948,8 +745,16 @@ var SEARCH_HOOKS_CHOICES = [
948
745
  async function resolveHooks(args) {
949
746
  const { plans, home, ctx, deps, flag, noHooks, dryRun, canPrompt } = args;
950
747
  const dataDir = ctx.dataDir;
951
- const stored = (await loadRawConfig(dataDir)).hooks?.searchMode;
952
- if (!plans.some((p) => p.harness === "claude")) {
748
+ const rawHooks = (await loadRawConfig(dataDir)).hooks;
749
+ const stored = rawHooks?.webSearch ?? rawHooks?.searchMode;
750
+ const storedWebSearch = rawHooks?.webSearch ?? rawHooks?.searchMode;
751
+ const storedAgentDispatchRaw = rawHooks?.agentDispatch ?? (rawHooks?.dispatchMode === "inherit" ? storedWebSearch : rawHooks?.dispatchMode);
752
+ const storedAgentDispatch = storedAgentDispatchRaw ?? (rawHooks?.searchMode !== void 0 ? storedWebSearch : void 0);
753
+ const storedWebSearchEff = storedWebSearch ?? DEFAULT_HOOK_MODE;
754
+ const storedAgentDispatchEff = storedAgentDispatch ?? storedWebSearch ?? DEFAULT_HOOK_MODE;
755
+ const hasClaude = plans.some((p) => p.harness === "claude");
756
+ const hasHermes = plans.some((p) => p.harness === "hermes");
757
+ if (!hasClaude && !hasHermes) {
953
758
  const harness = plans[0]?.harness ?? "shared";
954
759
  return hooksSkipped(
955
760
  harness,
@@ -960,26 +765,47 @@ async function resolveHooks(args) {
960
765
  );
961
766
  }
962
767
  if (noHooks) {
963
- return hooksSkipped("claude", home, dataDir, stored ?? DEFAULT_HOOK_MODE, "declined");
768
+ return hooksSkipped(
769
+ hasHermes ? "hermes" : "claude",
770
+ home,
771
+ dataDir,
772
+ stored ?? DEFAULT_HOOK_MODE,
773
+ "declined"
774
+ );
964
775
  }
965
776
  const mode = await chooseHookMode(flag, stored, deps, dryRun, canPrompt);
966
777
  if (mode === null) {
967
- return hooksSkipped("claude", home, dataDir, stored ?? DEFAULT_HOOK_MODE, "declined");
968
- }
969
- if (dryRun) return hooksSkipped("claude", home, dataDir, mode, "dry-run");
970
- if (mode !== (stored ?? DEFAULT_HOOK_MODE) || stored === void 0) {
971
- await persistSearchHookMode(dataDir, mode);
778
+ return hooksSkipped(
779
+ hasHermes ? "hermes" : "claude",
780
+ home,
781
+ dataDir,
782
+ stored ?? DEFAULT_HOOK_MODE,
783
+ "declined"
784
+ );
972
785
  }
973
- if (mode === "off") return hooksSkipped("claude", home, dataDir, mode, "mode-off");
786
+ const resultHarness = hasHermes && !hasClaude ? "hermes" : "claude";
787
+ if (dryRun) return hooksSkipped(resultHarness, home, dataDir, mode, "dry-run");
788
+ const isExplicitChoice = flag !== void 0 || canPrompt && !dryRun;
789
+ const hasAnyHookKey = rawHooks?.webSearch !== void 0 || rawHooks?.agentDispatch !== void 0 || rawHooks?.searchMode !== void 0 || rawHooks?.dispatchMode !== void 0;
790
+ const needsSync = isExplicitChoice ? rawHooks?.webSearch === void 0 || rawHooks?.agentDispatch === void 0 || mode !== storedWebSearchEff || mode !== storedAgentDispatchEff : !hasAnyHookKey;
791
+ if (needsSync) {
792
+ await persistWebSearchHookMode(dataDir, mode);
793
+ await persistAgentDispatchHookMode(dataDir, mode);
794
+ }
795
+ if (mode === "off") return hooksSkipped(resultHarness, home, dataDir, mode, "mode-off");
796
+ if (!hasClaude) return hooksSkipped("hermes", home, dataDir, mode, "native-harness");
974
797
  return wireSearchHooks({ homeDir: home, dataDir, mode });
975
798
  }
976
- var DEFAULT_HOOK_MODE = CONFIG_DEFAULTS.hooks.searchMode;
799
+ function hermesHooksEnabled(hooks) {
800
+ return hooks.skipped !== "declined" && hooks.skipped !== "mode-off" && hooks.skipped !== "harness-not-claude";
801
+ }
802
+ var DEFAULT_HOOK_MODE = CONFIG_DEFAULTS.hooks.webSearch;
977
803
  async function chooseHookMode(flag, stored, deps, dryRun, canPrompt) {
978
804
  if (flag !== void 0) return flag;
979
805
  if (dryRun || !canPrompt) return stored ?? DEFAULT_HOOK_MODE;
980
806
  const answer = await (deps.promptSearchHooks ?? defaultPromptSearchHooks)();
981
807
  if (answer === null) return null;
982
- const parsed = SearchHookModeSchema.safeParse(answer);
808
+ const parsed = WebSearchModeSchema.safeParse(answer);
983
809
  return parsed.success ? parsed.data : null;
984
810
  }
985
811
  function defaultPromptSearchHooks() {
@@ -989,24 +815,35 @@ function defaultPromptSearchHooks() {
989
815
  initialValue: "auto"
990
816
  });
991
817
  }
992
- function resolvePlans(override, home, which) {
818
+ function resolvePlans(override, home, hermesHome, which) {
993
819
  if (override !== void 0 && override.length > 0) {
994
- const plans2 = override.map((v) => planFor(validateHarness(v), ["override"], true, home));
820
+ const plans2 = override.map(
821
+ (v) => planFor(validateHarness(v), ["override"], true, home, hermesHome)
822
+ );
995
823
  return dedupeBySkillsDir(plans2);
996
824
  }
997
825
  const plans = [];
998
- const claudeBy = harnessDetectedBy(home, "claude", which);
999
- const codexBy = harnessDetectedBy(home, "codex", which);
1000
- if (claudeBy.length > 0) plans.push(planFor("claude", claudeBy, true, home));
1001
- if (codexBy.length > 0) plans.push(planFor("codex", codexBy, true, home));
826
+ const claudeBy = harnessDetectedBy(home, "claude", which, hermesHome);
827
+ const codexBy = harnessDetectedBy(home, "codex", which, hermesHome);
828
+ const hermesBy = harnessDetectedBy(home, "hermes", which, hermesHome);
829
+ if (claudeBy.length > 0) plans.push(planFor("claude", claudeBy, true, home, hermesHome));
830
+ if (codexBy.length > 0) plans.push(planFor("codex", codexBy, true, home, hermesHome));
831
+ if (hermesBy.length > 0) plans.push(planFor("hermes", hermesBy, true, home, hermesHome));
1002
832
  if (plans.length === 0) {
1003
- plans.push(planFor("shared", ["fallback"], false, home));
833
+ plans.push(planFor("shared", ["fallback"], false, home, hermesHome));
1004
834
  }
1005
835
  return dedupeBySkillsDir(plans);
1006
836
  }
1007
- function planFor(harness, detectedBy, detected, home) {
1008
- const skillsDir = harnessTargetDir(home, harness);
1009
- return { harness, detected, detectedBy, skillsDir, wiresAgentsMd: harness !== "claude", home };
837
+ function planFor(harness, detectedBy, detected, home, hermesHome) {
838
+ const skillsDir = harnessTargetDir(home, harness, hermesHome);
839
+ return {
840
+ harness,
841
+ detected,
842
+ detectedBy,
843
+ skillsDir,
844
+ wiresAgentsMd: harness !== "claude" && harness !== "hermes",
845
+ home
846
+ };
1010
847
  }
1011
848
  function dedupeBySkillsDir(plans) {
1012
849
  const seen = /* @__PURE__ */ new Set();
@@ -1029,8 +866,8 @@ async function applyPlan(plan, skillsSource, dryRun) {
1029
866
  const warnings = [];
1030
867
  for (const name of SKILL_NAMES) {
1031
868
  const { status, warning, preexisting } = await installSkill(
1032
- join2(skillsSource, name),
1033
- join2(plan.skillsDir, name),
869
+ join(skillsSource, name),
870
+ join(plan.skillsDir, name),
1034
871
  dryRun,
1035
872
  name
1036
873
  );
@@ -1073,7 +910,7 @@ function notesFor(plan, hostedArrivedFirst) {
1073
910
  return notes;
1074
911
  }
1075
912
  async function landedInvocable(skillsDir, skillsSource, name, dryRun) {
1076
- const read = await readSkillFile(join2(dryRun ? skillsSource : skillsDir, name, "SKILL.md"));
913
+ const read = await readSkillFile(join(dryRun ? skillsSource : skillsDir, name, "SKILL.md"));
1077
914
  if (read.kind !== "ok") return false;
1078
915
  return !isModelInvocationDisabled(read.bytes.toString("utf8"));
1079
916
  }
@@ -1082,8 +919,8 @@ async function assertSkillsLanded(plans, dryRun) {
1082
919
  const missing = [];
1083
920
  for (const plan of plans) {
1084
921
  for (const name of SKILL_NAMES) {
1085
- if (!existsSync(join2(plan.skillsDir, name, "SKILL.md"))) {
1086
- missing.push(join2(plan.skillsDir, name));
922
+ if (!existsSync(join(plan.skillsDir, name, "SKILL.md"))) {
923
+ missing.push(join(plan.skillsDir, name));
1087
924
  }
1088
925
  }
1089
926
  }
@@ -1102,14 +939,14 @@ function paint(io, format, text) {
1102
939
  }
1103
940
  async function assertSkillsSource(dir) {
1104
941
  for (const name of SKILL_NAMES) {
1105
- if (!existsSync(join2(dir, name, "SKILL.md"))) {
942
+ if (!existsSync(join(dir, name, "SKILL.md"))) {
1106
943
  throw new CliError("INTERNAL", `Packaged skill "${name}" is missing under ${dir}`, {
1107
944
  fix: "Reinstall tenjin-cli; the published package must ship every skill under skills/."
1108
945
  });
1109
946
  }
1110
947
  }
1111
948
  for (const name of CLI_SKILL_NAMES) {
1112
- const text = await readFile2(join2(dir, name, "SKILL.md"), "utf8");
949
+ const text = await readFile(join(dir, name, "SKILL.md"), "utf8");
1113
950
  if (isModelInvocationDisabled(text)) {
1114
951
  throw new CliError(
1115
952
  "INTERNAL",
@@ -1122,12 +959,14 @@ async function assertSkillsSource(dir) {
1122
959
  }
1123
960
  }
1124
961
  export {
962
+ BAZAAR_QUESTION,
1125
963
  PERMISSIONS_QUESTION,
1126
964
  PUBLISH_MODE_CHOICES,
1127
965
  PUBLISH_MODE_QUESTION,
1128
966
  SEARCH_HOOKS_CHOICES,
1129
967
  SEARCH_HOOKS_QUESTION,
1130
968
  WALLET_QUESTION,
969
+ permissionsQuestion,
1131
970
  runInstall
1132
971
  };
1133
- //# sourceMappingURL=install-YQVM3SUW.js.map
972
+ //# sourceMappingURL=install-GNK2W3PI.js.map