@ppdocs/mcp 2.5.0 → 2.5.2
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/dist/cli.js +37 -21
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -105,12 +105,14 @@ function initProject(opts) {
|
|
|
105
105
|
// ignore parse error
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
// Windows 需要 cmd /c 包装才能执行 npx
|
|
109
|
+
const isWindows = process.platform === 'win32';
|
|
110
|
+
const ppdocsServer = isWindows
|
|
111
|
+
? { command: 'cmd', args: ['/c', 'npx', '@ppdocs/mcp'] }
|
|
112
|
+
: { command: 'npx', args: ['@ppdocs/mcp'] };
|
|
108
113
|
mcpConfig.mcpServers = {
|
|
109
114
|
...(mcpConfig.mcpServers || {}),
|
|
110
|
-
ppdocs:
|
|
111
|
-
command: 'npx',
|
|
112
|
-
args: ['@ppdocs/mcp'],
|
|
113
|
-
},
|
|
115
|
+
ppdocs: ppdocsServer,
|
|
114
116
|
};
|
|
115
117
|
fs.writeFileSync(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
|
116
118
|
console.log(`✅ Created ${mcpPath}`);
|
|
@@ -144,6 +146,23 @@ function copyDirRecursive(src, dest) {
|
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
}
|
|
149
|
+
/** 生成跨平台的 hooks 配置 */
|
|
150
|
+
function generateHooksConfig() {
|
|
151
|
+
const isWindows = process.platform === 'win32';
|
|
152
|
+
const command = isWindows
|
|
153
|
+
? 'type ".claude\\hooks\\SystemPrompt.md"'
|
|
154
|
+
: 'cat ".claude/hooks/SystemPrompt.md"';
|
|
155
|
+
return {
|
|
156
|
+
hooks: {
|
|
157
|
+
UserPromptSubmit: [
|
|
158
|
+
{
|
|
159
|
+
matcher: '*',
|
|
160
|
+
hooks: [{ type: 'command', command }]
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
147
166
|
/** 安装 Claude Code 模板 */
|
|
148
167
|
function installClaudeTemplates(cwd) {
|
|
149
168
|
const claudeDir = path.join(cwd, '.claude');
|
|
@@ -161,26 +180,23 @@ function installClaudeTemplates(cwd) {
|
|
|
161
180
|
copyDirRecursive(srcHooks, destHooks);
|
|
162
181
|
console.log(`✅ Installed .claude/hooks/`);
|
|
163
182
|
}
|
|
164
|
-
// 3.
|
|
165
|
-
const settingsHooksPath = path.join(TEMPLATES_DIR, 'settings-hooks.json');
|
|
183
|
+
// 3. 生成跨平台 hooks 配置并合并到 settings.local.json
|
|
166
184
|
const settingsLocalPath = path.join(claudeDir, 'settings.local.json');
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
existingSettings = JSON.parse(fs.readFileSync(settingsLocalPath, 'utf-8'));
|
|
172
|
-
}
|
|
173
|
-
catch { /* ignore */ }
|
|
185
|
+
let existingSettings = {};
|
|
186
|
+
if (fs.existsSync(settingsLocalPath)) {
|
|
187
|
+
try {
|
|
188
|
+
existingSettings = JSON.parse(fs.readFileSync(settingsLocalPath, 'utf-8'));
|
|
174
189
|
}
|
|
175
|
-
|
|
176
|
-
const mergedSettings = {
|
|
177
|
-
...existingSettings,
|
|
178
|
-
hooks: hooksConfig.hooks
|
|
179
|
-
};
|
|
180
|
-
fs.mkdirSync(claudeDir, { recursive: true });
|
|
181
|
-
fs.writeFileSync(settingsLocalPath, JSON.stringify(mergedSettings, null, 2));
|
|
182
|
-
console.log(`✅ Configured .claude/settings.local.json hooks`);
|
|
190
|
+
catch { /* ignore */ }
|
|
183
191
|
}
|
|
192
|
+
const hooksConfig = generateHooksConfig();
|
|
193
|
+
const mergedSettings = {
|
|
194
|
+
...existingSettings,
|
|
195
|
+
...hooksConfig
|
|
196
|
+
};
|
|
197
|
+
fs.mkdirSync(claudeDir, { recursive: true });
|
|
198
|
+
fs.writeFileSync(settingsLocalPath, JSON.stringify(mergedSettings, null, 2));
|
|
199
|
+
console.log(`✅ Configured .claude/settings.local.json hooks (${process.platform})`);
|
|
184
200
|
}
|
|
185
201
|
/** 安装 Codex 模板 (生成 AGENTS.md) */
|
|
186
202
|
function installCodexTemplates(cwd) {
|