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

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 (126) hide show
  1. package/README.md +1 -0
  2. package/dist/{buy-3DTBFZ4B.js → buy-X4VPHFUA.js} +20 -20
  3. package/dist/{chunk-V5UHKC46.js → chunk-3NZCU6SD.js} +7 -7
  4. package/dist/{chunk-Y7ERTA7D.js → chunk-3P3ES4XU.js} +4 -6
  5. package/dist/chunk-3P3ES4XU.js.map +1 -0
  6. package/dist/{chunk-OZHJ3FLR.js → chunk-47YKYDOF.js} +5 -5
  7. package/dist/{chunk-WWIKAJFO.js → chunk-6JKD46OJ.js} +12 -10
  8. package/dist/{chunk-WWIKAJFO.js.map → chunk-6JKD46OJ.js.map} +1 -1
  9. package/dist/chunk-736DW4V3.js +65 -0
  10. package/dist/chunk-736DW4V3.js.map +1 -0
  11. package/dist/{chunk-IB63U6BM.js → chunk-B676GPS2.js} +34 -11
  12. package/dist/chunk-B676GPS2.js.map +1 -0
  13. package/dist/{chunk-4NTZETIL.js → chunk-BRAVLUGI.js} +2 -2
  14. package/dist/{chunk-HWHYPCCH.js → chunk-CA3JV7FX.js} +2 -2
  15. package/dist/{chunk-HWHYPCCH.js.map → chunk-CA3JV7FX.js.map} +1 -1
  16. package/dist/{chunk-ALUNME53.js → chunk-ELVDOTU7.js} +50 -66
  17. package/dist/chunk-ELVDOTU7.js.map +1 -0
  18. package/dist/{chunk-ILDVGY7K.js → chunk-GCGMXA2O.js} +13 -11
  19. package/dist/{chunk-ILDVGY7K.js.map → chunk-GCGMXA2O.js.map} +1 -1
  20. package/dist/{chunk-L3I2MVKR.js → chunk-IAR25V2E.js} +6 -6
  21. package/dist/{chunk-6UY2UQMY.js → chunk-IFPKA32J.js} +4 -4
  22. package/dist/{chunk-JTYIX6OD.js → chunk-IGHSLJUF.js} +6 -4
  23. package/dist/{chunk-JTYIX6OD.js.map → chunk-IGHSLJUF.js.map} +1 -1
  24. package/dist/{chunk-7MJVNALU.js → chunk-IKAJSA7E.js} +12 -10
  25. package/dist/{chunk-7MJVNALU.js.map → chunk-IKAJSA7E.js.map} +1 -1
  26. package/dist/{chunk-NUF2PKJO.js → chunk-J6FUAIRR.js} +4 -6
  27. package/dist/{chunk-NUF2PKJO.js.map → chunk-J6FUAIRR.js.map} +1 -1
  28. package/dist/{chunk-CNUXRXI2.js → chunk-JVBMPU5G.js} +5 -7
  29. package/dist/{chunk-CNUXRXI2.js.map → chunk-JVBMPU5G.js.map} +1 -1
  30. package/dist/{chunk-6RMEX74N.js → chunk-L4XNT3UW.js} +21 -16
  31. package/dist/chunk-L4XNT3UW.js.map +1 -0
  32. package/dist/{chunk-X2WZPGCF.js → chunk-NKN4YC5C.js} +5 -5
  33. package/dist/{chunk-P74I3WH4.js → chunk-OC3EIDCP.js} +3 -5
  34. package/dist/{chunk-P74I3WH4.js.map → chunk-OC3EIDCP.js.map} +1 -1
  35. package/dist/{chunk-E6YOODH7.js → chunk-OE36HRWG.js} +31 -5
  36. package/dist/{chunk-E6YOODH7.js.map → chunk-OE36HRWG.js.map} +1 -1
  37. package/dist/chunk-OUJDDY5L.js +189 -0
  38. package/dist/chunk-OUJDDY5L.js.map +1 -0
  39. package/dist/{chunk-6BGYHARE.js → chunk-OWVVI4VQ.js} +15 -15
  40. package/dist/{chunk-4TCU3YRD.js → chunk-OXUJ3FXU.js} +5 -1
  41. package/dist/{chunk-4TCU3YRD.js.map → chunk-OXUJ3FXU.js.map} +1 -1
  42. package/dist/{chunk-PZRAAAY2.js → chunk-PAOVPSP6.js} +10 -3
  43. package/dist/chunk-PAOVPSP6.js.map +1 -0
  44. package/dist/{chunk-TUXKOIOU.js → chunk-SPUORKD7.js} +3 -3
  45. package/dist/{chunk-UFPJBS4C.js → chunk-T4UWMVKV.js} +9 -7
  46. package/dist/{chunk-UFPJBS4C.js.map → chunk-T4UWMVKV.js.map} +1 -1
  47. package/dist/{chunk-CLOEU7RA.js → chunk-TXVC46SA.js} +8 -8
  48. package/dist/{chunk-SFGXAZ3M.js → chunk-UUARTUY2.js} +42 -9
  49. package/dist/chunk-UUARTUY2.js.map +1 -0
  50. package/dist/{chunk-ROAK2DOX.js → chunk-WMFRCSNC.js} +8 -8
  51. package/dist/{chunk-TDDN5GXR.js → chunk-WU5CZPLD.js} +5 -5
  52. package/dist/{chunk-RSBN67PA.js → chunk-WVHPGQH5.js} +4 -6
  53. package/dist/{chunk-RSBN67PA.js.map → chunk-WVHPGQH5.js.map} +1 -1
  54. package/dist/{chunk-PZSUWDF2.js → chunk-XGZ5EVMB.js} +2 -2
  55. package/dist/{chunk-MBKFZBB2.js → chunk-XXY77EZJ.js} +24 -24
  56. package/dist/{chunk-CBNXUQGM.js → chunk-YMUJZWHB.js} +10 -8
  57. package/dist/{chunk-CBNXUQGM.js.map → chunk-YMUJZWHB.js.map} +1 -1
  58. package/dist/{cli-3WZGLZDP.js → cli-XK5JZWU6.js} +51 -146
  59. package/dist/cli-XK5JZWU6.js.map +1 -0
  60. package/dist/{config-WDGMZKHU.js → config-CNK7MYUR.js} +7 -7
  61. package/dist/doctor-R7N7FUX5.js +27 -0
  62. package/dist/{edit-4UZQVFCK.js → edit-QSUEG7CL.js} +19 -19
  63. package/dist/{fund-JAPOFTUG.js → fund-JF6A76YS.js} +16 -16
  64. package/dist/index.js +1 -1
  65. package/dist/{inspect-IEV75A42.js → inspect-NFNAA4LA.js} +17 -17
  66. package/dist/{install-WXTOHDWC.js → install-YQVM3SUW.js} +20 -21
  67. package/dist/{install-WXTOHDWC.js.map → install-YQVM3SUW.js.map} +1 -1
  68. package/dist/outcome-IUSYFJTN.js +22 -0
  69. package/dist/{publish-6QNARH7E.js → publish-O2I6IAEL.js} +20 -20
  70. package/dist/{read-UAZGZ4UL.js → read-UF7QVQOU.js} +21 -21
  71. package/dist/{run-AJNCOT5R.js → run-GDZWHNWZ.js} +30 -30
  72. package/dist/search-JVOHEF3E.js +23 -0
  73. package/dist/{send-F34ZDXDZ.js → send-SI254H3R.js} +11 -10
  74. package/dist/{send-F34ZDXDZ.js.map → send-SI254H3R.js.map} +1 -1
  75. package/dist/{session-4N4ZT3AH.js → session-GJZJEXLJ.js} +14 -14
  76. package/dist/{skill-heal-XBEK272G.js → skill-heal-BPFT22XS.js} +5 -6
  77. package/dist/{skill-heal-XBEK272G.js.map → skill-heal-BPFT22XS.js.map} +1 -1
  78. package/dist/{uninstall-BTKPHPDL.js → uninstall-7ZZG6WQ5.js} +6 -7
  79. package/dist/{uninstall-BTKPHPDL.js.map → uninstall-7ZZG6WQ5.js.map} +1 -1
  80. package/dist/update-FPSBITLB.js +315 -0
  81. package/dist/update-FPSBITLB.js.map +1 -0
  82. package/dist/{wallet-UL4P2JRO.js → wallet-NS7TYWNN.js} +5 -6
  83. package/dist/{wallet-WJ6UP5OU.js → wallet-TZVD2M4I.js} +9 -9
  84. package/docs/agent-permissions.md +11 -0
  85. package/docs/command-reference.md +47 -0
  86. package/package.json +1 -1
  87. package/skills/tenjin-publish/SKILL.md +15 -2
  88. package/dist/chunk-2I4QTOLB.js +0 -11
  89. package/dist/chunk-2I4QTOLB.js.map +0 -1
  90. package/dist/chunk-6RMEX74N.js.map +0 -1
  91. package/dist/chunk-ALUNME53.js.map +0 -1
  92. package/dist/chunk-IB63U6BM.js.map +0 -1
  93. package/dist/chunk-PZRAAAY2.js.map +0 -1
  94. package/dist/chunk-SFGXAZ3M.js.map +0 -1
  95. package/dist/chunk-Y7ERTA7D.js.map +0 -1
  96. package/dist/cli-3WZGLZDP.js.map +0 -1
  97. package/dist/doctor-EKVCP7JP.js +0 -27
  98. package/dist/outcome-FYOFDOUK.js +0 -22
  99. package/dist/search-EEKTW6VK.js +0 -23
  100. /package/dist/{buy-3DTBFZ4B.js.map → buy-X4VPHFUA.js.map} +0 -0
  101. /package/dist/{chunk-V5UHKC46.js.map → chunk-3NZCU6SD.js.map} +0 -0
  102. /package/dist/{chunk-OZHJ3FLR.js.map → chunk-47YKYDOF.js.map} +0 -0
  103. /package/dist/{chunk-4NTZETIL.js.map → chunk-BRAVLUGI.js.map} +0 -0
  104. /package/dist/{chunk-L3I2MVKR.js.map → chunk-IAR25V2E.js.map} +0 -0
  105. /package/dist/{chunk-6UY2UQMY.js.map → chunk-IFPKA32J.js.map} +0 -0
  106. /package/dist/{chunk-X2WZPGCF.js.map → chunk-NKN4YC5C.js.map} +0 -0
  107. /package/dist/{chunk-6BGYHARE.js.map → chunk-OWVVI4VQ.js.map} +0 -0
  108. /package/dist/{chunk-TUXKOIOU.js.map → chunk-SPUORKD7.js.map} +0 -0
  109. /package/dist/{chunk-CLOEU7RA.js.map → chunk-TXVC46SA.js.map} +0 -0
  110. /package/dist/{chunk-ROAK2DOX.js.map → chunk-WMFRCSNC.js.map} +0 -0
  111. /package/dist/{chunk-TDDN5GXR.js.map → chunk-WU5CZPLD.js.map} +0 -0
  112. /package/dist/{chunk-PZSUWDF2.js.map → chunk-XGZ5EVMB.js.map} +0 -0
  113. /package/dist/{chunk-MBKFZBB2.js.map → chunk-XXY77EZJ.js.map} +0 -0
  114. /package/dist/{config-WDGMZKHU.js.map → config-CNK7MYUR.js.map} +0 -0
  115. /package/dist/{doctor-EKVCP7JP.js.map → doctor-R7N7FUX5.js.map} +0 -0
  116. /package/dist/{edit-4UZQVFCK.js.map → edit-QSUEG7CL.js.map} +0 -0
  117. /package/dist/{fund-JAPOFTUG.js.map → fund-JF6A76YS.js.map} +0 -0
  118. /package/dist/{inspect-IEV75A42.js.map → inspect-NFNAA4LA.js.map} +0 -0
  119. /package/dist/{outcome-FYOFDOUK.js.map → outcome-IUSYFJTN.js.map} +0 -0
  120. /package/dist/{publish-6QNARH7E.js.map → publish-O2I6IAEL.js.map} +0 -0
  121. /package/dist/{read-UAZGZ4UL.js.map → read-UF7QVQOU.js.map} +0 -0
  122. /package/dist/{run-AJNCOT5R.js.map → run-GDZWHNWZ.js.map} +0 -0
  123. /package/dist/{search-EEKTW6VK.js.map → search-JVOHEF3E.js.map} +0 -0
  124. /package/dist/{session-4N4ZT3AH.js.map → session-GJZJEXLJ.js.map} +0 -0
  125. /package/dist/{wallet-UL4P2JRO.js.map → wallet-NS7TYWNN.js.map} +0 -0
  126. /package/dist/{wallet-WJ6UP5OU.js.map → wallet-TZVD2M4I.js.map} +0 -0
