@ppdocs/mcp 3.2.35 → 3.2.37

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.
Files changed (41) hide show
  1. package/README.md +53 -27
  2. package/dist/cli.js +4 -48
  3. package/dist/storage/httpClient.d.ts +2 -27
  4. package/dist/storage/httpClient.js +3 -132
  5. package/dist/storage/types.d.ts +0 -28
  6. package/dist/storage/types.js +1 -1
  7. package/dist/tools/flowchart.d.ts +1 -5
  8. package/dist/tools/flowchart.js +647 -454
  9. package/dist/tools/index.d.ts +3 -3
  10. package/dist/tools/index.js +10 -13
  11. package/dist/tools/kg_status.d.ts +1 -1
  12. package/dist/tools/kg_status.js +6 -20
  13. package/dist/tools/projects.d.ts +2 -3
  14. package/dist/tools/projects.js +2 -3
  15. package/dist/tools/rules.d.ts +2 -3
  16. package/dist/tools/rules.js +2 -3
  17. package/dist/tools/shared.d.ts +0 -12
  18. package/dist/tools/shared.js +0 -59
  19. package/package.json +1 -1
  20. package/templates/AGENT.md +63 -38
  21. package/templates/commands/init.md +3 -3
  22. package/templates/commands/pp/diagnose.md +3 -3
  23. package/templates/commands/pp/init.md +9 -18
  24. package/templates/commands/pp/sync.md +10 -12
  25. package/templates/cursorrules.md +63 -64
  26. package/templates/hooks/SystemPrompt.md +14 -14
  27. package/templates/kiro-rules/ppdocs.md +63 -142
  28. package/dist/agent.d.ts +0 -6
  29. package/dist/agent.js +0 -130
  30. package/dist/tools/docs.d.ts +0 -8
  31. package/dist/tools/docs.js +0 -285
  32. package/dist/tools/helpers.d.ts +0 -37
  33. package/dist/tools/helpers.js +0 -94
  34. package/dist/vector/index.d.ts +0 -56
  35. package/dist/vector/index.js +0 -228
  36. package/dist/vector/manager.d.ts +0 -48
  37. package/dist/vector/manager.js +0 -250
  38. package/dist/web/server.d.ts +0 -43
  39. package/dist/web/server.js +0 -808
  40. package/dist/web/ui.d.ts +0 -5
  41. package/dist/web/ui.js +0 -642
@@ -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';
@@ -1,7 +1,6 @@
1
1
  /**
2
- * 📏 kg_rules (6→1)
3
- * 合并: kg_get_rules, kg_save_rules, kg_get_rules_meta, kg_save_rules_meta
4
- * 删除: kg_get_global_rules_meta, kg_save_global_rules_meta (管理员操作)
2
+ * 📏 kg_rules
3
+ * 统一规则入口: get | save | get_meta | save_meta | delete
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_rules (6→1)
3
- * 合并: kg_get_rules, kg_save_rules, kg_get_rules_meta, kg_save_rules_meta
4
- * 删除: kg_get_global_rules_meta, kg_save_global_rules_meta (管理员操作)
2
+ * 📏 kg_rules
3
+ * 统一规则入口: get | save | get_meta | save_meta | delete
5
4
  */
6
5
  import { z } from 'zod';
7
6
  import { getClient } from '../storage/httpClient.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.37",
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
+ - ?????? / ????????????
@@ -4,7 +4,7 @@ description: 初始化知识图谱:100%扫描代码库,为每个模块创建
4
4
 
5
5
  # /init 项目初始化
6
6
 
7
- 执行 `task_create("项目初始化: [项目名]")` → 递归扫描全部代码文件 → 逐文件审查创建节点 → 每处理5个文件调用 `task_add_log(progress)` 同步进度 → 全部完成后 `task_complete` 输出统计报告
7
+ 执行 `kg_task(action:"create", title:"项目初始化: [项目名]")` → 递归扫描全部代码文件 → 逐文件审查创建节点 → 每处理5个文件调用 `kg_task(action:"update", log_type:"progress")` 同步进度 → 全部完成后 `kg_task(action:"archive")` 输出统计报告
8
8
 
