@szc-ft/mcp-szcd-client 0.32.0 → 0.32.1

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.32.0",
3
+ "version": "0.32.1",
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",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "szcd-component-helper",
3
- "version": "0.32.0",
3
+ "version": "0.32.1",
4
4
  "description": "szcd 组件库 MCP 助手 — 查询组件信息、匹配需求、生成代码",
5
5
  "mcpServers": {
6
6
  "szcd-component-helper": {
@@ -103,24 +103,33 @@ function installWindows(browser) {
103
103
  const lnkPath = path.join(desktop, `${browser.name} DevSession.lnk`);
104
104
 
105
105
  // PowerShell 创建 .lnk
106
- // 注意:PowerShell -Command 参数里的双引号、反斜杠都得转义
107
- const ps = [
108
- `$s = (New-Object -ComObject WScript.Shell).CreateShortcut('${lnkPath.replace(/'/g, "''")}')`,
109
- `$s.TargetPath = '${browser.exe.replace(/'/g, "''")}'`,
110
- `$s.Arguments = '${args.replace(/'/g, "''")}'`,
111
- `$s.WorkingDirectory = '${path.dirname(browser.exe).replace(/'/g, "''")}'`,
112
- `$s.IconLocation = '${browser.exe.replace(/'/g, "''")},0'`,
113
- `$s.Description = '${browser.name} CDP dev mode (port ${CDP_PORT}) — used by szcd local-browser-test'`,
106
+ // 注意:Arguments 字符串里含 "C:/..." 这种裸双引号;为彻底避开 shell 引号嵌套,
107
+ // PowerShell -EncodedCommand:脚本块以 UTF-16LE 序列化后 base64 传入,
108
+ // 不再依赖 cmd / bash 的引号转义规则。
109
+ const psScript = [
110
+ `$s = (New-Object -ComObject WScript.Shell).CreateShortcut([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(lnkPath)}')))`,
111
+ `$s.TargetPath = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(browser.exe)}'))`,
112
+ `$s.Arguments = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(args)}'))`,
113
+ `$s.WorkingDirectory = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(path.dirname(browser.exe))}'))`,
114
+ `$s.IconLocation = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(browser.exe + ",0")}'))`,
115
+ `$s.Description = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(browser.name + " CDP dev mode (port " + CDP_PORT + ") — used by szcd local-browser-test")}'))`,
114
116
  `$s.Save()`,
115
117
  ].join("; ");
118
+ // -EncodedCommand 要求脚本块本身是 UTF-16LE base64
119
+ const encoded = Buffer.from(psScript, "utf16le").toString("base64");
116
120
  try {
117
- execSync(`powershell -NoProfile -ExecutionPolicy Bypass -Command "${ps}"`, { stdio: "ignore" });
121
+ execSync(`powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand ${encoded}`, { stdio: "ignore" });
118
122
  return { ok: true, path: lnkPath };
119
123
  } catch (e) {
120
124
  return { ok: false, error: e.message };
121
125
  }
122
126
  }
123
127
 
128
+ // 字符串 → UTF-8 bytes → base64,给 PowerShell 内联反序列化用
129
+ function b64utf8(s) {
130
+ return Buffer.from(String(s), "utf8").toString("base64");
131
+ }
132
+
124
133
  function installMac(browser) {
125
134
  const dataDir = getUserDataDir(browser.id, "darwin");
126
135
  const appDir = path.join(os.homedir(), "Applications");