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

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 (155) hide show
  1. package/README.md +36 -2
  2. package/dist/{buy-3DTBFZ4B.js → buy-2JBYPHAI.js} +23 -21
  3. package/dist/{chunk-Y7ERTA7D.js → chunk-3P3ES4XU.js} +4 -6
  4. package/dist/chunk-3P3ES4XU.js.map +1 -0
  5. package/dist/{chunk-WWIKAJFO.js → chunk-3ZW7HPY5.js} +12 -10
  6. package/dist/{chunk-WWIKAJFO.js.map → chunk-3ZW7HPY5.js.map} +1 -1
  7. package/dist/chunk-4UHNXY6B.js +786 -0
  8. package/dist/chunk-4UHNXY6B.js.map +1 -0
  9. package/dist/{chunk-6UY2UQMY.js → chunk-4Y53PDH6.js} +4 -4
  10. package/dist/{chunk-TUXKOIOU.js → chunk-54AJIO3E.js} +12 -13
  11. package/dist/chunk-54AJIO3E.js.map +1 -0
  12. package/dist/chunk-736DW4V3.js +65 -0
  13. package/dist/chunk-736DW4V3.js.map +1 -0
  14. package/dist/{chunk-CNUXRXI2.js → chunk-7GJQ5RGA.js} +9 -9
  15. package/dist/{chunk-4NTZETIL.js → chunk-7NADDA2V.js} +10 -7
  16. package/dist/{chunk-4NTZETIL.js.map → chunk-7NADDA2V.js.map} +1 -1
  17. package/dist/{chunk-UFPJBS4C.js → chunk-ACBEHJAH.js} +10 -8
  18. package/dist/{chunk-UFPJBS4C.js.map → chunk-ACBEHJAH.js.map} +1 -1
  19. package/dist/{chunk-IB63U6BM.js → chunk-B676GPS2.js} +34 -11
  20. package/dist/chunk-B676GPS2.js.map +1 -0
  21. package/dist/{chunk-MBKFZBB2.js → chunk-DAZAXFSF.js} +24 -24
  22. package/dist/{chunk-E6YOODH7.js → chunk-DTCXO7HS.js} +284 -406
  23. package/dist/chunk-DTCXO7HS.js.map +1 -0
  24. package/dist/{chunk-HWHYPCCH.js → chunk-ETKZWJ4B.js} +2 -2
  25. package/dist/{chunk-HWHYPCCH.js.map → chunk-ETKZWJ4B.js.map} +1 -1
  26. package/dist/{chunk-X2WZPGCF.js → chunk-FDUD3W5V.js} +5 -5
  27. package/dist/{chunk-6RMEX74N.js → chunk-GEHL43VE.js} +63 -26
  28. package/dist/chunk-GEHL43VE.js.map +1 -0
  29. package/dist/chunk-IU2HVT3Y.js +313 -0
  30. package/dist/chunk-IU2HVT3Y.js.map +1 -0
  31. package/dist/{chunk-4TCU3YRD.js → chunk-IUQZ4Z7M.js} +40 -8
  32. package/dist/chunk-IUQZ4Z7M.js.map +1 -0
  33. package/dist/{chunk-CBNXUQGM.js → chunk-IXZJ3JOO.js} +10 -8
  34. package/dist/{chunk-CBNXUQGM.js.map → chunk-IXZJ3JOO.js.map} +1 -1
  35. package/dist/{chunk-NUF2PKJO.js → chunk-J6FUAIRR.js} +4 -6
  36. package/dist/{chunk-NUF2PKJO.js.map → chunk-J6FUAIRR.js.map} +1 -1
  37. package/dist/{chunk-OZHJ3FLR.js → chunk-L6G35FU5.js} +5 -5
  38. package/dist/{chunk-ALUNME53.js → chunk-LSWP7MU2.js} +52 -68
  39. package/dist/chunk-LSWP7MU2.js.map +1 -0
  40. package/dist/chunk-MJSXP4LW.js +191 -0
  41. package/dist/chunk-MJSXP4LW.js.map +1 -0
  42. package/dist/{chunk-RSBN67PA.js → chunk-NAAMHWSI.js} +7 -6
  43. package/dist/chunk-NAAMHWSI.js.map +1 -0
  44. package/dist/{chunk-7MJVNALU.js → chunk-O75FOHXS.js} +35 -15
  45. package/dist/chunk-O75FOHXS.js.map +1 -0
  46. package/dist/{chunk-6BGYHARE.js → chunk-OWVVI4VQ.js} +15 -15
  47. package/dist/{chunk-PZRAAAY2.js → chunk-PAOVPSP6.js} +10 -3
  48. package/dist/chunk-PAOVPSP6.js.map +1 -0
  49. package/dist/{chunk-ROAK2DOX.js → chunk-PCX2JQ2J.js} +8 -8
  50. package/dist/{chunk-JTYIX6OD.js → chunk-PKW3H26Z.js} +7 -5
  51. package/dist/{chunk-JTYIX6OD.js.map → chunk-PKW3H26Z.js.map} +1 -1
  52. package/dist/{chunk-V5UHKC46.js → chunk-PQZVDCCA.js} +7 -7
  53. package/dist/{chunk-P74I3WH4.js → chunk-QWBUKIP2.js} +9 -5
  54. package/dist/chunk-QWBUKIP2.js.map +1 -0
  55. package/dist/{chunk-FKSAUOJU.js → chunk-UO22YNY4.js} +1 -69
  56. package/dist/chunk-UO22YNY4.js.map +1 -0
  57. package/dist/chunk-VEAERJVJ.js +43 -0
  58. package/dist/chunk-VEAERJVJ.js.map +1 -0
  59. package/dist/{chunk-ILDVGY7K.js → chunk-VRPLZERE.js} +25 -12
  60. package/dist/chunk-VRPLZERE.js.map +1 -0
  61. package/dist/{chunk-L3I2MVKR.js → chunk-W4VW5XYB.js} +6 -6
  62. package/dist/{chunk-TDDN5GXR.js → chunk-WU5CZPLD.js} +5 -5
  63. package/dist/chunk-WYLMJQVH.js +240 -0
  64. package/dist/chunk-WYLMJQVH.js.map +1 -0
  65. package/dist/{chunk-PZSUWDF2.js → chunk-XGZ5EVMB.js} +2 -2
  66. package/dist/{chunk-CLOEU7RA.js → chunk-XVPQGCH4.js} +14 -13
  67. package/dist/chunk-XVPQGCH4.js.map +1 -0
  68. package/dist/chunk-ZOBNS7CX.js +73 -0
  69. package/dist/chunk-ZOBNS7CX.js.map +1 -0
  70. package/dist/{cli-3WZGLZDP.js → cli-U2BEUA55.js} +53 -150
  71. package/dist/cli-U2BEUA55.js.map +1 -0
  72. package/dist/{config-WDGMZKHU.js → config-CNUIX23Q.js} +14 -8
  73. package/dist/doctor-QJJXRWTO.js +31 -0
  74. package/dist/edit-HJ44P44P.js +40 -0
  75. package/dist/{fund-JAPOFTUG.js → fund-Y5IAHZ5D.js} +19 -17
  76. package/dist/index.js +1 -1
  77. package/dist/inspect-NFQ6SQQQ.js +37 -0
  78. package/dist/{install-WXTOHDWC.js → install-DXX7PVUP.js} +128 -408
  79. package/dist/install-DXX7PVUP.js.map +1 -0
  80. package/dist/outcome-ANV4QIED.js +24 -0
  81. package/dist/publish-PCBTCXCZ.js +42 -0
  82. package/dist/{read-UAZGZ4UL.js → read-W7QVRBVD.js} +24 -22
  83. package/dist/{read-UAZGZ4UL.js.map → read-W7QVRBVD.js.map} +1 -1
  84. package/dist/{run-AJNCOT5R.js → run-CJWPGMIQ.js} +35 -33
  85. package/dist/{run-AJNCOT5R.js.map → run-CJWPGMIQ.js.map} +1 -1
  86. package/dist/search-JGAVKTYJ.js +25 -0
  87. package/dist/{send-F34ZDXDZ.js → send-C5EOKXOU.js} +13 -11
  88. package/dist/{send-F34ZDXDZ.js.map → send-C5EOKXOU.js.map} +1 -1
  89. package/dist/{session-4N4ZT3AH.js → session-OBCUUIFX.js} +16 -15
  90. package/dist/{session-4N4ZT3AH.js.map → session-OBCUUIFX.js.map} +1 -1
  91. package/dist/{skill-heal-XBEK272G.js → skill-heal-D6EPLPS6.js} +5 -6
  92. package/dist/skill-heal-D6EPLPS6.js.map +1 -0
  93. package/dist/{uninstall-BTKPHPDL.js → uninstall-OWJNJ5LI.js} +13 -8
  94. package/dist/uninstall-OWJNJ5LI.js.map +1 -0
  95. package/dist/update-24Y2CQTT.js +318 -0
  96. package/dist/update-24Y2CQTT.js.map +1 -0
  97. package/dist/{wallet-WJ6UP5OU.js → wallet-OFXDIIGP.js} +11 -10
  98. package/dist/{wallet-UL4P2JRO.js → wallet-SLRIYJ2U.js} +7 -7
  99. package/docs/agent-permissions.md +111 -16
  100. package/docs/command-reference.md +68 -11
  101. package/package.json +1 -1
  102. package/skills/tenjin-publish/SKILL.md +181 -192
  103. package/skills/tenjin-publish/references/maintain.md +39 -0
  104. package/skills/tenjin-search/SKILL.md +86 -279
  105. package/skills/tenjin-search/references/permissions.md +106 -0
  106. package/dist/chunk-2I4QTOLB.js +0 -11
  107. package/dist/chunk-2I4QTOLB.js.map +0 -1
  108. package/dist/chunk-4TCU3YRD.js.map +0 -1
  109. package/dist/chunk-6RMEX74N.js.map +0 -1
  110. package/dist/chunk-7MJVNALU.js.map +0 -1
  111. package/dist/chunk-ALUNME53.js.map +0 -1
  112. package/dist/chunk-CLOEU7RA.js.map +0 -1
  113. package/dist/chunk-E6YOODH7.js.map +0 -1
  114. package/dist/chunk-FKSAUOJU.js.map +0 -1
  115. package/dist/chunk-IB63U6BM.js.map +0 -1
  116. package/dist/chunk-ILDVGY7K.js.map +0 -1
  117. package/dist/chunk-P74I3WH4.js.map +0 -1
  118. package/dist/chunk-PZRAAAY2.js.map +0 -1
  119. package/dist/chunk-RSBN67PA.js.map +0 -1
  120. package/dist/chunk-SFGXAZ3M.js +0 -316
  121. package/dist/chunk-SFGXAZ3M.js.map +0 -1
  122. package/dist/chunk-TUXKOIOU.js.map +0 -1
  123. package/dist/chunk-Y7ERTA7D.js.map +0 -1
  124. package/dist/cli-3WZGLZDP.js.map +0 -1
  125. package/dist/doctor-EKVCP7JP.js +0 -27
  126. package/dist/edit-4UZQVFCK.js +0 -38
  127. package/dist/inspect-IEV75A42.js +0 -35
  128. package/dist/install-WXTOHDWC.js.map +0 -1
  129. package/dist/outcome-FYOFDOUK.js +0 -22
  130. package/dist/publish-6QNARH7E.js +0 -40
  131. package/dist/search-EEKTW6VK.js +0 -23
  132. package/dist/skill-heal-XBEK272G.js.map +0 -1
  133. package/dist/uninstall-BTKPHPDL.js.map +0 -1
  134. /package/dist/{buy-3DTBFZ4B.js.map → buy-2JBYPHAI.js.map} +0 -0
  135. /package/dist/{chunk-6UY2UQMY.js.map → chunk-4Y53PDH6.js.map} +0 -0
  136. /package/dist/{chunk-CNUXRXI2.js.map → chunk-7GJQ5RGA.js.map} +0 -0
  137. /package/dist/{chunk-MBKFZBB2.js.map → chunk-DAZAXFSF.js.map} +0 -0
  138. /package/dist/{chunk-X2WZPGCF.js.map → chunk-FDUD3W5V.js.map} +0 -0
  139. /package/dist/{chunk-OZHJ3FLR.js.map → chunk-L6G35FU5.js.map} +0 -0
  140. /package/dist/{chunk-6BGYHARE.js.map → chunk-OWVVI4VQ.js.map} +0 -0
  141. /package/dist/{chunk-ROAK2DOX.js.map → chunk-PCX2JQ2J.js.map} +0 -0
  142. /package/dist/{chunk-V5UHKC46.js.map → chunk-PQZVDCCA.js.map} +0 -0
  143. /package/dist/{chunk-L3I2MVKR.js.map → chunk-W4VW5XYB.js.map} +0 -0
  144. /package/dist/{chunk-TDDN5GXR.js.map → chunk-WU5CZPLD.js.map} +0 -0
  145. /package/dist/{chunk-PZSUWDF2.js.map → chunk-XGZ5EVMB.js.map} +0 -0
  146. /package/dist/{config-WDGMZKHU.js.map → config-CNUIX23Q.js.map} +0 -0
  147. /package/dist/{doctor-EKVCP7JP.js.map → doctor-QJJXRWTO.js.map} +0 -0
  148. /package/dist/{edit-4UZQVFCK.js.map → edit-HJ44P44P.js.map} +0 -0
  149. /package/dist/{fund-JAPOFTUG.js.map → fund-Y5IAHZ5D.js.map} +0 -0
  150. /package/dist/{inspect-IEV75A42.js.map → inspect-NFQ6SQQQ.js.map} +0 -0
  151. /package/dist/{outcome-FYOFDOUK.js.map → outcome-ANV4QIED.js.map} +0 -0
  152. /package/dist/{publish-6QNARH7E.js.map → publish-PCBTCXCZ.js.map} +0 -0
  153. /package/dist/{search-EEKTW6VK.js.map → search-JGAVKTYJ.js.map} +0 -0
  154. /package/dist/{wallet-UL4P2JRO.js.map → wallet-OFXDIIGP.js.map} +0 -0
  155. /package/dist/{wallet-WJ6UP5OU.js.map → wallet-SLRIYJ2U.js.map} +0 -0
