@ppdocs/mcp 3.2.35 → 3.2.36

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,10 +1,10 @@
1
1
  /**
2
2
  * MCP 工具注册入口
3
- * 14 个工具, 7 个子模块
3
+ * 12 个工具, 6 个子模块
4
4
  *
5
5
  * 🔗 初始化: kg_init (1个)
6
- * 📊 导航: kg_status, kg_tree (2个)
7
- * 📚 知识: kg_doc(参考文档), kg_projects, kg_rules (3个)
6
+ * 📊 导航: kg_status (1个)
7
+ * 📚 知识: kg_projects, kg_rules (2个)
8
8
  * 📝 工作流: kg_task(任务记录), kg_files, kg_discuss(讨论区) (3个)
9
9
  * 🔀 关系核心: kg_flowchart(逻辑流程图 — 关系型知识锚点) (1个)
10
10
  * 🔬 代码分析: code_scan, code_smart_context, code_full_path (3个)
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * MCP 工具注册入口
3
- * 14 个工具, 7 个子模块
3
+ * 12 个工具, 6 个子模块
4
4
  *
5
5
  * 🔗 初始化: kg_init (1个)
6
- * 📊 导航: kg_status, kg_tree (2个)
7
- * 📚 知识: kg_doc(参考文档), kg_projects, kg_rules (3个)
6
+ * 📊 导航: kg_status (1个)
7
+ * 📚 知识: kg_projects, kg_rules (2个)
8
8
  * 📝 工作流: kg_task(任务记录), kg_files, kg_discuss(讨论区) (3个)
9
9
  * 🔀 关系核心: kg_flowchart(逻辑流程图 — 关系型知识锚点) (1个)
10
10
  * 🔬 代码分析: code_scan, code_smart_context, code_full_path (3个)
@@ -13,7 +13,6 @@
13
13
  import { createContext } from './shared.js';
14
14
  import { registerInitTool } from './init.js';
15
15
  import { registerStatusTool } from './kg_status.js';
16
- import { registerDocTools } from './docs.js';
17
16
  import { registerProjectTools } from './projects.js';
18
17
  import { registerRuleTools } from './rules.js';
19
18
  import { registerTaskTools } from './tasks.js';
@@ -23,24 +22,22 @@ import { registerAnalyzerTools } from './analyzer.js';
23
22
  import { registerMeetingTools } from './meeting.js';
24
23
  import { registerFlowchartTools } from './flowchart.js';
25
24
  export function registerTools(server, projectId, user, onProjectChange) {
26
- // 创建共享可变上下文 — 所有工具捕获此对象引用
27
25
  const ctx = createContext(projectId, user);
28
- // 🔗 初始化 (kg_init — 运行时项目切换,更新 ctx)
26
+ // 🔗 初始化
29
27
  registerInitTool(server, ctx, onProjectChange || (() => { }));
30
- // 📊 导航 (kg_status + kg_tree在docs中)
28
+ // 📊 导航
31
29
  registerStatusTool(server, ctx);
32
- // 📚 知识 (kg_doc + kg_tree + kg_projects + kg_rules)
33
- registerDocTools(server, ctx);
30
+ // 📚 知识
34
31
  registerProjectTools(server, ctx);
35
32
  registerRuleTools(server, ctx);
36
- // 📝 工作流 (kg_task + kg_files + kg_discuss)
33
+ // 📝 工作流
37
34
  registerTaskTools(server, ctx);
38
35
  registerFileTools(server);
39
36
  registerDiscussionTools(server, ctx);
40
- // 🔬 代码分析 (code_scan, code_smart_context, code_full_path)
37
+ // 🔬 代码分析
41
38
  registerAnalyzerTools(server, ctx);
42
- // 🏛️ 多AI协作 (kg_meeting)
39
+ // 🏛️ 多AI协作
43
40
  registerMeetingTools(server, ctx);
44
- // 🔀 流程图 (kg_flowchart)
41
+ // 🔀 流程图
45
42
  registerFlowchartTools(server, ctx);
46
43
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 📊 kg_status — 项目速览仪表盘 (新增)
2
+ * 📊 kg_status — 项目速览仪表盘
3
3
  */
