@ada-mcp/launcher 0.1.43 → 0.1.45

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 (3) hide show
  1. package/README.md +11 -10
  2. package/launcher.mjs +34 -6
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  "mcpServers": {
10
10
  "ada-mcp": {
11
11
  "command": "pnpm",
12
- "args": ["dlx", "@ada-mcp/launcher@0.1.43"]
12
+ "args": ["dlx", "@ada-mcp/launcher@0.1.45"]
13
13
  }
14
14
  }
15
15
  }
@@ -18,13 +18,13 @@
18
18
  命令行:
19
19
 
20
20
  ```bash
21
- pnpm dlx @ada-mcp/launcher@0.1.43
21
+ pnpm dlx @ada-mcp/launcher@0.1.45
22
22
  ```
23
23
 
24
24
  npx 等价:
25
25
 
26
26
  ```bash
27
- npx -y @ada-mcp/launcher@0.1.43
27
+ npx -y @ada-mcp/launcher@0.1.45
28
28
  ```
29
29
 
30
30
  **npx 示例**:
@@ -34,7 +34,7 @@ npx -y @ada-mcp/launcher@0.1.43
34
34
  "mcpServers": {
35
35
  "ada-mcp": {
36
36
  "command": "npx",
37
- "args": ["-y", "@ada-mcp/launcher@0.1.43"]
37
+ "args": ["-y", "@ada-mcp/launcher@0.1.45"]
38
38
  }
39
39
  }
40
40
  }
@@ -42,9 +42,10 @@ npx -y @ada-mcp/launcher@0.1.43
42
42
 
43
43
  ## 版本
44
44
 
45
- - **使用**:`pnpm dlx @ada-mcp/launcher` 或 `@ada-mcp/launcher@0.1.43` 均可;不写 `@x.y.z` 时拉 npm **latest**(推荐生产环境钉版本)。
45
+ - **使用**:`pnpm dlx @ada-mcp/launcher` 或 `@ada-mcp/launcher@0.1.45` 均可;不写 `@x.y.z` 时拉 npm **latest**(推荐生产环境钉版本)。
46
46
  - **发布**:每次 `npm publish` 前必须在 `package.json` **递增 version**;不能重复发布同一版本。
47
- - **0.1.43**:修复 0.1.41 错误依赖未发布的 `@ada/download-probe`;探测逻辑已内联到本包。
47
+ - **0.1.44**:修复 `package.json` UTF-8 BOM 导致 JSON 解析失败;内联 download-probe,去掉未发布的 `@ada/download-probe` 依赖。
48
+ - **0.1.45**:Windows + `npx` 回退路径中 `npm install` 经 `cmd.exe /c` 执行,修复 `spawn EINVAL`(勿直接 `execFileSync('npm.cmd')`)。
48
49
 
49
50
  ## 可选环境变量
50
51
 
@@ -60,9 +61,9 @@ npx -y @ada-mcp/launcher@0.1.43
60
61
 
61
62
  | 方式 | 拉 MCP 包 | 安装 playwright 等 |
62
63
  |------|-----------|-------------------|
63
- | **`pnpm dlx @ada-mcp/launcher@0.1.43`**(标准) | launcher 测速 + `.npmrc` → `pnpm dlx` mcp-server | mcp-server preinstall + bootstrap |
64
- | **`npx -y @ada-mcp/launcher@0.1.43`** | 同上 → **`npx -y` mcp-server** | 同上 |
65
- | `pnpm dlx @ada-mcp/mcp-server@0.1.43` | 本机默认源 | 有 preinstall / bootstrap 测速 |
66
- | `npx -y @ada-mcp/mcp-server@0.1.43` | 无 launcher 测速 | 有 preinstall / bootstrap 测速 |
64
+ | **`pnpm dlx @ada-mcp/launcher@0.1.45`**(标准) | launcher 测速 + `.npmrc` → `pnpm dlx` mcp-server | mcp-server preinstall + bootstrap |
65
+ | **`npx -y @ada-mcp/launcher@0.1.45`** | 同上 → **`npx -y` mcp-server** | 同上 |
66
+ | `pnpm dlx @ada-mcp/mcp-server@0.1.45` | 本机默认源 | 有 preinstall / bootstrap 测速 |
67
+ | `npx -y @ada-mcp/mcp-server@0.1.45` | 无 launcher 测速 | 有 preinstall / bootstrap 测速 |
67
68
 