9
9
  ## 扫描规则
10
10
 
@@ -84,11 +84,11 @@ flowchart TB
84
84
 
85
85
  ## 进度同步
86
86
 
87
- 每处理5个文件或完成1个目录后,调用 `task_add_log("progress", "已处理: [文件列表], 创建节点: N个")`
87
+ 每处理5个文件或完成1个目录后,调用 `kg_task(action:"update", log_type:"progress", content:"已处理: [文件列表], 创建节点: N个")`
88
88
 
89
89
  ## 完成输出
90
90
 
91
- `task_complete` 时输出完整统计:
91
+ `kg_task(action:"archive")` 时输出完整统计:
92
92
 
93
93
  ```markdown
94
94
  | 统计项 | 数量 |
@@ -19,8 +19,8 @@
19
19
 
20
20
  **1.1 建立全景**
21
21
  ```
22
- kg_tree() 知识全景图
23
- kg_flowchart(action:"get") → 主图结构 (8个模块 + 连线)
22
+ kg_flowchart(action:"list") 知识图谱列表
23
+ kg_flowchart(action:"get") → 主图结构 (模块 + 连线)
24
24
  kg_rules(action:"get", ruleType:"errorAnalysis") → 错误分析规则
25
25
  ```
26
26
 
@@ -162,7 +162,7 @@ L2: 2个间接调用方可能受影响
162
162
 
163
163
  | 阶段 | 工具 | 用途 |
164
164
  |:---|:---|:---|
165
- | 锚定 | `kg_tree()` | 全景鸟瞰 |
165
+ | 锚定 | `kg_flowchart(list/get)` | 全景鸟瞰 |
166
166
  | 锚定 | `kg_flowchart(get)` | 主图结构 |
167
167
  | 锚定 | `kg_rules(get)` | 分析规则 |
168
168
  | 下探 | `kg_flowchart(get_node, expand:N)` | 节点详情+上下游 |
@@ -27,10 +27,10 @@
27
27
 
28
28
  ### Phase 0: 环境准备
29
29
  ```
30
- kg_init() → 连接项目上下文
31
- kg_status() → 查看仪表盘 (文档数/任务数/状态)
32
- kg_tree() 已有知识全景图
33
- kg_flowchart(action:"list") → 已有流程图列表
30
+ kg_init() → 连接项目上下文
31
+ kg_status() → 查看仪表盘 (流程图/任务/状态)
32
+ kg_flowchart(action:"list") 已有流程图列表
33
+ kg_flowchart(action:"get") → 主图结构总览
34
34
  ```
35
35
  如果已有图谱 → 提示用户选择: 增量补充 or 重建
36
36
 
@@ -125,27 +125,18 @@ kg_flowchart(action:"bind", nodeId:"n_graph_store",
125
125
  dirs:["src-tauri/src/storage/"])
126
126
  ```
127
127
 
128
- **3.2 创建参考文档 (遵循5分类规范)**
128
+ **3.2 写入节点内置文档 (`docEntries`)**
129
129
  ```
130
- 文档分类:
131
- /模块/后端/存储层 → 对应 n_storage
132
- /模块/后端/graph_store 对应 n_graph_store
133
- /模块/前端/FlowchartView → 对应 n_flowchart_view
134
- /架构/事件驱动 → 对应架构决策
135
- /功能/知识图谱编辑 → 对应用户功能
136
-
137
- kg_doc(action:"create",
138
- path:"/模块/后端/graph_store",
139
- summary:"项目/文档/规则/搜索的核心存储, JSON持久化",
140
- content:"## 职责\n...\n## 公开API\n...\n## 文件路径\n...",
141
- bindTo:"n_graph_store")
130
+ kg_flowchart(action:"update_node", chartId:"sub_storage", nodeId:"n_graph_store",
131
+ docSummary:"项目/规则/流程图数据持久化核心",
132
+ docContent:"## 职责\n...\n## 公开 API\n...\n## 文件路径\n- src-tauri/src/storage/graph_store.rs")
142
133
  ```
