tokenizor-mcp 0.3.2 → 0.3.3
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/bin/tokenizor-mcp.js +4 -2
- package/package.json +1 -1
- package/scripts/install.js +12 -12
package/bin/tokenizor-mcp.js
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
|
+
const os = require("os");
|
|
6
7
|
|
|
7
8
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
8
|
-
const
|
|
9
|
-
const
|
|
9
|
+
const installDir = path.join(os.homedir(), ".tokenizor", "bin");
|
|
10
|
+
const binPath = path.join(installDir, "tokenizor-mcp" + ext);
|
|
11
|
+
const pendingPath = path.join(installDir, "tokenizor-mcp.pending" + ext);
|
|
10
12
|
|
|
11
13
|
// Apply pending update if one was staged (binary was locked during npm update)
|
|
12
14
|
if (fs.existsSync(pendingPath)) {
|
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
const { execSync } = require("child_process");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
7
|
+
const os = require("os");
|
|
7
8
|
const https = require("https");
|
|
8
9
|
const http = require("http");
|
|
9
10
|
|
|
10
11
|
const REPO = "special-place-administrator/tokenizor_agentic_mcp";
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
// Binary lives outside node_modules so npm can update the JS wrapper
|
|
14
|
+
// even while the MCP server holds a lock on the running .exe (Windows).
|
|
15
|
+
const INSTALL_DIR = path.join(os.homedir(), ".tokenizor", "bin");
|
|
12
16
|
|
|
13
17
|
function getPlatformArtifact() {
|
|
14
18
|
const platform = process.platform;
|
|
@@ -31,12 +35,12 @@ function getVersion() {
|
|
|
31
35
|
|
|
32
36
|
function getBinaryPath() {
|
|
33
37
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
34
|
-
return path.join(
|
|
38
|
+
return path.join(INSTALL_DIR, "tokenizor-mcp" + ext);
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
function getPendingPath() {
|
|
38
42
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
39
|
-
return path.join(
|
|
43
|
+
return path.join(INSTALL_DIR, "tokenizor-mcp.pending" + ext);
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
function download(url) {
|
|
@@ -79,13 +83,12 @@ async function main() {
|
|
|
79
83
|
if (fs.existsSync(binPath)) {
|
|
80
84
|
const installed = getInstalledVersion(binPath);
|
|
81
85
|
if (installed === version) {
|
|
82
|
-
// Clean up any stale pending file
|
|
83
86
|
try { fs.unlinkSync(pendingPath); } catch {}
|
|
84
|
-
console.log(`tokenizor-mcp v${version} already installed
|
|
87
|
+
console.log(`tokenizor-mcp v${version} already installed at ${binPath}`);
|
|
85
88
|
return;
|
|
86
89
|
}
|
|
87
90
|
console.log(
|
|
88
|
-
`tokenizor-mcp
|
|
91
|
+
`tokenizor-mcp v${installed || "unknown"} found, updating to v${version}...`
|
|
89
92
|
);
|
|
90
93
|
}
|
|
91
94
|
|
|
@@ -97,23 +100,20 @@ async function main() {
|
|
|
97
100
|
|
|
98
101
|
try {
|
|
99
102
|
const data = await download(url);
|
|
100
|
-
fs.mkdirSync(
|
|
103
|
+
fs.mkdirSync(INSTALL_DIR, { recursive: true });
|
|
101
104
|
|
|
102
|
-
// Try writing directly to the target path
|
|
103
105
|
try {
|
|
104
106
|
fs.writeFileSync(binPath, data);
|
|
105
107
|
fs.chmodSync(binPath, 0o755);
|
|
106
|
-
// Clean up any stale pending file
|
|
107
108
|
try { fs.unlinkSync(pendingPath); } catch {}
|
|
108
109
|
console.log(`Installed: ${binPath}`);
|
|
109
110
|
} catch (writeErr) {
|
|
110
|
-
//
|
|
111
|
-
// Write to a .pending file — the JS wrapper will swap it in on next launch.
|
|
111
|
+
// Binary locked by running MCP server — stage for next launch
|
|
112
112
|
if (writeErr.code === "EPERM" || writeErr.code === "EBUSY") {
|
|
113
113
|
fs.writeFileSync(pendingPath, data);
|
|
114
114
|
fs.chmodSync(pendingPath, 0o755);
|
|
115
115
|
console.log(`Binary is locked (MCP server running). Staged update at: ${pendingPath}`);
|
|
116
|
-
console.log(`
|
|
116
|
+
console.log(`Update will apply automatically on next launch.`);
|
|
117
117
|
} else {
|
|
118
118
|
throw writeErr;
|
|
119
119
|
}
|