@@ -1,55 +1,66 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  runWalletCreate
4
- } from "./chunk-UFPJBS4C.js";
4
+ } from "./chunk-ACBEHJAH.js";
5
5
  import "./chunk-MJZZTKCC.js";
6
6
  import {
7
7
  describeWallet,
8
8
  resolveWalletProvider
9
- } from "./chunk-CNUXRXI2.js";
9
+ } from "./chunk-7GJQ5RGA.js";
10
10
  import {
11
11
  collectDoctorChecks,
12
12
  isNoWalletCheck
13
- } from "./chunk-6RMEX74N.js";
14
- import {
15
- PERMISSIONS_DOC_URL,
16
- recommendedPermissions
17
- } from "./chunk-4TCU3YRD.js";
18
- import "./chunk-TUXKOIOU.js";
19
- import "./chunk-HWHYPCCH.js";
20
- import "./chunk-NUF2PKJO.js";
21
- import "./chunk-PZSUWDF2.js";
13
+ } from "./chunk-GEHL43VE.js";
14
+ import "./chunk-J6FUAIRR.js";
15
+ import "./chunk-54AJIO3E.js";
16
+ import "./chunk-XGZ5EVMB.js";
22
17
  import {
23
18
  walletFileExists
24
- } from "./chunk-Y7ERTA7D.js";
19
+ } from "./chunk-3P3ES4XU.js";
25
20
  import {
26
- FREE_VERB_RULES,
27
- STOP_HOOK_FILE,
28
- WEBSEARCH_HOOK_FILE,
29
- claudeSettingsPath,
30
- inspectFreeVerbRules,
31
- permissionsSkipped,
32
- removeMarkerLines,
33
- stopHookScript,
34
- websearchHookScript,
35
- wireFreeVerbAllowlist
36
- } from "./chunk-E6YOODH7.js";
21
+ removeMarkerLines
22
+ } from "./chunk-WYLMJQVH.js";
37
23
  import {
38
24
  installSkill
39
- } from "./chunk-RSBN67PA.js";
25
+ } from "./chunk-NAAMHWSI.js";
40
26
  import {
41
27
  sanitizeForTerminal
42
- } from "./chunk-IB63U6BM.js";
28
+ } from "./chunk-B676GPS2.js";
43
29
  import {
30
+ confirmChoice,
31
+ hooksSkipped,
32
+ hooksUndo,
33
+ intro,
34
+ outro,
44
35
  persistInstallHarness,
45
36
  persistPublishMode,
46
- persistSearchHookMode
47
- } from "./chunk-SFGXAZ3M.js";
48
- import "./chunk-JTYIX6OD.js";
37
+ persistSearchHookMode,
38
+ selectOne,
39
+ wireSearchHooks
40
+ } from "./chunk-4UHNXY6B.js";
49
41
  import {
50
42
  ownsAnyLock,
51
43
  releaseOwnedLocks
52
- } from "./chunk-FKSAUOJU.js";
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";
53
64
  import {
54
65
  CONFIG_DEFAULTS,
55
66
  PublishModeSchema,
@@ -57,9 +68,9 @@ import {
57
68
  loadRawConfig,
58
69
  parsePublishModeFlag,
59
70
  parseSearchHookModeFlag
60
- } from "./chunk-ALUNME53.js";
71
+ } from "./chunk-LSWP7MU2.js";
72
+ import "./chunk-ETKZWJ4B.js";
61
73
  import {
62
- hooksDir,
63
74
  walletPath
64
75
  } from "./chunk-ZQIQ55KK.js";
