Chuyển đến nội dung chính

dsh-state-sync

Đã xác minh

dsh-state-sync · v0.1.0 · MIT · Giao diện web

DSH web plugin: one-click DSH state pack & sync — export portable state (settings, profile plugin manifests, lockfiles, skills, optional sessions) to a tar.gz under $DSH_HOME/backups, and restore with per-profile plugin reinstall. Settings page (Settings

Cài đặt

dsh plugin add dsh-state-sync

Xác nhận layer đã áp bằng dsh --profile default --dump-config — xem hướng dẫn cài plugin.

Mã nguồn

Phát hành lên npm mà không có repository công khai. Hãy kiểm tra nội dung package trước khi cài.

Thẻ

Readme

dsh-state-sync

给 DeepSeek Harness(dsh)提供一键状态打包与同步:把可移植的 dsh 状态导出为一个 .tar.gz,在新机器上恢复并按 profile 重装插件。

  • 设置页 — 设置 → DSH 状态打包与同步:导出、导入、浏览历史备份。
  • 斜杠命令/dsh-state export|import|list|home,可在输入框直接使用。
  • 独立脚本scripts/dsh-state-export.sh / scripts/dsh-state-restore.sh,不装插件也能用。

打包内容

路径 是否打包 说明
settings.yaml 偏好设置(主题 / 语言 / 模型 / 各插件设置)
profiles/*/package.json 插件依赖 + dsh.profile.bundles 激活列表
profiles/*/cordis.patch.yml 每个 profile 的用户覆盖层
profiles/*/pnpm-lock.yaml 依赖锁文件
profiles/*/pnpm-workspace.yaml profile 的 pnpm 配置
全局 cordis.patch.yml 存在时打包
skills/ 自定义技能
sessions/ 可选 --with-sessions 或设置页勾选
.credentials.yaml 永不打包 — 请单独、加密复制
profiles/*/node_modules/ 恢复时用 dsh plugin install 重建
storages/ 派生数据(索引、缓存),可重建

安装

与本仓库其他插件一样走 npm / bundle 通道:

dsh plugin --profile web add dsh-state-sync
# 本地 checkout:
dsh plugin --profile web add ./plugins/dsh-state-sync

下次启动 dsh 生效。卸载:dsh plugin --profile web remove dsh-state-sync

设置页

打开 设置 → DSH 状态打包与同步

  • 导出并打包 — 生成 $DSH_HOME/backups/dsh-state-<timestamp>.tar.gz。需要完整会话历史时勾选“同时打包 sessions/”(体积较大)。
  • 导入并恢复 — 输入备份包路径或从“历史备份”列表选择,确认后执行:先校验包内条目(拒绝绝对路径与 .. 穿越),再解包到 $DSH_HOME,最后对包内每个 profile 运行 dsh plugin --profile <name> install。只想解包不重装时,取消勾选“导入后立即重装各 profile 插件”。

凭据不会被包含。请手动复制 $DSH_HOME/.credentials.yaml,或单独加密:

tar -C "$DSH_HOME" -czf - .credentials.yaml | gpg -c > dsh-credentials.tar.gz.gpg

斜杠命令

在输入框使用:

/dsh-state export [--with-sessions] [target.tar.gz]
/dsh-state import [--no-install] [archive.tar.gz]
/dsh-state list
/dsh-state home

import 不带路径时使用 $DSH_HOME/backups 下最新的备份。

独立脚本

与插件行为一致,适合无 UI 环境或尚未安装 dsh 时使用:

# 导出到 $DSH_HOME/backups/
scripts/dsh-state-export.sh --with-sessions

# 恢复并重装插件
scripts/dsh-state-restore.sh ~/.dsh/backups/dsh-state-20250816-120000.tar.gz

# 只解包、不重装
scripts/dsh-state-restore.sh --no-install ~/.dsh/backups/dsh-state-20250816-120000.tar.gz

配置

bundle 行支持两个可选配置键(profile cordis.patch.yml,id 为 state-sync):

- insert:
    - id: state-sync
      name: dsh-state-sync
      config:
        backupDir: /Volumes/Backup/dsh-state   # 默认:$DSH_HOME/backups
        includeSessions: true                   # 默认:false

安全说明

  • JSON API 仅接受同源 POST,且 Host 地址必须是本机回环(或 web runtime 的 trustedHosts 列表内);跨站请求会被拒绝。
  • 解包前会检查归档条目,绝对路径与包含 .. 的条目会被拒绝。
  • 导入会按设计覆盖 $DSH_HOME 下的同名文件。只导入本插件自己创建的备份包。

License

MIT — 见 LICENSE