143
134
 
144
135
  ### Phase 4: 健康验证
145
136
  ```
146
137
  kg_flowchart(action:"orphans") → 孤立节点 (应为0)
147
138
  kg_flowchart(action:"health") → 冷热分布
148
- kg_tree() 全景确认文档覆盖
139
+ kg_flowchart(action:"get") 全景确认节点覆盖与连线
149
140
  kg_status() → 最终仪表盘
150
141
  ```
151
142
 
@@ -7,7 +7,7 @@
7
7
  | **代码即真理** | 代码与图谱冲突时以 Git 状态为准, 强制覆写 |
8
8
  | **层级感知** | 变更定位到具体子图层级, 逐层向上验证影响链 |
9
9
  | **最小变更** | 只更新有差异的节点/文档, 不做无意义的全量覆写 |
10
- | **创建即关联** | 新增节点必须 bind 源码 + 创建/关联文档, 无孤立资产 |
10
+ | **创建即关联** | 新增节点必须 bind 源码 + 写入节点文档, 无孤立资产 |
11
11
 
12
12
  ---
13
13
 
@@ -30,9 +30,9 @@
30
30
  **1.1 获取图谱现状**
31
31
  ```
32
32
  kg_init() → 确保项目连接
33
- kg_tree() → 文档全景
34
33
  kg_flowchart(action:"list") → 所有流程图
35
34
  kg_flowchart(action:"get") → 主图节点+连线
35
+ kg_flowchart(action:"search", query:"关键词") → 快速定位相关节点
36
36
  ```
37
37
 
38
38
  **1.2 获取代码变更**
@@ -106,12 +106,10 @@ all 模式:
106
106
  3. 绑定源码:
107
107
  kg_flowchart(action:"bind", nodeId:"n_xxx", files:["src/..."])
108
108
 
109
- 4. 创建文档 (遵循5分类):
110
- kg_doc(action:"create",
111
- path:"/模块/前端/xxx",
112
- summary:"一句话职责",
113
- content:"## 职责\n...\n## 公开API\n...\n## 文件路径\n...",
114
- bindTo:"n_xxx")
109
+ 4. 写入节点文档:
110
+ kg_flowchart(action:"update_node", chartId:目标子图, nodeId:"n_xxx",
111
+ docSummary:"一句话职责",
112
+ docContent:"## 职责\n...\n## 公开API\n...\n## 文件路径\n...")
115
113
  ```
116
114
 
117
115
  **3.2 处理 [MOD] — 更新节点**
@@ -126,8 +124,9 @@ all 模式:
126
124
  docSummary:"更新后的摘要")
127
125
 
128
126
  3. 追加版本记录:
129
- kg_doc(action:"update", path:"/模块/.../xxx",
130
- versions:[{version:当前+0.1, date:"ISO日期", changes:"变更摘要"}])
127
+ kg_flowchart(action:"update_node", chartId:目标子图, nodeId:"n_xxx",
128
+ docSummary:"本次变更摘要",
129
+ docContent:"更新后的详细文档")
131
130
 
132
131
  4. 检查连线是否需要更新:
133
132
  code_context(filePath) → 新的import列表
@@ -142,7 +141,6 @@ all 模式:
142
141
 
143
142
  选项B - 彻底删除:
144
143
  kg_flowchart(action:"delete_node", nodeId:"n_xxx")
145
- kg_doc(action:"delete", path:"/模块/.../xxx")
146
144
  ```
147
145
 
148
146
  **3.4 处理 [DRIFT] — 路径漂移**
@@ -177,7 +175,7 @@ kg_task(action:"update", taskId:"当前任务", log_type:"progress",
177
175
  ```
178
176
  kg_flowchart(action:"orphans") → 全局孤立节点 (应为0)
179
177
  kg_flowchart(action:"health") → 冷热分布
180
- kg_tree() 文档覆盖确认
178
+ kg_flowchart(action:"get") 节点覆盖确认
181
179
  ```
182
180
 
183
181
  ### Phase 5: 交付报告