@szc-ft/mcp-szcd-client 0.31.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.
@@ -182,13 +182,21 @@ Agent / SKILL.md
182
182
  结果缓存到 `~/.szcd-mcp/deps/decrypted-creds.json`。后续可直接用 `engine._credentials` 获取。
183
183
 
184
184
  用户一次性配置:
185
+
186
+ > 💡 **快捷方式自动创建**:`npm install @szc-ft/mcp-szcd-client` 时,postinstall 会自动检测本机
187
+ > Chrome / Edge 并在系统应用启动器里创建一个 **"DevSession"** 快捷方式(不动主图标、独立 profile、
188
+ > 默认 9222 端口)。双击该图标即可启动,下面命令仅作 fallback / 自定义参考。
189
+ >
190
+ > 落点:Windows 桌面 `.lnk`、macOS `~/Applications/<Name> DevSession.app`、
191
+ > Linux `~/.local/share/applications/szcd-<id>-devsession.desktop`。
192
+
185
193
  ```bash
186
194
  # macOS
187
- open -a "Google Chrome" --args --remote-debugging-port=9222
195
+ open -a "Google Chrome" --args --disable-features=RendererCodeIntegrity --disable-web-security --user-data-dir="$HOME/ChromeDevSession" --remote-debugging-port=9222
188
196
  # Linux
189
- google-chrome --remote-debugging-port=9222
197
+ google-chrome --disable-features=RendererCodeIntegrity --disable-web-security --user-data-dir="$HOME/ChromeDevSession" --remote-debugging-port=9222
190
198
  # Windows
191
- "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
199
+ "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --disable-features=RendererCodeIntegrity --disable-web-security --user-data-dir="C:/EdgeDevSession" --remote-debugging-port=9222
192
200
  ```
193
201
 
194
202
  ### launch 模式(回退)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@szc-ft/mcp-szcd-client",
3
- "version": "0.31.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.31.0",
3
+ "version": "0.32.1",
4
4
  "description": "szcd 组件库 MCP 助手 — 查询组件信息、匹配需求、生成代码",
