初始化 CodeGraph 索引

发布时间:2026/7/19 5:08:37
初始化 CodeGraph 索引 容器启动后对所有一级子项目批量初始化docker exec -it “CONTAINERNAMEbatchcodegraphinit.sh{CONTAINER_NAME} batch_codegraph_init.sh CONTAINERN​AMEbatchc​odegraphi​nit.sh{CONTAINER_PROJECTS_PATH}”初始化完成后重启容器让前置网关重新扫描已初始化项目一定要执行这步docker restart “${CONTAINER_NAME}”单个项目也可以手动初始化docker exec -it “CONTAINERNAMEcodegraphinit{CONTAINER_NAME} codegraph init CONTAINERN​AMEcodegraphinit{CONTAINER_PROJECTS_PATH}/project-a”检查状态docker exec -it “CONTAINERNAMEcodegraphstatus{CONTAINER_NAME} codegraph status CONTAINERN​AMEcodegraphstatus{CONTAINER_PROJECTS_PATH}/project-a”测试查询docker exec -it “CONTAINERNAMEcodegraphexplore某个函数名或你的问题−−path{CONTAINER_NAME} codegraph explore 某个函数名或你的问题 --path CONTAINERN​AMEcodegraphexplore某个函数名或你的问题−−path{CONTAINER_PROJECTS_PATH}/project-a”远程访问验证检查统一网关curl “http://远程机器:HOSTPORT{HOST_PORT}HOSTP​ORT{HEALTH_ENDPOINT}”查看项目映射curl “http://远程机器:${HOST_PORT}/projects”检查某个项目后端curl “http://远程机器:${HOST_PORT}/project-a/healthz”OpenClaud/Opencode远程MCP配置假设远程服务端有以下几个项目/home/dora/Desktop/Projects/git_rep/├── ragflow/├── openclaude/├── codegraph-mcp-gateway/下面分别给出OpenClaud/Opencode MCP配置示例OpenClaud{“permissions”: {“allow”: [“mcp__codegraph-codegraph-mcp-gateway__codegraph_explore”,“mcp__codegraph-codegraph-mcp-gateway__,“mcp__codegraph-openclaude__codegraph_explore”,mcp__codegraph-openclaude__”,“mcp__codegraph-ragflow__codegraph_explore”,“mcp__codegraph-ragflow__*”]},“hooks”: {“UserPromptSubmit”: [{“hooks”: [{“type”: “command”,“command”: “codegraph prompt-hook”}]}]},“mcpServers”: {“codegraph-ragflow”: {“type”: “http”,“url”: “http://192.168.220.128:8000/ragflow/mcp”,“enabled”: true},“codegraph-openclaude”: {“type”: “http”,“url”: “http://192.168.220.128:8000/openclaude/mcp”,“enabled”: true},“codegraph-codegraph-mcp-gateway”: {“type”: “http”,“url”: “http://192.168.220.128:8000/codegraph-mcp-gateway/mcp”,“enabled”: true}}}Opencode{“$schema”: “https://opencode.ai/config.json”,“model”: “deepseek-ai/DeepSeek-V4-Pro”,“provider”: {…},“mcp”: {“codegraph-openclaude”: {“type”: “remote”,“url”: “http://192.168.220.128:8000/openclaude/mcp”,“enabled”: true},“codegraph-ragflow”: {“type”: “remote”,“url”: “http://192.168.220.128:8000/ragflow/mcp”,“enabled”: true},“codegraph-codegraph-mcp-gateway”: {“type”: “remote”,“url”: “http://192.168.220.128:8000/codegraph-mcp-gateway/mcp”,“enabled”: true}},“tools”: {“mcp__codegraph-codegraph-mcp-gateway*”: true,“mcp__codegraph-openclaude__: true,mcp__codegraph-ragflow__”: true}}OpenClaud CLAUDE.md 和 Opencode AGENTS.md路由规则这里两个文件内容配置的完全相同CodeGraph 强制使用规则当用户问题涉及以下任一场景时必须先使用 CodeGraph再回答, 优先使用远程 MCP 工具查找函数、类、变量、接口、配置项的定义分析调用链、依赖关系、数据流解释某个项目/模块/功能的实现定位 bug、修改代码、评审代码询问“在哪里实现”“怎么调用”“谁调用了它”禁止在完成 CodeGraph 初查前使用 grep、read、逐文件扫描来寻找符号或调用关系。查询规则先用较小范围查询不要一次塞入大量关键词。每次codegraph_explore优先聚焦一个模块、文件或功能点。maxFiles优先使用 3 到 6只有结果不足时再提高。如果 MCP 返回超时缩小查询范围后重试。项目索引映射项目路径CodeGraph 索引名触发词codegraph-mcp-gatewayhttp://192.168.220.128:8000/codegraph-mcp-gateway/mcpcodegraph-mcp-gatewaycodegraph-mcp-gateway, 项目规划openclaudehttp://192.168.220.128:8000/openclaude/mcpopenclaudeopenclauderagflowhttp://192.168.220.128:8000/ragflow/mcpragflowragflow路由优先级如果用户给出了文件路径或当前工作目录按路径选择索引。如果用户明确提到项目名按项目名选择索引。如果只出现通用词例如 RAG、检索、agent、工具调用不要仅凭该词选择索引应根据上下文判断无法判断时先询问用户。不要把rag作为 openclaude 和 ragflow 的共同触发词。执行流程先判断是否是代码理解/定位/调用链类问题。选择唯一 CodeGraph 索引。调用codegraph_search查找相关符号或文件。只有在搜索结果需要展开时才调用codegraph_explore或委托 Explore 子代理。如果 CodeGraph 无结果说明已检索失败再使用 grep/read 作为兜底。回答时说明使用了哪个索引。