@ppdocs/mcp 2.6.13 → 2.6.15
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 +65 -6
- package/package.json +1 -1
package/dist/tools/index.js
CHANGED
|
@@ -118,14 +118,14 @@ export function registerTools(server, projectId, _user) {
|
|
|
118
118
|
return wrap(projectId, node ? JSON.stringify(node, null, 2) : '操作失败');
|
|
119
119
|
});
|
|
120
120
|
// 5. 搜索节点
|
|
121
|
-
server.tool('kg_search', '
|
|
121
|
+
server.tool('kg_search', '关键词搜索节点,按命中率排序返回', {
|
|
122
122
|
keywords: z.array(z.string()).describe('关键词列表(OR逻辑)'),
|
|
123
|
-
limit: z.number().optional().describe('返回数量(默认
|
|
123
|
+
limit: z.number().optional().describe('返回数量(默认10)')
|
|
124
124
|
}, async (args) => {
|
|
125
|
-
const results = await storage.searchNodes(projectId, args.keywords, args.limit);
|
|
125
|
+
const results = await storage.searchNodes(projectId, args.keywords, args.limit || 10);
|
|
126
126
|
const output = results.map(r => ({
|
|
127
127
|
id: r.node.id, title: r.node.title, type: r.node.type,
|
|
128
|
-
status: r.node.status,
|
|
128
|
+
status: r.node.status, hitRate: `${Math.round(r.score)}%`
|
|
129
129
|
}));
|
|
130
130
|
return wrap(projectId, JSON.stringify(output, null, 2));
|
|
131
131
|
});
|
|
@@ -175,13 +175,13 @@ export function registerTools(server, projectId, _user) {
|
|
|
175
175
|
for (const r of relations) {
|
|
176
176
|
if (r.direction === 'outgoing' && (direction === 'outgoing' || direction === 'both')) {
|
|
177
177
|
if (!outgoing.some(o => o.id === r.nodeId)) {
|
|
178
|
-
outgoing.push({ id: r.nodeId, title: r.title,
|
|
178
|
+
outgoing.push({ id: r.nodeId, title: r.title, edge: r.edgeType });
|
|
179
179
|
await fetchRelations(r.nodeId, currentDepth + 1, 'outgoing');
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
if (r.direction === 'incoming' && (direction === 'incoming' || direction === 'both')) {
|
|
183
183
|
if (!incoming.some(i => i.id === r.nodeId)) {
|
|
184
|
-
incoming.push({ id: r.nodeId, title: r.title,
|
|
184
|
+
incoming.push({ id: r.nodeId, title: r.title, edge: r.edgeType });
|
|
185
185
|
await fetchRelations(r.nodeId, currentDepth + 1, 'incoming');
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -193,6 +193,65 @@ export function registerTools(server, projectId, _user) {
|
|
|
193
193
|
}
|
|
194
194
|
return wrap(projectId, JSON.stringify({ outgoing, incoming }, null, 2));
|
|
195
195
|
});
|
|
196
|
+
// 9. 读取单个节点详情
|
|
197
|
+
server.tool('kg_read_node', '读取单个节点的完整内容(描述、关联文件、依赖、历史记录)', {
|
|
198
|
+
nodeId: z.string().describe('节点ID')
|
|
199
|
+
}, async (args) => {
|
|
200
|
+
const node = await storage.getNode(projectId, args.nodeId);
|
|
201
|
+
if (!node) {
|
|
202
|
+
return wrap(projectId, '节点不存在');
|
|
203
|
+
}
|
|
204
|
+
// 构建结构化输出
|
|
205
|
+
const lines = [];
|
|
206
|
+
// 基础信息
|
|
207
|
+
lines.push(`## ${node.title}\n`);
|
|
208
|
+
lines.push('**基础信息**');
|
|
209
|
+
lines.push(`| 字段 | 值 |`);
|
|
210
|
+
lines.push(`|:---|:---|`);
|
|
211
|
+
lines.push(`| ID | ${node.id} |`);
|
|
212
|
+
lines.push(`| 类型 | ${node.type} |`);
|
|
213
|
+
lines.push(`| 状态 | ${node.status} |`);
|
|
214
|
+
lines.push(`| 签名 | ${node.signature} |`);
|
|
215
|
+
if (node.categories && node.categories.length > 0) {
|
|
216
|
+
lines.push(`| 标签 | ${node.categories.join(', ')} |`);
|
|
217
|
+
}
|
|
218
|
+
lines.push('');
|
|
219
|
+
// 关联文件
|
|
220
|
+
if (node.relatedFiles && node.relatedFiles.length > 0) {
|
|
221
|
+
lines.push('**关联文件**');
|
|
222
|
+
node.relatedFiles.forEach(f => lines.push(`- ${f}`));
|
|
223
|
+
lines.push('');
|
|
224
|
+
}
|
|
225
|
+
// 依赖关系
|
|
226
|
+
if (node.dependencies && node.dependencies.length > 0) {
|
|
227
|
+
lines.push('**依赖关系**');
|
|
228
|
+
node.dependencies.forEach(d => lines.push(`- ${d.name}: ${d.description}`));
|
|
229
|
+
lines.push('');
|
|
230
|
+
}
|
|
231
|
+
// 描述内容
|
|
232
|
+
if (node.description) {
|
|
233
|
+
lines.push('**描述内容**');
|
|
234
|
+
lines.push(node.description);
|
|
235
|
+
lines.push('');
|
|
236
|
+
}
|
|
237
|
+
// 更新历史
|
|
238
|
+
if (node.versions && node.versions.length > 0) {
|
|
239
|
+
lines.push('**更新历史**');
|
|
240
|
+
lines.push('| 版本 | 日期 | 变更 |');
|
|
241
|
+
lines.push('|:---|:---|:---|');
|
|
242
|
+
node.versions.forEach(v => lines.push(`| ${v.version} | ${v.date} | ${v.changes} |`));
|
|
243
|
+
lines.push('');
|
|
244
|
+
}
|
|
245
|
+
// 修复历史
|
|
246
|
+
if (node.bugfixes && node.bugfixes.length > 0) {
|
|
247
|
+
lines.push('**修复历史**');
|
|
248
|
+
lines.push('| ID | 日期 | 问题 | 方案 |');
|
|
249
|
+
lines.push('|:---|:---|:---|:---|');
|
|
250
|
+
node.bugfixes.forEach(b => lines.push(`| ${b.id} | ${b.date} | ${b.issue} | ${b.solution} |`));
|
|
251
|
+
lines.push('');
|
|
252
|
+
}
|
|
253
|
+
return wrap(projectId, lines.join('\n'));
|
|
254
|
+
});
|
|
196
255
|
// ===================== 任务管理工具 =====================
|
|
197
256
|
// 10. 创建任务
|
|
198
257
|
server.tool('task_create', '创建开发任务,记录目标和关联节点', {
|