5
5
  "mcpServers": {
6
6
  "szcd-component-helper": {
@@ -182,13 +182,21 @@ Agent / SKILL.md
182
182
  结果缓存到 `~/.szcd-mcp/deps/decrypted-creds.json`。后续可直接用 `engine._credentials` 获取。
183
183
 
184
184
  用户一次性配置:
185
+
186
+ > 💡 **快捷方式自动创建**:`npm install @szc-ft/mcp-szcd-client` 时,postinstall 会自动检测本机
187
+ > Chrome / Edge 并在系统应用启动器里创建一个 **"DevSession"** 快捷方式(不动主图标、独立 profile、
188
+ > 默认 9222 端口)。双击该图标即可启动,下面命令仅作 fallback / 自定义参考。
189
+ >
190
+ > 落点:Windows 桌面 `.lnk`、macOS `~/Applications/<Name> DevSession.app`、
191
+ > Linux `~/.local/share/applications/szcd-<id>-devsession.desktop`。
192
+
185
193
  ```bash
186
194
  # macOS
187
- open -a "Google Chrome" --args --remote-debugging-port=9222
195
+ open -a "Google Chrome" --args --disable-features=RendererCodeIntegrity --disable-web-security --user-data-dir="$HOME/ChromeDevSession" --remote-debugging-port=9222
188
196
  # Linux
189
- google-chrome --remote-debugging-port=9222
197
+ google-chrome --disable-features=RendererCodeIntegrity --disable-web-security --user-data-dir="$HOME/ChromeDevSession" --remote-debugging-port=9222
190
198
  # Windows
191
- "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
199
+ "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --disable-features=RendererCodeIntegrity --disable-web-security --user-data-dir="C:/EdgeDevSession" --remote-debugging-port=9222
192
200
  ```
193
201
 
194
202
  ### launch 模式(回退)
@@ -0,0 +1,239 @@
1
+ /**
2
+ * dev-browser-shortcut.js — 为本地浏览器自动化创建"开发模式"快捷方式
3
+ *
4
+ * 目标:用户装包后无需手动敲 --remote-debugging-port=9222 等一长串参数,
5
+ * 双击快捷方式即可启动一个开 CDP + 独立 profile 的浏览器,配合 local-browser-test skill。
6
+ *
7
+ * 设计原则:
8
+ * 1. 不动用户主浏览器快捷方式 / Dock 图标 / 默认 profile
9
+ * 2. 同时检测 Chrome 和 Edge,找到几个就装几个(每个一个独立 profile)
10
+ * 3. 已存在的快捷方式覆盖(保持参数与 SKILL.md 同步),新版本能自动升级参数
11
+ * 4. 任何子步骤失败都只 warn,绝不让整个 postinstall 退出
12
+ *
13
+ * 三平台落点:
14
+ * Windows: 用户桌面 .lnk(PowerShell + WScript.Shell COM)
15
+ * Linux: ~/.local/share/applications/<id>.desktop + chmod +x(更新 desktop database 可选)
16
+ * macOS: ~/Applications/<Name> DevSession.app (wrapper .app,bash 启动器)
17
+ */
18
+
19
+ import fs from "node:fs";
20
+ import path from "node:path";
21
+ import os from "node:os";
22
+ import { execSync } from "node:child_process";
23
+
24
+ // 与 SKILL.md 第 186-191 行保持一致
25
+ const CDP_PORT = 9222;
26
+ const COMMON_FLAGS = [
27
+ "--disable-features=RendererCodeIntegrity",
28
+ "--disable-web-security",
29
+ `--remote-debugging-port=${CDP_PORT}`,
30
+ ];
31
+
32
+ // user-data-dir 与 SKILL.md 固定路径一致
33
+ function getUserDataDir(browser, platform) {
34
+ if (platform === "win32") {
35
+ return browser === "edge" ? "C:/EdgeDevSession" : "C:/ChromeDevSession";
36
+ }
37
+ return path.join(os.homedir(), browser === "edge" ? "EdgeDevSession" : "ChromeDevSession");
38
+ }
39
+
40
+ // ============ 浏览器检测 ============
41
+
42
+ function detectBrowsers(platform) {
43
+ const found = [];
44
+ if (platform === "win32") {
45
+ const candidates = [
46
+ { id: "edge", name: "Microsoft Edge", paths: [
47
+ "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe",
48
+ "C:/Program Files/Microsoft/Edge/Application/msedge.exe",
49
+ ]},
50
+ { id: "chrome", name: "Google Chrome", paths: [
51
+ "C:/Program Files/Google/Chrome/Application/chrome.exe",
52
+ "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
53
+ path.join(os.homedir(), "AppData/Local/Google/Chrome/Application/chrome.exe"),
54
+ ]},
55
+ ];
56
+ for (const c of candidates) {
57
+ const hit = c.paths.find(p => safeExists(p));
58
+ if (hit) found.push({ ...c, exe: hit });
59
+ }
60
+ } else if (platform === "darwin") {
61
+ const candidates = [
62
+ { id: "chrome", name: "Google Chrome",
63
+ app: "/Applications/Google Chrome.app",
64
+ exe: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" },
65
+ { id: "edge", name: "Microsoft Edge",
66
+ app: "/Applications/Microsoft Edge.app",
67
+ exe: "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" },
68
+ ];
69
+ for (const c of candidates) {
70
+ if (safeExists(c.app)) found.push(c);
71
+ }
72
+ } else {
73
+ // linux
74
+ const candidates = [
75
+ { id: "chrome", name: "Google Chrome", cmds: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"] },
76
+ { id: "edge", name: "Microsoft Edge", cmds: ["microsoft-edge", "microsoft-edge-stable"] },
77
+ ];
78
+ for (const c of candidates) {
79
+ const exe = c.cmds.map(which).find(Boolean);
80
+ if (exe) found.push({ id: c.id, name: c.name, exe });
81
+ }
82
+ }
83
+ return found;
84
+ }
85
+
86
+ function safeExists(p) {
87
+ try { return fs.existsSync(p); } catch { return false; }
88
+ }
89
+
90
+ function which(cmd) {
91
+ try {
92
+ const out = execSync(`command -v ${cmd}`, { stdio: ["ignore", "pipe", "ignore"] }).toString().trim();
93
+ return out || null;
94
+ } catch { return null; }
95
+ }
96
+
97
+ // ============ 平台实现 ============
98
+
99
+ function installWindows(browser) {
100
+ const dataDir = getUserDataDir(browser.id, "win32");
101
+ const args = [`--user-data-dir="${dataDir}"`, ...COMMON_FLAGS].join(" ");
102
+ const desktop = path.join(os.homedir(), "Desktop");
103
+ const lnkPath = path.join(desktop, `${browser.name} DevSession.lnk`);
104
+
105
+ // PowerShell 创建 .lnk
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")}'))`,
116
+ `$s.Save()`,
117
+ ].join("; ");
118
+ // -EncodedCommand 要求脚本块本身是 UTF-16LE base64
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 };
125
+ }
126
+ }
127
+
128
+ // 字符串 → UTF-8 bytes → base64,给 PowerShell 内联反序列化用
129
+ function b64utf8(s) {
130
+ return Buffer.from(String(s), "utf8").toString("base64");
131
+ }
132
+
133
+ function installMac(browser) {
134
+ const dataDir = getUserDataDir(browser.id, "darwin");
135
+ const appDir = path.join(os.homedir(), "Applications");
136
+ const wrapperApp = path.join(appDir, `${browser.name} DevSession.app`);
137
+ const macosDir = path.join(wrapperApp, "Contents", "MacOS");
138
+ const resourcesDir = path.join(wrapperApp, "Contents", "Resources");
139
+ const plistPath = path.join(wrapperApp, "Contents", "Info.plist");
140
+ const execName = "launch";
141
+ const execPath = path.join(macosDir, execName);
142
+
143
+ try {
144
+ fs.mkdirSync(macosDir, { recursive: true });
145
+ fs.mkdirSync(resourcesDir, { recursive: true });
146
+ const script = [
147
+ "#!/bin/bash",
148
+ `exec "${browser.exe}" --user-data-dir="${dataDir}" ${COMMON_FLAGS.join(" ")} "$@"`,
149
+ "",
150
+ ].join("\n");
151
+ fs.writeFileSync(execPath, script, { mode: 0o755 });
152
+ const plist = `<?xml version="1.0" encoding="UTF-8"?>
153
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
154
+ <plist version="1.0">
155
+ <dict>
156
+ <key>CFBundleExecutable</key><string>${execName}</string>
157
+ <key>CFBundleName</key><string>${browser.name} DevSession</string>
158
+ <key>CFBundleIdentifier</key><string>com.szc-ft.${browser.id}-devsession</string>
159
+ <key>CFBundlePackageType</key><string>APPL</string>
160
+ <key>CFBundleVersion</key><string>1</string>
161
+ <key>LSUIElement</key><false/>
162
+ </dict>
163
+ </plist>
164
+ `;
165
+ fs.writeFileSync(plistPath, plist);
166
+ return { ok: true, path: wrapperApp };
167
+ } catch (e) {
168
+ return { ok: false, error: e.message };
169
+ }
170
+ }
171
+
172
+ function installLinux(browser) {
173
+ const dataDir = getUserDataDir(browser.id, "linux");
174
+ const dir = path.join(os.homedir(), ".local", "share", "applications");
175
+ const file = path.join(dir, `szcd-${browser.id}-devsession.desktop`);
176
+ const content = [
177
+ "[Desktop Entry]",
178
+ "Version=1.0",
179
+ "Type=Application",
180
+ `Name=${browser.name} DevSession`,
181
+ `Comment=${browser.name} with CDP port ${CDP_PORT} and isolated profile — used by szcd local-browser-test`,
182
+ `Exec=${browser.exe} --user-data-dir=${dataDir} ${COMMON_FLAGS.join(" ")} %U`,
183
+ "Terminal=false",
184
+ "Categories=Development;WebBrowser;",
185
+ `Icon=${browser.id === "edge" ? "microsoft-edge" : "google-chrome"}`,
186
+ "StartupNotify=true",
187
+ "",
188
+ ].join("\n");
189
+ try {
190
+ fs.mkdirSync(dir, { recursive: true });
191
+ fs.writeFileSync(file, content, { mode: 0o644 });
192
+ fs.chmodSync(file, 0o755);
193
+ // 更新 desktop database(非必须,失败不影响)
194
+ try { execSync(`update-desktop-database "${dir}"`, { stdio: "ignore" }); } catch {}
195
+ return { ok: true, path: file };
196
+ } catch (e) {
197
+ return { ok: false, error: e.message };
198
+ }
199
+ }
200
+
201
+ // ============ 主入口 ============
202
+
203
+ export function setupDevBrowserShortcut(deps = {}) {
204
+ const platform = process.platform;
205
+ const results = [];
206
+
207
+ try {
208
+ const browsers = detectBrowsers(platform);
209
+ if (browsers.length === 0) {
210
+ console.log("⚠️ No Chrome/Edge detected — skipping dev-browser shortcut.");
211
+ return { ok: false, results, skipped: true };
212
+ }
213
+ const install =
214
+ platform === "win32" ? installWindows :
215
+ platform === "darwin" ? installMac :
216
+ installLinux;
217
+ for (const b of browsers) {
218
+ const r = install(b);
219
+ results.push({ browser: b.id, ...r });
220
+ if (r.ok) {
221
+ console.log(`✓ Created ${b.name} DevSession shortcut: ${r.path}`);
222
+ } else {
223
+ console.warn(`⚠️ Failed to create ${b.name} DevSession shortcut: ${r.error}`);
224
+ }
225
+ }
226
+ const okCount = results.filter(r => r.ok).length;
227
+ if (okCount > 0) {
228
+ const dirHint = platform === "win32" ? "桌面 (Desktop)"
229
+ : platform === "darwin" ? "~/Applications/ (Launchpad / Spotlight)"
230
+ : "应用菜单 (Activities)";
231
+ console.log(`\n💡 Double-click the "DevSession" shortcut in ${dirHint} to start a CDP-enabled browser`);
232
+ console.log(` on port ${CDP_PORT} with an isolated profile, then re-run your local-browser-test plan.`);
233
+ }
234
+ return { ok: okCount > 0, results };
235
+ } catch (e) {
236
+ console.warn(`⚠️ setupDevBrowserShortcut error: ${e.message}`);
237
+ return { ok: false, results, error: e.message };
238
+ }
239
+ }
@@ -24,6 +24,7 @@ import { setupClaudeCode } from "./lib/claude-code.js";
24
24
  import { setupOpenCode } from "./lib/opencode.js";
25
25
  import { setupQwenCode } from "./lib/qwen-code.js";
26
26
  import { setupQoder } from "./lib/qoder.js";
27
+ import { setupDevBrowserShortcut } from "./lib/dev-browser-shortcut.js";
27
28
 
28
29
  // 递归守卫在 common.js 加载时已执行
29
30
  // 超时保护在 common.js 中已初始化
@@ -227,6 +228,10 @@ function main() {
227
228
  console.log("\n🔧 Setting up Qoder CLI compatibility...\n");
228
229
  const qoderResult = setupQoder(deps);
229
230
 
231
+ // ---- Dev Browser Shortcut(local-browser-test 一键启动) ----
232
+ console.log("\n🔧 Setting up dev-browser shortcut for local-browser-test...\n");
233
+ setupDevBrowserShortcut(deps);
234
+
230
235
  showSuccessMessage(traeResult, claudeResult, qwenResult, qoderResult, openCodeResult);
231
236
  } catch (error) {
232
237
  console.error("\n❌ Error during installation:", error.message);
@@ -182,13 +182,21 @@ Agent / SKILL.md
182
182
  结果缓存到 `~/.szcd-mcp/deps/decrypted-creds.json`。后续可直接用 `engine._credentials` 获取。
183
183
 
184
184
  用户一次性配置:
185
+
186
+ > 💡 **快捷方式自动创建**:`npm install @szc-ft/mcp-szcd-client` 时,postinstall 会自动检测本机
187
+ > Chrome / Edge 并在系统应用启动器里创建一个 **"DevSession"** 快捷方式(不动主图标、独立 profile、
188
+ > 默认 9222 端口)。双击该图标即可启动,下面命令仅作 fallback / 自定义参考。
189
+ >
190
+ > 落点:Windows 桌面 `.lnk`、macOS `~/Applications/<Name> DevSession.app`、
191
+ > Linux `~/.local/share/applications/szcd-<id>-devsession.desktop`。
192
+
185
193
  ```bash
186
194
  # macOS
187
- open -a "Google Chrome" --args --remote-debugging-port=9222
195
+ open -a "Google Chrome" --args --disable-features=RendererCodeIntegrity --disable-web-security --user-data-dir="$HOME/ChromeDevSession" --remote-debugging-port=9222
188
196
  # Linux
189
- google-chrome --remote-debugging-port=9222
197
+ google-chrome --disable-features=RendererCodeIntegrity --disable-web-security --user-data-dir="$HOME/ChromeDevSession" --remote-debugging-port=9222
190
198
  # Windows
191
- "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
199
+ "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --disable-features=RendererCodeIntegrity --disable-web-security --user-data-dir="C:/EdgeDevSession" --remote-debugging-port=9222
192
200
  ```
193
201
 
194
202
  ### launch 模式(回退)