@weibaohui/dsh-sync 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,21 @@
1
- # dsh-plugin-dsh-sync
1
+ # @weibaohui/dsh-sync
2
2
 
3
- 一个小型 git 同步系统,让多个 dsh 副本通过一个**私有 GitCode 仓库**同步 skills / sessions / settings / plugins。每个实例只能以**分支 → PR → 合并**的形式提交变更,冲突因此显化为一个待合并的 PR,而不是静默覆盖。
3
+ [![DSH plugin](https://img.shields.io/badge/dsh-plugin-✅-green)](https://github.com/topics/dsh-plugin)
4
+ [![npm version](https://img.shields.io/npm/v/@weibaohui/dsh-sync)](https://www.npmjs.com/package/@weibaohui/dsh-sync)
4
5
 
6
+ **多机同步插件**:让多台机器上的 dsh 通过一个私有 GitCode 仓库保持一致——技能、会话、设置、插件清单都能同步。
7
+
8
+ ## 核心功能
9
+
10
+ - **四类内容可同步**(各有独立开关):
11
+ - 技能(skills,默认开)
12
+ - 会话记录(默认关,体积大)
13
+ - 设置(settings.yaml,默认开)
14
+ - 插件清单(各 profile 的依赖与配置,默认开)
15
+ - **分支 → PR → 合并**:每台机器的变更以 PR 形式提交,冲突显化为一个待合并的 PR,绝不静默覆盖
16
+ - **AI 一键解决冲突**:出现冲突时界面冒出「AI 解决冲突」按钮,点击后自动分析两边改动并合并,确定性的 git 操作不用你动手
17
+ - **安全**:强制私有仓库(公共仓库直接拒绝保存);访问 token 只写不回读
18
+ - **拉取安全**:pull 只回写本地没动过的远端变更,本地改过的内容不会被覆盖
5
19
 
6
20
  ## 安装
7
21
 
@@ -11,69 +25,10 @@ dsh plugin --profile web add @weibaohui/dsh-sync -w
11
25
 
12
26
  装完重启 `dsh web` 即生效。
13
27
 
14
- ## 发版(维护者)
15
-
16
- ```bash
17
- npm version patch # bump + commit + tag
18
- git push --follow-tags
19
- gh release create vX.Y.Z --generate-notes # 创建 Release 触发自动发布到 npm
20
- ```
21
-
22
- 发布由 GitHub Actions 完成(Release published 触发;打 tag 不发布),走 npm Trusted Publishing 免 token。
23
-
24
- ## 设计要点
25
-
26
- - **影子工作树**:`$DSH_HOME/dsh-sync/repo` 镜像选定的 live 根目录。不在 `~/.dsh` 直接开 git(里面混着凭证、profiles 的 node_modules)。push = fetch `origin/main` → shadow reset 到基线 → 覆盖 live 快照 → 建分支 → commit → push → 建 PR。
27
- - **三向算法**:live 目录是本机真相源,shadow+remote main 是合并账本。push 把本机增量做成 PR;pull 只把"本地没动过"的远端变更写回 live(本地动过的留给下个 push)。冲突由 PR 兜底。
28
- - **PR 即冲突闸口**:GitCode v5 REST(`POST /pulls`、`GET /pulls/:n`、`PUT /pulls/:n/merge`)。可合并则 squash 合并;冲突则留 PR 开着。
29
- - **冲突 = AI action button**:冲突时不机器硬合,也不纯人工挂起,而是 UI 冒出「AI 解决冲突」按钮,点击后启动一个 in-process agent(复用 skills-management share 的 `agents.create + followup` 通道),读 token、分析两边、改影子仓库、合并 PR。确定性的事(fetch/branch/commit/push)走 git CLI;只有需要语义判断的冲突才召唤 AI。
30
- - **私仓强制**:`settings.yaml` 整文件同步、**不脱敏**(含各 provider token)。前提是仓库必须 private——保存配置时调 `GET /repos/{owner}/{repo}` 校验 `private===true`,公共仓库直接拒绝。不代建仓库,用户自行到 gitcode.com 建私有仓库。
31
- - **token 只写不回读**:复用 skills-market 的 schemastery settings 模式,namespace `dsh-sync`,HTTP 只回 `hasToken`。
32
-
33
- ## 四类同步开关
34
-
35
- | 开关 | 默认 | 同步内容 |
36
- |---|---|---|
37
- | `syncSkills` | 开 | `~/.dsh/skills` + `~/.agents/skills`(软链解引用)+ `~/.agents/.skill-lock.json` |
38
- | `syncSessions` | **关** | `~/.dsh/sessions/**/*.session.jsonl.zstd`(写一次即不变,零冲突;默认关因体积大) |
39
- | `syncSettings` | 开 | `~/.dsh/settings.yaml` 整文件 |
40
- | `syncPlugins` | 开 | `~/.dsh/profiles/*/` 下 `package.json`/`cordis.patch.yml`/`pnpm-lock.yaml`/`pnpm-workspace.yaml`(排除 node_modules、.dsh-market、cordis.yml 产物) |
41
-
42
- ## 配置步骤
43
-
44
- 1. 在 gitcode.com 建一个**私有**空仓库(如 `my-dsh-sync`)。
45
- 2. 生成一个有该仓库读写权限的 access token。
46
- 3. dsh 侧栏点「同步」→ ⚙ 同步设置:填仓库地址、token、勾选要同步的类别。
47
- 4. 保存(私仓校验通过后)→ 立即同步。首次会全量上传。
48
-
49
- ## 已知局限
50
-
51
- - **plugins 跨机复现依赖 npm 包**:`cordis.patch.yml` 里 insert 的本地绝对路径插件(如 `dsh-plugin-hermes-prompt`)在另一台机器路径不存在,只能靠 `pnpm install` 拉 npm 包形式的插件。pull 下 profile 声明后需手动 `pnpm install` + 重启。
52
- - **settings 生效需重启**:运行中的 dsh 不一定热读 settings.yaml,pull 下来的 provider/UI 偏好要重启 dsh 才生效。token 类同生态共享无影响。
53
- - **多 profile 并发**:tui + web 同机双进程跑同一 `$DSH_HOME`,靠 `~/.dsh/dsh-sync/.lock`(O_EXCL + 死 pid 回收)串行化。
54
- - **`mergeable` 字段**:GitCode 文档动态渲染未显式列出,骨架按 Gitee/GitCode v5 兼容字段处理;联调时若该字段缺失,降级为"尝试合并、409 视为冲突"。
55
-
56
- ## 文件结构
57
-
58
- ```
59
- dsh-sync/
60
- ├── package.json # main: src/index.js, exports["./client"]: client/bundle.js
61
- ├── cordis.patch.yml # host-plane insert (id: dsh-sync)
62
- ├── src/index.js # 宿主:schemastery + settings + 私仓校验 + git 引擎 + 三向算法 + 冲突 action job + HTTP API + 调度
63
- ├── client/index.js # UI:状态面板 + token + 四开关 + 同步触发 + 冲突 action button
64
- ├── client/bundle.js # 由 scripts/build-client.mjs 生成
65
- ├── scripts/build-client.mjs
66
- └── test/sync.test.mjs # 本地 bare 仓库 + mock fetch 跑完整 push 流程
67
- ```
68
-
69
- ## 开发
70
-
71
- ```sh
72
- npm run check # node --check src + client
73
- npm test # node --test test/*.test.mjs(8 项,含端到端 push)
74
- npm run build:client # 重新生成 client/bundle.js
75
- ```
76
-
77
- ## 复用的 skills-management 基础设施
28
+ ## 使用
78
29
 
79
- schemastery 加载、settings register + hasToken 保密、`gitExec`/`authedUrl`、单飞去重、`ctx.effect` + `setInterval` 调度、slots + fullscreen overlay + 页内 dialog、in-process agent 事件泵——全部沿用 skills-management 已验收的实现。
30
+ 1. [gitcode.com](https://gitcode.com) 创建一个**私有**仓库(插件不会代建)
31
+ 2. 打开 Web UI → **设置页 → dsh-sync**,填入仓库地址与 access token,保存
32
+ 3. 按需开关四类同步内容
33
+ 4. 之后每次修改,通过同步操作把本机变更推成 PR;多机之间即可保持一致
34
+ 5. 出现冲突时,会话界面会出现「AI 解决冲突」按钮,点一下即可
package/client/bundle.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Regenerate with: npm run build:client
3
3
  */
4
4
  window.__ModuleLoader__.load({
5
- id: "dsh-plugin-dsh-sync",
5
+ id: "@weibaohui/dsh-sync",
6
6
  factory: (require) => {
7
7
  var module = { exports: {} }
8
8
  var exports = module.exports
@@ -459,7 +459,7 @@ window.__ModuleLoader__.load({
459
459
 
460
460
  // ── Plugin plane contract ────────────────────────────────────────────────
461
461
 
462
- const CLIENT_NAME = 'dsh-plugin-dsh-sync'
462
+ const CLIENT_NAME = '@weibaohui/dsh-sync'
463
463
 
464
464
  module.exports = {
465
465
  name: CLIENT_NAME,
package/client/index.js CHANGED
@@ -449,7 +449,7 @@ function SettingsSlotComponent(props) {
449
449
 
450
450
  // ── Plugin plane contract ────────────────────────────────────────────────
451
451
 
452
- const CLIENT_NAME = 'dsh-plugin-dsh-sync'
452
+ const CLIENT_NAME = '@weibaohui/dsh-sync'
453
453
 
454
454
  module.exports = {
455
455
  name: CLIENT_NAME,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weibaohui/dsh-sync",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "DeepSeek Harness plugin: a small git-based sync system for multiple dsh replicas. Mirrors skills / sessions / settings / plugins into a private GitCode repository and reconciles replicas through a branch → PR → merge flow, so conflicts surface as pull requests instead of silent overwrites.",
5
5
  "license": "MIT",
6
6
  "keywords": [