@@ -0,0 +1,315 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ channelTag,
4
+ fetchDistTags,
5
+ isNewer,
6
+ resolveTarget
7
+ } from "./chunk-OUJDDY5L.js";
8
+ import {
9
+ package_default
10
+ } from "./chunk-CA3JV7FX.js";
11
+ import {
12
+ emitWriteNotice,
13
+ sanitizeForTerminal
14
+ } from "./chunk-B676GPS2.js";
15
+ import "./chunk-ELVDOTU7.js";
16
+ import "./chunk-ZQIQ55KK.js";
17
+ import "./chunk-OC3EIDCP.js";
18
+ import {
19
+ CliError
20
+ } from "./chunk-PAOVPSP6.js";
21
+ import "./chunk-ZXTAQYNA.js";
22
+
23
+ // src/commands/update.ts
24
+ import { spawn } from "child_process";
25
+ import { homedir } from "os";
26
+ import { fileURLToPath } from "url";
27
+
28
+ // src/lib/install-location.ts
29
+ import { existsSync, realpathSync, statSync } from "fs";
30
+ import { delimiter, dirname, join, sep } from "path";
31
+ var REFUSALS = [
32
+ {
33
+ test: isSourceCheckout,
34
+ error: () => new CliError("REFUSED", "tenjin-cli is running from a source checkout, not an install", {
35
+ fix: "Update the checkout instead: git pull && pnpm install"
36
+ }),
37
+ needsVersion: false,
38
+ appliesToCheck: false
39
+ },
40
+ {
41
+ test: (moduleDir) => moduleDir.split(sep).includes("_npx"),
42
+ error: (spec) => new CliError("REFUSED", "tenjin-cli is running from the npx cache, not an install", {
43
+ // Writing a global here would "succeed" and change nothing: the next
44
+ // `npx tenjin` still resolves its own cached copy.
45
+ fix: `npx fetches its own copy every time. To keep one: npm i -g ${spec}`
46
+ }),
47
+ needsVersion: true,
48
+ appliesToCheck: false
49
+ },
50
+ {
51
+ // The ONLY manager still refused. `yarn global add` is yarn-1 only, and
52
+ // berry dropped global installs altogether, so there is no one command this
53
+ // can drive across the versions a user might have. Every other manager is
54
+ // delegated to rather than refused (see MANAGERS).
55
+ test: (moduleDir) => classifyManager(moduleDir) === "yarn",
56
+ error: (spec) => new CliError(
57
+ "REFUSED",
58
+ "This tenjin-cli was installed with yarn, whose global install exists only in yarn 1",
59
+ { fix: `yarn global add ${spec}` }
60
+ ),
61
+ needsVersion: true,
62
+ appliesToCheck: false
63
+ },
64
+ {
65
+ // Scoped to npm on purpose: the prefix-vs-project-root test is written for
66
+ // npm's layout. pnpm's global store and bun's global dir both keep a
67
+ // package.json beside `node_modules`, so an unscoped test would read either
68
+ // as a project-local install and refuse the very case we now delegate.
69
+ test: (moduleDir) => classifyManager(moduleDir) === "npm" && !isGlobalTree(moduleDir),
70
+ error: (spec) => new CliError(
71
+ "REFUSED",
72
+ "This tenjin-cli is a project-local dependency, not a global install",
73
+ {
74
+ fix: `Update it where it is declared: npm i ${spec}`
75
+ }
76
+ ),
77
+ needsVersion: true,
78
+ appliesToCheck: false
79
+ }
80
+ ];
81
+ function refuse(moduleDir, opts) {
82
+ for (const entry of REFUSALS) {
83
+ if (opts.check && !entry.appliesToCheck) continue;
84
+ if (entry.needsVersion !== (opts.spec !== null)) continue;
85
+ if (entry.test(moduleDir)) throw entry.error(opts.spec ?? "", moduleDir);
86
+ }
87
+ }
88
+ function isSourceCheckout(moduleDir) {
89
+ let dir = moduleDir;
90
+ for (let i = 0; i < 8; i += 1) {
91
+ if (existsSync(join(dir, "package.json"))) return existsSync(join(dir, "src"));
92
+ const parent = dirname(dir);
93
+ if (parent === dir) break;
94
+ dir = parent;
95
+ }
96
+ return false;
97
+ }
98
+ function isGlobalTree(moduleDir) {
99
+ const segs = moduleDir.split(sep);
100
+ const i = segs.lastIndexOf("node_modules");
101
+ if (i <= 0) return false;
102
+ return !existsSync(join(segs.slice(0, i).join(sep), "package.json"));
103
+ }
104
+ function classifyManager(moduleDir) {
105
+ const segs = moduleDir.split(sep);
106
+ const pair = (a, b) => segs.includes(a) && segs.includes(b);
107
+ if (segs.includes(".pnpm") || pair("pnpm", "global")) return "pnpm";
108
+ if (segs.includes(".bun")) return "bun";
109
+ if (segs.includes(".yarn") || pair("yarn", "global")) return "yarn";
110
+ return "npm";
111
+ }
112
+ var MANAGERS = {
113
+ npm: {
114
+ bin: "npm",
115
+ scriptSuffixes: ["npm-cli.js"],
116
+ besideNode: true,
117
+ args: (spec) => ["install", "-g", "--ignore-scripts", spec],
118
+ manual: (spec) => `npm i -g ${spec}`
119
+ },
120
+ pnpm: {
121
+ bin: "pnpm",
122
+ // corepack's shim resolves to `pnpm.js`, a standalone install to `pnpm.cjs`.
123
+ scriptSuffixes: [".cjs", ".js"],
124
+ besideNode: false,
125
+ args: (spec) => ["add", "-g", "--ignore-scripts", spec],
126
+ manual: (spec) => `pnpm add -g ${spec}`
127
+ },
128
+ bun: {
129
+ bin: "bun",
130
+ scriptSuffixes: [],
131
+ besideNode: false,
132
+ // No --ignore-scripts: bun's flag surface for it is not stable across the
133
+ // versions in the wild, and an unknown flag would fail the install outright.
134
+ args: (spec) => ["add", "-g", spec],
135
+ manual: (spec) => `bun add -g ${spec}`
136
+ }
137
+ };
138
+ function resolveManagerScript(manager, execPath, env = process.env) {
139
+ const plan = MANAGERS[manager];
140
+ if (plan.scriptSuffixes.length === 0) return null;
141
+ const beside = plan.besideNode ? scriptNear(dirname(execPath), plan.bin) : null;
142
+ return beside ?? scriptOnPath(plan.bin, plan.scriptSuffixes, env);
143
+ }
144
+ function scriptNear(dir, bin) {
145
+ const candidates = [
146
+ join(dir, "node_modules", bin, "bin", `${bin}-cli.js`),
147
+ join(dir, "..", "lib", "node_modules", bin, "bin", `${bin}-cli.js`)
148
+ ];
149
+ return candidates.find(isFile) ?? null;
150
+ }
151
+ function scriptOnPath(bin, suffixes, env) {
152
+ const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter((e) => e.length > 0)] : [""];
153
+ for (const part of (env.PATH ?? "").split(delimiter)) {
154
+ if (part.length === 0) continue;
155
+ for (const ext of exts) {
156
+ if (!isFile(join(part, `${bin}${ext}`))) continue;
157
+ const real = realpathOrNull(join(part, `${bin}${ext}`));
158
+ if (real !== null && suffixes.some((suffix) => real.endsWith(suffix))) return real;
159
+ const near = scriptNear(part, bin);
160
+ if (near !== null) return near;
161
+ }
162
+ }
163
+ return null;
164
+ }
165
+ function isFile(p) {
166
+ try {
167
+ return statSync(p).isFile();
168
+ } catch {
169
+ return false;
170
+ }
171
+ }
172
+ function realpathOrNull(p) {
173
+ try {
174
+ return realpathSync(p);
175
+ } catch {
176
+ return null;
177
+ }
178
+ }
179
+
180
+ // src/commands/update.ts
181
+ var INSTALL_TIMEOUT_MS = 3e5;
182
+ function resolveManager(manager, deps) {
183
+ const script = deps.managerScript !== void 0 ? deps.managerScript : resolveManagerScript(manager, process.execPath);
184
+ return script === null ? { cmd: MANAGERS[manager].bin, prefix: [] } : { cmd: process.execPath, prefix: [script] };
185
+ }
186
+ async function runUpdate(opts, ctx, deps = {}) {
187
+ const current = deps.currentVersion ?? package_default.version;
188
+ const channel = channelTag(current);
189
+ const moduleDir = deps.moduleDir ?? fileURLToPath(new URL(".", import.meta.url));
190
+ if (channel === null) {
191
+ throw new CliError("REFUSED", `tenjin-cli reports an unrecognizable version (${current})`, {
192
+ fix: "Reinstall a published build: npm i -g tenjin-cli"
193
+ });
194
+ }
195
+ refuse(moduleDir, { check: opts.check, spec: null });
196
+ const tags = await fetchDistTags({
197
+ fetchImpl: deps.fetchImpl,
198
+ timeoutMs: ctx.flags.timeout
199
+ });
200
+ if (tags === null) {
201
+ throw new CliError("NETWORK_ERROR", "Could not read tenjin-cli dist-tags from npm", {
202
+ fix: "Check access to registry.npmjs.org and retry"
203
+ });
204
+ }
205
+ const latest = resolveTarget(current, tags);
206
+ if (latest === null) {
207
+ throw new CliError(
208
+ "RESOURCE_NOT_FOUND",
209
+ `npm has no published tenjin-cli on the ${channel} or latest tag`,
210
+ { fix: "Pick a version yourself: npm view tenjin-cli versions" }
211
+ );
212
+ }
213
+ const updateAvailable = isNewer(latest, current);
214
+ const data = (updated) => ({
215
+ current,
216
+ latest,
217
+ channel,
218
+ updateAvailable,
219
+ updated
220
+ });
221
+ if (!updateAvailable) {
222
+ return {
223
+ data: data(false),
224
+ // Not "(alpha channel)": the answer is no longer bounded by one tag, and
225
+ // naming one was how this line read as authoritative while being wrong.
226
+ humanLines: [`tenjin-cli ${current} is up to date`]
227
+ };
228
+ }
229
+ if (opts.check) {
230
+ return {
231
+ data: data(false),
232
+ humanLines: [
233
+ `tenjin-cli ${latest} is available (you have ${current}).`,
234
+ "Run tenjin update to install it."
235
+ ]
236
+ };
237
+ }
238
+ const spec = `tenjin-cli@${latest}`;
239
+ refuse(moduleDir, { check: false, spec });
240
+ const human = ctx.io.isTTY && !ctx.flags.json;
241
+ let tail = "";
242
+ const onOutput = (chunk) => {
243
+ tail = (tail + chunk).slice(-2e3);
244
+ if (human) ctx.io.stderr.write(chunk.split("\n").map(sanitizeForTerminal).join("\n"));
245
+ };
246
+ const manager = classifyManager(moduleDir);
247
+ const plan = MANAGERS[manager];
248
+ const args = plan.args(spec);
249
+ const resolved = resolveManager(manager, deps);
250
+ const manual = `Run it yourself: ${plan.manual(spec)}`;
251
+ const outcome = await (deps.spawnImpl ?? spawnCapture)(
252
+ resolved.cmd,
253
+ [...resolved.prefix, ...args],
254
+ { cwd: homedir(), timeoutMs: INSTALL_TIMEOUT_MS },
255
+ onOutput
256
+ );
257
+ if (outcome.kind === "start-failed") {
258
+ throw new CliError("UPDATE_FAILED", `Could not start ${manager}`, {
259
+ fix: manual,
260
+ cause: outcome.cause
261
+ });
262
+ }
263
+ if (outcome.kind === "timeout") {
264
+ throw new CliError(
265
+ "UPDATE_FAILED",
266
+ `${manager} did not finish in ${INSTALL_TIMEOUT_MS / 1e3}s`,
267
+ { fix: manual, details: { output: tail } }
268
+ );
269
+ }
270
+ if (outcome.code !== 0) {
271
+ throw new CliError("UPDATE_FAILED", `${manager} ${args.join(" ")} exited ${outcome.code}`, {
272
+ // EACCES on a root-owned global prefix is the common cause; the operator
273
+ // fixing that themselves beats this CLI ever escalating.
274
+ fix: manual,
275
+ details: { output: tail }
276
+ });
277
+ }
278
+ emitWriteNotice(
279
+ ctx.io,
280
+ `tenjin update: replaced the global tenjin-cli with ${latest} via ${manager}`
281
+ );
282
+ return {
283
+ data: data(true),
284
+ humanLines: [`Updated tenjin-cli ${current} -> ${latest}. New builds pick it up immediately.`]
285
+ };
286
+ }
287
+ var spawnCapture = (cmd, args, opts, onOutput) => new Promise((res) => {
288
+ let child;
289
+ try {
290
+ child = spawn(cmd, args, { stdio: ["ignore", "pipe", "pipe"], cwd: opts.cwd });
291
+ } catch (cause) {
292
+ res({ kind: "start-failed", cause });
293
+ return;
294
+ }
295
+ let timedOut = false;
296
+ const timer = setTimeout(() => {
297
+ timedOut = true;
298
+ child.kill("SIGKILL");
299
+ }, opts.timeoutMs);
300
+ child.stdout?.on("data", (chunk) => onOutput(chunk.toString()));
301
+ child.stderr?.on("data", (chunk) => onOutput(chunk.toString()));
302
+ child.on("error", (cause) => {
303
+ clearTimeout(timer);
304
+ res({ kind: "start-failed", cause });
305
+ });
306
+ child.on("close", (code) => {
307
+ clearTimeout(timer);
308
+ res(timedOut ? { kind: "timeout" } : { kind: "exit", code: code ?? 1 });
309
+ });
310
+ });
311
+ export {
312
+ runUpdate,
313
+ spawnCapture
314
+ };
315
+ //# sourceMappingURL=update-FPSBITLB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/update.ts","../src/lib/install-location.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { homedir } from 'node:os';\nimport { fileURLToPath } from 'node:url';\nimport pkg from '../../package.json';\nimport { CliError } from '../lib/errors';\nimport { MANAGERS, classifyManager, refuse, resolveManagerScript } from '../lib/install-location';\nimport type { Delegable } from '../lib/install-location';\nimport { emitWriteNotice, sanitizeForTerminal } from '../lib/output';\nimport { channelTag, fetchDistTags, isNewer, resolveTarget } from '../lib/update-check';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin update`: replace this install with the newest version npm offers it,\n * by spawning the package manager that OWNS the install rather than\n * reimplementing one. Four invariants:\n *\n * - The argv pins the EXACT version the registry just named, never the tag, so\n * the check and the install cannot disagree about what ships, and the version\n * string is certified parseable by the same `isNewer` gate the nudge trusts\n * before it goes anywhere near an argv.\n * - The owner performs the install. npm, pnpm and bun are each driven with their\n * own global-add command, because the PATH race that makes a second install\n * dangerous comes from CROSS-manager writes, not from asking the owner to do\n * what it already owns. What cannot be driven is refused instead of guessed\n * at: a source checkout updates by git, an npx run has nothing installed to\n * replace, a project-local copy updates where it is declared, and yarn's\n * global install exists only in yarn 1. See lib/install-location.\n * - The child is a binary or `node <script>`, never a shell. That is what makes\n * the pinned argv worth pinning, and it is the only form that works on win32.\n * - The manager's chatter goes to stderr (live, human mode only, sanitized) and\n * its failure into the error envelope; stdout stays the one envelope every\n * command emits.\n */\n\n/** How long the npm child gets before it is killed. npm's own retry budget runs\n * into minutes, and an agent's turn should not hang on a wedged registry. */\nconst INSTALL_TIMEOUT_MS = 300_000;\n\nexport interface UpdateOptions {\n /** Report whether a newer version exists; never install. */\n check: boolean;\n}\n\n/**\n * How the child ended. Never rejects: all three outcomes are envelope-shaped\n * facts the caller reports, not exceptions, and each is separately testable.\n */\nexport type SpawnResult =\n { kind: 'exit'; code: number } | { kind: 'start-failed'; cause: unknown } | { kind: 'timeout' };\n\nexport type UpdateSpawn = (\n cmd: string,\n args: string[],\n opts: { cwd: string; timeoutMs: number },\n onOutput: (chunk: string) => void,\n) => Promise<SpawnResult>;\n\n/** What to spawn for one manager: a command and any argv that must precede its own. */\ninterface ResolvedManager {\n cmd: string;\n prefix: readonly string[];\n}\n\n/**\n * Turn a manager into a spawnable command. A resolved script runs under THIS\n * node, keeping `shell` unset on every platform; otherwise the bare binary name\n * is used, which is correct for a native binary and fails closed on win32 for a\n * `.cmd` shim.\n */\nfunction resolveManager(manager: Delegable, deps: UpdateDeps): ResolvedManager {\n const script =\n deps.managerScript !== undefined\n ? deps.managerScript\n : resolveManagerScript(manager, process.execPath);\n return script === null\n ? { cmd: MANAGERS[manager].bin, prefix: [] }\n : { cmd: process.execPath, prefix: [script] };\n}\n\nexport interface UpdateDeps {\n fetchImpl?: typeof fetch;\n spawnImpl?: UpdateSpawn;\n /** Where this build's code lives on disk; tests point it at fixture trees. */\n moduleDir?: string;\n /** The running version; defaults to this build's. Injectable for tests. */\n currentVersion?: string;\n /** The owning manager's entry script, or null when it has none to find.\n * Injectable so the argv shape is asserted without depending on the runner. */\n managerScript?: string | null;\n}\n\ninterface UpdateData {\n current: string;\n latest: string;\n channel: 'alpha' | 'latest';\n updateAvailable: boolean;\n updated: boolean;\n}\n\nexport async function runUpdate(\n opts: UpdateOptions,\n ctx: CommandContext,\n deps: UpdateDeps = {},\n): Promise<CommandResult> {\n const current = deps.currentVersion ?? pkg.version;\n const channel = channelTag(current);\n const moduleDir = deps.moduleDir ?? fileURLToPath(new URL('.', import.meta.url));\n\n // Refused, not defaulted to a channel: a build whose version this package\n // cannot parse has no release line to compare against, and guessing one is how\n // a foreign build gets told it is up to date forever.\n if (channel === null) {\n throw new CliError('REFUSED', `tenjin-cli reports an unrecognizable version (${current})`, {\n fix: 'Reinstall a published build: npm i -g tenjin-cli',\n });\n }\n\n // First stage: everything whose fix string does not need a resolved version,\n // so it answers without the network. An offline contributor in a checkout is\n // told they are in a checkout, not told to go debug their registry access.\n refuse(moduleDir, { check: opts.check, spec: null });\n\n const tags = await fetchDistTags({\n fetchImpl: deps.fetchImpl,\n timeoutMs: ctx.flags.timeout,\n });\n if (tags === null) {\n throw new CliError('NETWORK_ERROR', 'Could not read tenjin-cli dist-tags from npm', {\n fix: 'Check access to registry.npmjs.org and retry',\n });\n }\n const latest = resolveTarget(current, tags);\n // The registry answered, it just has nothing on the tags this build follows.\n // Not a NETWORK_ERROR: nothing about the connection is wrong, and telling the\n // user to check their access sends them after a fault that is not there.\n if (latest === null) {\n throw new CliError(\n 'RESOURCE_NOT_FOUND',\n `npm has no published tenjin-cli on the ${channel} or latest tag`,\n { fix: 'Pick a version yourself: npm view tenjin-cli versions' },\n );\n }\n\n const updateAvailable = isNewer(latest, current);\n const data = (updated: boolean): UpdateData => ({\n current,\n latest,\n channel,\n updateAvailable,\n updated,\n });\n\n if (!updateAvailable) {\n return {\n data: data(false),\n // Not \"(alpha channel)\": the answer is no longer bounded by one tag, and\n // naming one was how this line read as authoritative while being wrong.\n humanLines: [`tenjin-cli ${current} is up to date`],\n };\n }\n if (opts.check) {\n return {\n data: data(false),\n humanLines: [\n `tenjin-cli ${latest} is available (you have ${current}).`,\n 'Run tenjin update to install it.',\n ],\n };\n }\n\n // `latest` is argv-safe here: isNewer returned true, so it matched VERSION_RE.\n const spec = `tenjin-cli@${latest}`;\n\n // Second stage: the entries whose fix strings name the version just resolved.\n // Reached only on the install path, since --check has already returned.\n refuse(moduleDir, { check: false, spec });\n\n // Live chatter is a human courtesy only; the tail rides in the error envelope\n // so a piped failure is still diagnosable. Sanitized per line, because npm\n // relays publisher-controlled text (deprecation notices) and a line break is\n // the one control character this stream must keep.\n const human = ctx.io.isTTY && !ctx.flags.json;\n let tail = '';\n const onOutput = (chunk: string): void => {\n tail = (tail + chunk).slice(-2000);\n if (human) ctx.io.stderr.write(chunk.split('\\n').map(sanitizeForTerminal).join('\\n'));\n };\n\n // Whoever owns the install performs it. The PATH-race objection that used to\n // make this a refusal only applies to CROSS-manager writes; invoking the owner\n // is exactly what the refusal used to tell the user to type by hand.\n //\n // The cast is sound only because `refuse` ran directly above and yarn is one\n // of its entries, so the one non-delegable manager has already thrown. Move\n // this line above that call and it becomes a lie.\n const manager = classifyManager(moduleDir) as Delegable;\n const plan = MANAGERS[manager];\n // --ignore-scripts where the manager has it (tenjin-cli has no runtime\n // dependencies and no registry install runs its own `prepare`), and cwd is the\n // home directory so the child never reads a project's config by accident.\n const args = plan.args(spec);\n const resolved = resolveManager(manager, deps);\n const manual = `Run it yourself: ${plan.manual(spec)}`;\n\n const outcome = await (deps.spawnImpl ?? spawnCapture)(\n resolved.cmd,\n [...resolved.prefix, ...args],\n { cwd: homedir(), timeoutMs: INSTALL_TIMEOUT_MS },\n onOutput,\n );\n if (outcome.kind === 'start-failed') {\n throw new CliError('UPDATE_FAILED', `Could not start ${manager}`, {\n fix: manual,\n cause: outcome.cause,\n });\n }\n if (outcome.kind === 'timeout') {\n throw new CliError(\n 'UPDATE_FAILED',\n `${manager} did not finish in ${INSTALL_TIMEOUT_MS / 1000}s`,\n { fix: manual, details: { output: tail } },\n );\n }\n if (outcome.code !== 0) {\n throw new CliError('UPDATE_FAILED', `${manager} ${args.join(' ')} exited ${outcome.code}`, {\n // EACCES on a root-owned global prefix is the common cause; the operator\n // fixing that themselves beats this CLI ever escalating.\n fix: manual,\n details: { output: tail },\n });\n }\n\n emitWriteNotice(\n ctx.io,\n `tenjin update: replaced the global tenjin-cli with ${latest} via ${manager}`,\n );\n return {\n data: data(true),\n humanLines: [`Updated tenjin-cli ${current} -> ${latest}. New builds pick it up immediately.`],\n };\n}\n\n/**\n * Default spawn: merged stdout+stderr chunks out, an outcome back, no shell.\n * Bounded by its own timer rather than Node's `timeout` option so that a kill\n * this code ordered is distinguishable from any other death by signal.\n */\nexport const spawnCapture: UpdateSpawn = (cmd, args, opts, onOutput) =>\n new Promise((res) => {\n let child;\n try {\n child = spawn(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'], cwd: opts.cwd });\n } catch (cause) {\n // An argv or option Node rejects outright throws here; ENOENT arrives on\n // the 'error' event instead. Both mean the same thing to the caller.\n res({ kind: 'start-failed', cause });\n return;\n }\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill('SIGKILL');\n }, opts.timeoutMs);\n child.stdout?.on('data', (chunk: Buffer) => onOutput(chunk.toString()));\n child.stderr?.on('data', (chunk: Buffer) => onOutput(chunk.toString()));\n child.on('error', (cause) => {\n clearTimeout(timer);\n res({ kind: 'start-failed', cause });\n });\n child.on('close', (code) => {\n clearTimeout(timer);\n res(timedOut ? { kind: 'timeout' } : { kind: 'exit', code: code ?? 1 });\n });\n });\n","import { existsSync, realpathSync, statSync } from 'node:fs';\nimport { delimiter, dirname, join, sep } from 'node:path';\nimport { CliError } from './errors';\n\n/**\n * WHERE this build is installed, and what that implies about replacing it.\n *\n * Its own module because it answers a different question from the command that\n * uses it: \"what IS this install\" rather than \"how do I replace it\". The\n * refusal set is the load-bearing part, and it got re-cut in three consecutive\n * reviews while it was expressed positionally inside the command body.\n */\n\n/** Managers a global install can be handed back to. yarn is deliberately absent\n * from the delegable set: see the yarn entry in REFUSALS. */\nexport type Delegable = 'npm' | 'pnpm' | 'bun';\n\n/**\n * One reason `npm install -g` would not actually replace THIS build.\n *\n * Each entry carries the three properties that decide WHEN it is evaluated,\n * because expressing them by where the line sat is what made this set get\n * re-cut three times: a missing entry, then a copy on the wrong side of the\n * fetch, then a duplicate that could not run. Declaring them means adding a\n * refusal is a matter of answering three questions, not of guessing a position.\n */\ninterface Refusal {\n /** Does this install location refuse? Pure filesystem, never the network. */\n test: (moduleDir: string) => boolean;\n error: (spec: string, moduleDir: string) => CliError;\n /**\n * Does the fix string name the version the registry just resolved? This is\n * also what decides whether the entry may run BEFORE the fetch: one that does\n * not need a version is evaluated first, so an offline user in a checkout is\n * told they are in a checkout rather than told to go debug their network.\n */\n needsVersion: boolean;\n /**\n * Does it apply to `--check`? Everything here is a reason not to WRITE, and\n * `--check` only reports, so today nothing does. An entry that ever answers\n * yes is one whose test says the REPORT would be wrong, not the install.\n */\n appliesToCheck: boolean;\n}\n\n/**\n * Ordered most-specific first: a checkout and an npx cache are recognizable\n * before any question of which manager or which tree, and the manager entry\n * precedes the global/local one because a pnpm or bun store has its own layout\n * that `isGlobalTree` is not written for.\n */\nexport const REFUSALS: readonly Refusal[] = [\n {\n test: isSourceCheckout,\n error: () =>\n new CliError('REFUSED', 'tenjin-cli is running from a source checkout, not an install', {\n fix: 'Update the checkout instead: git pull && pnpm install',\n }),\n needsVersion: false,\n appliesToCheck: false,\n },\n {\n test: (moduleDir) => moduleDir.split(sep).includes('_npx'),\n error: (spec) =>\n new CliError('REFUSED', 'tenjin-cli is running from the npx cache, not an install', {\n // Writing a global here would \"succeed\" and change nothing: the next\n // `npx tenjin` still resolves its own cached copy.\n fix: `npx fetches its own copy every time. To keep one: npm i -g ${spec}`,\n }),\n needsVersion: true,\n appliesToCheck: false,\n },\n {\n // The ONLY manager still refused. `yarn global add` is yarn-1 only, and\n // berry dropped global installs altogether, so there is no one command this\n // can drive across the versions a user might have. Every other manager is\n // delegated to rather than refused (see MANAGERS).\n test: (moduleDir) => classifyManager(moduleDir) === 'yarn',\n error: (spec) =>\n new CliError(\n 'REFUSED',\n 'This tenjin-cli was installed with yarn, whose global install exists only in yarn 1',\n { fix: `yarn global add ${spec}` },\n ),\n needsVersion: true,\n appliesToCheck: false,\n },\n {\n // Scoped to npm on purpose: the prefix-vs-project-root test is written for\n // npm's layout. pnpm's global store and bun's global dir both keep a\n // package.json beside `node_modules`, so an unscoped test would read either\n // as a project-local install and refuse the very case we now delegate.\n test: (moduleDir) => classifyManager(moduleDir) === 'npm' && !isGlobalTree(moduleDir),\n error: (spec) =>\n new CliError(\n 'REFUSED',\n 'This tenjin-cli is a project-local dependency, not a global install',\n {\n fix: `Update it where it is declared: npm i ${spec}`,\n },\n ),\n needsVersion: true,\n appliesToCheck: false,\n },\n];\n\n/**\n * Evaluate the refusal set, once per stage. `spec` is null before the registry\n * has been asked and the resolved `tenjin-cli@<version>` after, which is what\n * selects the eligible entries: every entry runs in exactly one stage, so no\n * refusal can be reached twice or, as in round three, be written twice and\n * reached once.\n */\nexport function refuse(moduleDir: string, opts: { check: boolean; spec: string | null }): void {\n for (const entry of REFUSALS) {\n if (opts.check && !entry.appliesToCheck) continue;\n if (entry.needsVersion !== (opts.spec !== null)) continue;\n if (entry.test(moduleDir)) throw entry.error(opts.spec ?? '', moduleDir);\n }\n}\n\n/**\n * The published package ships `dist/`, `docs/`, and `skills/` with no `src/`\n * beside them (the `files` array), so a `src/` next to the nearest package.json\n * means a checkout, whose version number says nothing about what HEAD holds.\n * Same test skill-heal uses to keep its hands off working-tree skills.\n */\nexport function isSourceCheckout(moduleDir: string): boolean {\n let dir = moduleDir;\n for (let i = 0; i < 8; i += 1) {\n if (existsSync(join(dir, 'package.json'))) return existsSync(join(dir, 'src'));\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return false;\n}\n\n/**\n * Is this a GLOBAL npm tree? A global install sits under a prefix directory that\n * is not itself a package (`<prefix>/lib/node_modules/tenjin-cli` on POSIX,\n * `<prefix>\\node_modules\\tenjin-cli` on win32), while a project-local one sits\n * under the project root, which by definition has a package.json. That parent is\n * the whole test, which is why it holds for homebrew, nvm, volta and a\n * user-set `npm config prefix` alike without this code enumerating any of them.\n */\nexport function isGlobalTree(moduleDir: string): boolean {\n const segs = moduleDir.split(sep);\n const i = segs.lastIndexOf('node_modules');\n if (i <= 0) return false;\n return !existsSync(join(segs.slice(0, i).join(sep), 'package.json'));\n}\n\n/**\n * Which package manager owns this install, read off the on-disk path. Node\n * resolved the bin symlink before loading us, so the segments name the real\n * store: pnpm's virtual store keeps a literal `.pnpm` segment (or\n * `pnpm/global` for older layouts), bun installs under `.bun`, yarn under\n * `.yarn` or `yarn/global`. Everything else is treated as npm's tree; that\n * covers nvm and volta, both of which route `npm i -g` correctly.\n */\nexport function classifyManager(moduleDir: string): Delegable | 'yarn' {\n const segs = moduleDir.split(sep);\n const pair = (a: string, b: string): boolean => segs.includes(a) && segs.includes(b);\n if (segs.includes('.pnpm') || pair('pnpm', 'global')) return 'pnpm';\n if (segs.includes('.bun')) return 'bun';\n if (segs.includes('.yarn') || pair('yarn', 'global')) return 'yarn';\n return 'npm';\n}\n\n/**\n * How to perform a global install with each manager we delegate to.\n *\n * `scriptSuffixes` is what a PATH shim may resolve to that Node can run\n * directly, which is how win32 is served without a shell: npm and pnpm ship as\n * JS, so the child becomes `node <script>`. An empty list means the binary is\n * native (bun), where spawning it by name already works on every platform.\n */\nexport const MANAGERS: Record<\n Delegable,\n {\n bin: string;\n scriptSuffixes: readonly string[];\n /** Ships beside the running node, as npm does inside the Node distribution. */\n besideNode: boolean;\n args: (spec: string) => string[];\n manual: (spec: string) => string;\n }\n> = {\n npm: {\n bin: 'npm',\n scriptSuffixes: ['npm-cli.js'],\n besideNode: true,\n args: (spec) => ['install', '-g', '--ignore-scripts', spec],\n manual: (spec) => `npm i -g ${spec}`,\n },\n pnpm: {\n bin: 'pnpm',\n // corepack's shim resolves to `pnpm.js`, a standalone install to `pnpm.cjs`.\n scriptSuffixes: ['.cjs', '.js'],\n besideNode: false,\n args: (spec) => ['add', '-g', '--ignore-scripts', spec],\n manual: (spec) => `pnpm add -g ${spec}`,\n },\n bun: {\n bin: 'bun',\n scriptSuffixes: [],\n besideNode: false,\n // No --ignore-scripts: bun's flag surface for it is not stable across the\n // versions in the wild, and an unknown flag would fail the install outright.\n args: (spec) => ['add', '-g', spec],\n manual: (spec) => `bun add -g ${spec}`,\n },\n};\n\n/**\n * npm's own entry script, so the child can be `node npm-cli.js` rather than the\n * `npm` shim.\n *\n * On win32 the shim is `npm.cmd`, which Node refuses to spawn without\n * `shell: true`, and `shell: true` is exactly what this command must not do —\n * it would hand back the argv safety the pinned version buys.\n *\n * Deliberately NOT \"npm ships inside the Node distribution\". That is a property\n * of the installer, not of Node: Homebrew's plain `node` formula keeps only\n * corepack in the keg and puts npm at the brew prefix, so a probe relative to\n * `process.execPath` alone returns null on one of the most common macOS setups.\n * So the layout is searched, not assumed — beside the running binary first\n * (official tarball and installer, nvm, volta, versioned brew kegs), then off\n * PATH, where on POSIX the `npm` shim is itself a symlink to `npm-cli.js` and on\n * win32 `npm.cmd` has `node_modules` beside it. Still null when npm cannot be\n * found at all; the caller then falls back to the bare shim, which works\n * everywhere but win32 and fails closed there into UPDATE_FAILED carrying the\n * manual command.\n */\nexport function resolveNpmCli(\n execPath: string,\n env: NodeJS.ProcessEnv = process.env,\n): string | null {\n return resolveManagerScript('npm', execPath, env);\n}\n\n/**\n * The JS entry script for `manager`, or null when it has none to find (a native\n * binary, or a shim this cannot see through). Null means \"spawn the bare name\",\n * which works everywhere but win32 and fails closed there.\n */\nexport function resolveManagerScript(\n manager: Delegable,\n execPath: string,\n env: NodeJS.ProcessEnv = process.env,\n): string | null {\n const plan = MANAGERS[manager];\n if (plan.scriptSuffixes.length === 0) return null;\n const beside = plan.besideNode ? scriptNear(dirname(execPath), plan.bin) : null;\n return beside ?? scriptOnPath(plan.bin, plan.scriptSuffixes, env);\n}\n\n/** A manager's script relative to a directory holding `node` or its own shim. */\nfunction scriptNear(dir: string, bin: string): string | null {\n const candidates = [\n join(dir, 'node_modules', bin, 'bin', `${bin}-cli.js`),\n join(dir, '..', 'lib', 'node_modules', bin, 'bin', `${bin}-cli.js`),\n ];\n return candidates.find(isFile) ?? null;\n}\n\n/**\n * Walk PATH for the manager's shim and turn it into its script. Probes the\n * PATHEXT extensions on win32 for the same reason `onPath` in skill-wiring.ts\n * does: the real file there is `npm.cmd`, never a bare `npm`.\n */\nfunction scriptOnPath(\n bin: string,\n suffixes: readonly string[],\n env: NodeJS.ProcessEnv,\n): string | null {\n const exts =\n process.platform === 'win32'\n ? ['', ...(env.PATHEXT ?? '.EXE;.CMD;.BAT;.COM').split(';').filter((e) => e.length > 0)]\n : [''];\n for (const part of (env.PATH ?? '').split(delimiter)) {\n if (part.length === 0) continue;\n for (const ext of exts) {\n if (!isFile(join(part, `${bin}${ext}`))) continue;\n // POSIX package managers link the shim straight at the script, which is\n // what makes this layout-independent rather than a longer guess list.\n //\n // The endsWith is a CORRECTNESS check, not a security guard: it asks \"did\n // this symlink land on npm's script or on something else\", and a shim\n // pointed elsewhere returns null, which falls back to spawning that same\n // retargeted shim anyway. PATH poisoning is out of scope by construction —\n // an attacker ahead of npm on PATH owns every tool the user runs, and the\n // pre-existing fallback `spawn('npm', ...)` resolved through the same PATH.\n const real = realpathOrNull(join(part, `${bin}${ext}`));\n if (real !== null && suffixes.some((suffix) => real.endsWith(suffix))) return real;\n const near = scriptNear(part, bin);\n if (near !== null) return near;\n }\n }\n return null;\n}\n\nfunction isFile(p: string): boolean {\n try {\n return statSync(p).isFile();\n } catch {\n return false;\n }\n}\n\nfunction realpathOrNull(p: string): string | null {\n try {\n return realpathSync(p);\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,qBAAqB;;;ACF9B,SAAS,YAAY,cAAc,gBAAgB;AACnD,SAAS,WAAW,SAAS,MAAM,WAAW;AAkDvC,IAAM,WAA+B;AAAA,EAC1C;AAAA,IACE,MAAM;AAAA,IACN,OAAO,MACL,IAAI,SAAS,WAAW,gEAAgE;AAAA,MACtF,KAAK;AAAA,IACP,CAAC;AAAA,IACH,cAAc;AAAA,IACd,gBAAgB;AAAA,EAClB;AAAA,EACA;AAAA,IACE,MAAM,CAAC,cAAc,UAAU,MAAM,GAAG,EAAE,SAAS,MAAM;AAAA,IACzD,OAAO,CAAC,SACN,IAAI,SAAS,WAAW,4DAA4D;AAAA;AAAA;AAAA,MAGlF,KAAK,8DAA8D,IAAI;AAAA,IACzE,CAAC;AAAA,IACH,cAAc;AAAA,IACd,gBAAgB;AAAA,EAClB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKE,MAAM,CAAC,cAAc,gBAAgB,SAAS,MAAM;AAAA,IACpD,OAAO,CAAC,SACN,IAAI;AAAA,MACF;AAAA,MACA;AAAA,MACA,EAAE,KAAK,mBAAmB,IAAI,GAAG;AAAA,IACnC;AAAA,IACF,cAAc;AAAA,IACd,gBAAgB;AAAA,EAClB;AAAA,E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AAA,IACJ,sDAAsD,MAAM,QAAQ,OAAO;AAAA,EAC7E;AACA,SAAO;AAAA,IACL,MAAM,KAAK,IAAI;AAAA,IACf,YAAY,CAAC,sBAAsB,OAAO,OAAO,MAAM,sCAAsC;AAAA,EAC/F;AACF;AAOO,IAAM,eAA4B,CAAC,KAAK,MAAM,MAAM,aACzD,IAAI,QAAQ,CAAC,QAAQ;AACnB,MAAI;AACJ,MAAI;AACF,YAAQ,MAAM,KAAK,MAAM,EAAE,OAAO,CAAC,UAAU,QAAQ,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC;AAAA,EAC/E,SAAS,OAAO;AAGd,QAAI,EAAE,MAAM,gBAAgB,MAAM,CAAC;AACnC;AAAA,EACF;AACA,MAAI,WAAW;AACf,QAAM,QAAQ,WAAW,MAAM;AAC7B,eAAW;AACX,UAAM,KAAK,SAAS;AAAA,EACtB,GAAG,KAAK,SAAS;AACjB,QAAM,QAAQ,GAAG,QAAQ,CAAC,UAAkB,SAAS,MAAM,SAAS,CAAC,CAAC;AACtE,QAAM,QAAQ,GAAG,QAAQ,CAAC,UAAkB,SAAS,MAAM,SAAS,CAAC,CAAC;AACtE,QAAM,GAAG,SAAS,CAAC,UAAU;AAC3B,iBAAa,KAAK;AAClB,QAAI,EAAE,MAAM,gBAAgB,MAAM,CAAC;AAAA,EACrC,CAAC;AACD,QAAM,GAAG,SAAS,CAAC,SAAS;AAC1B,iBAAa,KAAK;AAClB,QAAI,WAAW,EAAE,MAAM,UAAU,IAAI,EAAE,MAAM,QAAQ,MAAM,QAAQ,EAAE,CAAC;AAAA,EACxE,CAAC;AACH,CAAC;","names":[]}
@@ -11,13 +11,12 @@ import {
11
11
  restoreParkedWallet,
12
12
  verifyAndPreserveOutgoingWallet,
13
13
  verifyLocalWallet
14
- } from "./chunk-CNUXRXI2.js";
15
- import "./chunk-Y7ERTA7D.js";
16
- import "./chunk-IB63U6BM.js";
14
+ } from "./chunk-JVBMPU5G.js";
15
+ import "./chunk-3P3ES4XU.js";
16
+ import "./chunk-B676GPS2.js";
17
17
  import "./chunk-FKSAUOJU.js";
