Back to home@ShinonomeAya

dsh-git-chain

DeepSeek Harness plugin: Cursor-style Git commit-chain graph with SVG lanes, commit details, diff, filtering, and guarded branch switching.

Stars
0
Language
TypeScript
Created
Aug 26, 2026
Updated
Aug 26, 2026
GitHub repo

Introduction

dsh-git-chain

DSH web GUI 插件:Cursor 式 Git 链路图(提交图)面板——SVG 泳道拓扑、提交详情/完整 Diff、受守卫的分支切换。双面 Cordis 插件:Host 侧工作区门禁 git 服务 + /git-chain/* 路由,浏览器侧 React 面板;优先挂载为 dsh-better-sidebar tab,无基座时回退为输入栏芯片 + 浮动面板。

功能

  • 提交链路图git log --branches --tags --remotes --topo-order --parents 全分支拓扑;SVG 渲染泳道(竖线 + merge 贝塞尔汇入 + 节点圆点/菱形),非文本字形;固定行高 + 虚拟滚动,千级提交流畅。
  • 过滤:按主题 / 作者 / 引用 / oid 客户端即时过滤。
  • 提交详情:点击行查看作者/提交者/时间/父提交/变更文件(+/- 行数),懒加载完整 unified diff(行级着色,Host 侧 1MB 输出上限)。
  • 分支切换:下拉列出本地分支,git switch --no-guess;切换前守卫(未解决冲突 / 进行中操作 / 其他 worktree 检出),失败映射为稳定错误码并双语展示。
  • 自动刷新:Host SSE(30s 轮询 + 15s 心跳)推送外部变更 + 窗口聚焦节流刷新。
  • 双语:zh / en,跟随 DSH locale 实时切换。

架构

src/
  index.ts               Host 入口:inject webServer/subprocess/workspaceRegistry
  mount-once.ts          单实例守卫(聚合包 + 独立安装并存)
  host/
    git-service.ts       工作区门禁 git 服务(status/branches/graph/switch/show/diff)
    git-runner.ts        dsh-subprocess runner seam(win32 走 git.exe)
    routes.ts            /git-chain/* JSON 信封 + SSE 事件流
    access.ts / http.ts  loopback 受信栅栏 + JSON body 工具
  core/
    types.ts             线协议类型 + git 输出解析器 + 运行时窄化
    git-command.ts       argv 构建 + 切换失败分类 + 分支名校验镜像
    graph-layout.ts      泳道列分配 + merge 汇入/延续边(纯函数)
  client/
    index.ts             浏览器入口:better-sidebar tab(主)+ 输入芯片回退(辅)
    graph-panel.tsx      SVG 泳道图 + 虚拟滚动 + 工具栏 + 详情联动
    commit-detail.tsx    详情 + 懒加载 Diff
    fallback-chip.tsx    无基座时的芯片 + 浮动面板
    api.ts               /git-chain 客户端 + SSE 订阅

安全模型沿用 DSH 生态已验证的方案(参考 @linxin666/dsh-client-ui-git-graph,Apache-2.0):

  • /git-chain/* 只接受已注册 workspace 的路径(realpath 规范化 + workspaceRegistry.list() 比对);
  • 路由默认 loopback-only(socket 对端必须是本机),配对的远端设备 cookie 是额外放行路径;
  • 切换操作要求 application/json(CSRF 加固);
  • oid 严格十六进制白名单,绝不作为 shell 输入。

构建与检查

pnpm install
pnpm run typecheck   # tsc 双工程(host + client)
pnpm test            # 36 个测试:解析器/泳道布局 + 组件 DOM(jsdom)+ Host 集成(真实 git)
pnpm run build       # tsdown → lib/index.js(host,自包含)+ lib/client.js(浏览器 bundle)
node scripts/browser-smoke.mjs   # 真实 Chromium 冒烟(构建产物 + shell shim,截图到 smoke/)

lib/client.jswindow.__ModuleLoader__.load 闭包工厂产物,由 Host 的 client-modules 按 /plugins/dsh-git-chain/client.js 伺服;react 等框架依赖由外壳模块表提供(dsh.client.external 之外的统一基座),Host bundle 只保留 node: 内置模块为外部依赖,任何装配路径都能加载。

安装(开发,link 方式)

dsh plugin --profile desktop add link:F:\sokusai\DSH\dsh-git-chain
  • bundle patch(cordis.patch.yml)插入行 id git-chain,下次启动 profile 时生效(Host 半更新需要重启 DSH;client 半改动只需 pnpm run build 后硬刷新页面)。
  • @linxin666/dsh-client-ui-git-graph 等插件共存:路由前缀独立(/git-chain)、行 id 独立。

卸载

dsh plugin --profile desktop remove dsh-git-chain

发布

pnpm pack   # 或 npm publish(files 字段已限定 lib/src/cordis.patch.yml/README)

已知限制

  • 过滤只作用于已加载窗口(客户端过滤);全量过滤需服务端 git log <ref> 查询,留待后续。
  • 泳道布局为最小泳道算法(同参考实现);罕见菱形合并的曲线有微小重叠,可接受。
  • 虚拟滚动下,泳道边在窗口上下缘有截断(overscan 8 行补偿)。
  • 完整 diff 单次上限 1MB(Host 输出收集上限),超大变更会截断并标注。