前言¶
在 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 倉庫。