isayrhythm/dsh-plugin-repo-snapshot ↗★ 0

dsh-plugin-repo-snapshot

将加密的工作区仓库快照备份至本地或云端 适合需要自动备份工作区代码及 Git 记录以防丢失的用户。

包名
dsh-plugin-repo-snapshot
兼容性
待验证
Harness 依赖范围
*
Cordis 依赖范围
*
版本
1.0.0
许可证
MIT
最近更新
2026年9月19日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:isayrhythm/dsh-plugin-repo-snapshot

使用

重启后打开 设置 → 仓库快照备份。

  1. 启用 开关决定是否创建快照
  2. 存储位置 选「本机目录」或「阿里云 OSS」
    • 选 OSS 时填 Region(如 oss-cn-hangzhou)、Bucket、AccessKey ID、AccessKey Secret
    • 建议用只有该 bucket 写权限的 RAM 子账号
  3. 点 保存并测试连接 验证配置(会在目标位置写入并删除一个探针文件)
  4. 点 立即备份一次 立即生成一份快照;也可等会话开始自动触发

阿里云 OSS 建议

  • 权限策略最小化:只给目标 bucket 的 PutObject / DeleteObject

  • 想让密钥不落盘?把设置页的 AK/SK 留空,改用环境变量:

    export ALIYUN_OSS_ACCESS_KEY_ID=LTAI...
    export ALIYUN_OSS_ACCESS_KEY_SECRET=...
    

配置参考

设置页写入 /repo-snapshot/settings.json,优先于 cordis.patch.yml 里的配置。

配置项默认说明
enabledtrue总开关
oss.providerlocallocal / aliyun
oss.region—如 oss-cn-hangzhou
oss.bucket—bucket 名
oss.prefixrepo-snapshots/对象键前缀
oss.signatureVersionautoOSS 签名方案:auto(先试 V4,失败回退 V1)/ v4 / v1
oss.localDir``本机模式根目录;前缀会追加在其后
encryption.enabledtrue是否加密
encryption.algorithmaes-256-gcmaes-256-gcm / aes-256-ctr
scan.includeGittrue是否包含 .git
scan.excludePatternsnode_modules, dist, .venv, …裸目录名匹配任意层级
scan.maxFileSizeMB5单文件上限,超限跳过并计数
scan.excludeSensitiveFilestrue敏感文件拦截
triggersession-startsession-start / pre-step / both / manual
dedupetrue内容未变时跳过
maxSnapshotsPerSession5防止失控
injectStatusMessagetrue在对话中提示快照结果

HTTP 接口

宿主注册了四个路由,供设置页调用(也可脚本化):

方法路径说明
GET/plugins/repo-snapshot/status当前配置(密钥已脱敏)、密钥指纹、最近快照
POST/plugins/repo-snapshot/settings保存设置,接受扁平字段名或点号路径
POST/plugins/repo-snapshot/test探测目的地是否可用
POST/plugins/repo-snapshot/backup-now立即备份,可传 workspacePath