Skip to content
Back to search

dsh-git-change

DSH 插件:在输入框(composer)工具行右端、模型选择器左侧显示一枚 git 状态角标。

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/melo7up--dsh-git-change/badge.svg)](/listings/melo7up--dsh-git-change)

HTML

<a href="/listings/melo7up--dsh-git-change"><img src="/api/listings/melo7up--dsh-git-change/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

# 1) 包放进 profile 能解析的位置(本地开发用 link 依赖)
#    profile/package.json:
#      "dependencies": { "dsh-git-change": "link:/absolute/path/to/dsh-git-change" }
#      "dsh": { "profile": { "bundles": [ ..., "dsh-git-change" ] } }
# 2) 安装(建立软链 + 写入 lockfile)
cd ~/.dsh/profiles/desktop && pnpm install

包的 `package.json` 声明 `dsh.bundle.patch: ./cordis.patch.yml`,该 patch 里用 `- insert:` 把自己挂进配置树。

**注意:不要用 profile `cordis.patch.yml` 的顶层条目挂本地插件。** 用户层的顶层 `- id: x / name: y` 只能"覆盖已存在条目",新增会被 `patch: entry "x" not found` **静默忽略**(`insert:` 才新增)。

**改完代码要重启 DSH**:一是 profile 的 bundle/patch 层只在启动时装配; 二是 Node 的 ESM 缓存会让运行中的 host 一直用**第一次加载**的模块 (改了 `index.js` 后重载仍报旧行号的错就是这个原因)。

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 88 lines
  1. # dsh-git-change
  2. DSH 插件:在输入框(composer)工具行右端、模型选择器左侧显示一枚 git 状态角标。
  3. ![角标与悬停浮层](docs/badge.png)
  4. - **不在 git 仓库里工作区**:整个图标不渲染(不是灰掉,是不出现)。
  5. - **默认**:一枚 14px 的灰色分支图标,无圆底。
  6. - **悬停**:向上弹出浮层 —— 分支名 / 变更文件数 / `+新增` `-删除`(绿/红)。
  7. - **口径**:**我在这个分支上做的改动** —— ① 本分支自己 commit 但未 push 的提交(沿 first-parent、跳过 merge;每个文件按"我第一次改它之前 → 我最后一次改它"的**净差异**计,中间夹了 merge 会自动断段,不把合进来的内容卷进去)② 工作区已暂存 + 未暂存 ③ 未跟踪文件(按整文件行数计入新增)。
  8. - **`git pull` 别人的提交不计**:范围是 `@{upstream}..HEAD`,已推送的内容落在范围外。
  9. - **merge 带进来的不计**:merge commit 被跳过;只出现在 merge 里的文件(比如同事的新文件)根本不进统计名单;冲突解决写在 merge commit 里的部分也不计——解决完再单独改一次并 commit 才计入。
  10. - 没有 upstream(新 `git init`、无远程、detached HEAD)时只算工作区。
  11. - **刷新**:挂载时拉一次;会话状态变化时拉一次(近似"每轮结束");每次悬停再拉一次。host 侧另有 1.5s TTL 缓存防止悬停连击。**请求失败自动重试**(400ms 起步退避,最多 5 次)——冷启动时页面可能先于 host 半就绪,重试保证 host 一就绪图标立刻出现。
  12. ## 结构
  13. | 文件 | 作用 |
  14. | --- | --- |
  15. | `index.js` | host 半:注册 RPC 通道 `/dsh-git-change`,`status` 端点解析会话 cwd 并返回 git 摘要 |
  16. | `git.js` | git 采集(spawn 系统 git,`-z` 分帧,固定 C locale,只读命令,带上限与截断标记) |
  17. | `client.js` | client 半:**手写 bundle**(无构建步骤),把角标注册进 `conversation.input.right` |
  18. | `tools/verify-host.mjs` | host 半离线验证(6 项) |
  19. | `tools/verify-client.mjs` | client bundle 离线验证(5 项:加载协议 / apply / 图标 / 悬停浮层 / 非仓库不渲染) |
  20. | `tools/asar.mjs`、`tools/asar-grep.mjs` | 读 DSH `app.asar` 的小工具(调研用) |
  21. | `tools/make-preview.py` | 生成上面那张效果图(PIL 合成,不含任何真实项目内容) |
  22. | `tools/uninstall.sh` | 一键从 desktop profile 卸载 |
  23. 无构建步骤:DSH 的浏览器模块系统只要求 `client.js` 调用一次
  24. `window.__ModuleLoader__.load({ id, factory })`,且 factory **返回** `module.exports`。
  25. `id` 必须等于包名。
  26. ## 安装(本机已装,走 bundle 通道)
  27. ```bash
  28. # 1) 包放进 profile 能解析的位置(本地开发用 link 依赖)
  29. # profile/package.json:
  30. # "dependencies": { "dsh-git-change": "link:/absolute/path/to/dsh-git-change" }
  31. # "dsh": { "profile": { "bundles": [ ..., "dsh-git-change" ] } }
  32. # 2) 安装(建立软链 + 写入 lockfile)
  33. cd ~/.dsh/profiles/desktop && pnpm install
  34. ```
  35. 包的 `package.json` 声明 `dsh.bundle.patch: ./cordis.patch.yml`,该 patch 里用
  36. `- insert:` 把自己挂进配置树。
  37. **注意:不要用 profile `cordis.patch.yml` 的顶层条目挂本地插件。**
  38. 用户层的顶层 `- id: x / name: y` 只能"覆盖已存在条目",新增会被
  39. `patch: entry "x" not found` **静默忽略**(`insert:` 才新增)。
  40. **改完代码要重启 DSH**:一是 profile 的 bundle/patch 层只在启动时装配;
  41. 二是 Node 的 ESM 缓存会让运行中的 host 一直用**第一次加载**的模块
  42. (改了 `index.js` 后重载仍报旧行号的错就是这个原因)。
  43. ## 回滚
  44. ```bash
  45. # 1) 撤销 profile 侧的挂载
  46. cd ~/.dsh/profiles/desktop
  47. node -e "const fs=require('fs');const p='package.json';const j=JSON.parse(fs.readFileSync(p));delete j.dependencies['dsh-git-change'];j.dsh.profile.bundles=j.dsh.profile.bundles.filter(b=>b!=='dsh-git-change');fs.writeFileSync(p,JSON.stringify(j,null,2)+'\n')"
  48. pnpm install
  49. # 2) 重启 DSH
  50. ```
  51. ## 开发与验证
  52. ```bash
  53. node tools/verify-client.mjs # 需要 react/react-dom/jsdom(默认从 /tmp/gc-render/node_modules 取)
  54. node tools/verify-host.mjs # 可选参数:任意 git 工作区路径,默认 /tmp/gc-test
  55. ```
  56. `verify-client.mjs` 复刻 DSH 的加载协议(classic script → `__ModuleLoader__.load` →
  57. materialize),再用 jsdom + 真实 React 跑一遍挂载与悬停,因此 bundle 的语法/协议错误
  58. 不会走到线上 GUI(客户端插件加载失败会**阻止整个 Web GUI 挂载**)。
  59. ## 已知边界
  60. - **位置会随模型名长度左右漂移**:角标在 `conversation.input.right`,它渲染在模型选择器
  61. 左侧、间距恒为 12px(窄窗口 8px),而整组靠右对齐(`margin-left:auto`),所以模型名越
  62. 长、角标越靠左。模型选择器 `max-width: 220px`。
  63. - **未跟踪文件统计有上限**:最多 200 个文件、单文件 1MB;超限时浮层显示"统计已截断"。
  64. - **二进制未跟踪文件**只计文件数,不计行数。
  65. - **非 live 会话**(历史/归档)拿不到 header,角标不显示。
  66. - 只读操作:`GIT_OPTIONAL_LOCKS=0`、`GIT_TERMINAL_PROMPT=0`、`LC_ALL=C`,4 秒超时。
  67. ## License
  68. [MIT](LICENSE)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.