@ppdocs/mcp 2.6.10 → 2.6.12

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.
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import * as storage from '../storage/httpClient.js';
3
- import { decodeUnicodeEscapes, decodeObjectStrings, wrapResult, clearStyleCache } from '../utils.js';
3
+ import { decodeUnicodeEscapes, decodeObjectStrings, wrapResult, clearStyleCache, getRootStyle } from '../utils.js';
4
4
  // 辅助函数: 包装返回结果
5
5
  async function wrap(projectId, text) {
6
6
  const wrapped = await wrapResult(projectId, text);
@@ -51,19 +51,35 @@ export function registerTools(server, projectId, _user) {
51
51
  name: z.string(),
52
52
  description: z.string()
53
53
  })).optional().describe('依赖列表'),
54
- relatedFiles: z.array(z.string()).optional().describe('关联的源文件路径数组')
54
+ relatedFiles: z.array(z.string()).optional().describe('关联的源文件路径数组'),
55
+ versions: z.array(z.object({
56
+ version: z.number(),
57
+ date: z.string(),
58
+ changes: z.string()
59
+ })).optional().describe('版本记录'),
60
+ bugfixes: z.array(z.object({
61
+ id: z.string(),
62
+ date: z.string(),
63
+ issue: z.string(),
64
+ solution: z.string(),
65
+ impact: z.string().optional()
66
+ })).optional().describe('修复记录')
55
67
  }, async (args) => {
56
- const { nodeId, tags, relatedFiles, ...rest } = args;
68
+ const { nodeId, tags, relatedFiles, versions, bugfixes, ...rest } = args;
57
69
  // 根节点必须使用 kg_update_root 更新
58
70
  if (nodeId === 'root') {
59
71
  return wrap(projectId, '❌ 根节点请使用 kg_update_root 方法更新');
60
72
  }
61
- // API 参数 tags 转换为内部字段 categories
73
+ // API 参数转换
62
74
  let updates = { ...rest };
63
75
  if (tags !== undefined)
64
76
  updates.categories = tags;
65
77
  if (relatedFiles !== undefined)
66
78
  updates.relatedFiles = relatedFiles;
79
+ if (versions !== undefined)
80
+ updates.versions = versions;
81
+ if (bugfixes !== undefined)
82
+ updates.bugfixes = bugfixes;
67
83
  const node = await storage.updateNode(projectId, nodeId, updates);
68
84
  return wrap(projectId, node ? JSON.stringify(node, null, 2) : '更新失败(节点不存在或已锁定)');
69
85
  });
@@ -86,6 +102,14 @@ export function registerTools(server, projectId, _user) {
86
102
  clearStyleCache();
87
103
  return wrap(projectId, node ? JSON.stringify(node, null, 2) : '更新失败(根节点已锁定)');
88
104
  });
105
+ // 3.6 获取项目规则 (独立方法,按需调用)
106
+ server.tool('kg_get_rules', '获取项目规则列表(按需调用,不再自动附加到每个方法返回)', {}, async () => {
107
+ const style = await getRootStyle(projectId);
108
+ if (!style || style.trim() === '') {
109
+ return { content: [{ type: 'text', text: '暂无项目规则' }] };
110
+ }
111
+ return { content: [{ type: 'text', text: `[项目规则]\n${style}` }] };
112
+ });
89
113
  // 4. 锁定节点 (只能锁定,解锁需用户在前端手动操作)
90
114
  server.tool('kg_lock_node', '锁定节点(锁定后只能读取,解锁需用户在前端手动操作)', {
91
115
  nodeId: z.string().describe('节点ID')
package/dist/utils.d.ts CHANGED
@@ -10,9 +10,9 @@ export declare function getRootStyle(projectId: string): Promise<string>;
10
10
  */
11
11
  export declare function clearStyleCache(): void;
12
12
  /**
13
- * 包装工具返回结果 (注入用户风格)
13
+ * 包装工具返回结果 (不再自动注入规则,使用 kg_get_rules 按需获取)
14
14
  */
15
- export declare function wrapResult(projectId: string, result: string): Promise<string>;
15
+ export declare function wrapResult(_projectId: string, result: string): Promise<string>;
16
16
  /**
17
17
  * 解码 Unicode 转义序列
18
18
  * 将 \uXXXX 格式的转义序列转换为实际字符
package/dist/utils.js CHANGED
@@ -50,14 +50,10 @@ export function clearStyleCache() {
50
50
  cacheProjectId = null;
51
51
  }
52
52
  /**
53
- * 包装工具返回结果 (注入用户风格)
53
+ * 包装工具返回结果 (不再自动注入规则,使用 kg_get_rules 按需获取)
54
54
  */
55
- export async function wrapResult(projectId, result) {
56
- const style = await getRootStyle(projectId);
57
- if (!style || style.trim() === '') {
58
- return result;
59
- }
60
- return `[项目规则]\n${style}\n\n---\n[结果]\n${result}`;
55
+ export async function wrapResult(_projectId, result) {
56
+ return result;
61
57
  }
62
58
  /**
63
59
  * 解码 Unicode 转义序列
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ppdocs/mcp",
3
- "version": "2.6.10",
3
+ "version": "2.6.12",
4
4
  "description": "ppdocs MCP Server - Knowledge Graph for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",