dsh-web
zhu1090093659/dsh-webDeepSeek Harness(DSH)Web 插件聚合生态包 · 一切皆插件,创意工坊分发(dsh-market.com)
DSH 的交互式代码图谱:以侧栏入口呈现(装了 dsh-better-sidebar 时则是它的一个标签页),渲染 dsh-codegraph(.codegraph/codegraph.db 或 codegraph CLI)或 dsh-tool-lens 提供的数据,支持调用链追踪、循环依赖检测、依赖与影响分析、目录/文件/函数聚类、四种布局与 PNG/SVG/JSON 导出。需要 dsh-codegraph 或 dsh-tool-lens 提供数据源,否则图谱为空。
DeepSeek Harness (DSH) 代码图谱可视化插件 — 将
dsh-codegraph与dsh-tool-lens数据源聚合为交互式代码关系图谱
DSH CodeGraph Visualizer 是一个 DeepSeek Harness 生态插件,填补了代码关系图谱可视化领域的空白。它将 dsh-codegraph(CodeGraph CLI 封装工具)和 dsh-tool-lens(AST 代码图谱与拓扑分析)两个数据源的输出聚合、转换,并通过 Cytoscape.js 渲染为交互式代码关系图谱面板,嵌入 DSH Web UI 侧边栏。
dsh-codegraph 与 dsh-tool-lens,自动合并去重dsh web)# 安装插件(两种方式均可)
dsh plugin --profile web add github:xuanyuanchumo/dsh-codegraph-visualizer
dsh plugin --profile web add xuanyuanchumo/dsh-codegraph-visualizer
# 卸载插件
dsh plugin --profile web remove dsh-codegraph-visualizer
安装完成后启动 DSH Web 即可在侧边栏看到 "Code Graph" 标签页:
dsh web
# → http://localhost:3080,点击侧边栏 "Code Graph" 标签页
git clone https://github.com/xuanyuanchumo/dsh-codegraph-visualizer.git
cd dsh-codegraph-visualizer
pnpm install
pnpm run build
# 将构建产物安装到 DSH
dsh plugin --profile web add /path/to/dsh-codegraph-visualizer
# 启动自包含的 dev server(模拟 DSH Web Shell + 模拟数据)
pnpm run dev
# → http://localhost:3080
pnpm run test # 单元测试(320 tests)
pnpm run test:e2e # E2E 测试(需先启动 dev server)
pnpm run typecheck # 类型检查
pnpm run lint # Lint
┌─────────────────────────────────────────────────────────────┐
│ DSH Web UI Shell │
│ ┌───────────────────────────────────────────────────────┐ │
│ │ CodeGraph Visualizer Plugin │ │
│ │ │ │
│ │ ┌─────────────┐ ┌──────────────┐ ┌─────────────┐ │ │
│ │ │ Host Layer │ │ Data Layer │ │ Client Layer│ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ • routes │ │ • CodeGraph │ │ • GraphPanel│ │ │
│ │ │ • watcher │ │ Adapter │ │ • Toolbar │ │ │
│ │ │ • config │ │ • LensAdapter│ │ • Cytoscape │ │ │
│ │ │ • security │ │ • GraphData │ │ Renderer │ │ │
│ │ │ • prereqs │ │ Merger │ │ • Store │ │ │
│ │ │ │ │ │ │ • i18n │ │ │
│ │ └─────────────┘ └──────────────┘ └─────────────┘ │ │
│ └───────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
src/
├── index.ts # Host 端插件入口(re-export 聚合)
├── tools.ts # 4 个工具定义(graph_status/data/symbol/impact)
├── types/ # Branded 类型、GraphData、事件声明合并
├── adapters/ # 数据源适配器
│ ├── CodeGraphAdapter.ts # dsh-codegraph 数据源
│ └── LensAdapter.ts # dsh-tool-lens 数据源
├── merger/
│ └── GraphDataMerger.ts # 多数据源融合器(去重 + 合并)
├── host/ # Host 端模块
│ ├── config.ts # 配置定义与校验
│ ├── routes.ts # HTTP 路由注册
│ ├── watcher.ts # 文件监听与事件监听
│ ├── security.ts # 路径安全校验
│ └── prerequisites.ts # 前置条件检测
├── client/ # Client 端模块(浏览器渲染)
│ ├── index.ts # Client 端插件入口
│ ├── GraphPanel.tsx # 主面板 UI 组件
│ ├── api/ # HTTP API helpers
│ ├── components/ # UI 组件(Toolbar, SearchBar, ImportPanel, ...)
│ ├── renderer/ # 渲染引擎
│ │ ├── CytoscapeRenderer.ts # Cytoscape.js 渲染器
│ │ ├── IRenderer.ts # 渲染器接口
│ │ └── styles/ # 主题样式
│ ├── store/ # 状态管理
│ │ ├── graphStore.ts # Zustand 全局状态
│ │ └── cluster/ # 聚类策略模块
│ │ ├── types.ts # ClusterLevel/ClusterNode/ClusterEdge
│ │ ├── index.ts # 策略注册表
│ │ ├── directoryCluster.ts # 目录级聚类
│ │ ├── fileCluster.ts # 文件级聚类
│ │ ├── functionCluster.ts # 函数级(透传)
│ │ └── smartCluster.ts # 智能聚类(标签传播)
│ ├── i18n/ # 国际化(中/英)
│ ├── hooks/ # React Hooks
│ └── utils/ # 工具函数
├── push/ # 推送通知模块
└── shared/ # Host/Client 共享模块
采用 策略模式(Strategy Pattern) 实现 4 级聚类:
| 级别 | 策略 | 行为 |
|---|---|---|
directory | DirectoryClusterStrategy | 按顶级目录聚合,展开后显示文件级聚类节点 |
file | FileClusterStrategy | 按文件聚合,展开后显示函数/类/变量节点 |
function | FunctionClusterStrategy | 透传,不做聚类 |
smart | SmartClusterStrategy | 标签传播社区检测算法 |
渐进式层级展开:在目录级模式下,展开一个目录聚类节点会显示该目录下的文件级聚类节点(而非所有原始节点)。用户可以继续展开文件级聚类节点来查看函数级原始节点。
本项目遵循 DSH 插件开发规范九条红线:
src/index.ts 使用 definePlugin() 注册dsh.bundle.patch 指定 Cordis 补丁文件dsh.client.platform 为 "web"dsh.client.inject 声明运行时注入依赖peerDependencies 声明 Cordis/DSP-Tools/Reactexports 字段正确导出 host/client 入口files 字段仅包含 dist 和 cordis.patch.ymlengines 字段声明 Node/pnpm 版本要求packageManager 字段指定 pnpm 版本| 层 | 技术 |
|---|---|
| 语言 | TypeScript 5.7+ |
| 框架 | React 19 + Cordis 4 |
| 渲染 | Cytoscape.js 3.26 + cytoscape-dagre |
| 状态 | Zustand 5 |
| 构建 | tsdown (rolldown) |
| 测试 | Vitest 3 + Playwright 1.62 |
| Lint | oxlint |
| 包管理 | pnpm 9 |
pnpm run build # 完整构建(host + client)
pnpm run build:client # 仅构建 client bundle
pnpm run dev # 启动 dev server
pnpm run test # 单元测试
pnpm run test:e2e # E2E 测试
pnpm run typecheck # 三面类型检查
pnpm run lint # Lint
pnpm run lint:fix # Lint 自动修复
项目使用两个独立的 GitHub Actions 工作流:
| 工作流 | 文件 | 触发条件 | 职责 |
|---|---|---|---|
| CI | ci.yml | push/PR to master | lint + typecheck + test + build |
| Release | release.yml | push tag v* | build + GitHub Release + npm publish |