Zou82/dsh-plugin-git-sync ↗★ 1

dsh-plugin-git-sync

Git + GitHub automation for DeepSeek Harness: ask-before-init repo creation (name confirmed by user, rename on demand) and auto-sync on every code update. 适合需要将代码更新自动同步至GitHub的Agent自动化任务。

패키지
dsh-plugin-git-sync
호환성
미검증
Harness peer 범위
^0.1.1-rc.2 || ^0.2.0-rc.1
Cordis peer 범위
^4.0.1
버전
0.5.5
라이선스
MIT
최근 업데이트
2026. 9. 30.

설치

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Zou82/dsh-plugin-git-sync

配置

插件有两类配置:GitHub 令牌(凭据)和插件设置。两者都可以在 DSH 设置界面里改(设置 → 插件 → 插件配置 → GitHub 同步 卡片,0.2.0 起内置),也支持直接编辑文件,效果相同且实时生效(无需重启)。

1. 配置 GitHub 令牌(必须)

位置:~/.dsh/.credentials.yaml(DSH 凭据文件),或在上述设置卡片中直接填写(令牌只写不读,不出现在界面上)。

在 refs: 下添加一行:

version: 1
refs:
  DEEPSEEK_API_KEY: 你的-其他-密钥
  GITHUB_TOKEN: github_pat_xxxxxxxxxxxx

令牌权限要求(GitHub → Settings → Developer settings → Personal access tokens):

令牌类型需要的权限
Fine-grained PAT(推荐)Administration: Read and write(建仓)、Contents: Read and write(推送)、Metadata: Read
Classic PATrepo(整个 scope)

安全提示:令牌创建后只显示一次;请勿把令牌写进任何会被提交到 git 的文件。

2. 配置插件设置(可选,有默认值)

位置:DSH 设置界面 → 插件 → 插件配置 → GitHub 同步卡片;或 ~/.dsh/settings.yaml 的 git-sync: 段(二者等价,实时生效)

git-sync:
  github:
    username: 你的GitHub用户名        # 建仓 owner;留空则用令牌对应账号
    visibility: private               # 默认仓库可见性:private / public
    defaultBranch: main
    insecureTls: false                # 本机 TLS 被拦截时设为 true(见「常见问题」)
  auth:
    method: extraheader               # git 凭据注入方式:extraheader / askpass
  git:
    committerName: ""                 # 提交作者名;留空用 GitHub 用户名
    committerEmail: ""                # 提交作者邮箱;留空用 GitHub noreply 邮箱
  autoSync: true                      # 回合结束兜底:true 自动推送 / false 关闭 / "ask" 询问
  askBeforeInit: true                 # 项目启动时是否询问建仓
  init:
    createGitignore: true
    initialCommitMessage: "chore: initial commit"
  safety:
    scanForSecrets: true              # 提交前扫描敏感文件并阻止提交
    maxFileSizeMb: 50                 # 大文件告警阈值(GitHub 上限 100MB)

也可以在 cordis.patch.yml 的 config: 段提供同样的配置(二选一,patch 内配置随包分发、settings 是运行时可改的)。

3. 配置项一览

配置项默认值说明
github.username空(用令牌账号)建仓 owner(个人名或组织名)
github.visibilityprivate默认仓库可见性
github.defaultBranchmain默认分支名
github.insecureTlsfalse本机 TLS 证书链异常时跳过校验(仅可信网络建议开启)
auth.methodextraheadergit 凭据注入方式
git.committerName / committerEmail空提交身份,留空自动用 GitHub 账号 + noreply 邮箱
autoSynctrue回合结束兜底策略
askBeforeInittrue是否询问建仓
init.createGitignoretrue建仓时生成 .gitignore
init.initialCommitMessagechore: initial commit首次提交信息
safety.scanForSecretstrue敏感文件扫描
safety.maxFileSizeMb50大文件告警阈值
commit.conventionaltrue引导 agent 使用 Conventional Commits 提交信息
fileWatcher.enabledtrue文件监听:保存文件后自动提交推送(需 autoSync: true;忽略 .git/node_modules)
fileWatcher.debounceMs1500连续变化的防抖毫秒数(合并一次编辑为一次同步)
fileWatcher.ignoredist, build, __pycache__, ...额外忽略的目录/文件名(逗号分隔,按路径片段匹配)
fileWatcher.pollMs5000文件监听不可用时的轮询回退间隔(轻量 git status 检查)