18
18
  import "./chunk-ZQIQ55KK.js";
19
- import "./chunk-2I4QTOLB.js";
20
- import "./chunk-PZRAAAY2.js";
19
+ import "./chunk-PAOVPSP6.js";
21
20
  import "./chunk-M2O56UK7.js";
22
21
  import "./chunk-UHTVXQ2O.js";
23
22
  import "./chunk-W6R3HAAG.js";
@@ -39,4 +38,4 @@ export {
39
38
  verifyAndPreserveOutgoingWallet,
40
39
  verifyLocalWallet
41
40
  };
42
- //# sourceMappingURL=wallet-UL4P2JRO.js.map
41
+ //# sourceMappingURL=wallet-NS7TYWNN.js.map
@@ -3,17 +3,17 @@ import {
3
3
  runWalletBalance,
4
4
  runWalletCreate,
5
5
  runWalletShow
6
- } from "./chunk-UFPJBS4C.js";
6
+ } from "./chunk-T4UWMVKV.js";
7
7
  import "./chunk-MJZZTKCC.js";
8
- import "./chunk-CNUXRXI2.js";
9
- import "./chunk-Y7ERTA7D.js";
10
- import "./chunk-IB63U6BM.js";
8
+ import "./chunk-JVBMPU5G.js";
9
+ import "./chunk-3P3ES4XU.js";
10
+ import "./chunk-B676GPS2.js";
11
11
  import "./chunk-FKSAUOJU.js";