65
76
  import {
@@ -73,15 +84,12 @@ import {
73
84
  onPath,
74
85
  readSkillFile,
75
86
  resolveSkillsSource
76
- } from "./chunk-P74I3WH4.js";
77
- import {
78
- hasCode
79
- } from "./chunk-2I4QTOLB.js";
87
+ } from "./chunk-QWBUKIP2.js";
80
88
  import {
81
89
  CliError,
82
90
  external_exports,
83
- writeFileAtomic
84
- } from "./chunk-PZRAAAY2.js";
91
+ hasCode
92
+ } from "./chunk-PAOVPSP6.js";
85
93
  import "./chunk-7FK2UN2T.js";
86
94
  import "./chunk-M2O56UK7.js";
87
95
  import "./chunk-UHTVXQ2O.js";
@@ -95,329 +103,12 @@ import "./chunk-ZXTAQYNA.js";
95
103
 
96
104
  // src/commands/install.ts
97
105
  import { existsSync } from "fs";
98
- import { readFile as readFile2 } from "fs/promises";
106
+ import { readFile } from "fs/promises";
99
107
  import { fileURLToPath } from "url";
100
- import { dirname, isAbsolute, join as join2 } from "path";
108
+ import { dirname, isAbsolute, join } from "path";
101
109
  import { homedir } from "os";
