@ppdocs/mcp 2.6.10 → 2.6.11
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/tools/index.js +9 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +3 -7
- package/package.json +1 -1
package/dist/tools/index.js
CHANGED
|
@@ -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);
|
|
@@ -86,6 +86,14 @@ export function registerTools(server, projectId, _user) {
|
|
|
86
86
|
clearStyleCache();
|
|
87
87
|
return wrap(projectId, node ? JSON.stringify(node, null, 2) : '更新失败(根节点已锁定)');
|
|
88
88
|
});
|
|
89
|
+
// 3.6 获取项目规则 (独立方法,按需调用)
|
|
90
|
+
server.tool('kg_get_rules', '获取项目规则列表(按需调用,不再自动附加到每个方法返回)', {}, async () => {
|
|
91
|
+
const style = await getRootStyle(projectId);
|
|
92
|
+
if (!style || style.trim() === '') {
|
|
93
|
+
return { content: [{ type: 'text', text: '暂无项目规则' }] };
|
|
94
|
+
}
|
|
95
|
+
return { content: [{ type: 'text', text: `[项目规则]\n${style}` }] };
|
|
96
|
+
});
|
|
89
97
|
// 4. 锁定节点 (只能锁定,解锁需用户在前端手动操作)
|
|
90
98
|
server.tool('kg_lock_node', '锁定节点(锁定后只能读取,解锁需用户在前端手动操作)', {
|
|
91
99
|
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(
|
|
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(
|
|
56
|
-
|
|
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 转义序列
|