12
- import "./chunk-ALUNME53.js";
12
+ import "./chunk-736DW4V3.js";
13
+ import "./chunk-ELVDOTU7.js";
13
14
  import "./chunk-ZQIQ55KK.js";
14
- import "./chunk-P74I3WH4.js";
15
- import "./chunk-2I4QTOLB.js";
16
- import "./chunk-PZRAAAY2.js";
15
+ import "./chunk-OC3EIDCP.js";
16
+ import "./chunk-PAOVPSP6.js";
17
17
  import "./chunk-7FK2UN2T.js";
18
18
  import "./chunk-M2O56UK7.js";
19
19
  import "./chunk-UHTVXQ2O.js";
@@ -29,4 +29,4 @@ export {
29
29
  runWalletCreate,
30
30
  runWalletShow
31
31
  };
32
- //# sourceMappingURL=wallet-WJ6UP5OU.js.map
32
+ //# sourceMappingURL=wallet-TZVD2M4I.js.map
@@ -193,10 +193,21 @@ Deliberately **never** recommended, because each is a human decision:
193
193
  | `tenjin config set` | It can widen the agent's own spend policy. |
194
194
  | `tenjin install` | Writes into harness config and skills directories. |
195
195
  | `tenjin mcp` | It re-exposes every command core, so clearing it clears everything. |
