jiangzhenguo/dsh-codegraph
dsh-codegraph
dsh-codegraph is a community DeepSeek Harness plugin. Read the repository README before installing.
Install
npx @deepseek-ai/dsh plugin --profile web add github:jiangzhenguo/dsh-codegraphRestart `dsh web` after install. Bundle APIs can change during the developer preview.
README badge
[](https://dshhub.dev/plugins/dsh-codegraph)Paste this into your README. The star count updates with every catalog sync.
From the README
Excerpt from jiangzhenguo/dsh-codegraph, cleaned of badges and images.
dsh-codegraph
让 DSH 会话直接使用 CodeGraph
(@colbymchenry/codegraph)的预索引代码知识图谱能力。
这是一个可一键安装的 DSH 插件(bundle):它把 codegraph CLI 包装成
模型可见的原生工具,模型在分析代码时无需 grep/读大量文件,直接按符号、
按区域、按调用链查询索引,并能自举并维护索引(init/index/sync)。
工具面(surface):借鉴上游项目「
codegraph_explore是唯一稳定赢得模型调用的工具」 的实测结论(其官方 MCP server 默认只暴露 explore),本插件默认只注册 4 个核心工具 (codegraph_status/codegraph_init/codegraph_sync/codegraph_explore), 保持模型工具列表精简、引导集中。需要全部 13 个工具时,在组合层配置surface: 'full'(见下文「配置」)。
提供的工具
| 工具 | 对应 CLI | 用途 |
|---|---|---|
codegraph_status | status --json | 索引状态(是否已初始化、版本、文件/节点/边数、待同步变更、建议重建等) |
codegraph_init | init | 初始化项目并建立初始索引(.codegraph/) |
codegraph_index | index | 全量(重)索引;status 建议 reindex 时用 |
codegraph_sync | sync | 增量同步索引(改代码后调用,让查询反映新代码) |
codegraph_uninit | uninit -f | 删除项目索引 |
codegraph_query | query --json | 按名称/子串搜索符号,返回结构化 JSON |
codegraph_node | node | 单个符号源码 + 调用/被调用轨迹,或带行号读文件 + 依赖 |
codegraph_explore | explore | 自然语言探索一块代码区域,直接返回相关文件源码与调用路径 |
codegraph_files | files --json | 索引内的项目文件结构 |
codegraph_callers | callers --json | 谁调用了某个符号 |
codegraph_callees | callees --json | 某个符号调用了什么 |
codegraph_impact | impact --json | 改动某个符号会波及哪些代码(重构/改名前用) |
codegraph_affected | affected --json | 改动若干源文件后应运行哪些测试文件 |
工具名与 CodeGraph 官方 MCP 工具同名,模型的使用心智与官方文档一致。
前置要求
-
已安装 DSH(本插件为 DSH bundle,随 DSH web 应用装载)。
-
已安装
codegraphCLI 且其可执行文件在PATH上(插件在运行时按名字codegraph解析可执行文件):npm i -g @colbymchenry/codegraph # 或按官方 install.sh / npm thin shim 安装 codegraph --version # 确认可用(≥ 1.0)
一键安装
在 DSH 应用的 web profile 中安装(一条命令,无需手动改任何配置文件):
dsh plugin --profile web add github:jiangzhenguo/dsh-codegraph
做了什么:
dsh plugin会在 profile 目录里跑pnpm add github:jiangzhenguo/dsh-codegraph;- 因为本包的
package.json声明了dsh.bundle.patch,DSH 的 plugin 管理器会把它自动 加入 profile 的dsh.profile.bundles层栈(cordis.patch.yml里那一条insert就是它的 组合层,不需要你手动加); - 重启 DSH 应用后,任意会话里模型即可看到
codegraph_*工具(默认 core 面 4 个)。
其他 profile:把
--profile web换成--profile tui等即可。
从 npm 安装(备选)
本包同样可按常规 npm 包发布/安装;若已发布到 npm,用包名替换上面开头的 github: 即可。
卸载
dsh plugin --profile web remove dsh-codegraph
一装上就会优先调用 codegraph 搜代码
插件不只是一个「把工具放出来」的包,它还会在系统提示词里注入一条高优先级指引
(tool:codegraph,order: 98),让模型在搜索/探索代码时优先用 codegraph_* 而不是
grep / glob / read:
- DSH 内置文件工具的指引集中在
order 100–104(read=100、write=101、edit=102、glob=103、grep=104)。本插件的指引放在 98,落在它们之前,因此模型先看到 “优先用 codegraph_* 搜代码”。 - 指引措辞采用上游官方 MCP server instructions 的同款策略(软性 "Prefer" 会被模型忽略,
实测会退回 grep/bash 反射路径):命令式(MUST use
codegraph_exploreINSTEAD of grep/glob/read)+ 反模式清单(不要先 grep「找文件」、不要用 grep 复核 codegraph 结果——它来自完整 AST 解析)+ 未索引项目的硬停止规则(不自行初始化时,本会话 不再调用 codegraph 工具,索引与否是用户的决定)。 - 指引只点名 core surface 的 4 个工具:
codegraph_status确认索引 → 未初始化则codegraph_init→ 之后用codegraph_explore一次拿到相关符号的逐行源码 + 调用链, 改完代码用codegraph_sync。
也就是说:装上即生效,无需每个会话单独配置——其他会话也一样会优先走 codegraph 来完成代码搜索。
结构化 prompt 自动前置注入(frontload)
提示词指引仍是「软性」的——模型可能忽略它(上游实测如此)。因此本插件实现了上游
UserPromptSubmit prompt-hook 的 DSH 等价物,也是上游验证过最有效的采用率手段:
…