68
69
  内置 registry 测速候选顺序(相同时靠前优先):**npmmirror(阿里)** → npmjs → 腾讯 → 上海交大 → 中科大 → 华为云。
package/launcher.mjs CHANGED
@@ -18,8 +18,16 @@ import {
18
18
 
19
19
  const NPMJS_REGISTRY = "https://registry.npmjs.org";
20
20
 
21
+ function readJsonFile(filePath) {
22
+ let raw = fs.readFileSync(filePath, "utf8");
23
+ if (raw.charCodeAt(0) === 0xfeff) {
24
+ raw = raw.slice(1);
25
+ }
26
+ return JSON.parse(raw);
27
+ }
28
+
21
29
  const LAUNCHER_DIR = path.dirname(fileURLToPath(import.meta.url));
22
- const LAUNCHER_PKG = JSON.parse(fs.readFileSync(path.join(LAUNCHER_DIR, "package.json"), "utf8"));
30
+ const LAUNCHER_PKG = readJsonFile(path.join(LAUNCHER_DIR, "package.json"));
23
31
  const LAUNCHER_VERSION = String(LAUNCHER_PKG.version ?? "0.0.0");
24
32
  const LAUNCHER_PKG_NAME = "@ada-mcp/launcher";
25
33
 
@@ -190,12 +198,17 @@ function quoteCmdToken(token) {
190
198
  return s;
191
199
  }
192
200
 
201
+ function win32CmdLine(executable, args) {
202
+ const comspec = process.env.ComSpec || "cmd.exe";
203
+ const line = [quoteCmdToken(executable), ...args.map(quoteCmdToken)].join(" ");
204
+ return { comspec, line };
205
+ }
206
+
193
207
  function spawnRunner(executable, args, options = {}) {
194
208
  const { stdio = "inherit", cwd, env } = options;
195
209
  const childEnv = env ?? process.env;
196
210
  if (process.platform === "win32") {
197
- const comspec = process.env.ComSpec || "cmd.exe";
198
- const line = [quoteCmdToken(executable), ...args.map(quoteCmdToken)].join(" ");
211
+ const { comspec, line } = win32CmdLine(executable, args);
199
212
  return spawn(comspec, ["/d", "/s", "/c", line], {
200
213
  stdio,
201
214
  cwd,
@@ -212,6 +225,22 @@ function spawnRunner(executable, args, options = {}) {
212
225
  });
213
226
  }
214
227
 
228
+ /** 与 spawnRunner 相同:Windows 下经 cmd.exe /c,避免对 npm.cmd 直接 exec 触发 EINVAL */
229
+ function execRunnerSync(executable, args, options = {}) {
230
+ const { stdio = "inherit", cwd, env } = options;
231
+ const childEnv = env ?? process.env;
232
+ if (process.platform === "win32") {
233
+ const { comspec, line } = win32CmdLine(executable, args);
234
+ return execFileSync(comspec, ["/d", "/s", "/c", line], {
235
+ cwd,
236
+ env: childEnv,
237
+ stdio,
238
+ windowsHide: true
239
+ });
240
+ }
241
+ return execFileSync(executable, args, { cwd, env: childEnv, stdio });
242
+ }
243
+
215
244
  function runnerArgs(runner, pkgSpec, extra) {
216
245
  if (runner === "pnpm") {
217
246
  return ["dlx", pkgSpec, ...extra];
@@ -307,10 +336,9 @@ async function resolvePackageRunner() {
307
336
  function spawnMcpServerViaNodeInstall(pkgSpec, extra, options) {
308
337
  const { cwd, env } = options;
309
338
  const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "ada-mcp-run-"));
310
- const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
311
339
  console.error(`[ada-mcp launcher] Windows npx fallback: npm install ${pkgSpec} -> node cli.cjs`);
312
- execFileSync(
313
- npmCmd,
340
+ execRunnerSync(
341
+ "npm",
314
342
  ["install", pkgSpec, "--omit=dev", "--no-fund", "--no-audit", "--loglevel=error"],
315
343
  { cwd: tmpDir, env, stdio: "inherit" }
316
344
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
- {
1
+ {
2
2
  "name": "@ada-mcp/launcher",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "description": "Probe fastest npm registry then pnpm dlx @ada-mcp/mcp-server (zero deps)",
5
5
  "private": false,
6
6
  "type": "module",