@he0119/dsh-settings-sync 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-settings-sync contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,122 @@
1
+ # Sync configuration
2
+
3
+ Sync a profile's plugin configuration and this device's credentials between devices over WebDAV. For
4
+ configuration the unit is each entry's `config` block in the profile patch file (`cordis.patch.yml`);
5
+ credentials are listed by name. Both sync by default, and you can keep an entry, a key or a credential
6
+ on one device by marking it "this device only" after picking it in Sync scope. The remote holds one
7
+ snapshot encrypted with AES-256-GCM, and the web UI previews changes before you confirm.
8
+
9
+ ## Install
10
+
11
+ Requires DSH `0.2.3-alpha.3` or newer; install it on both devices.
12
+
13
+ ```sh
14
+ npx @deepseek-ai/dsh@alpha plugin --profile web add @he0119/dsh-settings-sync
15
+ ```
16
+
17
+ `web` is the profile name; use yours, then restart it (`npx @deepseek-ai/dsh@alpha web`).
18
+
19
+ ## Configure
20
+
21
+ Have a WebDAV account ready and pick the directory that should hold the sync file. Missing folders
22
+ are created on the first upload. Generate a key once in a terminal with
23
+ `openssl rand -hex 32` and enter the same "sync encryption key" in the plugin detail page on both
24
+ devices. You can also provide it through the local credential store or the
25
+ `DSH_SETTINGS_SYNC_KEY` environment variable at startup.
26
+
27
+ In the plugin detail page on both devices, find "Sync settings" and enter an HTTPS WebDAV
28
+ directory URL. The plugin creates a `dsh-settings-sync` folder inside it and keeps `dsh-settings.bin`
29
+ there; the folder is created on the first upload, so you do not have to make it by hand. A URL
30
+ without a trailing slash counts as a directory too, so `…/dav` and `…/dav/` mean the same place. When the server needs a login, fill in the user name
31
+ and password, then click "Save settings". The password is stored in the DSH credential store;
32
+ leaving it blank keeps the saved password. With the startup environment you can keep providing the
33
+ password through `DSH_SETTINGS_SYNC_PASSWORD`.
34
+
35
+ The device-only list can also live in the configuration patch:
36
+
37
+ ```yaml
38
+ - id: settings-sync
39
+ config:
40
+ sync:
41
+ url: https://dav.example.com/dsh/
42
+ username: alice
43
+ localOnly:
44
+ - session-manager:sync.machineId
45
+ - tailnet-admin
46
+ ```
47
+
48
+ `sync.passwordRef` names the credential reference for the WebDAV password; the default is
49
+ `DSH_SETTINGS_SYNC_PASSWORD`. `sync.keyEnv` names the credential for the encryption key. Both devices need the same folder and the same
50
+ encryption key.
51
+
52
+ ## Usage
53
+
54
+ - Every entry in this device's patch file syncs by default. Upload once by hand first; automatic
55
+ sync needs a snapshot on the remote side.
56
+ - Automatic sync is off by default. After you enable and save "Automatic sync", DSH checks once a
57
+ minute while it runs. Keys changed on one side sync automatically; when both sides changed the
58
+ same key, confirm manually. After DSH restarts, the comparison baseline is rebuilt from the keys
59
+ that are the same on both sides, and keys that still differ need manual confirmation.
60
+ - With the plugin enabled, open **Plugins → Sync settings** in the web UI and find "Sync settings".
61
+ Click "Preview upload" or "Preview download", review the entries, keys and credentials that would
62
+ change, then
63
+ click "Confirm upload" or "Confirm download". "Cancel" discards the preview.
64
+ ## What gets synced
65
+
66
+ Sync scope lists every syncable entry in this device's patch file together with this device's
67
+ credentials, expanded by entry and key, and all of them sync by default. Unchecking an entry, a key
68
+ or a credential marks it "this device only": it is not uploaded and is never overwritten by a
69
+ download. A group row shows "device-only / total".
70
+
71
+ Each row shows that item's current value from the patch file on the right: one line, truncated when
72
+ long, with the full text in the tooltip; arrays read "N items: …". It is the value written in the
73
+ patch, not the plugin default, and secret paths never appear here.
74
+
75
+ Rows marked "this device only" stay in the tree, just unchecked; re-checking one key under them puts
76
+ only that key back. Rules that name an entry or key no longer present in this device's patch are
77
+ listed at the end of the tree, and unchecking them removes the rule.
78
+
79
+ These never sync:
80
+
81
+ - the plugin's own `settings-sync` entry (URL, username, and scope differ per device);
82
+ - configuration that contains `!!js` expressions (they may reference local paths or environment);
83
+ - fields the DSH settings interface marks as secret.
84
+
85
+ Entries whose plugin is missing on the target device are skipped during a download and reported.
86
+ Downloads merge per entry: keys in the snapshot but not on this device are added, and keys on this
87
+ device but not in the snapshot keep their value. Uploads replace only the entries this device has
88
+ and leave the rest of the remote snapshot alone. Marking an entry this-device-only does not delete the copy already in the remote snapshot;
89
+ remove or rewrite that snapshot first if you need the copy gone. The encrypted snapshot can be up
90
+ to 256 KiB.
91
+
92
+ ### Credentials
93
+
94
+ Credentials ride along with a manual configuration sync; you pick them in Sync scope, where they are
95
+ listed by name under a Credentials group, and unchecking one keeps it on this device. Preview upload
96
+ or Preview download lists the configuration entries and the credentials that would change (credentials
97
+ report only how many are added or overwritten), and one confirmation writes both. If either side
98
+ changed before you confirm, preview again.
99
+
100
+ Credentials and configuration share one encrypted snapshot, so the remote holds a single file.
101
+ Whether a credential syncs depends entirely on Sync scope: everything is in by default, unchecking one
102
+ keeps it on this device, and the plugin keeps no exclusion list of its own, so the WebDAV password and
103
+ encryption key used for syncing are listed too; uncheck them if you do not want them moved.
104
+ Automatic sync covers configuration only; when credentials in scope have changed, its result mentions
105
+ how many, and you sync them by hand.
106
+
107
+ - The host identifies entries as `ref:NAME` (credential reference) or `record:scope/id`
108
+ (credential record).
109
+ - A download merges per entry and keeps entries that exist only on the target. Only the names checked
110
+ in Sync scope move.
111
+ - WebDAV must support conditional `PUT` requests; updating an existing file also needs a strong
112
+ ETag (used to mark the file version). When the server redirects, use the final file URL instead.
113
+
114
+ ## Development
115
+
116
+ Use Node.js 24.22.3 and pnpm 12.23.0. Run `pnpm install` in the repository to install dependencies,
117
+ and `pnpm check` to check types, build, tests, and the installation package. The source entry
118
+ points, individual commands, and local verification steps are in [Development](docs/development.md).
119
+
120
+ ## License
121
+
122
+ MIT, see [LICENSE](LICENSE).
package/README.md CHANGED
@@ -1,3 +1,77 @@
1
- # Temporary Holding Version
1
+ # 配置同步
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 通过 WebDAV 在设备之间同步 profile 的插件配置和本机凭据。配置的范围是 profile 补丁文件(`cordis.patch.yml`)里每个条目的 `config` 段,凭据按名字列出;两者都默认全部同步,可以在同步范围里把条目、键或凭据标成「仅本机」留在原设备。远端只有一份 AES-256-GCM 加密的快照,网页端先预览再确认写入。
4
+
5
+ ## 安装
6
+
7
+ 需要 DSH `0.2.3-alpha.3` 及以上,两台设备各装一次。
8
+
9
+ ```sh
10
+ npx @deepseek-ai/dsh@alpha plugin --profile web add @he0119/dsh-settings-sync
11
+ ```
12
+
13
+ `web` 是 profile 名,换成你在用的那个;装完重启它(`npx @deepseek-ai/dsh@alpha web`)。
14
+
15
+ ## 配置
16
+
17
+ 准备一个 WebDAV 账号,并想在哪个目录下存放同步文件。目录不存在的部分第一次上传时会自动建出来。可在终端用 `openssl rand -hex 32` 生成一次密钥,在两台设备的插件详情页填写同一份「同步加密密钥」。也可以通过本机凭据存储或启动环境设置 `DSH_SETTINGS_SYNC_KEY`。
18
+
19
+ 在两台设备的插件详情页找到「同步配置」,填写 HTTPS WebDAV 目录地址。插件会在里面自建 `dsh-settings-sync` 文件夹,同步文件 `dsh-settings.bin` 放在那里面;第一次上传时目录不存在会自动建出来,所以不需要事先手动创建。地址没写结尾斜杠也按目录处理,填 `…/dav` 和 `…/dav/` 是同一个地方。服务器需要登录时,同时填写用户名和密码,再点击「保存设置」。密码保存在 DSH 凭据存储中,留空会保留已保存的密码。使用启动环境时可继续通过 `DSH_SETTINGS_SYNC_PASSWORD` 提供密码。
20
+
21
+ 仅本机清单也可以直接写进配置补丁:
22
+
23
+ ```yaml
24
+ - id: settings-sync
25
+ config:
26
+ sync:
27
+ url: https://dav.example.com/dsh/
28
+ username: alice
29
+ localOnly:
30
+ - session-manager:sync.machineId
31
+ - tailnet-admin
32
+ ```
33
+
34
+ `sync.passwordRef` 可指定 WebDAV 密码的凭据引用名,默认是 `DSH_SETTINGS_SYNC_PASSWORD`。`sync.keyEnv` 可指定加密密钥的凭据名。两台设备需要填写同一个目录地址和使用同一份加密密钥。
35
+
36
+ ## 使用
37
+
38
+ - 默认同步本机补丁文件里的全部条目。第一次同步时请先手动上传一次,远端有了快照之后再按需开启自动同步。
39
+ - 自动同步默认关闭。启用并保存「自动同步」后,DSH 在运行期间每分钟检查一次。只有一边改动的键会自动同步;两边把同一个键改成不同值时,需要手动确认。DSH 重启后从两边相同的键重新建立比较基准,仍有差异的键需要手动确认。
40
+ - 确认插件已启用,在网页端打开 **插件 → 配置同步**,找到「同步配置」。点击「预览上传」或「预览下载」,检查会改动的条目、键和凭据,再点击「确认上传」或「确认下载」。点击「取消」可放弃这次预览。
41
+ ## 同步范围
42
+
43
+ 「同步范围」列出本机补丁文件里所有可同步的条目和本机凭据,按条目、键逐层展开,默认全部参与同步。取消勾选一个条目、一个键或一项凭据,它就变成「仅本机」:不上传,也不会被下载覆盖。分组行上的数字是「仅本机 / 总数」。
44
+
45
+ 每行右侧显示这一项在补丁文件里的当前值:折成一行、超长截断,鼠标悬停看全文;数组写成「N 项:…」。它显示的是补丁里写的值,不是插件默认值;秘密路径不会出现在这里。
46
+
47
+ 被标成仅本机的行仍留在树里,只是不勾选;在它下面重新勾选单个键,会只把那个键放回同步。规则里写的条目或键在本机配置里已经不存在时,列表末尾会单独列出来,取消勾选即可移除。
48
+
49
+ 以下内容永远不参与同步:
50
+
51
+ - 插件自己的 `settings-sync` 条目(两台设备的地址用户名、范围各不相同);
52
+ - 含 `!!js` 表达式的配置(表达式可能引用本机路径或环境变量);
53
+ - DSH 设置接口标成秘密的字段。
54
+
55
+ 目标设备没有安装的插件,其条目在下载时会跳过,并在结果里报告。下载按条目合并:快照里有、本机没有的键会新增,本机有、快照里没有的键保留原值。上传同样只覆盖快照里本机有的条目,其他条目留在远端。把已经上传过的条目改成仅本机,不会删除远端已有的那一份;要清掉请先在远端删除或改写快照。加密快照最多 256 KiB。
56
+
57
+ ### 凭据
58
+
59
+ 凭据和配置走同一次手动同步,勾选在「同步范围」里完成:凭据挂在「凭据」分组下,显示的是名称,
60
+ 取消勾选就留在本机。点「预览上传」或「预览下载」,预览里会同时列出将改动的配置条目和凭据(凭据只报
61
+ 新增与覆盖的数量),确认之后两者一起写入。确认前配置或凭据任何一边变了,都要重新预览。
62
+
63
+ 凭据和配置存在同一份加密快照里,远端只有一个文件。凭据要不要同步完全看「同步范围」:默认都在,
64
+ 取消勾选就留在本机;插件不另设名单,同步连接的 WebDAV 密码、加密密钥一样列在里面,不想要取消勾选
65
+ 即可。自动同步只处理配置;范围内有凭据改动时,自动同步的结果里会提示数量,凭据需要手动同步。
66
+
67
+ - 宿主用 `ref:名称`(凭据引用)或 `record:范围/标识`(凭据记录)区分条目。
68
+ - 下载按条目合并,保留目标机独有的条目;只搬同步范围里打勾的名字。
69
+ - WebDAV 需要支持带条件的 `PUT` 请求,更新现有文件还需要强 ETag(用于标记文件版本)。服务器返回重定向时,请改用最终文件地址。
70
+
71
+ ## 开发
72
+
73
+ 使用 Node.js 24.22.3 和 pnpm 12.23.0。在仓库目录运行 `pnpm install` 安装依赖,运行 `pnpm check` 检查类型、构建、测试和安装包。源码入口、单项命令与本地验证步骤见 [开发说明](docs/development.md)。
74
+
75
+ ## 许可证
76
+
77
+ MIT,见 [LICENSE](LICENSE)。
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: settings-sync
3
+ name: '@he0119/dsh-settings-sync'
package/icon.svg ADDED
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
2
+ <g fill="none" stroke="#487CE0" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
3
+ <path d="M27 13a10 10 0 0 0-16.7-2.6L7 14m0 0v-6m0 6h6"/>
4
+ <path d="M9 23a10 10 0 0 0 16.7 2.6L29 22m0 0v6m0-6h-6"/>
5
+ </g>
6
+ <circle cx="18" cy="18" r="3" fill="#319D9C"/>
7
+ </svg>