diff --git a/07-Other/AI/AI Agent/UnrealEngine/Graphify 知识图谱.md b/07-Other/AI/AI Agent/UnrealEngine/Graphify 知识图谱.md index 80661b1..a8ce057 100644 --- a/07-Other/AI/AI Agent/UnrealEngine/Graphify 知识图谱.md +++ b/07-Other/AI/AI Agent/UnrealEngine/Graphify 知识图谱.md @@ -179,39 +179,35 @@ graphify install # 自动向 CLAUDE.md 注入架构索引规则 # 具体执行方案 --- -**Gemini** - 实现这一方案的关键在于将 `graphify` 从一个“傻瓜式扫描器”转变为一个“受控的提取引擎”。针对 Unreal Engine 的庞大规模,我们需要通过精确的路径控制和排除规则来实施。 以下是具体的执行方法与命令: - ### 1\. 离线构建 Engine 基础图谱 (The Static Atlas) 由于引擎源码几乎不变量,我们只需构建一次。 **执行策略:** 只索引 `Public` 接口,忽略所有实现(`.cpp` )和私有目录。 - **具体命令:** - ``` # 进入引擎 Source 目录 -cd /Users/Shared/Epic\ Games/UE_5.4/Engine/Source +cd /d D:/UnrealEngine/UE_5.7/Engine/Source + +claude --dangerously-skip-permissions # 执行 graphify 扫描 # --include: 仅包含 Public 文件夹下的头文件,这是剪枝的核心 # --ignore: 排除掉极其庞大的第三方库和中间件 -graphify index . \ - --output ~/ue_engine_full.graph \ +/graphify index . \ + --output D:/MatrixTA/AIGameDev/AIDM0/Docs/Graphify/UE5.7_Header.graph \ --include "**/Public/**/*.h" \ - --ignore "ThirdParty/**,Developer/**,Programs/**,Intermediate/**,**/Private/**" \ - --max-depth 5 + --ignore "ThirdParty/**,Developer/**,Programs/**,Intermediate/**,**/Private/**" ``` **提示:** 这一步在 M1 Ultra 上可能仍需数十分钟。建议通过 `--max-depth` 限制继承链的抓取深度,通常设置为 5 已经能覆盖 90% 的关键基类(如 `UObject` -> `AActor` -> `APawn` -> `ACharacter` )。 --- -### 2\. 针对 UE 的“剪枝”策略配置文件 +### 2\. ~~针对 UE 的“剪枝”策略配置文件~~ 为了避免长命令,建议在项目根目录创建一个 `.graphifyconfig` (或工具支持的配置文件)。 @@ -225,8 +221,7 @@ graphify index . \ - `Runtime/InputCore` **自动化剪枝脚本示例 (Python):** 如果你发现 `graphify` 无法过滤细碎路径,可以用这个脚本生成一个“干净”的临时符号链接目录供其索引: - -``` +```python import os from pathlib import Path @@ -248,21 +243,17 @@ for module in core_modules: --- ### 3\. 实时构建 Project 业务图谱 (The Dynamic Layer) - 业务代码变动频繁,需要更轻量、更高频的更新。 - **执行命令:** - ``` # 在你的项目根目录执行,排除插件和中间文件 -graphify index ./Source \ +/graphify index ./Source \ --output ./project_current.graph \ --ignore "**/Intermediate/**,**/Binaries/**" \ --watch ``` **进阶:结合 ClaudeCode 的 `CLAUDE.md`** 在项目根目录的 `CLAUDE.md` 中添加指令,让 Claude 意识到有两个图谱存在: - ``` ### Knowledge Graph Context - **Static Engine Graph:** \`~/ue_engine_full.graph\` (Read-only, contains UE5 API) @@ -270,14 +261,41 @@ graphify index ./Source \ - **Rule:** When a class is prefixed with 'U' or 'A' and not in Project Graph, query Engine Graph via \`mcp-graph-tool\`. ``` +#### C++ & Puerts代码图谱 +```bash +# 同时指定项目路径和外部引擎路径 +# TODO:添加Index Plugins +/graphify index ./Source ./TypeScript \ + --output ./Docs/Graphify/Project/Project.graph \ + --include "*.cpp,*.h,*.hpp,*.ts" \ + --ignore "**/Intermediate/**,**/ThirdParty/**" +``` + +#### 增量更新模式(逻辑合并 - 推荐方案) +这是最符合工程实践的方法。先建立基础图谱,再将其他目录的内容“追随”进去。`graphify` 的 `--update` 标志会自动处理节点冲突并合并新的关系。 + +**执行命令:** +```bash +# 第一步:索引引擎(静态基础) +/graphify index /path/to/ue_engine/Source/Runtime \ + --output ./ue_workspace.graph \ + --include "**/Public/**/*.h" + +# 第二步:将项目目录合并到同一个图谱中 +/graphify index ./MyProject/Source \ + --output ./ue_workspace.graph \ + --update # 关键参数:在现有图谱基础上合并 +``` + + + + --- ### 4\. 实施 Multi-Graph 挂载的 MCP 方案 - 要让 ClaudeCode 真正理解这两个图谱,你需要一个简单的 MCP Server 来做中转。 **开发建议:** - 1. **加载:** 启动时同时 Load 两个 `.graph` 文件到内存。 2. **查询逻辑:** ``` @@ -293,7 +311,6 @@ graphify index ./Source \ ``` ### 总结执行清单: - 1. **环境准备:** 确定 UE 引擎路径。 2. **首次索引:** 使用上述“剪枝命令”生成 `ue_engine_full.graph` ,存放在家目录作为持久缓存。 3. **项目配置:** 在项目内运行带有 `--watch` 的 `graphify` 。