dshbase

插件目录 / Automation / dsh-git-plugin

dsh-git-plugin

已验证 · 实测可装 MashedPotato817

✓ 持续维护 基于 6 个官方 DSH 包

查看 GitHub ↗ ← 返回插件目录

2Stars
0Forks
0未关闭 issue
JavaScript语言
2026-08-13最近推送
跨平台平台

功能简介

dsh-git-plugin — DSH 插件(编排)

✅
我们的评价
可用 — 实测通过,早期项目

dsh-git-plugin — DSH 插件(编排) 实测能干净安装、正常启动。早期项目,但功能可用。

「已验证」表示我们的自动化 CI 在干净 profile 里实际执行了 dsh plugin add 并启动成功——仅此而已。功能描述与版本兼容性均为作者声明。这不是安全审计,也不代表对第三方代码的背书。

README

dsh-git-plugin

npm version
npm downloads
License

给 DeepSeek Harness(DSH)的 Git 工作流插件:补齐 DSH 相比 Claude Code / Codex 缺失的「程序员手感」——diff 感知、自动分支、规范提交、可恢复撤销。全部通过 ctx.subprocess seam 以纯 argv 调用 git,不经过 shell 层,每次运行都受字节与超时上限约束。

能力

命令(面向人 / 斜杠命令)

命令 作用
/status 显示当前分支与工作区状态(porcelain v1)
/diff 摘要显示已暂存 / 未暂存的改动
/branch [<name>] 不带参数列出分支;带参数则 git switch -c <name> 新建并切换
/commit [<message>] 带参数则 git add -A + 提交;不带参数显示提交规范与当前改动
/undo [list|pop] 默认 git stash push -u 做可恢复快照;list 查看、pop 恢复

工具(面向模型 / 只读)

工具 作用
git-status 分支 + 工作区状态
git-diff 未暂存(默认)或已暂存(staged=true)的 diff
git-log 最近提交历史(count 控制条数,path 过滤文件)
git-show 查看某个提交(默认 HEAD)的 message / author / diff

插件还会注入一段 system-prompt 指引,让模型主动用 git 工具查看状态、并遵循仓库的提交与分支规范。

仓库发现

当会话工作目录不是 git 仓库时,插件会:若其直接子目录里只有一个 git 仓库,自动使用它;有多个则列出让用户选择;一个都没有才报 not a git repository。这让它能在「项目集合」式的工作区根目录下正常工作。

安装

已发布到 npm([email protected]),一条命令安装:

dsh plugin --profile <name> add dsh-git-plugin

本地 / 源码开发时也可用路径安装:

dsh plugin --profile <name> add /path/to/dsh-git-plugin

安装后,在 profile 的 cordis.patch.yml 里用 insert 声明启用:

- insert:
    - id: dsh-git-plugin
      name: dsh-git-plugin

需要配置时加上 config:

- insert:
    - id: dsh-git-plugin
      name: dsh-git-plugin
      config:
        preCommit: [npm, test]

配置

键 默认值 含义
maxBytes 1048576 单次 git 调用 stdout 的上限字节数
stderrMaxBytes 65536 单次 git 调用 stderr 的上限字节数
graceMs 3000 子进程终止前的宽限毫秒数
timeoutMs 30000 工具调用的协作超时毫秒数
preCommit [] 提交前要运行的 argv 命令(如 ["npm","test"]);非零退出则中止 /commit

提交规范

/commit 默认提示 MAA 风格的提交信息,与本仓库约定一致:

<类型>(<可选作用域>): <中文主体>
feat / fix / docs / chore / style / refactor / test / perf

若仓库根目录存在 AGENTS.md / CLAUDE.md,模型会读取并遵循其中的自定义规范。

开发

  • 分支工作流:所有开发在功能分支进行,稳定后才合并到 main。
  • 分支命名:feat/xxx、fix/xxx、docs/xxx、chore/xxx。
  • 提交消息:<类型>(<可选作用域>): <中文主体>。

本地校验与测试:

npm install
npm run check   # 语法校验
npm test        # 单元 + 真实 git 集成测试

集成测试会在临时目录里真正 git init / commit / stash,验证 /commit、/undo、/branch 与只读工具端到端可用。

Hook 与 CI

  • 插件 pre-commit 钩子:通过 config.preCommit 配置一个 argv 命令,/commit 会在 git add 前运行它,失败即中止提交。

  • 仓库 commit-msg 钩子:.githooks/commit-msg 强制 MAA 提交格式。启用:

    git config core.hooksPath .githooks
    
  • CI:.github/workflows/ci.yml 在 push / PR 时跑 npm ci、node --check 和 node --test。

License

MIT

安装

🧩 让 Agent 自动装(推荐)

装一次目录插件,之后本站所有插件都能让 DeepSeek Harness 自动找、自动装:

dsh plugin add dshbase-catalog

然后对 agent 说「帮我装 dsh-git-plugin」,它会在目录里找到并自动安装。文档:dshbase-catalog · 已验证场景包。

Web profile:

dsh plugin --profile web add dsh-git-plugin

Headless(CLI)profile:

dsh plugin --profile headless add dsh-git-plugin

包信息

npm:dsh-git-plugin · 版本 0.1.0 · 实测环境 dsh 0.1.0-rc.6

实测报告

端到端验证通过:dsh 0.1.0-rc.6 上 L1 安装 + L2 加载 + L3 运行问答。

使用场景

自动化一项重复工作——调度、串联任务或响应事件——不用你亲手启动。

适合谁

有周期性工作、想 cron 式无人值守而非手动触发的人。

二次开发建议

触发器和任务模板是缝——加事件驱动或文件监听触发,以及更丰富的流程编排。

安全:尚未扫描——我们的每日静态扫描将很快覆盖它。

分享徽章

Automation 里更多

浏览全部 7797 个插件 →