196
+ | `tenjin update` | It replaces the tenjin binary the agent then runs. See below. |
196
197
 
197
198
  For the same reason, prefer the narrow rules above over a broad `Bash(tenjin:*)`,
198
199
  `Bash(tenjin wallet:*)`, or `Bash(tenjin config:*)`, which would swallow them.
199
200
 
201
+ ### `tenjin update`, a human decision
202
+
203
+ `tenjin update` replaces the globally installed `tenjin` with whatever npm serves
204
+ next, which is the binary the agent goes on to run for the rest of the session and
205
+ every session after it. Which build an agent executes is an operator decision, so
206
+ no recommended rule pre-clears it. `tenjin update --check` only reports, but a
207
+ prefix rule pins the **verb**, not the flags, so clearing the check would clear
208
+ the install with it. Nothing stops you adding the rule yourself; it stays off the
209
+ recommended set.
210
+
200
211
  ### `tenjin fund`, free on both surfaces
201
212
 
202
213
  Free by owner decision (2026-08-12), because on either surface the command just
@@ -40,6 +40,53 @@ It never touches `~/.tenjin`, so your wallet, config, library, search history, a
40
40
 
41
41
  Checks the local environment, API reachability, API contracts, skill wiring, session state, wallet state, and balance. Human output includes `fix:` lines where useful; `--json` includes the permission recommendation under `permissions`.