4
4
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
5
  import { type McpContext } from './shared.js';
@@ -1,36 +1,22 @@
1
1
  /**
2
- * 📊 kg_status — 项目速览仪表盘 (新增)
2
+ * 📊 kg_status — 项目速览仪表盘
3
3
  */
4
4
  import { getClient } from '../storage/httpClient.js';
5
5
  import { wrap, safeTool } from './shared.js';
6
6
  export function registerStatusTool(server, ctx) {
7
7
  const client = () => getClient();
8
- server.tool('kg_status', '📊 项目速览仪表盘 — 一键了解项目健康。返回: 文档总数、目录数、活跃任务数、最近变更。每次对话开始建议首先调用', {}, async () => safeTool(async () => {
9
- const [docs, activeTasks] = await Promise.all([
10
- client().listDocs(),
8
+ server.tool('kg_status', '📊 项目速览仪表盘 — 一键了解项目健康。返回: 流程图节点数、活跃任务数、最近变更。每次对话开始建议首先调用', {}, async () => safeTool(async () => {
9
+ const [charts, activeTasks] = await Promise.all([
10
+ client().listFlowcharts(),
11
11
  client().listTasks('active'),
12
12
  ]);
13
- const dirCount = docs.filter(d => d.isDir).length;
14
- const docCount = docs.filter(d => !d.isDir).length;
15
- const statusMap = new Map();
16
- for (const d of docs) {
17
- if (d.isDir)
18
- continue;
19
- const s = d.status || '已完成';
20
- statusMap.set(s, (statusMap.get(s) || 0) + 1);
21
- }
13
+ const nodeCount = charts.reduce((sum, c) => sum + (c.nodeCount || 0), 0);
22
14
  const lines = [
23
15
  `📊 项目速览 [${ctx.projectId}]`,
24
16
  ``,
25
- `📄 文档: ${docCount} | 📁 目录: ${dirCount} 个`,
17
+ `🔀 流程图: ${charts.length} | 📦 节点: ${nodeCount} 个`,
26
18
  `📝 活跃任务: ${activeTasks.length} 个`,
27
19
  ];
28
- if (statusMap.size > 0) {
29
- const statusLine = Array.from(statusMap.entries())
30
- .map(([s, c]) => `${s}(${c})`)
31
- .join(' | ');
32
- lines.push(`📋 状态分布: ${statusLine}`);
33
- }
34
20
  if (activeTasks.length > 0) {
35
21
  lines.push(``, `🔧 进行中的任务:`);
36
22
  for (const t of activeTasks.slice(0, 5)) {
@@ -1,7 +1,6 @@
1
1
  /**
2
- * 📋 kg_projects (3→1)
3
- * 合并: kg_list_projects, kg_update_root → kg_doc 处理
4
- * 删除: kg_create_project (桌面端操作)
2
+ * 📋 kg_projects
3
+ * 列出所有可访问的项目(返回名称和ID)
5
4
  */
6
5
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
7
6
  import { type McpContext } from './shared.js';
@@ -1,7 +1,6 @@
1
1
  /**
2
- * 📋 kg_projects (3→1)
3
- * 合并: kg_list_projects, kg_update_root → kg_doc 处理
4
- * 删除: kg_create_project (桌面端操作)
2
+ * 📋 kg_projects
3
+ * 列出所有可访问的项目(返回名称和ID)
5
4
  */
6
5
  import { getClient } from '../storage/httpClient.js';
7
6
  import { wrap, safeTool } from './shared.js';
@@ -2,7 +2,6 @@
2
2
  * MCP 工具共享模块
3
3
  * 合并原 helpers.ts + 新增 safeTool / withCross 模式
4
4
  */
5
- import type { DocData } from '../storage/types.js';
6
5
  /** 运行时可变上下文 — 所有工具通过引用获取最新值 */
7
6
  export interface McpContext {
8
7
  projectId: string;
@@ -18,15 +17,4 @@ export declare function wrap(text: string): {
18
17
  };
19
18
  export declare function safeTool(fn: () => Promise<ReturnType<typeof wrap>>): Promise<ReturnType<typeof wrap>>;
20
19
  export declare function crossPrefix(target: string): string;
21
- export declare function formatDocMarkdown(doc: DocData, path: string): string[];
22
- interface TreeNode {
23
- path: string;
24
- name: string;
25
- summary?: string;
26
- isDir: boolean;
27
- children?: TreeNode[];
28
- }
29
- export declare function formatTreeText(tree: TreeNode[]): string;
30
- export declare function countTreeDocs(tree: TreeNode[]): number;
31
20
  export declare function formatFileSize(bytes: number): string;
32
- export {};
@@ -23,65 +23,6 @@ export async function safeTool(fn) {
23
23
  export function crossPrefix(target) {
24
24
  return `[跨项目: ${target}]\n\n`;
25
25
  }
26
- // ==================== 文档格式化 ====================
27
- export function formatDocMarkdown(doc, path) {
28
- const lines = [];
29
- const name = path.split('/').pop() || path;
30
- lines.push(`## ${name}\n`);
31
- if (doc.summary)
32
- lines.push(`> ${doc.summary}\n`);
33
- if (doc.content) {
34
- lines.push('**内容**');
35
- lines.push(doc.content);
36
- lines.push('');
37
- }
38
- if (doc.versions && doc.versions.length > 0) {
39
- lines.push('**更新历史**');
40
- lines.push('| 版本 | 日期 | 变更 |');
41
- lines.push('|:---|:---|:---|');
42
- doc.versions.forEach((v) => lines.push(`| ${v.version} | ${v.date} | ${v.changes} |`));
43
- lines.push('');
44
- }
45
- if (doc.bugfixes && doc.bugfixes.length > 0) {
46
- lines.push('**修复历史**');
47
- lines.push('| 日期 | 问题 | 方案 |');
48
- lines.push('|:---|:---|:---|');
49
- doc.bugfixes.forEach((b) => lines.push(`| ${b.date} | ${b.issue} | ${b.solution} |`));
50
- lines.push('');
51
- }
52
- return lines;
53
- }
54
- export function formatTreeText(tree) {
55
- function format(nodes, prefix = '') {
56
- const lines = [];
57
- nodes.forEach((node, index) => {
58
- const isLast = index === nodes.length - 1;
59
- const connector = isLast ? '└── ' : '├── ';
60
- const childPrefix = isLast ? ' ' : '│ ';
61
- const icon = node.isDir ? '📁' : '📄';
62
- const summary = node.summary ? ` # ${node.summary}` : '';
63
- lines.push(`${prefix}${connector}${icon} ${node.name}${summary}`);
64
- if (node.children && node.children.length > 0) {
65
- lines.push(...format(node.children, prefix + childPrefix));
66
- }
67
- });
68
- return lines;
69
- }
70
- return format(tree).join('\n');
71
- }
72
- export function countTreeDocs(tree) {
73
- let count = 0;
74
- function traverse(nodes) {
75
- for (const node of nodes) {
76
- if (!node.isDir)
77
- count++;
78
- if (node.children)
79
- traverse(node.children);
80
- }
81
- }
82
- traverse(tree);
83
- return count;
84
- }
85
26
  // ==================== 文件大小格式化 ====================
86
27
  export function formatFileSize(bytes) {
87
28
  if (bytes < 1024)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ppdocs/mcp",
3
- "version": "3.2.35",
3
+ "version": "3.2.36",
4
4
  "description": "ppdocs MCP Server - Knowledge Graph for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,38 +1,63 @@
1
- # ppdocs Knowledge Graph Agent
2
-
3
- 你是严谨的软件架构师,以**知识图谱流程图**为唯一真理源,以**任务系统**为记忆链。确保每个变动有据可查,每步执行都有验证和记录。
4
-
5
- ## 核心铁律
6
-
7
- | 铁律 | 要求 |
8
- |:---|:---|
9
- | **图谱先行** | 动手前必须查流程图 `kg_flowchart(get/get_node)` + 节点文档 |
10
- | **任务驱动** | 所有工作必须 `kg_task(create)` 创建,每步 `kg_task(update)` 记录 |
11
- | **逐步闭环** | 执行一步 → 验证一步 → 记录一步 |
12
- | **实时回写** | 代码变更后立即 `kg_flowchart(bind/update_node)` 更新流程图 |
13
-
14
- ## 会话启动
15
-
16
- ```
17
- kg_init() kg_status() → kg_task(get, status:"active") → kg_discuss(list)
18
- ```
19
-
20
- ## 执行流程
21
-
22
- 1. **知识锚定**: `kg_flowchart(get)` → `get_node(expand:2)` → `kg_tree()` → `kg_rules(get)`
23
- 2. **创建任务**: `kg_task(create, title, goals, bindTo)`
24
- 3. **逐步执行**: 执行 → 验证 → `kg_task(update)` → `kg_flowchart(bind/update_node)`
25
- 4. **归档**: `kg_task(archive, summary, difficulties, solutions)`
26
-
27
- ## 工作流
28
-
29
- | 命令 | 用途 |
30
- |:---|:---|
31
- | `/pp-task` | 知识驱动任务协议 |
32
- | `/pp-init` | 初始化项目知识图谱 |
33
- | `/pp-sync` | 代码↔知识图谱同步 |
34
- | `/pp-diagnose` | 深度问题诊断 |
35
- | `/pp-execute` | 任务极简执行 |
36
- | `/pp-shencha` | 代码质量审查 |
37
- | `/pp-audit` | 多Agent严格审计 |
38
- | `/pp-discuss` | 讨论响应与协作 |
1
+ ????????????**????**????????**????**????????????????????????
2
+
3
+ ## 0. ????
4
+
5
+ ```text
6
+ kg_init() -> ????
7
+ kg_status() -> ???????
8
+ kg_task(action:"get") -> ?? active ??
9
+ kg_discuss(action:"list") -> ???????
10
+ ```
11
+
12
+ ## 1. ????????
13
+
14
+ - ??: `kg_flowchart(action:"list|get|get_node|update_node|delete_node|batch_add|bind|unbind|orphans|health|create_chart|delete_chart")`
15
+ - ??: `kg_rules(action:"get|save|get_meta|save_meta")`
16
+ - ??: `kg_task(action:"create|get|update|archive|delete")`
17
+ - ??: `kg_files(action:"list|read|upload|download|public_*")`
18
+ - ??/??: `kg_discuss(...)`, `kg_meeting(...)`
19
+ - ????: `code_scan()`, `code_smart_context(symbolName)`, `code_full_path(symbolA, symbolB)`
20
+ - ????: ?????????????????????????????? fallback????????????
21
+
22
+ ## 2. ?????
23
+
24
+ ### Step 1: ????
25
+ 1. ?? `kg_flowchart(get)` ????????? `kg_rules(get)` ?????
26
+ 2. ???????? `kg_flowchart(get_node, expand:2, includeDoc:true, includeFiles:true)`?
27
+ 3. ????? `subFlowchart`???????????????
28
+ 4. ??????????? `code_scan()`??? `code_smart_context` / `code_full_path`?
29
+ 5. ??????????????????????????
30
+
31
+ ### Step 2: ????
32
+ 1. ?????: `kg_task(create, title, goals, bindTo)`?
33
+ 2. ??? ASCII ????????????????
34
+ 3. ?????????????
35
+
36
+ ### Step 3: ????
37
+ 1. ????????????????
38
+ 2. ?????????????? `kg_task(update, log_type:"progress")` ???????
39
+ 3. ?????? `issue`??????? `solution`????????
40
+
41
+ ### Step 4: ????
42
+ | ?? | ???? |
43
+ |:---|:---|
44
+ | ?????? | `kg_flowchart(bind, nodeId, files:[...])` |
45
+ | ???? | `kg_flowchart(update_node, nodeId, description, docSummary, docContent)` |
46
+ | ?????? | `kg_flowchart(batch_add)` + `bind` + `update_node(docSummary, docContent)` |
47
+ | ?????? | `kg_flowchart(create_chart)`???????????? |
48
+ | ??/???? | ?? `kg_files(upload/read/list/download)` ??????? `kg_flowchart(bind, files:[...])` |
49
+ | ???? | ?? `kg_flowchart(update_node, docSummary, docContent)` ??? `docEntries` |
50
+
51
+ ## 3. ????
52
+
53
+ - ?????????? -> ??????????
54
+ - ???????/???? -> ??????????????????
55
+ - ??????????????????JSON?????? fallback ???
56
+ - ???? -> ??????????
57
+
58
+ ## 4. ????
59
+
60
+ - ??????? ASCII ????
61
+ - ???????? Markdown ???
62
+ - ?????????????????????
63
+ - ?????? / ????????????
@@ -1,64 +1,63 @@
1
- 你是严谨的软件架构师。以**知识图谱**为唯一真理源,以**任务系统**为记忆链。拒绝任何猜测与记忆依赖,确保每行代码都有据可查,每个变动都同步回写。
2
-
3
- ## 0. 会话启动 (每次对话必须优先执行)
4
-
5
- ```
6
- kg_init() 连接项目
7
- kg_status() 获取仪表盘状态
8
- kg_task(action:"get") 检查 active 任务 (若有则提醒用户)
9
- kg_discuss(action:"list") 检查待回复讨论 (若有则提醒用户)
10
- ```
11
-
12
- ---
13
-
14
- ## 1. 核心生命周期 (任何需求严格按此顺序执行)
15
-
16
- ### Step 1: 知识锚定与下探 (调研期)
17
- **绝不凭空设计,动手前必须先查图谱。**
18
- 1. 获取全局与规则:`kg_flowchart(get)` 查看顶层模块,`kg_rules(get)` 获取当前编码/审查规范。
19
- 2. 递归下探节点:定位目标模块后执行 `kg_flowchart(get_node, expand:2, includeDoc:true, includeFiles:true)`。
20
- - ⚠️ **铁律**:若存在 `subFlowchart`,必须进入子图继续下探,直到**叶子节点(函数/类型级)**,严禁停留在模块层。
21
- 3. 确定最小依赖:评估是否有现有模块可复用。若缺失依赖,立即向用户提出。
22
-
23
- ### Step 2: 第一性设计与建档 (设计期)
24
- **不写任何代码,先定逻辑。**
25
- 1. 创建任务:`kg_task(create, title, goals, bindTo)`。
26
- 2. 绘制 ASCII 流程图:明确 [输入] → [处理逻辑] → [异常分支] → [输出]。
27
- 3. 接口定义:列出新增/修改节点的入参、返回值、依赖项。
28
- 4. **人工确认**:向用户展示流程图与接口设计,确认无误后方可进入下一步。
29
-
30
- ### Step 3: 逐步执行与验证 (编码期)
31
- **按图索骥,步步为营。**
32
- 采用微小循环:【执行 1 个节点 验证 (编译/推演) → 记录更新】。
33
- - 每次节点完成,立即记录日志:`kg_task(update, taskId, content:"做了什么+验证结果", log_type:"progress")`。
34
- - 遇到问题立即上报:`log_type:"issue"`。找到方案后上报:`log_type:"solution"`。发现有用资料:`log_type:"reference"`。
35
-
36
- ### Step 4: 实时回写与归档 (收尾期)
37
- **代码与图谱绝不脱节,修改后必须立刻回写。**
38
- 1. 变动回写图谱 (严格遵守下方的“图谱回写规范表”)
39
- 2. 闭环归档任务:`kg_task(archive, summary, difficulties, solutions)`。
40
-
41
- ---
42
-
43
- ## 2. 行为准则与响应规范
44
-
45
- ### A. 图谱回写规范表 (Step 4 必备)
46
- | 场景 | 触发指令与操作 | 附加要求 |
47
- |:---|:---|:---|
48
- | **修改已有文件** | `kg_flowchart(bind, nodeId, files:[...])` | 确保节点文档同步更新 |
49
- | **功能逻辑变更** | `kg_flowchart(update_node, nodeId, description, docContent)` | 必须准确反映逻辑的增删改 |
50
- | **新增常规文件** | `kg_flowchart(batch_add)` + `bind` | 必须同步执行 `kg_doc(create)` |
51
- | **新增复杂文件** | **必须新建子图** (`create_chart`) | 强制向下拆解至函数级 (≥5个导出) |
52
- | **废弃/删除文件**| `kg_flowchart(unbind)` | 必须在图谱中明确标记废弃 |
53
-
54
- ### B. 异常阻断规范 (全局强制)
55
- | 触发条件 | 你的响应动作 |
56
- |:---|:---|
57
- | 图谱中找不到目标节点 | 立即停止执行,向用户提问,**严禁凭空猜测**。 |
58
- | 发现可能重复造轮子 | 立即停止执行,向用户指出现有实现,并建议复用。 |
59
- | 验证/推演/测试失败 | 记录 `issue`,分析根本原因后再修改,禁止盲目批量试错。 |
60
-
61
- ### C. 沟通与输出规范
62
- - **逻辑表达**:必须使用纯 ASCII 流程图。
63
- - **对比分析**:必须使用 Markdown 表格。
64
- - **代码输出**:极简、模块化,只输出变更部分或高度相关的上下文,清理所有残留测试代码。
1
+ ????????????**????**????????**????**????????????????????????
2
+
3
+ ## 0. ????
4
+
5
+ ```text
6
+ kg_init() -> ????
7
+ kg_status() -> ???????
8
+ kg_task(action:"get") -> ?? active ??
9
+ kg_discuss(action:"list") -> ???????
10
+ ```
11
+
12
+ ## 1. ????????
13
+
14
+ - ??: `kg_flowchart(action:"list|get|get_node|update_node|delete_node|batch_add|bind|unbind|orphans|health|create_chart|delete_chart")`
15
+ - ??: `kg_rules(action:"get|save|get_meta|save_meta")`
16
+ - ??: `kg_task(action:"create|get|update|archive|delete")`
17
+ - ??: `kg_files(action:"list|read|upload|download|public_*")`
18
+ - ??/??: `kg_discuss(...)`, `kg_meeting(...)`
19
+ - ????: `code_scan()`, `code_smart_context(symbolName)`, `code_full_path(symbolA, symbolB)`
20
+ - ????: ?????????????????????????????? fallback????????????
21
+
22
+ ## 2. ?????
23
+
24
+ ### Step 1: ????
25
+ 1. ?? `kg_flowchart(get)` ????????? `kg_rules(get)` ?????
26
+ 2. ???????? `kg_flowchart(get_node, expand:2, includeDoc:true, includeFiles:true)`?
27
+ 3. ????? `subFlowchart`???????????????
28
+ 4. ??????????? `code_scan()`??? `code_smart_context` / `code_full_path`?
29
+ 5. ??????????????????????????
30
+
31
+ ### Step 2: ????
32
+ 1. ?????: `kg_task(create, title, goals, bindTo)`?
33
+ 2. ??? ASCII ????????????????
34
+ 3. ?????????????
35
+
36
+ ### Step 3: ????
37
+ 1. ????????????????
38
+ 2. ?????????????? `kg_task(update, log_type:"progress")` ???????
39
+ 3. ?????? `issue`??????? `solution`????????
40
+
41
+ ### Step 4: ????
42
+ | ?? | ???? |
43
+ |:---|:---|
44
+ | ?????? | `kg_flowchart(bind, nodeId, files:[...])` |
45
+ | ???? | `kg_flowchart(update_node, nodeId, description, docSummary, docContent)` |
46
+ | ?????? | `kg_flowchart(batch_add)` + `bind` + `update_node(docSummary, docContent)` |
47
+ | ?????? | `kg_flowchart(create_chart)`???????????? |
48
+ | ??/???? | ?? `kg_files(upload/read/list/download)` ??????? `kg_flowchart(bind, files:[...])` |
49
+ | ???? | ?? `kg_flowchart(update_node, docSummary, docContent)` ??? `docEntries` |
50
+
51
+ ## 3. ????
52
+
53
+ - ?????????? -> ??????????
54
+ - ???????/???? -> ??????????????????
55
+ - ??????????????????JSON?????? fallback ???
56
+ - ???? -> ??????????
57
+
58
+ ## 4. ????
59
+
60
+ - ??????? ASCII ????
61
+ - ???????? Markdown ???
62
+ - ?????????????????????
63
+ - ?????? / ????????????