@szc-ft/mcp-szcd-client 0.31.0 → 0.32.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/opencode-extension/skills/local-browser-test/SKILL.md +11 -3
- package/package.json +1 -1
- package/qwen-extension/qwen-extension.json +1 -1
- package/qwen-extension/skills/local-browser-test/SKILL.md +11 -3
- package/scripts/lib/dev-browser-shortcut.js +230 -0
- package/scripts/postinstall.js +5 -0
- package/standard-skill/local-browser-test/SKILL.md +11 -3
|
@@ -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\
|
|
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
|
@@ -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\
|
|
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,230 @@
|
|
|
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
|
+
// 注意: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'`,
|
|
114
|
+
`$s.Save()`,
|
|
115
|
+
].join("; ");
|
|
116
|
+
try {
|
|
117
|
+
execSync(`powershell -NoProfile -ExecutionPolicy Bypass -Command "${ps}"`, { stdio: "ignore" });
|
|
118
|
+
return { ok: true, path: lnkPath };
|
|
119
|
+
} catch (e) {
|
|
120
|
+
return { ok: false, error: e.message };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function installMac(browser) {
|
|
125
|
+
const dataDir = getUserDataDir(browser.id, "darwin");
|
|
126
|
+
const appDir = path.join(os.homedir(), "Applications");
|
|
127
|
+
const wrapperApp = path.join(appDir, `${browser.name} DevSession.app`);
|
|
128
|
+
const macosDir = path.join(wrapperApp, "Contents", "MacOS");
|
|
129
|
+
const resourcesDir = path.join(wrapperApp, "Contents", "Resources");
|
|
130
|
+
const plistPath = path.join(wrapperApp, "Contents", "Info.plist");
|
|
131
|
+
const execName = "launch";
|
|
132
|
+
const execPath = path.join(macosDir, execName);
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
fs.mkdirSync(macosDir, { recursive: true });
|
|
136
|
+
fs.mkdirSync(resourcesDir, { recursive: true });
|
|
137
|
+
const script = [
|
|
138
|
+
"#!/bin/bash",
|
|
139
|
+
`exec "${browser.exe}" --user-data-dir="${dataDir}" ${COMMON_FLAGS.join(" ")} "$@"`,
|
|
140
|
+
"",
|
|
141
|
+
].join("\n");
|
|
142
|
+
fs.writeFileSync(execPath, script, { mode: 0o755 });
|
|
143
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
144
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
145
|
+
<plist version="1.0">
|
|
146
|
+
<dict>
|
|
147
|
+
<key>CFBundleExecutable</key><string>${execName}</string>
|
|
148
|
+
<key>CFBundleName</key><string>${browser.name} DevSession</string>
|
|
149
|
+
<key>CFBundleIdentifier</key><string>com.szc-ft.${browser.id}-devsession</string>
|
|
150
|
+
<key>CFBundlePackageType</key><string>APPL</string>
|
|
151
|
+
<key>CFBundleVersion</key><string>1</string>
|
|
152
|
+
<key>LSUIElement</key><false/>
|
|
153
|
+
</dict>
|
|
154
|
+
</plist>
|
|
155
|
+
`;
|
|
156
|
+
fs.writeFileSync(plistPath, plist);
|
|
157
|
+
return { ok: true, path: wrapperApp };
|
|
158
|
+
} catch (e) {
|
|
159
|
+
return { ok: false, error: e.message };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function installLinux(browser) {
|
|
164
|
+
const dataDir = getUserDataDir(browser.id, "linux");
|
|
165
|
+
const dir = path.join(os.homedir(), ".local", "share", "applications");
|
|
166
|
+
const file = path.join(dir, `szcd-${browser.id}-devsession.desktop`);
|
|
167
|
+
const content = [
|
|
168
|
+
"[Desktop Entry]",
|
|
169
|
+
"Version=1.0",
|
|
170
|
+
"Type=Application",
|
|
171
|
+
`Name=${browser.name} DevSession`,
|
|
172
|
+
`Comment=${browser.name} with CDP port ${CDP_PORT} and isolated profile — used by szcd local-browser-test`,
|
|
173
|
+
`Exec=${browser.exe} --user-data-dir=${dataDir} ${COMMON_FLAGS.join(" ")} %U`,
|
|
174
|
+
"Terminal=false",
|
|
175
|
+
"Categories=Development;WebBrowser;",
|
|
176
|
+
`Icon=${browser.id === "edge" ? "microsoft-edge" : "google-chrome"}`,
|
|
177
|
+
"StartupNotify=true",
|
|
178
|
+
"",
|
|
179
|
+
].join("\n");
|
|
180
|
+
try {
|
|
181
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
182
|
+
fs.writeFileSync(file, content, { mode: 0o644 });
|
|
183
|
+
fs.chmodSync(file, 0o755);
|
|
184
|
+
// 更新 desktop database(非必须,失败不影响)
|
|
185
|
+
try { execSync(`update-desktop-database "${dir}"`, { stdio: "ignore" }); } catch {}
|
|
186
|
+
return { ok: true, path: file };
|
|
187
|
+
} catch (e) {
|
|
188
|
+
return { ok: false, error: e.message };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ============ 主入口 ============
|
|
193
|
+
|
|
194
|
+
export function setupDevBrowserShortcut(deps = {}) {
|
|
195
|
+
const platform = process.platform;
|
|
196
|
+
const results = [];
|
|
197
|
+
|
|
198
|
+
try {
|
|
199
|
+
const browsers = detectBrowsers(platform);
|
|
200
|
+
if (browsers.length === 0) {
|
|
201
|
+
console.log("⚠️ No Chrome/Edge detected — skipping dev-browser shortcut.");
|
|
202
|
+
return { ok: false, results, skipped: true };
|
|
203
|
+
}
|
|
204
|
+
const install =
|
|
205
|
+
platform === "win32" ? installWindows :
|
|
206
|
+
platform === "darwin" ? installMac :
|
|
207
|
+
installLinux;
|
|
208
|
+
for (const b of browsers) {
|
|
209
|
+
const r = install(b);
|
|
210
|
+
results.push({ browser: b.id, ...r });
|
|
211
|
+
if (r.ok) {
|
|
212
|
+
console.log(`✓ Created ${b.name} DevSession shortcut: ${r.path}`);
|
|
213
|
+
} else {
|
|
214
|
+
console.warn(`⚠️ Failed to create ${b.name} DevSession shortcut: ${r.error}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const okCount = results.filter(r => r.ok).length;
|
|
218
|
+
if (okCount > 0) {
|
|
219
|
+
const dirHint = platform === "win32" ? "桌面 (Desktop)"
|
|
220
|
+
: platform === "darwin" ? "~/Applications/ (Launchpad / Spotlight)"
|
|
221
|
+
: "应用菜单 (Activities)";
|
|
222
|
+
console.log(`\n💡 Double-click the "DevSession" shortcut in ${dirHint} to start a CDP-enabled browser`);
|
|
223
|
+
console.log(` on port ${CDP_PORT} with an isolated profile, then re-run your local-browser-test plan.`);
|
|
224
|
+
}
|
|
225
|
+
return { ok: okCount > 0, results };
|
|
226
|
+
} catch (e) {
|
|
227
|
+
console.warn(`⚠️ setupDevBrowserShortcut error: ${e.message}`);
|
|
228
|
+
return { ok: false, results, error: e.message };
|
|
229
|
+
}
|
|
230
|
+
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -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\
|
|
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 模式(回退)
|