tenjin-cli 0.1.0-alpha.27 → 0.1.0-alpha.28
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.
- package/README.md +6 -17
- package/dist/alive-3J3CHOQP.js +21 -0
- package/dist/{chunk-SKQQOEWH.js → chunk-3QJREVMX.js} +5 -7
- package/dist/{chunk-SKQQOEWH.js.map → chunk-3QJREVMX.js.map} +1 -1
- package/dist/{chunk-BOAI23CX.js → chunk-6KA4HFX5.js} +21 -15
- package/dist/chunk-6KA4HFX5.js.map +1 -0
- package/dist/chunk-6W5GYG3W.js +128 -0
- package/dist/chunk-6W5GYG3W.js.map +1 -0
- package/dist/{chunk-4L7KMA7P.js → chunk-7H3RN4WJ.js} +7 -9
- package/dist/{chunk-4L7KMA7P.js.map → chunk-7H3RN4WJ.js.map} +1 -1
- package/dist/{chunk-O7CUHHYU.js → chunk-7R37M6WV.js} +7 -9
- package/dist/{chunk-O7CUHHYU.js.map → chunk-7R37M6WV.js.map} +1 -1
- package/dist/{chunk-LAIZ2AQA.js → chunk-A5H3E5QA.js} +2 -2
- package/dist/{update-RJDA5ZY3.js → chunk-AO54FM4H.js} +147 -26
- package/dist/chunk-AO54FM4H.js.map +1 -0
- package/dist/{chunk-VNNXAYJE.js → chunk-BRHREK7E.js} +2 -2
- package/dist/{chunk-YQOQ6XEI.js → chunk-DJYAPACT.js} +35 -33
- package/dist/chunk-DJYAPACT.js.map +1 -0
- package/dist/{chunk-GU4GGKYP.js → chunk-DYSDQE7S.js} +36 -2
- package/dist/chunk-DYSDQE7S.js.map +1 -0
- package/dist/{chunk-YKM2ZTA2.js → chunk-FQ6DHINU.js} +36 -38
- package/dist/{chunk-YKM2ZTA2.js.map → chunk-FQ6DHINU.js.map} +1 -1
- package/dist/{chunk-6ZSGER3A.js → chunk-FZTSGQVK.js} +2 -2
- package/dist/{chunk-AWKQSKUL.js → chunk-KAMRYUK2.js} +2 -2
- package/dist/{chunk-2TYQD22Q.js → chunk-MNTQMZJB.js} +6 -8
- package/dist/{chunk-2TYQD22Q.js.map → chunk-MNTQMZJB.js.map} +1 -1
- package/dist/{chunk-VIOUZW7Z.js → chunk-QTND6XWJ.js} +159 -35
- package/dist/chunk-QTND6XWJ.js.map +1 -0
- package/dist/chunk-RLPLYUME.js +115 -0
- package/dist/{chunk-HC3QEZKT.js.map → chunk-RLPLYUME.js.map} +1 -1
- package/dist/{chunk-5NEHH2E5.js → chunk-UEOWNDQG.js} +8 -10
- package/dist/{chunk-5NEHH2E5.js.map → chunk-UEOWNDQG.js.map} +1 -1
- package/dist/{chunk-OHZYNZSD.js → chunk-UOW5JXYY.js} +5 -7
- package/dist/{chunk-OHZYNZSD.js.map → chunk-UOW5JXYY.js.map} +1 -1
- package/dist/chunk-VSUHGRVB.js +1455 -0
- package/dist/chunk-VSUHGRVB.js.map +1 -0
- package/dist/{chunk-64SE3QC5.js → chunk-W6JX4LYF.js} +12 -4
- package/dist/chunk-W6JX4LYF.js.map +1 -0
- package/dist/{chunk-5FGO6TYT.js → chunk-XVTD7UWR.js} +3 -5
- package/dist/{chunk-5FGO6TYT.js.map → chunk-XVTD7UWR.js.map} +1 -1
- package/dist/{chunk-X7I343ZY.js → chunk-YFJJYHVG.js} +2 -2
- package/dist/{chunk-XVYATBKD.js → chunk-ZG6ZZLO7.js} +898 -521
- package/dist/chunk-ZG6ZZLO7.js.map +1 -0
- package/dist/{chunk-DATCR7AU.js → chunk-ZO3X5NPG.js} +4 -6
- package/dist/{chunk-DATCR7AU.js.map → chunk-ZO3X5NPG.js.map} +1 -1
- package/dist/{chunk-VXIBZ6W5.js → chunk-ZP5PV3JB.js} +3 -3
- package/dist/{chunk-G4AM2SOL.js → chunk-ZP7AHN7Z.js} +4 -6
- package/dist/{chunk-G4AM2SOL.js.map → chunk-ZP7AHN7Z.js.map} +1 -1
- package/dist/{cli-6JNIPZQ6.js → cli-234DNHN6.js} +54 -53
- package/dist/{cli-6JNIPZQ6.js.map → cli-234DNHN6.js.map} +1 -1
- package/dist/{config-G75YT6NC.js → config-IY2OJCAK.js} +10 -13
- package/dist/{doctor-3GMDOW4Y.js → doctor-2UZZF44A.js} +267 -242
- package/dist/doctor-2UZZF44A.js.map +1 -0
- package/dist/{fund-3IPR5YRJ.js → fund-RZ2QFULK.js} +92 -38
- package/dist/{fund-3IPR5YRJ.js.map → fund-RZ2QFULK.js.map} +1 -1
- package/dist/hook-command-PZHKS7ES.js +31 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +14 -0
- package/dist/hosts/claude/tenjin/.mcp.json +11 -0
- package/dist/hosts/claude/tenjin/hooks/hooks.json +206 -0
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/install-O5FJ5EP3.js +48 -0
- package/dist/{install-identity-PM4AGFFX.js → install-identity-QM44IQ6Z.js} +7 -8
- package/dist/{install-wallet-6756NOB5.js → install-wallet-Z52EDLPB.js} +14 -15
- package/dist/{install-wallet-6756NOB5.js.map → install-wallet-Z52EDLPB.js.map} +1 -1
- package/dist/{mcp-33FAAZ7F.js → mcp-33HAADDF.js} +80 -67
- package/dist/{mcp-33FAAZ7F.js.map → mcp-33HAADDF.js.map} +1 -1
- package/dist/package-RT24HTTP.js +37 -0
- package/dist/{pay-XOYR4PCH.js → pay-IR2V76FX.js} +16 -17
- package/dist/{payments-UTQDBO7H.js → payments-GFV4HU5R.js} +9 -10
- package/dist/{payments-UTQDBO7H.js.map → payments-GFV4HU5R.js.map} +1 -1
- package/dist/{send-CVGNOQW3.js → send-PI4NUA7I.js} +12 -14
- package/dist/{send-CVGNOQW3.js.map → send-PI4NUA7I.js.map} +1 -1
- package/dist/{status-NACN4DGX.js → status-ZUHTJK46.js} +6 -7
- package/dist/{status-NACN4DGX.js.map → status-ZUHTJK46.js.map} +1 -1
- package/dist/{status-line-3IQKGRUH.js → status-line-2G5JPQAE.js} +6 -7
- package/dist/{status-line-3IQKGRUH.js.map → status-line-2G5JPQAE.js.map} +1 -1
- package/dist/uninstall-THKUH5ZT.js +136 -0
- package/dist/uninstall-THKUH5ZT.js.map +1 -0
- package/dist/update-NPZDP24E.js +18 -0
- package/dist/update-NPZDP24E.js.map +1 -0
- package/dist/{wallet-B3FVHNTS.js → wallet-53EFH4M5.js} +11 -12
- package/dist/wallet-53EFH4M5.js.map +1 -0
- package/docs/agent-permissions.md +27 -17
- package/package.json +1 -1
- package/dist/chunk-64SE3QC5.js.map +0 -1
- package/dist/chunk-BOAI23CX.js.map +0 -1
- package/dist/chunk-DSNXKUXI.js +0 -172
- package/dist/chunk-DSNXKUXI.js.map +0 -1
- package/dist/chunk-GU4GGKYP.js.map +0 -1
- package/dist/chunk-H2L33M7F.js +0 -944
- package/dist/chunk-H2L33M7F.js.map +0 -1
- package/dist/chunk-HC3QEZKT.js +0 -87
- package/dist/chunk-JLEF5WHM.js +0 -132
- package/dist/chunk-JLEF5WHM.js.map +0 -1
- package/dist/chunk-MAQUL5BD.js +0 -99
- package/dist/chunk-MAQUL5BD.js.map +0 -1
- package/dist/chunk-PY7MQUKP.js +0 -755
- package/dist/chunk-PY7MQUKP.js.map +0 -1
- package/dist/chunk-TGLKKLQG.js +0 -11
- package/dist/chunk-TGLKKLQG.js.map +0 -1
- package/dist/chunk-VIOUZW7Z.js.map +0 -1
- package/dist/chunk-XVYATBKD.js.map +0 -1
- package/dist/chunk-YQOQ6XEI.js.map +0 -1
- package/dist/doctor-3GMDOW4Y.js.map +0 -1
- package/dist/hook-command-ZXX4FT4N.js +0 -32
- package/dist/install-6OROTYHZ.js +0 -72
- package/dist/status-line-wiring-QXBOOY2T.js +0 -31
- package/dist/uninstall-NYFKSYW4.js +0 -175
- package/dist/uninstall-NYFKSYW4.js.map +0 -1
- package/dist/update-RJDA5ZY3.js.map +0 -1
- /package/dist/{config-G75YT6NC.js.map → alive-3J3CHOQP.js.map} +0 -0
- /package/dist/{chunk-LAIZ2AQA.js.map → chunk-A5H3E5QA.js.map} +0 -0
- /package/dist/{chunk-VNNXAYJE.js.map → chunk-BRHREK7E.js.map} +0 -0
- /package/dist/{chunk-6ZSGER3A.js.map → chunk-FZTSGQVK.js.map} +0 -0
- /package/dist/{chunk-AWKQSKUL.js.map → chunk-KAMRYUK2.js.map} +0 -0
- /package/dist/{chunk-X7I343ZY.js.map → chunk-YFJJYHVG.js.map} +0 -0
- /package/dist/{chunk-VXIBZ6W5.js.map → chunk-ZP5PV3JB.js.map} +0 -0
- /package/dist/{hook-command-ZXX4FT4N.js.map → config-IY2OJCAK.js.map} +0 -0
- /package/dist/{install-6OROTYHZ.js.map → hook-command-PZHKS7ES.js.map} +0 -0
- /package/dist/{install-identity-PM4AGFFX.js.map → install-O5FJ5EP3.js.map} +0 -0
- /package/dist/{pay-XOYR4PCH.js.map → install-identity-QM44IQ6Z.js.map} +0 -0
- /package/dist/{status-line-wiring-QXBOOY2T.js.map → package-RT24HTTP.js.map} +0 -0
- /package/dist/{wallet-B3FVHNTS.js.map → pay-IR2V76FX.js.map} +0 -0
package/dist/install-6OROTYHZ.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
AFTER_CALL_TIMEOUT_SECONDS,
|
|
4
|
-
ALLOW_RULE,
|
|
5
|
-
ASK_MATCHER,
|
|
6
|
-
DELEGATION_MATCHER,
|
|
7
|
-
DENY_RULE,
|
|
8
|
-
DISCLOSURE,
|
|
9
|
-
MCP_ADD_COMMAND,
|
|
10
|
-
NATIVE_MATCHER,
|
|
11
|
-
ROUTE_HOOK_TIMEOUT_SECONDS,
|
|
12
|
-
classifyMcpEntry,
|
|
13
|
-
mcpAddCommand,
|
|
14
|
-
mcpRemoveCommand,
|
|
15
|
-
mcpScope,
|
|
16
|
-
readMcpEntry,
|
|
17
|
-
routerHookPlan,
|
|
18
|
-
routerSettingsPath,
|
|
19
|
-
runRouterInstall,
|
|
20
|
-
statusLineProblems
|
|
21
|
-
} from "./chunk-PY7MQUKP.js";
|
|
22
|
-
import "./chunk-64SE3QC5.js";
|
|
23
|
-
import "./chunk-MAQUL5BD.js";
|
|
24
|
-
import "./chunk-DSNXKUXI.js";
|
|
25
|
-
import "./chunk-S4SAZ7OD.js";
|
|
26
|
-
import "./chunk-OHZYNZSD.js";
|
|
27
|
-
import "./chunk-H2L33M7F.js";
|
|
28
|
-
import "./chunk-GU4GGKYP.js";
|
|
29
|
-
import "./chunk-A36LQPHV.js";
|
|
30
|
-
import {
|
|
31
|
-
pruneHooks
|
|
32
|
-
} from "./chunk-XVYATBKD.js";
|
|
33
|
-
import "./chunk-AKWGE6JQ.js";
|
|
34
|
-
import {
|
|
35
|
-
MCP_SERVER_NAME
|
|
36
|
-
} from "./chunk-TGLKKLQG.js";
|
|
37
|
-
import "./chunk-P7LABKCW.js";
|
|
38
|
-
import "./chunk-MEFB5KHA.js";
|
|
39
|
-
import "./chunk-B2L53TMK.js";
|
|
40
|
-
import "./chunk-5FGO6TYT.js";
|
|
41
|
-
import "./chunk-DATCR7AU.js";
|
|
42
|
-
import "./chunk-HC3QEZKT.js";
|
|
43
|
-
import "./chunk-2I4QTOLB.js";
|
|
44
|
-
import "./chunk-G4AM2SOL.js";
|
|
45
|
-
import "./chunk-6ZSGER3A.js";
|
|
46
|
-
import "./chunk-VIOUZW7Z.js";
|
|
47
|
-
import "./chunk-JLEF5WHM.js";
|
|
48
|
-
import "./chunk-K6AXXYCG.js";
|
|
49
|
-
import "./chunk-ZXTAQYNA.js";
|
|
50
|
-
export {
|
|
51
|
-
AFTER_CALL_TIMEOUT_SECONDS,
|
|
52
|
-
ALLOW_RULE,
|
|
53
|
-
ASK_MATCHER,
|
|
54
|
-
DELEGATION_MATCHER,
|
|
55
|
-
DENY_RULE,
|
|
56
|
-
DISCLOSURE,
|
|
57
|
-
MCP_ADD_COMMAND,
|
|
58
|
-
MCP_SERVER_NAME,
|
|
59
|
-
NATIVE_MATCHER,
|
|
60
|
-
ROUTE_HOOK_TIMEOUT_SECONDS,
|
|
61
|
-
classifyMcpEntry,
|
|
62
|
-
mcpAddCommand,
|
|
63
|
-
mcpRemoveCommand,
|
|
64
|
-
mcpScope,
|
|
65
|
-
pruneHooks,
|
|
66
|
-
readMcpEntry,
|
|
67
|
-
routerHookPlan,
|
|
68
|
-
routerSettingsPath,
|
|
69
|
-
runRouterInstall,
|
|
70
|
-
statusLineProblems
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=install-6OROTYHZ.js.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
STATUS_LINE_COMMAND,
|
|
4
|
-
STATUS_LINE_REFRESH_SECONDS,
|
|
5
|
-
classifyStatusLine,
|
|
6
|
-
composeCommand,
|
|
7
|
-
decomposeCommand,
|
|
8
|
-
ensureStatusLine,
|
|
9
|
-
inspectStatusLine,
|
|
10
|
-
removeStatusLine,
|
|
11
|
-
statusLineMode
|
|
12
|
-
} from "./chunk-DSNXKUXI.js";
|
|
13
|
-
import "./chunk-XVYATBKD.js";
|
|
14
|
-
import "./chunk-AKWGE6JQ.js";
|
|
15
|
-
import "./chunk-TGLKKLQG.js";
|
|
16
|
-
import "./chunk-HC3QEZKT.js";
|
|
17
|
-
import "./chunk-JLEF5WHM.js";
|
|
18
|
-
import "./chunk-K6AXXYCG.js";
|
|
19
|
-
import "./chunk-ZXTAQYNA.js";
|
|
20
|
-
export {
|
|
21
|
-
STATUS_LINE_COMMAND,
|
|
22
|
-
STATUS_LINE_REFRESH_SECONDS,
|
|
23
|
-
classifyStatusLine,
|
|
24
|
-
composeCommand,
|
|
25
|
-
decomposeCommand,
|
|
26
|
-
ensureStatusLine,
|
|
27
|
-
inspectStatusLine,
|
|
28
|
-
removeStatusLine,
|
|
29
|
-
statusLineMode
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=status-line-wiring-QXBOOY2T.js.map
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ALLOW_RULE,
|
|
4
|
-
DENY_RULE,
|
|
5
|
-
mcpRemoveCommand,
|
|
6
|
-
mcpScope,
|
|
7
|
-
readMcpEntry,
|
|
8
|
-
routerSettingsPath
|
|
9
|
-
} from "./chunk-PY7MQUKP.js";
|
|
10
|
-
import "./chunk-64SE3QC5.js";
|
|
11
|
-
import "./chunk-MAQUL5BD.js";
|
|
12
|
-
import {
|
|
13
|
-
removeStatusLine
|
|
14
|
-
} from "./chunk-DSNXKUXI.js";
|
|
15
|
-
import "./chunk-S4SAZ7OD.js";
|
|
16
|
-
import "./chunk-OHZYNZSD.js";
|
|
17
|
-
import {
|
|
18
|
-
onPath,
|
|
19
|
-
persistRouterProject
|
|
20
|
-
} from "./chunk-H2L33M7F.js";
|
|
21
|
-
import "./chunk-GU4GGKYP.js";
|
|
22
|
-
import "./chunk-A36LQPHV.js";
|
|
23
|
-
import {
|
|
24
|
-
inspectHooksFile,
|
|
25
|
-
pruneHooks
|
|
26
|
-
} from "./chunk-XVYATBKD.js";
|
|
27
|
-
import "./chunk-AKWGE6JQ.js";
|
|
28
|
-
import {
|
|
29
|
-
MCP_SERVER_NAME
|
|
30
|
-
} from "./chunk-TGLKKLQG.js";
|
|
31
|
-
import "./chunk-P7LABKCW.js";
|
|
32
|
-
import "./chunk-MEFB5KHA.js";
|
|
33
|
-
import "./chunk-B2L53TMK.js";
|
|
34
|
-
import "./chunk-5FGO6TYT.js";
|
|
35
|
-
import "./chunk-DATCR7AU.js";
|
|
36
|
-
import "./chunk-HC3QEZKT.js";
|
|
37
|
-
import "./chunk-2I4QTOLB.js";
|
|
38
|
-
import "./chunk-G4AM2SOL.js";
|
|
39
|
-
import "./chunk-6ZSGER3A.js";
|
|
40
|
-
import "./chunk-VIOUZW7Z.js";
|
|
41
|
-
import {
|
|
42
|
-
writeFileAtomic
|
|
43
|
-
} from "./chunk-JLEF5WHM.js";
|
|
44
|
-
import "./chunk-K6AXXYCG.js";
|
|
45
|
-
import "./chunk-ZXTAQYNA.js";
|
|
46
|
-
|
|
47
|
-
// src/router/uninstall.ts
|
|
48
|
-
import { execFile } from "node:child_process";
|
|
49
|
-
import { homedir } from "node:os";
|
|
50
|
-
import { readFile, stat } from "node:fs/promises";
|
|
51
|
-
import { isAbsolute } from "node:path";
|
|
52
|
-
import { promisify } from "node:util";
|
|
53
|
-
var exec = promisify(execFile);
|
|
54
|
-
var MCP_REMOVE_COMMAND = mcpRemoveCommand();
|
|
55
|
-
async function runRouterUninstall(args, ctx, deps = {}) {
|
|
56
|
-
const env = deps.env ?? process.env;
|
|
57
|
-
const home = deps.homeDir ?? homedir();
|
|
58
|
-
if (!isAbsolute(home)) throw new Error("The home directory is not an absolute path.");
|
|
59
|
-
const cwd = deps.cwd ?? process.cwd();
|
|
60
|
-
const settingsPath = routerSettingsPath({
|
|
61
|
-
...args.project === true ? { project: true } : {},
|
|
62
|
-
homeDir: home,
|
|
63
|
-
cwd
|
|
64
|
-
});
|
|
65
|
-
const removed = await removeFromSettings(settingsPath, ctx.dataDir);
|
|
66
|
-
const statusLine = await removeStatusLine(settingsPath);
|
|
67
|
-
if (args.project === true) {
|
|
68
|
-
await persistRouterProject(ctx.dataDir, cwd, false).catch(() => void 0);
|
|
69
|
-
}
|
|
70
|
-
const mcp = await removeMcpServer(deps, env, args.project === true, cwd, home);
|
|
71
|
-
const data = {
|
|
72
|
-
settingsPath,
|
|
73
|
-
...removed,
|
|
74
|
-
statusLine,
|
|
75
|
-
mcp,
|
|
76
|
-
kept: ["wallet.json", "spend.json", "config.json"]
|
|
77
|
-
};
|
|
78
|
-
return {
|
|
79
|
-
data,
|
|
80
|
-
humanLines: [
|
|
81
|
-
removed.warning === void 0 ? `removed ${removed.events.length > 0 ? removed.events.join(", ") : "no"} hook entries and ${removed.ruleRemoved || removed.denyRuleRemoved ? "the" : "no"} permission rules from ${settingsPath}` : `${settingsPath} was left untouched (${removed.warning})`,
|
|
82
|
-
statusLine.wrote ? "removed the x402 status line" : statusLine.state === "composed" ? "status line: yours also runs the x402 footer; edit that command to drop it" : "status line: none of ours was registered",
|
|
83
|
-
mcp.removed ? `removed the ${MCP_SERVER_NAME} MCP server (${mcp.scope} scope)` : mcp.kept !== void 0 ? `mcp: ${mcp.reason ?? "left in place"}` : `mcp: run ${mcp.command}`,
|
|
84
|
-
"Your wallet, spend ledger and config are kept."
|
|
85
|
-
]
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
async function removeFromSettings(path, dataDir) {
|
|
89
|
-
const nothing = { events: [], ruleRemoved: false, denyRuleRemoved: false, wrote: false };
|
|
90
|
-
const found = await inspectHooksFile(path);
|
|
91
|
-
if ("refusal" in found) return { ...nothing, warning: found.refusal.reason };
|
|
92
|
-
const { raw, settings, hooks } = found;
|
|
93
|
-
if (raw === null) return nothing;
|
|
94
|
-
const pruned = pruneHooks(hooks, dataDir);
|
|
95
|
-
const permissions = settings.permissions !== null && typeof settings.permissions === "object" && !Array.isArray(settings.permissions) ? settings.permissions : void 0;
|
|
96
|
-
const allow = Array.isArray(permissions?.allow) ? permissions.allow : void 0;
|
|
97
|
-
const deny = Array.isArray(permissions?.deny) ? permissions.deny : void 0;
|
|
98
|
-
const ruleRemoved = allow?.includes(ALLOW_RULE) === true;
|
|
99
|
-
const denyRuleRemoved = deny?.includes(DENY_RULE) === true;
|
|
100
|
-
const next = {
|
|
101
|
-
...settings,
|
|
102
|
-
hooks: pruned.next,
|
|
103
|
-
...permissions !== void 0 ? {
|
|
104
|
-
permissions: {
|
|
105
|
-
...permissions,
|
|
106
|
-
...allow !== void 0 ? { allow: allow.filter((r) => r !== ALLOW_RULE) } : {},
|
|
107
|
-
...deny !== void 0 ? { deny: deny.filter((r) => r !== DENY_RULE) } : {}
|
|
108
|
-
}
|
|
109
|
-
} : {}
|
|
110
|
-
};
|
|
111
|
-
const body = `${JSON.stringify(next, null, 2)}
|
|
112
|
-
`;
|
|
113
|
-
if (body === raw) {
|
|
114
|
-
return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: false };
|
|
115
|
-
}
|
|
116
|
-
const mode = await stat(found.path).then((s) => ({ mode: s.mode & 511 })).catch(() => ({}));
|
|
117
|
-
if (await readFile(found.path, "utf8").catch(() => null) !== raw) {
|
|
118
|
-
return { ...nothing, warning: "changed-since-read" };
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
await writeFileAtomic(found.path, body, mode);
|
|
122
|
-
} catch (err) {
|
|
123
|
-
return { ...nothing, warning: err instanceof Error ? err.message : String(err) };
|
|
124
|
-
}
|
|
125
|
-
return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: true };
|
|
126
|
-
}
|
|
127
|
-
async function removeMcpServer(deps, env, project, cwd, home) {
|
|
128
|
-
const scope = mcpScope(project);
|
|
129
|
-
const command = mcpRemoveCommand(project);
|
|
130
|
-
const existing = await (deps.readMcpEntry ?? readMcpEntry)(scope, cwd, home);
|
|
131
|
-
if (existing.state === "wrong-command") {
|
|
132
|
-
return {
|
|
133
|
-
removed: false,
|
|
134
|
-
scope,
|
|
135
|
-
command,
|
|
136
|
-
kept: "foreign",
|
|
137
|
-
reason: `an MCP server named ${MCP_SERVER_NAME} at ${scope} scope launches something else; this command will not remove a registration it did not write, so it was left in place`
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
if (existing.state === "unreadable") {
|
|
141
|
-
return {
|
|
142
|
-
removed: false,
|
|
143
|
-
scope,
|
|
144
|
-
command,
|
|
145
|
-
kept: "unreadable",
|
|
146
|
-
reason: `the ${scope}-scope registration file could not be read, so nothing was removed from it`
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
const which = deps.which ?? ((bin) => onPath(bin, env));
|
|
150
|
-
if (!which("claude")) {
|
|
151
|
-
return { removed: false, scope, command, reason: "the `claude` binary is not on PATH" };
|
|
152
|
-
}
|
|
153
|
-
try {
|
|
154
|
-
await (deps.removeMcp ?? runClaudeMcpRemove)({ scope, cwd });
|
|
155
|
-
return { removed: true, scope, command };
|
|
156
|
-
} catch (err) {
|
|
157
|
-
return {
|
|
158
|
-
removed: false,
|
|
159
|
-
scope,
|
|
160
|
-
command,
|
|
161
|
-
reason: err instanceof Error ? err.message : String(err)
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async function runClaudeMcpRemove(opts) {
|
|
166
|
-
await exec("claude", ["mcp", "remove", MCP_SERVER_NAME, "-s", opts.scope], {
|
|
167
|
-
timeout: 2e4,
|
|
168
|
-
cwd: opts.cwd
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
export {
|
|
172
|
-
MCP_REMOVE_COMMAND,
|
|
173
|
-
runRouterUninstall
|
|
174
|
-
};
|
|
175
|
-
//# sourceMappingURL=uninstall-NYFKSYW4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/router/uninstall.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { homedir } from 'node:os';\nimport { readFile, stat } from 'node:fs/promises';\nimport { isAbsolute } from 'node:path';\nimport { promisify } from 'node:util';\nimport { persistRouterProject } from '../commands/config';\nimport { writeFileAtomic } from '../lib/atomic-json';\nimport { inspectHooksFile, pruneHooks } from '../lib/harness-hooks';\nimport { onPath } from '../lib/skill-wiring';\nimport type { CommandContext, CommandResult } from '../context';\nimport {\n ALLOW_RULE,\n DENY_RULE,\n MCP_SERVER_NAME,\n mcpRemoveCommand,\n mcpScope,\n readMcpEntry,\n routerSettingsPath,\n type McpEntryState,\n} from './install';\nimport { removeStatusLine } from './status-line-wiring';\n\n/**\n * `tenjin uninstall`: take out the hook entries, the allow and deny rules and\n * the MCP registration, and nothing else.\n *\n * THE WALLET AND `spend.json` STAY. Removing an integration is not a reason to\n * destroy a key that holds funds or a ledger that records what was spent; both\n * are the user's, and `tenjin wallet` is where they go to move either.\n */\n\nconst exec = promisify(execFile);\n/** The user-scope form; `--project` removes at project scope symmetrically. */\nexport const MCP_REMOVE_COMMAND = mcpRemoveCommand();\n\nexport interface RouterUninstallArgs {\n project?: boolean;\n}\n\nexport interface RouterUninstallDeps {\n homeDir?: string;\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n which?: (bin: string) => boolean;\n removeMcp?: (opts: { scope: 'user' | 'project'; cwd: string }) => Promise<void>;\n /** Reads the registration the scope's own file holds; tests inject it. */\n readMcpEntry?: (\n scope: 'user' | 'project',\n cwd: string,\n home: string,\n ) => Promise<{ found: boolean; state: McpEntryState }>;\n}\n\nexport async function runRouterUninstall(\n args: RouterUninstallArgs,\n ctx: CommandContext,\n deps: RouterUninstallDeps = {},\n): Promise<CommandResult> {\n const env = deps.env ?? process.env;\n const home = deps.homeDir ?? homedir();\n if (!isAbsolute(home)) throw new Error('The home directory is not an absolute path.');\n const cwd = deps.cwd ?? process.cwd();\n const settingsPath = routerSettingsPath({\n ...(args.project === true ? { project: true } : {}),\n homeDir: home,\n cwd,\n });\n\n const removed = await removeFromSettings(settingsPath, ctx.dataDir);\n // OURS ALONE, and after the hooks write so the two never touch the file at\n // once. A COMPOSED status line is the user's own text with ours appended:\n // deleting it would take their line with it, so it is reported and kept.\n const statusLine = await removeStatusLine(settingsPath);\n // Forgotten, so a later `tenjin update` does not go looking for a project\n // this machine no longer wires.\n if (args.project === true) {\n await persistRouterProject(ctx.dataDir, cwd, false).catch(() => undefined);\n }\n // The SAME scope the install used, or a `--project` uninstall would leave the\n // project's registration behind and reach into the user's file instead.\n const mcp = await removeMcpServer(deps, env, args.project === true, cwd, home);\n const data = {\n settingsPath,\n ...removed,\n statusLine,\n mcp,\n kept: ['wallet.json', 'spend.json', 'config.json'],\n };\n return {\n data,\n humanLines: [\n removed.warning === undefined\n ? `removed ${removed.events.length > 0 ? removed.events.join(', ') : 'no'} hook entries and ${removed.ruleRemoved || removed.denyRuleRemoved ? 'the' : 'no'} permission rules from ${settingsPath}`\n : `${settingsPath} was left untouched (${removed.warning})`,\n statusLine.wrote\n ? 'removed the x402 status line'\n : statusLine.state === 'composed'\n ? 'status line: yours also runs the x402 footer; edit that command to drop it'\n : 'status line: none of ours was registered',\n mcp.removed\n ? `removed the ${MCP_SERVER_NAME} MCP server (${mcp.scope} scope)`\n : mcp.kept !== undefined\n ? `mcp: ${mcp.reason ?? 'left in place'}`\n : `mcp: run ${mcp.command}`,\n 'Your wallet, spend ledger and config are kept.',\n ],\n };\n}\n\ninterface SettingsRemoval {\n /** The events an entry of ours was taken out of. */\n events: string[];\n ruleRemoved: boolean;\n denyRuleRemoved: boolean;\n wrote: boolean;\n warning?: string;\n}\n\nasync function removeFromSettings(path: string, dataDir: string): Promise<SettingsRemoval> {\n const nothing = { events: [], ruleRemoved: false, denyRuleRemoved: false, wrote: false };\n const found = await inspectHooksFile(path);\n if ('refusal' in found) return { ...nothing, warning: found.refusal.reason };\n const { raw, settings, hooks } = found;\n if (raw === null) return nothing;\n const pruned = pruneHooks(hooks, dataDir);\n const permissions =\n settings.permissions !== null &&\n typeof settings.permissions === 'object' &&\n !Array.isArray(settings.permissions)\n ? (settings.permissions as Record<string, unknown>)\n : undefined;\n // Each list loses our one rule and keeps every other entry; a list that is\n // absent or not an array is left as it is.\n const allow = Array.isArray(permissions?.allow) ? permissions.allow : undefined;\n const deny = Array.isArray(permissions?.deny) ? permissions.deny : undefined;\n const ruleRemoved = allow?.includes(ALLOW_RULE) === true;\n const denyRuleRemoved = deny?.includes(DENY_RULE) === true;\n const next = {\n ...settings,\n hooks: pruned.next,\n ...(permissions !== undefined\n ? {\n permissions: {\n ...permissions,\n ...(allow !== undefined ? { allow: allow.filter((r) => r !== ALLOW_RULE) } : {}),\n ...(deny !== undefined ? { deny: deny.filter((r) => r !== DENY_RULE) } : {}),\n },\n }\n : {}),\n };\n const body = `${JSON.stringify(next, null, 2)}\\n`;\n if (body === raw) {\n return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: false };\n }\n const mode = await stat(found.path)\n .then((s) => ({ mode: s.mode & 0o777 }))\n .catch(() => ({}));\n if ((await readFile(found.path, 'utf8').catch(() => null)) !== raw) {\n return { ...nothing, warning: 'changed-since-read' };\n }\n try {\n await writeFileAtomic(found.path, body, mode);\n } catch (err) {\n return { ...nothing, warning: err instanceof Error ? err.message : String(err) };\n }\n return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: true };\n}\n\nasync function removeMcpServer(\n deps: RouterUninstallDeps,\n env: NodeJS.ProcessEnv,\n project: boolean,\n cwd: string,\n home: string,\n): Promise<{\n removed: boolean;\n scope: 'user' | 'project';\n command: string;\n reason?: string;\n kept?: 'foreign' | 'unreadable';\n}> {\n const scope = mcpScope(project);\n const command = mcpRemoveCommand(project);\n // THE SAME CHECK INSTALL MAKES. The name `x402` proves nothing: another tool\n // can register its own server under it, and install refuses to touch that\n // entry. Uninstall must not remove it either. An absent entry falls through\n // to the remove as before, so nothing changes for a normal install.\n const existing = await (deps.readMcpEntry ?? readMcpEntry)(scope, cwd, home);\n if (existing.state === 'wrong-command') {\n return {\n removed: false,\n scope,\n command,\n kept: 'foreign',\n reason: `an MCP server named ${MCP_SERVER_NAME} at ${scope} scope launches something else; this command will not remove a registration it did not write, so it was left in place`,\n };\n }\n if (existing.state === 'unreadable') {\n return {\n removed: false,\n scope,\n command,\n kept: 'unreadable',\n reason: `the ${scope}-scope registration file could not be read, so nothing was removed from it`,\n };\n }\n const which = deps.which ?? ((bin: string) => onPath(bin, env));\n if (!which('claude')) {\n return { removed: false, scope, command, reason: 'the `claude` binary is not on PATH' };\n }\n try {\n await (deps.removeMcp ?? runClaudeMcpRemove)({ scope, cwd });\n return { removed: true, scope, command };\n } catch (err) {\n return {\n removed: false,\n scope,\n command,\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nasync function runClaudeMcpRemove(opts: { scope: 'user' | 'project'; cwd: string }): Promise<void> {\n await exec('claude', ['mcp', 'remove', MCP_SERVER_NAME, '-s', opts.scope], {\n timeout: 20_000,\n cwd: opts.cwd,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,UAAU,YAAY;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AA2B1B,IAAM,OAAO,UAAU,QAAQ;AAExB,IAAM,qBAAqB,iBAAiB;AAoBnD,eAAsB,mBACpB,MACA,KACA,OAA4B,CAAC,GACL;AACxB,QAAM,MAAM,KAAK,OAAO,QAAQ;AAChC,QAAM,OAAO,KAAK,WAAW,QAAQ;AACrC,MAAI,CAAC,WAAW,IAAI,EAAG,OAAM,IAAI,MAAM,6CAA6C;AACpF,QAAM,MAAM,KAAK,OAAO,QAAQ,IAAI;AACpC,QAAM,eAAe,mBAAmB;AAAA,IACtC,GAAI,KAAK,YAAY,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;AAAA,IACjD,SAAS;AAAA,IACT;AAAA,EACF,CAAC;AAED,QAAM,UAAU,MAAM,mBAAmB,cAAc,IAAI,OAAO;AAIlE,QAAM,aAAa,MAAM,iBAAiB,YAAY;AAGtD,MAAI,KAAK,YAAY,MAAM;AACzB,UAAM,qBAAqB,IAAI,SAAS,KAAK,KAAK,EAAE,MAAM,MAAM,MAAS;AAAA,EAC3E;AAGA,QAAM,MAAM,MAAM,gBAAgB,MAAM,KAAK,KAAK,YAAY,MAAM,KAAK,IAAI;AAC7E,QAAM,OAAO;AAAA,IACX;AAAA,IACA,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA,MAAM,CAAC,eAAe,cAAc,aAAa;AAAA,EACnD;AACA,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,MACV,QAAQ,YAAY,SAChB,WAAW,QAAQ,OAAO,SAAS,IAAI,QAAQ,OAA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AAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,QAAQ,OAAO,KAAK;AAAA,IACtB;AAAA,EACF;AACA,QAAM,QAAQ,KAAK,UAAU,CAAC,QAAgB,OAAO,KAAK,GAAG;AAC7D,MAAI,CAAC,MAAM,QAAQ,GAAG;AACpB,WAAO,EAAE,SAAS,OAAO,OAAO,SAAS,QAAQ,qCAAqC;AAAA,EACxF;AACA,MAAI;AACF,WAAO,KAAK,aAAa,oBAAoB,EAAE,OAAO,IAAI,CAAC;AAC3D,WAAO,EAAE,SAAS,MAAM,OAAO,QAAQ;AAAA,EACzC,SAAS,KAAK;AACZ,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA,QAAQ,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,IACzD;AAAA,EACF;AACF;AAEA,eAAe,mBAAmB,MAAiE;AACjG,QAAM,KAAK,UAAU,CAAC,OAAO,UAAU,iBAAiB,MAAM,KAAK,KAAK,GAAG;AAAA,IACzE,SAAS;AAAA,IACT,KAAK,KAAK;AAAA,EACZ,CAAC;AACH;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/update.ts","../src/lib/install-location.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { existsSync, statSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { resolve, sep } from 'node:path';\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 {\n NUDGE_OPT_OUT,\n channelTag,\n fetchDistTags,\n isNewer,\n resolveTarget,\n} from '../lib/update-check';\nimport { defaultDataDir } from '../lib/paths';\nimport type { CommandContext, CommandResult } from '../context';\nimport {\n readMcpServers,\n RECONNECT_FIX,\n type InstalledAt,\n type ListMcpProcesses,\n} from '../router/mcp-processes';\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: {\n cwd: string;\n timeoutMs: number;\n /** Variables layered ONTO this process's environment, for the per-profile\n * `TENJIN_DATA_DIR` the refresh pass sets. Absent means inherit unchanged. */\n env?: Record<string, string>;\n },\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 /** Home whose manual-fix command the report names. Defaults to os.homedir(). */\n homeDir?: string;\n /**\n * The CLI entry the refresh child runs. Defaults to `process.argv[1]`, which\n * after the swap resolves to the NEWLY installed script — that is the whole\n * point of spawning rather than calling.\n */\n refreshCommand?: string;\n /** This user's running `tenjin mcp` processes; tests inject them. */\n listMcpProcesses?: ListMcpProcesses;\n /** When the new build was installed; tests inject it. */\n installedAt?: InstalledAt;\n}\n\ninterface UpdateData {\n current: string;\n latest: string;\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 // 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 const raw = tags[channel];\n throw raw === undefined\n ? new CliError('RESOURCE_NOT_FOUND', 'npm has no published tenjin-cli on the latest tag', {\n fix: 'Pick a version yourself: npm view tenjin-cli versions',\n })\n : new CliError(\n 'RESOURCE_NOT_FOUND',\n // Registry-controlled: bounded here, escaped by the error emitter.\n `npm's latest tenjin-cli (${raw.slice(0, 40)}) is not a version this build can read`,\n {\n fix: 'Install it by name: npm i -g tenjin-cli@<version> (npm view tenjin-cli versions)',\n },\n );\n }\n\n const updateAvailable = isNewer(latest, current);\n const data = (updated: boolean): UpdateData => ({\n current,\n latest,\n updateAvailable,\n updated,\n });\n\n if (!updateAvailable) {\n return {\n data: data(false),\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\n const refresh = await refreshProfiles(ctx, deps);\n // The refresh child's output is captured, so the warning it would print about\n // a `tenjin mcp` still running the old build is checked again here.\n const servers = await readMcpServers(deps);\n return {\n data: { ...data(true), refresh, mcpServer: servers.check },\n humanLines: [\n `Updated tenjin-cli ${current} -> ${latest}.`,\n ...refreshLines(refresh),\n ...(servers.stale > 0 ? [`! ${servers.check.detail}. ${RECONNECT_FIX}`] : []),\n ],\n };\n}\n\n/** How long one `install --refresh` child gets. Local file writes only, no\n * registry: a minute is already generous, and `update` must not hang a turn. */\nconst REFRESH_TIMEOUT_MS = 60_000;\n\n/** One profile this update did not bring up to date, and why. */\nexport interface RefreshFailure {\n /** The profile's data dir. */\n dataDir: string;\n /**\n * Why it is not up to date, in the words of whoever decided that: the child's\n * own `error.message` when it printed a failure envelope, this pass's own\n * account when the child was never run or never got that far. Always present,\n * because a failure whose four causes render identically is the reason this\n * field exists.\n */\n reason: string;\n /** The command that converges THIS profile; see {@link manualFix}. */\n fix: string;\n}\n\n/** What the post-swap re-materialize did, per profile. */\nexport interface RefreshOutcome {\n /** Data dirs a refresh was run for, whether or not it succeeded. */\n profiles: string[];\n /**\n * Profiles this update did not bring up to date, each with its reason and the\n * manual command to finish it. Both halves land here: a refresh that ran and\n * did not report success, and one that was never run at all (no entry to\n * re-exec, a data dir that is not a directory).\n */\n failed: RefreshFailure[];\n}\n\n/**\n * Re-materialize what the swap left stale, on the NEW binary.\n *\n * `update` replaces the package and nothing else, but `install` bakes this\n * build's identity into files: the generated hook scripts carry a version, and\n * the wired skills carry this release's instructions. Until something rewrites\n * them the highest-volume request path keeps reporting the previous version and\n * agents keep reading the previous release's guidance (tenjin-agent#171).\n *\n * SPAWNED, NOT CALLED. This process is the OLD build; it cannot render the new\n * version's copies, and re-exec is the only way to reach code that can. The\n * child is the freshly installed entry, and what it runs is\n * `install --refresh` — a mode that converges existing surfaces and creates\n * none, which is the only kind of write an unattended upgrade may make.\n *\n * ONCE PER HOOK-OWNER PROFILE. `install` bakes its data dir into the scripts it\n * generates, so a machine whose hooks were installed under `TENJIN_DATA_DIR`\n * has hooks belonging to THAT profile while a bare `tenjin update` resolves the\n * default one. Refreshing only the invoking profile there would leave the\n * registered scripts — the ones the harness actually fires — stale forever,\n * which is exactly the shelf runbook's manual re-install step. So the detector\n * reads the harness settings and each profile it names is refreshed with\n * `TENJIN_DATA_DIR` set to it. A machine with no registered hooks has no other\n * profile to find, and gets one refresh for the invoking one.\n *\n * NEVER FAILS THE UPDATE. The swap already happened and is the thing the\n * operator asked for. A refusal, a run with nothing to converge, a crash, a\n * timeout, or an older-binary \"unknown option --refresh\" all land here as a warn\n * naming the manual command.\n *\n * EACH FAILURE CARRIES ITS OWN REASON AND ITS OWN FIX. The four ways a profile\n * misses are not interchangeable — a dir that is not a directory, a settings\n * file that changed underneath, a machine that never ran `install`, and a\n * timeout each want a different next move — so the child's output is collected\n * and its `error.message` reported per profile rather than collapsed into one\n * parent line.\n */\nasync function refreshProfiles(ctx: CommandContext, deps: UpdateDeps): Promise<RefreshOutcome> {\n const home = deps.homeDir ?? homedir();\n // THE INVOKING PROFILE, AND ONLY IT. The pre-daemon installer baked its data\n // dir into eight generated scripts, so an upgrade had to find every profile\n // registered in settings.json and refresh each one's bodies. Nothing is baked\n // any more: the two bundles are the same bytes for every profile, and a\n // profile's daemon picks up the new build the next time its own `tenjin`\n // command runs. So there is nothing left to hunt for, and a detector reading\n // paths out of somebody's settings file is not worth keeping to say so.\n const candidates = [ctx.dataDir];\n const fixFor = (dataDir: string): string => manualFix(dataDir, home, ctx.dataDir);\n\n // The child would CREATE a data dir that is not there: `install --refresh`\n // converges surfaces rather than materializing them, but the process around it\n // mkdirs the tree for the update cache on its way out. So a path that is not\n // already a directory is reported unrefreshed instead of visited.\n const profiles: string[] = [];\n const unrun: RefreshFailure[] = [];\n for (const dataDir of candidates) {\n if (isExistingDir(dataDir)) profiles.push(dataDir);\n else unrun.push({ dataDir, reason: 'It is not a directory.', fix: fixFor(dataDir) });\n }\n\n const entry = versionFreeEntry(deps.refreshCommand ?? process.argv[1]);\n // Nothing safe to re-exec: no argv (an embedder, a stripped argv), or a path\n // that names the version being replaced (see versionFreeEntry). Report the\n // profiles as unrefreshed rather than guessing, since guessing is how a hook\n // script gets rewritten by the wrong binary — and a refresh that ran the OLD\n // build would report success while writing the bytes the update just left.\n if (entry === null) {\n const reason = 'This build has no entry the update could safely re-execute.';\n return {\n profiles: [],\n failed: candidates.map((d) => ({ dataDir: d, reason, fix: fixFor(d) })),\n };\n }\n\n const failed = [...unrun];\n for (const dataDir of profiles) {\n // A BOUNDED COLLECTOR, not the manager's live echo. npm's chatter is minutes\n // of progress a human wants to see; this child emits one envelope on a pipe,\n // and painting that JSON into the human's stderr is noise. It is still kept,\n // because the envelope is where the child says WHICH refusal this was.\n let tail = '';\n const outcome = await (deps.spawnImpl ?? spawnCapture)(\n process.execPath,\n [entry, 'install', '--refresh'],\n {\n cwd: homedir(),\n timeoutMs: REFRESH_TIMEOUT_MS,\n // TENJIN_DATA_DIR aims the child at this profile; the nudge opt-out is\n // what keeps it from touching any other file in there (lib/update-check).\n env: { TENJIN_DATA_DIR: dataDir, [NUDGE_OPT_OUT]: '1' },\n },\n (chunk) => {\n tail = (tail + chunk).slice(-REFRESH_TAIL_LIMIT);\n },\n );\n // The child's exit code IS the verdict: `install --refresh` exits non-zero\n // when it refused or found nothing to converge, so a machine that never ran\n // `install` warns here instead of being told its hooks were refreshed. The\n // envelope on the pipe is what turns that verdict into a reason.\n if (outcome.kind !== 'exit' || outcome.code !== 0) {\n failed.push({ dataDir, reason: refreshReason(outcome, tail), fix: fixFor(dataDir) });\n }\n }\n return { profiles, failed };\n}\n\n/** How much of one refresh child's output is kept. It prints a single envelope,\n * not a build log, so this is headroom rather than a budget. */\nconst REFRESH_TAIL_LIMIT = 4000;\n\n/** How much of a child's own message reaches the parent's report. Long enough\n * for every message `install --refresh` can produce, short enough that a child\n * which somehow printed prose cannot own the operator's terminal. */\nconst REASON_LIMIT = 300;\n\n/**\n * Why this profile is not up to date, preferring the child's own account.\n *\n * The exit code separates success from failure and nothing else, so the four\n * refusals `install --refresh` can reach would otherwise reach the operator as\n * one line that names none of them. The envelope on the pipe carries the\n * distinction; the outcome kind covers the deaths that never printed one.\n */\nfunction refreshReason(outcome: SpawnResult, output: string): string {\n const reported = envelopeMessage(output);\n if (reported !== undefined) return reported;\n if (outcome.kind === 'timeout') return `It did not finish in ${REFRESH_TIMEOUT_MS / 1000}s.`;\n if (outcome.kind === 'start-failed') return 'The refresh could not be started.';\n // An older binary rejecting `--refresh` is the expected shape here: commander\n // writes its own usage error and exits without an envelope of ours.\n return `The refresh exited ${outcome.code} without reporting a reason.`;\n}\n\n/**\n * The `error.message` out of the one failure envelope the child printed.\n *\n * Read from the LAST envelope because stdout carries exactly one while stderr\n * may carry notices ahead of it, and the two pipes are merged here.\n *\n * `writeJson` PRETTY-PRINTS, so the envelope spans many lines and its only line\n * starting with `{` is a bare `{` that does not parse alone. So scan backwards\n * for an opening line and parse from there to the end; a compact single line\n * still parses through the same path, which keeps an older child readable.\n *\n * Sanitized because this text is bound for a human's terminal and the child\n * relays paths and parse errors it did not author.\n */\nfunction envelopeMessage(output: string): string | undefined {\n const lines = output.split('\\n');\n for (let i = lines.length - 1; i >= 0; i -= 1) {\n const line = lines[i]?.trim();\n if (line === undefined || !line.startsWith('{')) continue;\n let parsed: { ok?: unknown; error?: { message?: unknown } };\n try {\n parsed = JSON.parse(lines.slice(i).join('\\n')) as typeof parsed;\n } catch {\n continue;\n }\n if (parsed?.ok !== false || typeof parsed.error?.message !== 'string') continue;\n const message = sanitizeForTerminal(parsed.error.message).trim();\n if (message.length > 0) return message.slice(0, REASON_LIMIT);\n }\n return undefined;\n}\n\n/** A path that already exists AND is a directory. Follows links on purpose: a\n * data dir behind a symlink is an ordinary machine layout, an absent one is not\n * a profile this command may create. */\nfunction isExistingDir(path: string): boolean {\n return statSync(path, { throwIfNoEntry: false })?.isDirectory() === true;\n}\n\n/**\n * The manual command that converges THIS profile.\n *\n * A bare `tenjin install` resolves one data dir, so handing it to an operator\n * whose failed profile is a shelf — the case the per-profile loop exists for —\n * is advice that cannot repair the thing it names. The bare form is emitted only\n * for a dir that is the default under this home AND the one this invocation\n * itself resolved, so it is right under either reading of \"what a bare install\n * would do next\"; every other profile gets the explicit env prefix, which is the\n * same form the shelf runbook uses and is right unconditionally.\n */\nfunction manualFix(dataDir: string, home: string, invoking: string): string {\n const bare =\n resolve(dataDir) === resolve(defaultDataDir(home)) && resolve(dataDir) === resolve(invoking);\n const command = bare ? 'tenjin install' : `TENJIN_DATA_DIR=${dataDir} tenjin install`;\n return `Run \\`${command}\\` to bring the skills and hook scripts up to this version.`;\n}\n\n/**\n * The entry to re-exec, or null when there is none this code may trust.\n *\n * `process.argv[1]` is the path Node RESOLVED, symlinks and all (see\n * `classifyManager`, which reads the manager off exactly that property). Under\n * npm and bun that path carries no version, so after the swap it is already the\n * new build. Under pnpm it points into the virtual store, whose directory names\n * PIN A VERSION: `.../node_modules/.pnpm/tenjin-cli@<version>/node_modules/tenjin-cli/dist/index.js`.\n * Re-executing that is the worst available outcome — it runs the build the\n * update just replaced and reports a successful refresh over the previous\n * version's bytes, which is the exact staleness this whole command exists to\n * end (tenjin-agent#171).\n *\n * The virtual store keeps the version-free link one level out, beside `.pnpm`,\n * and the swap repoints it, so the same path with the store segments removed is\n * the new build. It is derived rather than assumed: if the result is not on\n * disk, this returns null and the caller warns instead of running anything.\n */\nexport function versionFreeEntry(entry: string | undefined): string | null {\n if (entry === undefined || entry.length === 0) return null;\n const segs = entry.split(sep);\n const store = segs.indexOf('.pnpm');\n if (store === -1) return segs.join(sep);\n // `.pnpm/<name>@<version>/node_modules/<name>/...`: everything from the second\n // `node_modules` on is the package's own path within the global tree.\n const inner = segs.indexOf('node_modules', store);\n if (inner === -1) return null;\n const derived = [...segs.slice(0, store), ...segs.slice(inner + 1)].join(sep);\n return existsSync(derived) ? derived : null;\n}\n\n/**\n * What the refresh actually did, as lines.\n *\n * It replaces \"New builds pick it up immediately\", which was true of the binary\n * and false of everything install had written — so it read as reassurance about\n * precisely the thing that was NOT handled (tenjin-agent#171).\n *\n * The successes are reported ALONGSIDE the failures rather than instead of them:\n * a machine where 8 of 12 profiles converged is not a machine where the refresh\n * did nothing, and one line per failure is what lets its own reason and its own\n * command travel with it.\n */\nfunction refreshLines(refresh: RefreshOutcome): string[] {\n const failedDirs = new Set(refresh.failed.map((f) => f.dataDir));\n const done = refresh.profiles.filter((p) => !failedDirs.has(p));\n if (refresh.failed.length === 0) {\n return [\n done.length > 1\n ? `Refreshed the skills and hook scripts for ${done.length} profiles: ${done.join(', ')}.`\n : `Refreshed the skills and hook scripts for ${done[0]}.`,\n ];\n }\n const total = done.length + refresh.failed.length;\n const lines =\n done.length > 0\n ? [\n `Refreshed the skills and hook scripts for ${done.length} of ${total} profiles: ${done.join(', ')}.`,\n ]\n : [];\n lines.push(`Could not refresh the skills and hook scripts for ${refresh.failed.length}:`);\n lines.push(...refresh.failed.map((f) => `- ${f.dataDir}: ${f.reason} ${f.fix}`));\n return lines;\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, {\n stdio: ['ignore', 'pipe', 'pipe'],\n cwd: opts.cwd,\n // Layered onto this process's environment rather than replacing it: the\n // child is a Node CLI that needs PATH and HOME, and only the keys named\n // here are being decided.\n ...(opts.env !== undefined ? { env: { ...process.env, ...opts.env } } : {}),\n });\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,cAAAA,aAAY,YAAAC,iBAAgB;AACrC,SAAS,eAAe;AACxB,SAAS,SAAS,OAAAC,YAAW;AAC7B,SAAS,qBAAqB;;;ACJ9B,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,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKE,MAAM,CAAC,cAAc,gBAAgB,SAAS,MAAM,SAAS,CAAC,aAAa,SAAS;AAAA,IACpF,OAAO,CAAC,SACN,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AI,WAAW,EAAE,MAAM,UAAU,IAAI,EAAE,MAAM,QAAQ,MAAM,QAAQ,EAAE,CAAC;AAAA,EACxE,CAAC;AACH,CAAC;","names":["existsSync","statSync","sep","statSync","sep","existsSync"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|