@szc-ft/mcp-szcd-client 0.33.0 → 0.34.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@szc-ft/mcp-szcd-client",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "description": "MCP client for szcd component library - auto-configures AI coding tools with MCP server, skills, agents and commands",
5
5
  "keywords": [
6
6
  "mcp",
@@ -22,6 +22,7 @@
22
22
  "bin": {
23
23
  "szcd-mcp-proxy": "mcp-proxy.js",
24
24
  "szcd-mcp-setup": "scripts/postinstall.js",
25
+ "szcd-mcp-install-shortcuts": "scripts/install-dev-shortcuts.js",
25
26
  "szcd-mcp-update-url": "scripts/update-mcp-url.js",
26
27
  "szcd-mcp-coding-config": "scripts/update-coding-config.js",
27
28
  "szcd-mcp-api-config": "scripts/update-api-config.js",
@@ -32,6 +33,7 @@
32
33
  "local-browser-executor.js",
33
34
  "lib/",
34
35
  "scripts/postinstall.js",
36
+ "scripts/install-dev-shortcuts.js",
35
37
  "scripts/update-mcp-url.js",
36
38
  "scripts/update-coding-config.js",
37
39
  "scripts/update-api-config.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "szcd-component-helper",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "description": "szcd 组件库 MCP 助手 — 查询组件信息、匹配需求、生成代码",
5
5
  "mcpServers": {
6
6
  "szcd-component-helper": {
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * install-dev-shortcuts.js — 手动重跑 dev-browser 快捷方式安装的 CLI
4
+ *
5
+ * 用途:postinstall 静默失败时(特别是 Windows 中文系统、AV 拦截、ExecutionPolicy 等)
6
+ * 用户跑 `npx szcd-mcp-install-shortcuts` 单独重试并看到完整错误信息。
7
+ *
8
+ * 与 postinstall 调用同一个 setupDevBrowserShortcut;本 CLI 区别在于:
9
+ * 1. 进程退出码:失败时 exit 1(postinstall 是 exit 0 不阻塞 npm install)
10
+ * 2. 输出更详细:直接传入 process 的 stdout / stderr,不被 npm install 折叠
11
+ * 3. 文末汇总:成功/失败计数 + 每条失败的完整错误,便于贴回 issue
12
+ */
13
+
14
+ import { setupDevBrowserShortcut } from "./lib/dev-browser-shortcut.js";
15
+
16
+ console.log("============================================================");
17
+ console.log(" szcd-mcp dev-browser DevSession shortcut installer");
18
+ console.log("============================================================");
19
+ console.log(`Platform: ${process.platform}`);
20
+ console.log(`Node: ${process.version}`);
21
+ console.log("");
22
+
23
+ const result = setupDevBrowserShortcut({});
24
+
25
+ console.log("");
26
+ console.log("============================================================");
27
+ console.log(" Summary");
28
+ console.log("============================================================");
29
+ if (result.skipped) {
30
+ console.log("⚠️ No Chrome/Edge detected on this machine.");
31
+ console.log(" Install Google Chrome or Microsoft Edge, then re-run this command.");
32
+ process.exit(1);
33
+ }
34
+
35
+ const okCount = result.results.filter(r => r.ok).length;
36
+ const total = result.results.length;
37
+ console.log(`Installed: ${okCount}/${total}`);
38
+ for (const r of result.results) {
39
+ if (r.ok) {
40
+ console.log(` ✓ ${r.name}: ${r.path}`);
41
+ } else {
42
+ console.log(` ✗ ${r.name}:`);
43
+ for (const line of String(r.error || "(unknown error)").split("\n")) {
44
+ console.log(` ${line}`);
45
+ }
46
+ }
47
+ }
48
+ console.log("");
49
+
50
+ process.exit(result.ok ? 0 : 1);
@@ -19,7 +19,7 @@
19
19
  import fs from "node:fs";
20
20
  import path from "node:path";
21
21
  import os from "node:os";
22
- import { execSync } from "node:child_process";
22
+ import { execSync, spawnSync } from "node:child_process";
23
23
 
24
24
  // 与 SKILL.md 第 186-191 行保持一致
25
25
  const CDP_PORT = 9222;
@@ -117,12 +117,40 @@ function installWindows(browser) {
117
117
  ].join("; ");
118
118
  // -EncodedCommand 要求脚本块本身是 UTF-16LE base64
119
119
  const encoded = Buffer.from(psScript, "utf16le").toString("base64");
120
- try {
121
- execSync(`powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand ${encoded}`, { stdio: "ignore" });
122
- return { ok: true, path: lnkPath };
123
- } catch (e) {
124
- return { ok: false, error: e.message };
120
+
121
+ // 反馈 #18(2026-06-24, accuracy=1):原先用
122
+ // execSync('powershell ... -EncodedCommand ...', { stdio: 'ignore' })
123
+ // 在中文 Windows + 全局 npm install 场景下静默失败:execSync 经 cmd.exe /d /s /c
124
+ // 调用 PowerShell,中文 Windows PowerShell 启动期向 stderr 写 CLIXML
125
+ // (progress/information record),stdio:'ignore' 导致 stderr 写入失败,
126
+ // PowerShell 以 exit code 1 终止,CreateShortcut COM 调用未执行;
127
+ // 外层 try/catch 仅 console.warn,postinstall 整体仍成功,用户无法察觉。
128
+ //
129
+ // 修复:用 spawnSync 直接调 powershell.exe,绕开 cmd.exe;stderr/stdout 用 pipe
130
+ // 而不是 ignore,捕获真实失败信息以便排查。
131
+ const result = spawnSync(
132
+ "powershell.exe",
133
+ ["-NoProfile", "-ExecutionPolicy", "Bypass", "-EncodedCommand", encoded],
134
+ { stdio: ["ignore", "pipe", "pipe"], windowsHide: true }
135
+ );
136
+ if (result.error) {
137
+ return { ok: false, error: `spawn failed: ${result.error.message}` };
125
138
  }
139
+ if (result.status !== 0) {
140
+ const stderr = (result.stderr?.toString() || "").trim();
141
+ const stdout = (result.stdout?.toString() || "").trim();
142
+ return {
143
+ ok: false,
144
+ error: `powershell exit code ${result.status}` +
145
+ (stderr ? `\n stderr: ${stderr.slice(0, 400)}` : "") +
146
+ (stdout ? `\n stdout: ${stdout.slice(0, 200)}` : ""),
147
+ };
148
+ }
149
+ // 二次校验:文件实际存在再算成功
150
+ if (!fs.existsSync(lnkPath)) {
151
+ return { ok: false, error: `powershell exit 0 but ${lnkPath} not created` };
152
+ }
153
+ return { ok: true, path: lnkPath };
126
154
  }
127
155
 
128
156
  // 字符串 → UTF-8 bytes → base64,给 PowerShell 内联反序列化用
@@ -216,14 +244,15 @@ export function setupDevBrowserShortcut(deps = {}) {
216
244
  installLinux;
217
245
  for (const b of browsers) {
218
246
  const r = install(b);
219
- results.push({ browser: b.id, ...r });
247
+ results.push({ browser: b.id, name: b.name, ...r });
220
248
  if (r.ok) {
221
249
  console.log(`✓ Created ${b.name} DevSession shortcut: ${r.path}`);
222
250
  } else {
223
- console.warn(`⚠️ Failed to create ${b.name} DevSession shortcut: ${r.error}`);
251
+ console.warn(`⚠️ Failed to create ${b.name} DevSession shortcut:\n ${r.error}`);
224
252
  }
225
253
  }
226
254
  const okCount = results.filter(r => r.ok).length;
255
+ const failCount = results.length - okCount;
227
256
  if (okCount > 0) {
228
257
  const dirHint = platform === "win32" ? "桌面 (Desktop)"
229
258
  : platform === "darwin" ? "~/Applications/ (Launchpad / Spotlight)"
@@ -231,7 +260,16 @@ export function setupDevBrowserShortcut(deps = {}) {
231
260
  console.log(`\n💡 Double-click the "DevSession" shortcut in ${dirHint} to start a CDP-enabled browser`);
232
261
  console.log(` on port ${CDP_PORT} with an isolated profile, then re-run your local-browser-test plan.`);
233
262
  }
234
- return { ok: okCount > 0, results };
263
+ if (failCount > 0) {
264
+ // 醒目告警 + 手动重跑命令(反馈 #18 要求)
265
+ console.warn("");
266
+ console.warn("⚠️ ============================================================");
267
+ console.warn(`⚠️ ${failCount}/${results.length} dev-browser shortcut(s) failed to install.`);
268
+ console.warn("⚠️ Re-run the dedicated CLI to retry with full diagnostics:");
269
+ console.warn("⚠️ npx szcd-mcp-install-shortcuts");
270
+ console.warn("⚠️ ============================================================");
271
+ }
272
+ return { ok: okCount > 0 && failCount === 0, results, platform };
235
273
  } catch (e) {
236
274
  console.warn(`⚠️ setupDevBrowserShortcut error: ${e.message}`);
237
275
  return { ok: false, results, error: e.message };