42
42
 
43
+ ### `tenjin update`
44
+
45
+ Installs the newest version npm offers this build, pinned to the exact version the registry names.
46
+
47
+ | Flag | Effect |
48
+ | --------- | --------------------------------------------------------- |
49
+ | `--check` | Report whether a newer version exists without installing. |
50
+
51
+ The manager that owns the install performs it: npm, pnpm, and bun are each driven with their own global-add command. What cannot be driven is refused with the instruction that is correct there, rather than writing a global you never had: a source checkout updates by git, an npx run has nothing installed to replace, a project-local copy updates where it is declared, and yarn is refused because `yarn global add` exists only in yarn 1. `--check` answers from all of them.
52
+
53
+ Deliberately not in the recommended permission allowlist: it replaces the binary your agent then runs. See [agent-permissions.md](./agent-permissions.md).
54
+
55
+ ### The update check
56
+
57
+ Once a day, at most, the CLI asks npm whether a newer version exists. It never installs on its own; it reports, and you or your agent decide.
58
+
59
+ | Surface | Who sees it |
60
+ | -------------------------------------- | ---------------------------------------------------------------------------------- |
61
+ | One dim stderr line | A human at a TTY. |
62
+ | `updateAvailable` on the JSON envelope | Anything reading the envelope, including an agent. Carries `current` and `latest`. |
63
+ | A line on hook output | A harness reading `additionalContext`. |
64
+
65
+ ```jsonc
66
+ {
67
+ "schemaVersion": 1,
68
+ "command": "search",
69
+ "ok": true,
70
+ "data": {},
71
+ "updateAvailable": { "current": "0.1.0-alpha.6", "latest": "0.1.0-alpha.7" },
72
+ }
73
+ ```
74
+
75
+ An agent that sees the field can run `tenjin update` itself, at a moment it chooses. That is deliberate: this CLI starts a fresh process per invocation, so there is no deferred-activation window to hide a binary swap in. "Next start" is "mid-session" for whatever is driving it.
76
+
77
+ `update.mode` controls the reporting:
78
+
79
+ | Mode | Behavior |
80
+ | ------- | ------------------------------------------------ |
81
+ | `nudge` | Default. All three surfaces above. |
82
+ | `off` | None of them; the CLI stops asking npm entirely. |
83
+
84
+ ```bash
85
+ tenjin config set update.mode off
86
+ ```
87
+
88
+ The field is read from the check's cache, never fetched while your command runs, so it costs no request and no delay.
89
+
43
90
  ## Search and read
