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自动化任务。
설치
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 PAT | repo(整个 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.visibility | private | 默认仓库可见性 |
github.defaultBranch | main | 默认分支名 |
github.insecureTls | false | 本机 TLS 证书链异常时跳过校验(仅可信网络建议开启) |
auth.method | extraheader | git 凭据注入方式 |
git.committerName / committerEmail | 空 | 提交身份,留空自动用 GitHub 账号 + noreply 邮箱 |
autoSync | true | 回合结束兜底策略 |
askBeforeInit | true | 是否询问建仓 |
init.createGitignore | true | 建仓时生成 .gitignore |
init.initialCommitMessage | chore: initial commit | 首次提交信息 |
safety.scanForSecrets | true | 敏感文件扫描 |
safety.maxFileSizeMb | 50 | 大文件告警阈值 |
commit.conventional | true | 引导 agent 使用 Conventional Commits 提交信息 |
fileWatcher.enabled | true | 文件监听:保存文件后自动提交推送(需 autoSync: true;忽略 .git/node_modules) |
fileWatcher.debounceMs | 1500 | 连续变化的防抖毫秒数(合并一次编辑为一次同步) |
fileWatcher.ignore | dist, build, __pycache__, ... | 额外忽略的目录/文件名(逗号分隔,按路径片段匹配) |
fileWatcher.pollMs | 5000 | 文件监听不可用时的轮询回退间隔(轻量 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 PAT | repo(整个 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.visibility | private | 默认仓库可见性 |
github.defaultBranch | main | 默认分支名 |
github.insecureTls | false | 本机 TLS 证书链异常时跳过校验(仅可信网络建议开启) |
auth.method | extraheader | git 凭据注入方式 |
git.committerName / committerEmail | 空 | 提交身份,留空自动用 GitHub 账号 + noreply 邮箱 |
autoSync | true | 回合结束兜底策略 |
askBeforeInit | true | 是否询问建仓 |
init.createGitignore | true | 建仓时生成 .gitignore |
init.initialCommitMessage | chore: initial commit | 首次提交信息 |
safety.scanForSecrets | true | 敏感文件扫描 |
safety.maxFileSizeMb | 50 | 大文件告警阈值 |
commit.conventional | true | 引导 agent 使用 Conventional Commits 提交信息 |
fileWatcher.enabled | true | 文件监听:保存文件后自动提交推送(需 autoSync: true;忽略 .git/node_modules) |
fileWatcher.debounceMs | 1500 | 连续变化的防抖毫秒数(合并一次编辑为一次同步) |
fileWatcher.ignore | dist, build, __pycache__, ... | 额外忽略的目录/文件名(逗号分隔,按路径片段匹配) |
fileWatcher.pollMs | 5000 | 文件监听不可用时的轮询回退间隔(轻量 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提交推送;漏掉时回合结束自动兜底推送