@ppdocs/mcp 2.5.1 → 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 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. 合并 settings.local.json hooks 配置
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
- if (fs.existsSync(settingsHooksPath)) {
168
- let existingSettings = {};
169
- if (fs.existsSync(settingsLocalPath)) {
170
- try {
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
- const hooksConfig = JSON.parse(fs.readFileSync(settingsHooksPath, 'utf-8'));
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ppdocs/mcp",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "ppdocs MCP Server - Knowledge Graph for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -6,7 +6,7 @@
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
9
- "command": "node -e \"console.log(require('fs').readFileSync('.claude/hooks/SystemPrompt.md','utf8'))\""
9
+ "command": "type \".claude\\hooks\\SystemPrompt.md\""
10
10
  }
11
11
  ]
12
12
  }