@cup319/mmpl-rust 0.1.0 → 0.2.0
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/install.js +68 -0
- package/mmpl-v0.2.0-linux-x86_64.tar.gz +0 -0
- package/package.json +8 -7
- package/run.js +15 -0
package/install.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* MMPL Rust 版 npm 安装器 v2
|
|
4
|
+
* 优先用包内自带 tar.gz(离线可用);缺失时回落 CNB Release 下载(需公开访问)。
|
|
5
|
+
*/
|
|
6
|
+
const { createWriteStream, existsSync, mkdirSync, chmodSync } = require("fs");
|
|
7
|
+
const { pipeline } = require("stream/promises");
|
|
8
|
+
const { get } = require("https");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const { execSync } = require("child_process");
|
|
11
|
+
|
|
12
|
+
const VERSION = "0.2.0";
|
|
13
|
+
const ASSET_NAME = `mmpl-v${VERSION}-linux-x86_64.tar.gz`;
|
|
14
|
+
const URL = `https://cnb.cool/cnb-t/MMPL/-/releases/download/rust-v${VERSION}/${ASSET_NAME}`;
|
|
15
|
+
const BIN = path.join(__dirname, "bin", "mmpl");
|
|
16
|
+
const BUNDLED = path.join(__dirname, ASSET_NAME);
|
|
17
|
+
|
|
18
|
+
function extract(tarPath) {
|
|
19
|
+
mkdirSync(path.dirname(BIN), { recursive: true });
|
|
20
|
+
execSync(`tar xzf ${JSON.stringify(tarPath)} -C ${JSON.stringify(path.dirname(BIN))}`);
|
|
21
|
+
execSync(`mv ${JSON.stringify(path.join(path.dirname(BIN), "mmpl-linux-x86_64"))} ${JSON.stringify(BIN)}`);
|
|
22
|
+
chmodSync(BIN, 0o755);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function download(url, redirects = 5) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
get(url, { headers: { "User-Agent": "mmpl-installer" } }, (res) => {
|
|
28
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location && redirects > 0) {
|
|
29
|
+
res.resume();
|
|
30
|
+
return resolve(download(res.headers.location, redirects - 1));
|
|
31
|
+
}
|
|
32
|
+
if (res.statusCode !== 200) {
|
|
33
|
+
res.resume();
|
|
34
|
+
return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
|
|
35
|
+
}
|
|
36
|
+
resolve(res);
|
|
37
|
+
}).on("error", reject);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function main() {
|
|
42
|
+
if (existsSync(BIN)) return;
|
|
43
|
+
|
|
44
|
+
// 1) 包内自带(发布时打入)
|
|
45
|
+
if (existsSync(BUNDLED)) {
|
|
46
|
+
console.log("[mmpl] extracting bundled binary ...");
|
|
47
|
+
extract(BUNDLED);
|
|
48
|
+
console.log(`[mmpl] installed: ${BIN}`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 2) 回落下载
|
|
53
|
+
console.log(`[mmpl] downloading Rust binary v${VERSION} ...`);
|
|
54
|
+
try {
|
|
55
|
+
const res = await download(URL);
|
|
56
|
+
const tmpTar = BIN + ".tar.gz";
|
|
57
|
+
await pipeline(res, createWriteStream(tmpTar));
|
|
58
|
+
extract(tmpTar);
|
|
59
|
+
execSync(`rm -f ${JSON.stringify(tmpTar)}`);
|
|
60
|
+
console.log(`[mmpl] installed: ${BIN}`);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.warn(`[mmpl] ⚠️ install failed: ${e.message}`);
|
|
63
|
+
console.warn(`[mmpl] 手动安装: curl -LO ${URL} && tar xzf ${ASSET_NAME}`);
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main();
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cup319/mmpl-rust",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "MMPL (Memory Palace) Rust Edition — 单二进制 DuckDB 向量记忆 MCP Server (
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "MMPL (Memory Palace) Rust Edition — 单二进制 DuckDB 向量记忆 MCP Server (9 工具全量: 检索/生命周期/L0-L3 管道/宫殿/符号压缩)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
8
8
|
"registry": "https://registry.npmjs.org/"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
|
-
"mmpl-rust": "./
|
|
11
|
+
"mmpl-rust": "./run.js"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
|
-
"
|
|
14
|
+
"install.js",
|
|
15
|
+
"run.js",
|
|
15
16
|
"README.md",
|
|
16
|
-
"
|
|
17
|
+
"mmpl-v0.2.0-linux-x86_64.tar.gz"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
|
-
"postinstall": "node
|
|
20
|
+
"postinstall": "node install.js"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [
|
|
22
23
|
"mcp",
|
|
@@ -31,4 +32,4 @@
|
|
|
31
32
|
"url": "https://cnb.cool/cnb-t/MMPL.git",
|
|
32
33
|
"directory": "rust"
|
|
33
34
|
}
|
|
34
|
-
}
|
|
35
|
+
}
|
package/run.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** bin 入口:转发到下载好的二进制 */
|
|
3
|
+
const { spawn } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const BIN = path.join(__dirname, "bin", "mmpl");
|
|
7
|
+
const child = spawn(BIN, process.argv.slice(2), {
|
|
8
|
+
stdio: "inherit",
|
|
9
|
+
env: process.env,
|
|
10
|
+
});
|
|
11
|
+
child.on("error", (e) => {
|
|
12
|
+
console.error("[mmpl-rust] binary not found — run `npm rebuild @cup319/mmpl-rust` or see README");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
});
|
|
15
|
+
child.on("exit", (code) => process.exit(code ?? 1));
|