44
91
 
45
92
  ### `tenjin search "<question>"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tenjin-cli",
3
- "version": "0.1.0-alpha.12",
3
+ "version": "0.1.0-alpha.13",
4
4
  "mcpName": "blog.tenjin/tenjin",
5
5
  "type": "module",
6
6
  "description": "Tenjin agent CLI for the x402 knowledge marketplace.",
@@ -3,8 +3,9 @@ name: tenjin-publish
3
3
  description: >-
4
4
  Publish, update, or maintain your own reusable answers on the Tenjin
5
5
  knowledge marketplace so you earn on every future buyer. Three routes in:
6
- the user asks to publish, update, or manage Tenjin content, or asks about
7
- their sales or drafts; the tenjin-search after-a-MISS flow has a finished,
6
+ the user asks to publish, update, or manage Tenjin content, asks whether
7
+ recent work holds anything worth selling, or asks about their sales or
8
+ drafts; the tenjin-search after-a-MISS flow has a finished,
8
9
  reusable, public, rights-clean finding to publish under your publish.mode;
9
10
  or you just finished something worth selling unprompted — substantial public
10
11
  research (a multi-source synthesis, a tested comparison, a runbook) or an
@@ -49,6 +50,18 @@ This skill's reachability is not a safety layer; the description above is the
49
50
  whole trigger boundary.
