@scorehub/creator-outreach 1.0.5 → 1.0.7
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/install.js +28 -1
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -29,6 +29,24 @@ const MCP_CONFIG = {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
// 工具函数:解析 WorkBuddy 捆绑的 node bin 目录
|
|
33
|
+
// WorkBuddy spawn 子进程的 PATH 不含 node,npx 及其下载的包依赖 #!/usr/bin/env node,
|
|
34
|
+
// 找不到 node 会秒退导致 "Connection closed"。返回 npx 全路径 + bin 目录用于注入 PATH。
|
|
35
|
+
function resolveWorkBuddyNode() {
|
|
36
|
+
const versionsDir = path.join(WORKBUDDY_DIR, 'binaries', 'node', 'versions');
|
|
37
|
+
try {
|
|
38
|
+
const versions = fs.readdirSync(versionsDir);
|
|
39
|
+
if (versions.length > 0) {
|
|
40
|
+
const binDir = path.join(versionsDir, versions[0], 'bin');
|
|
41
|
+
const npxPath = path.join(binDir, 'npx');
|
|
42
|
+
if (fs.existsSync(npxPath)) return { npx: npxPath, binDir };
|
|
43
|
+
}
|
|
44
|
+
} catch {
|
|
45
|
+
// 目录不存在或无权限
|
|
46
|
+
}
|
|
47
|
+
return { npx: 'npx', binDir: null };
|
|
48
|
+
}
|
|
49
|
+
|
|
32
50
|
// 工具函数:合并 MCP Server 配置到 JSON 文件
|
|
33
51
|
function mergeMcpConfig(configPath, serverName, serverConfig, extraFields) {
|
|
34
52
|
let config = {};
|
|
@@ -87,7 +105,16 @@ if (hasWorkBuddy) {
|
|
|
87
105
|
console.log(`✓ WorkBuddy: 插件文件已安装 → ${WORKBUDDY_PLUGIN_DIR}`);
|
|
88
106
|
|
|
89
107
|
// 4. 合并 MCP Server 配置到 ~/.workbuddy/mcp.json
|
|
90
|
-
|
|
108
|
+
// - 去掉 type 字段(WorkBuddy 不识别)
|
|
109
|
+
// - command 用 npx 全路径(WorkBuddy PATH 不含系统 npx)
|
|
110
|
+
// - env.PATH 注入 node bin 目录(否则 npx 及其子进程的 shebang 找不到 node,秒退报 Connection closed)
|
|
111
|
+
const { npx, binDir } = resolveWorkBuddyNode();
|
|
112
|
+
const { type: _, ...baseMCPConfig } = MCP_CONFIG;
|
|
113
|
+
const wbEnv = binDir
|
|
114
|
+
? Object.assign({}, MCP_CONFIG.env, { PATH: `${binDir}:/usr/local/bin:/usr/bin:/bin` })
|
|
115
|
+
: MCP_CONFIG.env;
|
|
116
|
+
const wbMCPConfig = Object.assign({}, baseMCPConfig, { command: npx, env: wbEnv });
|
|
117
|
+
mergeMcpConfig(WORKBUDDY_MCP_JSON, 'scorehub', wbMCPConfig, { disabled: false });
|
|
91
118
|
console.log(`✓ WorkBuddy: MCP Server 已配置 → ${WORKBUDDY_MCP_JSON}`);
|
|
92
119
|
}
|
|
93
120
|
|