用途:查询代码库的依赖图谱,理解组件关系、调用链以及修改代码前的影响范围,属于 AI Maestro 套件。
前提条件:需在本地运行 AI Maestro,且代码库已完成索引。安装方式: git clone https://github.com/23blocks-OS/ai-maestro-plugins.git cd ai-maestro-plugins && ./install-graph-tools.sh
核心行为:读取任意代码文件后,先查询图谱理解依赖,再继续操作,即“读取文件 -> 查询图谱 -> 继续”。
查询命令:graph-describe.sh <name> 描述组件或函数;graph-find-callers.sh <fn> 查找函数的所有调用者;graph-find-callees.sh <fn> 查找该函数调用的所有函数;graph-find-related.sh <component> 查找相关组件;graph-find-by-type.sh <type> 按类型查找组件;graph-find-serializers.sh <model> 查找模型的序列化器;graph-find-associations.sh <model> 查找模型关联;graph-find-path.sh <from> <to> 查找函数间调用路径。
索引命令:graph-index-delta.sh [path] 索引或更新代码图谱。
组件类型:可与 graph-find-by-type.sh 配合使用,包括 model、serializer、controller、service、job、concern、component、hook。
使用示例:读取模型文件后执行 graph-describe.sh User、graph-find-serializers.sh User、graph-find-associations.sh User;修改函数前执行 graph-find-callers.sh process_payment、graph-find-callees.sh process_payment;查找调用链执行 graph-find-path.sh handleRequest sendResponse;索引代码库执行 graph-index-delta.sh /path/to/project。
修改前查询的原因:不检查图谱可能导致修改函数签名时破坏调用者、模型变更时遗漏需更新的序列化器、忽略继承修改的子类。
限制:依赖本地 AI Maestro 运行与代码库索引;具体支持语言、平台与收费信息暂未提供。