102
110
  import { styleText } from "util";
103
111
  import { Stream } from "stream";
104
-
105
- // src/lib/harness-hooks.ts
106
- import { lstat, readFile, realpath } from "fs/promises";
107
- import { join } from "path";
108
- var WEBSEARCH_MATCHER = "WebSearch";
109
- var HOOK_TIMEOUT_SECONDS = 5;
110
- function hooksUndo(settingsPath, scriptsDir) {
111
- return `Undo anytime: \`tenjin config set hooks.searchMode off\` disarms them, or delete the tenjin hook entries from ${settingsPath} and the scripts in ${scriptsDir}.`;
112
- }
113
- function skip(reason, args) {
114
- return {
115
- harness: args.harness,
116
- ...args.path !== void 0 ? { path: args.path } : {},
117
- scriptsDir: args.scriptsDir,
118
- mode: args.mode,
119
- added: [],
120
- alreadyPresent: [],
121
- updated: [],
122
- scripts: [],
123
- skipped: reason,
124
- ...args.warning !== void 0 ? { warning: args.warning } : {},
125
- ...args.fix !== void 0 ? { fix: args.fix } : {}
126
- };
127
- }
128
- function hooksSkipped(harness, homeDir, dataDir, mode, reason) {
129
- return skip(reason, {
130
- harness,
131
- ...harness === "claude" ? { path: claudeSettingsPath(homeDir) } : {},
132
- scriptsDir: hooksDir(dataDir),
133
- mode,
134
- fix: fixFor(reason)
135
- });
136
- }
137
- function fixFor(reason) {
138
- switch (reason) {
139
- case "harness-not-claude":
140
- return "Hooks are wired for Claude Code only. Re-run `tenjin install --harness claude` on a machine with Claude Code.";
141
- case "mode-off":
142
- return "Enable them with `tenjin config set hooks.searchMode auto`, then re-run `tenjin install`.";
143
- case "declined":
144
- case "dry-run":
145
- return "Wire them with `tenjin install --search-hooks auto`.";
146
- case "changed-since-read":
147
- return "Another process changed the file mid-run; re-run `tenjin install`.";
148
- default:
149
- return "Fix the reported file, then re-run `tenjin install --search-hooks auto`.";
150
- }
151
- }
152
- function isPlainObject(value) {
153
- return typeof value === "object" && value !== null && !Array.isArray(value);
154
- }
155
- function quoteForShell(path, platform = process.platform) {
156
- if (platform === "win32") return `"${path}"`;
157
- return `'${path.replaceAll("'", `'\\''`)}'`;
158
- }
159
- function commandFor(scriptPath, platform) {
160
- return `node ${quoteForShell(scriptPath, platform)}`;
161
- }
162
- function handlerFor(scriptPath, platform) {
163
- return {
164
- type: "command",
165
- command: commandFor(scriptPath, platform),
166
- timeout: HOOK_TIMEOUT_SECONDS
167
- };
168
- }
169
- function ownsEntry(entry, scriptFile) {
170
- if (!isPlainObject(entry)) return false;
171
- const handlers = entry.hooks;
172
- if (!Array.isArray(handlers)) return false;
173
- return handlers.some(
174
- (h) => isPlainObject(h) && typeof h.command === "string" && h.command.includes(scriptFile)
175
- );
176
- }
177
- function specs(dataDir) {
178
- return [
179
- {
180
- event: "PreToolUse",
181
- scriptFile: WEBSEARCH_HOOK_FILE,
182
- script: websearchHookScript(dataDir),
183
- matcher: WEBSEARCH_MATCHER
184
- },
185
- { event: "Stop", scriptFile: STOP_HOOK_FILE, script: stopHookScript(dataDir) }
186
- ];
187
- }
188
- async function wireSearchHooks(opts) {
189
- const { homeDir, dataDir, mode, platform } = opts;
190
- const scriptsDir = hooksDir(dataDir);
191
- const plan = specs(dataDir);
192
- const found = await inspectSettings(homeDir, scriptsDir, mode);
193
- if ("result" in found) return found.result;
194
- const { path, raw, settings, hooks } = found;
195
- const added = [];
196
- const alreadyPresent = [];
197
- const updated = [];
198
- const nextHooks = { ...hooks };
199
- for (const spec of plan) {
200
- const existing = hooks[spec.event];
201
- if (existing !== void 0 && !Array.isArray(existing)) {
202
- return refuse(
203
- path,
204
- scriptsDir,
205
- mode,
206
- "unexpected-shape",
207
- `${path} has a "hooks.${spec.event}" key that is not an array; it was left exactly as it is.`
208
- );
209
- }
210
- const list = existing ?? [];
211
- const desired = {
212
- ...spec.matcher !== void 0 ? { matcher: spec.matcher } : {},
213
- hooks: [handlerFor(join(scriptsDir, spec.scriptFile), platform)]
214
- };
215
- const idx = list.findIndex((e) => ownsEntry(e, spec.scriptFile));
216
- if (idx === -1) {
217
- nextHooks[spec.event] = [...list, desired];
218
- added.push(spec.event);
219
- continue;
220
- }
221
- if (JSON.stringify(list[idx]) === JSON.stringify(desired)) {
222
- alreadyPresent.push(spec.event);
223
- continue;
224
- }
225
- nextHooks[spec.event] = list.map((e, i) => i === idx ? desired : e);
226
- updated.push(spec.event);
227
- }
228
- if (added.length === 0 && updated.length === 0) {
229
- const scripts2 = await writeScripts(plan, scriptsDir);
230
- return { harness: "claude", path, scriptsDir, mode, added, alreadyPresent, updated, scripts: scripts2 };
231
- }
232
- const next = { ...settings, hooks: nextHooks };
233
- const changed = async () => await readFile(path, "utf8").catch(() => null) !== raw;
234
- if (await changed()) return refuseChanged(path, scriptsDir, mode, []);
235
- const scripts = await writeScripts(plan, scriptsDir);
236
- if (await changed()) return refuseChanged(path, scriptsDir, mode, scripts);
237
- await writeFileAtomic(path, `${JSON.stringify(next, null, 2)}
238
- `);
239
- return { harness: "claude", path, scriptsDir, mode, added, alreadyPresent, updated, scripts };
240
- }
241
- function refuseChanged(path, scriptsDir, mode, scripts) {
242
- return {
243
- ...refuse(
244
- path,
245
- scriptsDir,
246
- mode,
247
- "changed-since-read",
248
- `${path} changed while it was being updated, so no hooks were registered. Re-run \`tenjin install\`.`
249
- ),
250
- scripts
251
- };
252
- }
253
- async function writeScripts(plan, scriptsDir) {
254
- const written = [];
255
- for (const spec of plan) {
256
- const target = join(scriptsDir, spec.scriptFile);
257
- const onDisk = await readFile(target, "utf8").catch(() => null);
258
- if (onDisk === spec.script) continue;
259
- await writeFileAtomic(target, spec.script, { mode: 493, dirMode: 448 });
260
- written.push(target);
261
- }
262
- return written;
263
- }
264
- function refuse(path, scriptsDir, mode, reason, warning) {
265
- return skip(reason, { harness: "claude", path, scriptsDir, mode, warning, fix: fixFor(reason) });
266
- }
267
- async function inspectSettings(homeDir, scriptsDir, mode) {
268
- const declaredPath = claudeSettingsPath(homeDir);
269
- const entry = await lstat(declaredPath).catch(() => null);
270
- let path = declaredPath;
271
- if (entry !== null) {
272
- try {
273
- path = await realpath(declaredPath);
274
- } catch (err) {
275
- return {
276
- result: refuse(
277
- declaredPath,
278
- scriptsDir,
279
- mode,
280
- "unresolvable",
281
- `${declaredPath} could not be resolved (${err.message}); it was left exactly as it is.`
282
- )
283
- };
284
- }
285
- }
286
- let settings = {};
287
- let raw = null;
288
- if (entry !== null) {
289
- try {
290
- raw = await readFile(path, "utf8");
291
- } catch (err) {
292
- return {
293
- result: refuse(
294
- path,
295
- scriptsDir,
296
- mode,
297
- "unreadable",
298
- `${path} could not be read (${err.message}); no hooks were registered.`
299
- )
300
- };
301
- }
302
- let parsed;
303
- try {
304
- parsed = JSON.parse(raw);
305
- } catch (err) {
306
- return {
307
- result: refuse(
308
- path,
309
- scriptsDir,
310
- mode,
311
- "unparsable",
312
- `${path} is not valid JSON (${err.message}); it was left exactly as it is.`
313
- )
314
- };
315
- }
316
- if (!isPlainObject(parsed)) {
317
- return {
318
- result: refuse(
319
- path,
320
- scriptsDir,
321
- mode,
322
- "unexpected-shape",
323
- `${path} is not a JSON object; it was left exactly as it is.`
324
- )
325
- };
326
- }
327
- settings = parsed;
328
- }
329
- const hooksValue = settings.hooks;
330
- if (hooksValue !== void 0 && !isPlainObject(hooksValue)) {
331
- return {
332
- result: refuse(
333
- path,
334
- scriptsDir,
335
- mode,
336
- "unexpected-shape",
337
- `${path} has a "hooks" key that is not an object; it was left exactly as it is.`
338
- )
339
- };
340
- }
341
- return { path, raw, settings, hooks: hooksValue ?? {} };
342
- }
343
-
344
- // src/lib/clack.ts
345
- var SHOW_CURSOR = "\x1B[?25h";
346
- function withInputEnd(streams, onEnd, run) {
347
- const controller = new AbortController();
348
- let settleEnd;
349
- const ended = new Promise((resolve) => {
350
- settleEnd = () => {
351
- streams.output.write(SHOW_CURSOR);
352
- resolve(onEnd);
353
- };
354
- });
355
- const end = () => {
356
- controller.abort();
357
- settleEnd?.();
358
- };
359
- const onKeypress = (_text, key) => {
360
- if (key?.ctrl === true && key.name === "d") end();
361
- };
362
- streams.input.on("keypress", onKeypress);
363
- if (streams.input.readableEnded) {
364
- queueMicrotask(end);
365
- } else {
366
- streams.input.once("end", end);
367
- streams.input.once("close", end);
368
- }
369
- return Promise.race([run(controller.signal), ended]).finally(() => {
370
- streams.input.off("keypress", onKeypress);
371
- streams.input.off("end", end);
372
- streams.input.off("close", end);
373
- });
374
- }
375
- function resolveStreams(streams) {
376
- return { input: streams.input ?? process.stdin, output: streams.output ?? process.stderr };
377
- }
378
- async function selectOne(opts) {
379
- const { select, isCancel } = await import("./dist-U4M6QCKE.js");
380
- const streams = resolveStreams(opts.streams ?? {});
381
- return withInputEnd(streams, null, async (signal) => {
382
- const answer = await select({
383
- message: opts.message,
384
- options: opts.choices.map((c) => ({
385
- value: c.value,
386
- label: c.label,
387
- ...c.hint !== void 0 ? { hint: c.hint } : {}
388
- })),
389
- initialValue: opts.initialValue,
390
- input: streams.input,
391
- output: streams.output,
392
- signal
393
- });
394
- return isCancel(answer) ? null : answer;
395
- });
396
- }
397
- async function confirmChoice(message, initialValue = true, streams = {}) {
398
- const { confirm, isCancel } = await import("./dist-U4M6QCKE.js");
399
- const resolved = resolveStreams(streams);
400
- return withInputEnd(resolved, false, async (signal) => {
401
- const answer = await confirm({
402
- message,
403
- initialValue,
404
- input: resolved.input,
405
- output: resolved.output,
406
- signal
407
- });
408
- return isCancel(answer) ? false : answer;
409
- });
410
- }
411
- async function intro(message) {
412
- const clack = await import("./dist-U4M6QCKE.js");
413
- clack.intro(message, { output: process.stderr });
414
- }
415
- async function outro(message) {
416
- const clack = await import("./dist-U4M6QCKE.js");
417
- clack.outro(message, { output: process.stderr });
418
- }
419
-
420
- // src/commands/install.ts
421
112
  var HARNESSES = HARNESS_TARGETS;