50
51
  Publishing is free and an incomplete card still publishes as a browse-only piece.
51
52
 
53
+ ## The harvest ask
54
+
55
+ "Anything from our recent work worth publishing?" routes here too. Sweep what
56
+ you can actually see: this conversation's finished work, plus anything the
57
+ user names. Never go digging through transcripts or session archives the user
58
+ did not hand you; the sweep reads what is in front of you. Grade each
59
+ candidate against the sell rubric below, then offer the survivors ONCE, as one
60
+ batch with honest prices — never one at a time across the session. A no on a
61
+ candidate is final: it is not raised again in this session or a later one, and
62
+ nothing is saved anywhere to re-ask. Zero candidates is a fine answer; say so
63
+ in one line and stop.
64
+
52
65
  ## What makes a piece sell
53
66
 
54
67
  Not a permission gate: publishing is never blocked on these. They are what makes
@@ -1,11 +0,0 @@
1
- import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
-
3
- // src/lib/errno.ts
4
- function hasCode(err, code) {
5
- return typeof err === "object" && err !== null && "code" in err && err.code === code;
6
- }
7
-
8
- export {
9
- hasCode
10
- };
11
- //# sourceMappingURL=chunk-2I4QTOLB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/errno.ts"],"sourcesContent":["/**\n * True when `err` is a Node system error carrying the given `code` (ENOENT,\n * EEXIST, …). One definition so the fs-error checks scattered across the wallet\n * store, config loader, and session cache stay identical.\n */\nexport function hasCode(err: unknown, code: string): boolean {\n return (\n typeof err === 'object' &&\n err !== null &&\n 'code' in err &&\n (err as { code?: unknown }).code === code\n );\n}\n"],"mappings":";;;AAKO,SAAS,QAAQ,KAAc,MAAuB;AAC3D,SACE,OAAO,QAAQ,YACf,QAAQ,QACR,UAAU,OACT,IAA2B,SAAS;AAEzC;","names":[]}