dsh-graphify:在 DeepSeek Harness 里构建与查询代码库知识图谱

前言

在 DSH 里让 Agent 理解大型代码库,常见做法是反复读文件、搜符号,上下文容易碎、跨模块关系也难一次说清。若把项目先建成一张本地知识图谱,再按自然语言或路径做查询,结构和依赖会更集中。dsh-graphify 是社区插件,把上游 graphify CLI 接到 Harness:提供七项 Agent 工具、一条 /graphify 命令,以及 Web UI 里的 Graphify 页面。图谱构建在本地完成;code 与 update 模式用 tree-sitter 解析 AST,不需要 API Key,也不会改你的源码。

这是什么

dsh-graphify(维护者 clrockrock,分类:记忆)面向 DeepSeek Harness 用户:在当前工程目录下生成 graphify 产物(默认落在 graphify-out/),并从对话、命令行或侧边栏页面查看统计、报告与交互图。插件本身不重写建图与查询逻辑,只解析工程路径、拼装 CLI 参数、设超时并回传结果。

社区目录页:skillhub.cn/plugins/clrockrock/dsh-graphify。源码与说明:github.com/clrockrock/dsh-graphify(MIT,当前 package 版本 0.1.0)。

核心功能

Agent 工具(七个)

工具 作用
graphify_status CLI 是否可用、版本、图谱路径、节点/边/社区数量、置信度分解、产物是否存在、建议问题
graphify_build 构建或刷新:code(本地 AST,无 Key)、update(增量)、full(文档/PDF/图片,需 LLM)
graphify_query 对图谱做自然语言提问;可用 BFS 取广上下文或 DFS 追一条链
graphify_path 两概念间最短路径及每一跳关系
graphify_explain 单节点:文件、位置、社区、度、邻居
graphify_god_nodes 连接度最高的「枢纽」节点
graphify_export 导出 wiki、html、svg、graphml、obsidian 到 graphify-out/

各工具可选 path;省略时默认 Session 工作目录,或在配置里指定 projectPath。

/graphify 命令

由 Host 直接执行,不会把整行发给模型:

/graphify status
/graphify build [code|update|full]
/graphify query <question>
/graphify path <source> <target>
/graphify explain <node>
/graphify god
/graphify export <wiki|html|svg|graphml|obsidian>

Graphify 页面

侧边栏入口打开后,通过插件同源 HTTP 读取当前工程状态(可输入目录切换项目):图谱统计与置信度分解、god 节点与大社区、内嵌渲染 GRAPH_REPORT.md、打开项目内 graph.html 交互图,以及 Build index、Update、Full extract、Export wiki 等与工具等价的操作。

构建模式

模式 是否需要 LLM Key 典型用途
code 否 首次索引;产出 graph.json、GRAPH_REPORT.md、graph.html
update 否 代码变更后只重抽改过的文件
full 是 在 graphify 侧用已配置的 LLM 后端处理文档、PDF、图片

环境与依赖

项 说明
DeepSeek Harness 0.2.1-rc.2 或更新(README 在 0.2.1-rc.2 上验证)
Node.js 20+(Host 要求)
graphify CLI uv tool install graphifyy 或 pipx install graphifyy;插件会查 PATH、~/.local/bin 及 uv/pipx 安装根
LLM API Key 仅 full 构建需要;code / update 不需要

README 记载与 graphify 0.9.97、DSH 0.2.1-rc.2 做过联调。

安装与启用

1、安装插件(资料原文命令,web profile):

dsh plugin --profile web add github:clrockrock/dsh-graphify

目录上架后也可在 Harness 内 Plugins → Discover 搜索 graphify 安装。每次 release 附带预构建 tarball,可跳过源码检出式安装。

2、安装 graphify CLI:

uv tool install graphifyy

3、重启 dsh web。重启后可让 Agent 调用 graphify_status,或点侧边栏 Graphify 图标。

典型用法

经过上面的步骤,可按 README 快速路径操作:

1、为当前项目建图:对 Agent 说「build the graph for this project」,或执行 /graphify build code,或在 Graphify 页点 Build index。

2、查询:例如问「module A 如何连到 module B」,或 /graphify query ...,或在页面看报告与交互图。

3、保持同步:代码改完后 /graphify update 或页面 Update。

可选配置写在 profile 补丁 ~/.dsh/profiles/<profile>/cordis.patch.yml(空配置可用):

- id: dsh-graphify
  name: dsh-graphify
  config:
    command: graphify
    extraArgs: []
    projectPath: ''
    graphPath: ''
    buildTimeoutMs: 1800000
    queryTimeoutMs: 120000

command 可改为绝对路径;若通过 uvx 调用可设 extraArgs 等。

适用场景与注意

适合:希望在 DSH 对话里稳定引用「模块—关系—社区」结构、要本地索引且 code/update 离线、或要在 Web UI 里一眼看 god 节点与 GRAPH_REPORT.md 的团队。

务必知晓:

  • 插件以当前 dsh 进程权限运行;安装前请自行查看仓库源码与 MIT 许可证,社区目录与 DeepSeek / 幻方无官方从属关系。
  • 无遥测;code/update 不联网;full 才走你为 graphify 配置的 LLM。
  • 索引只通过 graphify 写入 <project>/graphify-out/,不修改被索引源码。
  • 图谱与报告有体积上限(如 graph 文件 128 MiB 等),过大时会降级为提示而非无界加载。

结尾

dsh-graphify 把 graphify 的建图、查询与导出收成 Harness 内的工具、命令和页面,让「代码库记忆」落在本地图谱上而不是零散文件片段。进一步了解请访问 目录页 与 GitHub 仓库。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