422
113
  var InstallInputSchema = external_exports.object({
423
114
  harness: external_exports.array(external_exports.string()).optional(),
@@ -551,7 +242,8 @@ async function installBody(input, ctx, deps, markPhase) {
551
242
  deps,
552
243
  flag: allowFreeVerbs,
553
244
  dryRun,
554
- canPrompt
245
+ canPrompt,
246
+ publishMode: publishMode.value
555
247
  });
556
248
  const hooks = await underDataDir(
557
249
  ctx.dataDir,
@@ -583,7 +275,7 @@ async function installBody(input, ctx, deps, markPhase) {
583
275
  // `wired` is the outcome of THIS run's settings.json write; the three
584
276
  // recommendation tiers beside it are unchanged, so a machine consumer that
585
277
  // read `alwaysSafe` / `optIn` / `neverAllowlisted` before still does.
586
- permissions: { ...recommendedPermissions(), wired: permissions },
278
+ permissions: { ...recommendedPermissions(publishMode.value), wired: permissions },
587
279
  hooks,
588
280
  wallet
589
281
  };
@@ -652,19 +344,13 @@ function noticeLines(io, s) {
652
344
  `Removed the old Tenjin pointer line from ${s.pointerCleanup.join(" and ")}; the skills carry their own triggers now.`
653
345
  );
654
346
  }
655
- if (s.permissions.removed.length > 0) {
347
+ const stale = s.permissions.removed.filter((r) => !MODE_GATED_RULES.includes(r));
348
+ if (stale.length > 0) {
656
349
  lines.push(
657
- `Removed ${s.permissions.removed.length} permission rule(s) an older tenjin left in ${s.permissions.path ?? "your settings"} for commands that no longer exist.`
350
+ `Removed ${stale.length} permission rule(s) an older tenjin left in ${s.permissions.path ?? "your settings"} for commands that no longer exist.`
658
351
  );
659
352
  }
660
- if (s.permissions.added.length > 0) {
661
- lines.push(
662
- paint(
663
- io,
664
- "dim",
665
- `${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\`.`
666
- )
667
- );
353
+ if (s.permissions.planned !== true && s.permissions.added.length > 0) {
668
354
  lines.push(paint(io, "dim", `Undo anytime: remove those lines from ${s.permissions.path}.`));
669
355
  }
670
356
  if (s.hooks.added.length > 0 || s.hooks.updated.length > 0) {
@@ -692,7 +378,7 @@ function noticeLines(io, s) {
692
378
  function summaryLines(io, s) {
693
379
  return [
694
380
  ...s.harnesses.map((h) => skillsLine(io, h, s.dryRun)),
695
- publishingLine(io, s.publishMode.value),
381
+ publishingLine(io, s.publishMode.value, s.permissions),
696
382
  permissionsLine(io, s.permissions),
697
383
  hooksLine(io, s.hooks),
698
384
  walletLine(io, s.wallet),
@@ -741,30 +427,38 @@ function skillsLine(io, h, dryRun) {
741
427
  const head = `${harnessLabel(h.harness)}: ${h.skills.length} skills ${verb}`;
742
428
  return `${paint(io, "green", "\u2713")} ${paint(io, "bold", head)} in ${h.skillsDir}. ${skillRoster(h)}.`;
743
429
  }
744
- function publishingLine(io, mode) {
745
- return `${paint(io, "green", "\u2713")} ${paint(io, "bold", `Publishing: ${mode}`)}. ${modeBlurb(mode)}`;
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}`;
746
433
  }
747
434
  function permissionsLine(io, p) {
748
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
+ }
749
443
  if (p.added.length > 0) {
750
- return `${paint(io, "green", "\u2713")} ${label} ${p.added.length} free tenjin commands added to ${p.path}. Full caveats: ${PERMISSIONS_DOC_URL}`;
444
+ return `${paint(io, "green", "\u2713")} ${label} ${allowed} tenjin commands allowed in ${p.path}.${gaveBack} Details: ${PERMISSIONS_DOC_URL}`;
751
445
  }
752
446
  if (p.skipped === void 0) {
753
- return `${paint(io, "green", "\u2713")} ${label} the ${FREE_VERB_RULES.length} free tenjin commands were already allowed in ${p.path}`;
447
+ return `${paint(io, "green", "\u2713")} ${label} the ${FREE_VERB_RULES.length} free tenjin commands were already allowed in ${p.path}.${gaveBack}`;
754
448
  }
755
449
  if (p.skipped === "harness-not-claude") {
756
- return `${paint(io, "dim", "-")} ${label} not wired (Claude Code only). The lines your harness needs: ${PERMISSIONS_DOC_URL}`;
450
+ return `${paint(io, "dim", "-")} ${label} not wired for this harness (Claude Code only).${gaveBack} The lines your harness needs: ${PERMISSIONS_DOC_URL}`;
757
451
  }
758
452
  if (p.skipped === "dry-run") {
759
- return `${paint(io, "dim", "-")} ${label} unchanged (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}`;
760
454
  }
761
455
  if (p.skipped === "declined" || p.skipped === "not-requested") {
762
- return `${paint(io, "dim", "-")} ${label} unchanged. Allow the ${FREE_VERB_RULES.length} free tenjin commands with: tenjin install --allow-free-verbs`;
456
+ return `${paint(io, "dim", "-")} ${label} ${unchanged}.${gaveBack} Allow the ${FREE_VERB_RULES.length} free tenjin commands with: tenjin install --allow-free-verbs`;
763
457
  }
764
458
  if (p.skipped === "changed-since-read") {
765
- return `${paint(io, "yellow", "!")} ${label} ${p.path} changed while it was being updated, so nothing was written. Re-run: tenjin install`;
459
+ return `${paint(io, "yellow", "!")} ${label} ${p.path} changed while it was being updated, so nothing was written.${gaveBack} Re-run: tenjin install`;
766
460
  }
767
- return `${paint(io, "yellow", "!")} ${label} ${p.path} was left untouched. Fix it, then: tenjin install --allow-free-verbs`;
461
+ return `${paint(io, "yellow", "!")} ${label} ${p.path} was left untouched.${gaveBack} Fix it, then: tenjin install --allow-free-verbs`;
768
462
  }
769
463
  function walletLine(io, w) {
770
464
  const label = paint(io, "bold", "Wallet:");
@@ -797,7 +491,7 @@ function skillRoster(h) {
797
491
  return parts.join("; ");
798
492
  }
799
493
  function modeBlurb(v) {
800
- 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.";
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.";
801
495
  }
802
496
  async function resolveWallet(ctx, deps, skipReason, canPrompt) {
803
497
  const exists = await (deps.walletExists ?? walletFileExists)(ctx.dataDir);
@@ -870,10 +564,10 @@ var PUBLISH_MODE_CHOICES = [
870
564
  {
871
565
  value: "auto",
872
566
  label: "Auto (recommended)",
873
- hint: "your agent publishes clean pieces on its own; your harness still shows each command for approval"
567
+ hint: "your agent publishes and updates pieces on its own, under your identity"
874
568
  },
875
569
  { value: "review", label: "Ask me in chat first" },
876
- { value: "full-auto", label: "Fully unattended", hint: "only hard blocks stop it" }
570
+ { value: "full-auto", label: "Fully unattended", hint: "only a hard block stops it" }
877
571
  ];
878
572
  var PUBLISH_MODE_QUESTION = "When your agent has something worth publishing:";
879
573
  async function resolvePublishMode(flag, ctx, deps, dryRun, interactive) {
@@ -907,32 +601,57 @@ function defaultPromptPublishMode() {
907
601
  function parseModeFlag(value) {
908
602
  return parsePublishModeFlag(value, "--publish-mode");
909
603
  }
910
- var PERMISSIONS_QUESTION = [
911
- "Let your agent search tenjin without permission popups?",
912
- `Adds ${FREE_VERB_RULES.length} free commands to ~/.claude/settings.json.`,
913
- "None can spend USDC or move your keys; doctor may check your wallet still opens.",
914
- "Three send or store data (search, outcome, read).",
915
- `Full caveats: ${PERMISSIONS_DOC_URL}`
916
- ].join(" ");
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
+ }
917
613
  var WALLET_QUESTION = "Create a wallet now?";
918
614
  async function resolvePermissions(args) {
919
- const { plans, home, deps, flag, dryRun, canPrompt } = 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
+ };
920
634
  if (!plans.some((p) => p.harness === "claude")) {
921
- return permissionsSkipped(plans[0]?.harness ?? "shared", home, "harness-not-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));
922
647
  }
923
- if (dryRun) return permissionsSkipped("claude", home, "dry-run");
924
- if (flag === false) return permissionsSkipped("claude", home, "declined");
925
- const probe = await (deps.inspectPermissions ?? inspectFreeVerbRules)(home);
926
- if (probe.satisfied !== void 0) return probe.satisfied;
927
- if (probe.pending !== null && probe.pending.length === 0) return wireFreeVerbAllowlist(home);
928
- if (flag === true || !canPrompt) return wireFreeVerbAllowlist(home);
929
648
  const confirm = deps.confirmPermissions ?? defaultConfirm;
930
- if (!await confirm(PERMISSIONS_QUESTION)) {
931
- return permissionsSkipped("claude", home, "declined");
649
+ if (!await confirm(permissionsQuestion(publishMode))) {
650
+ return withRetraction(permissionsSkipped("claude", home, "declined"));
932
651
  }
933
- return wireFreeVerbAllowlist(home);
652
+ return withRetraction(await wireFreeVerbAllowlist(home, publishMode));
934
653
  }
935
- var SEARCH_HOOKS_QUESTION = "Let Tenjin ride along with your web searches? (Escape skips, registering nothing)";
654
+ var SEARCH_HOOKS_QUESTION = "Let Tenjin ride along with your web searches?";
936
655
  var SEARCH_HOOKS_CHOICES = [
937
656
  {
938
657
  value: "auto",
@@ -1030,8 +749,8 @@ async function applyPlan(plan, skillsSource, dryRun) {
1030
749
  const warnings = [];
1031
750
  for (const name of SKILL_NAMES) {
1032
751
  const { status, warning, preexisting } = await installSkill(
1033
- join2(skillsSource, name),
1034
- join2(plan.skillsDir, name),
752
+ join(skillsSource, name),
753
+ join(plan.skillsDir, name),
1035
754
  dryRun,
1036
755
  name
1037
756
  );
@@ -1074,7 +793,7 @@ function notesFor(plan, hostedArrivedFirst) {
1074
793
  return notes;
1075
794
  }
1076
795
  async function landedInvocable(skillsDir, skillsSource, name, dryRun) {
1077
- const read = await readSkillFile(join2(dryRun ? skillsSource : skillsDir, name, "SKILL.md"));
796
+ const read = await readSkillFile(join(dryRun ? skillsSource : skillsDir, name, "SKILL.md"));
1078
797
  if (read.kind !== "ok") return false;
1079
798
  return !isModelInvocationDisabled(read.bytes.toString("utf8"));
1080
799
  }
@@ -1083,8 +802,8 @@ async function assertSkillsLanded(plans, dryRun) {
1083
802
  const missing = [];
1084
803
  for (const plan of plans) {
1085
804
  for (const name of SKILL_NAMES) {
1086
- if (!existsSync(join2(plan.skillsDir, name, "SKILL.md"))) {
1087
- missing.push(join2(plan.skillsDir, name));
805
+ if (!existsSync(join(plan.skillsDir, name, "SKILL.md"))) {
806
+ missing.push(join(plan.skillsDir, name));
1088
807
  }
1089
808
  }
1090
809
  }
@@ -1103,14 +822,14 @@ function paint(io, format, text) {
1103
822
  }
1104
823
  async function assertSkillsSource(dir) {
1105
824
  for (const name of SKILL_NAMES) {
1106
- if (!existsSync(join2(dir, name, "SKILL.md"))) {
825
+ if (!existsSync(join(dir, name, "SKILL.md"))) {
1107
826
  throw new CliError("INTERNAL", `Packaged skill "${name}" is missing under ${dir}`, {
1108
827
  fix: "Reinstall tenjin-cli; the published package must ship every skill under skills/."
1109
828
  });
1110
829
  }
1111
830
  }
1112
831
  for (const name of CLI_SKILL_NAMES) {
1113
- const text = await readFile2(join2(dir, name, "SKILL.md"), "utf8");
832
+ const text = await readFile(join(dir, name, "SKILL.md"), "utf8");
1114
833
  if (isModelInvocationDisabled(text)) {
1115
834
  throw new CliError(
1116
835
  "INTERNAL",
@@ -1129,6 +848,7 @@ export {
1129
848
  SEARCH_HOOKS_CHOICES,
1130
849
  SEARCH_HOOKS_QUESTION,
1131
850
  WALLET_QUESTION,
851
+ permissionsQuestion,
1132
852
  runInstall
1133
853
  };
1134
- //# sourceMappingURL=install-WXTOHDWC.js.map
854
+ //# sourceMappingURL=install-DXX7PVUP.js.map