1. 配置 GitHub 令牌(必须)

位置:~/.dsh/.credentials.yaml(DSH 凭据文件),或在上述设置卡片中直接填写(令牌只写不读,不出现在界面上)。

在 refs: 下添加一行:

version: 1
refs:
  DEEPSEEK_API_KEY: 你的-其他-密钥
  GITHUB_TOKEN: github_pat_xxxxxxxxxxxx

令牌权限要求(GitHub → Settings → Developer settings → Personal access tokens):

令牌类型需要的权限
Fine-grained PAT(推荐)Administration: Read and write(建仓)、Contents: Read and write(推送)、Metadata: Read
Classic PATrepo(整个 scope)

安全提示:令牌创建后只显示一次;请勿把令牌写进任何会被提交到 git 的文件。

2. 配置插件设置(可选,有默认值)

位置:DSH 设置界面 → 插件 → 插件配置 → GitHub 同步卡片;或 ~/.dsh/settings.yaml 的 git-sync: 段(二者等价,实时生效)

git-sync:
  github:
    username: 你的GitHub用户名        # 建仓 owner;留空则用令牌对应账号
    visibility: private               # 默认仓库可见性:private / public
    defaultBranch: main
    insecureTls: false                # 本机 TLS 被拦截时设为 true(见「常见问题」)
  auth:
    method: extraheader               # git 凭据注入方式:extraheader / askpass
  git:
    committerName: ""                 # 提交作者名;留空用 GitHub 用户名
    committerEmail: ""                # 提交作者邮箱;留空用 GitHub noreply 邮箱
  autoSync: true                      # 回合结束兜底:true 自动推送 / false 关闭 / "ask" 询问
  askBeforeInit: true                 # 项目启动时是否询问建仓
  init:
    createGitignore: true
    initialCommitMessage: "chore: initial commit"
  safety:
    scanForSecrets: true              # 提交前扫描敏感文件并阻止提交
    maxFileSizeMb: 50                 # 大文件告警阈值(GitHub 上限 100MB)

也可以在 cordis.patch.yml 的 config: 段提供同样的配置(二选一,patch 内配置随包分发、settings 是运行时可改的)。

3. 配置项一览

配置项默认值说明
github.username空(用令牌账号)建仓 owner(个人名或组织名)
github.visibilityprivate默认仓库可见性
github.defaultBranchmain默认分支名
github.insecureTlsfalse本机 TLS 证书链异常时跳过校验(仅可信网络建议开启)
auth.methodextraheadergit 凭据注入方式
git.committerName / committerEmail空提交身份,留空自动用 GitHub 账号 + noreply 邮箱
autoSynctrue回合结束兜底策略
askBeforeInittrue是否询问建仓
init.createGitignoretrue建仓时生成 .gitignore
init.initialCommitMessagechore: initial commit首次提交信息
safety.scanForSecretstrue敏感文件扫描
safety.maxFileSizeMb50大文件告警阈值
commit.conventionaltrue引导 agent 使用 Conventional Commits 提交信息
fileWatcher.enabledtrue文件监听:保存文件后自动提交推送(需 autoSync: true;忽略 .git/node_modules)
fileWatcher.debounceMs1500连续变化的防抖毫秒数(合并一次编辑为一次同步)
fileWatcher.ignoredist, build, __pycache__, ...额外忽略的目录/文件名(逗号分隔,按路径片段匹配)
fileWatcher.pollMs5000文件监听不可用时的轮询回退间隔(轻量 git status 检查)

使用

插件工具在新开对话中可用(当前对话的工具列表是固定的)。典型流程:

① 建仓(含仓库名确认/自定义)

我准备在 D:\my-project 开始一个新项目(目录为空),帮我建 GitHub 仓库并写一个 Python 脚本。

  • agent 调用 git_init → 询问「是否建仓」(选私有/公开/暂不)
  • 询问「仓库名使用 my-project?」→ 选「自定义名称」输入你想要的名称(不满意可改)
  • 名称冲突时自动建议 my-project-2 或让你重输
  • 自动完成本地 init + GitHub 建仓 + 首次提交推送

② 改名

把仓库名改成 better-name。

  • agent 调用 git_rename → 确认 → GitHub 改名 + 本地 remote 同步(旧链接 301 重定向)

③ 改代码后自动同步

加一个参数解析功能。

  • agent 改完代码调用 git_sync 提交推送;漏掉时回合结束自动兜底推送