dsh-profile-config-sync 0.7.4 → 0.7.5
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 +2 -2
- package/package.json +1 -1
- package/release-notes.json +3 -3
- package/runtime/sync-engine.mjs +122 -24
- package/runtime/webdav.mjs +6 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ DSH 的配置散在 `~/.dsh` 的十几处:profile、全局提示、Skills、Ag
|
|
|
65
65
|
| 插件市场 | 客户端「插件市场 → 发现」搜「配置备份与同步」(`market-index.json` 登记的 `source.type` 是 `npm`,装的就是 registry 上的在线版) |
|
|
66
66
|
| 离线 tgz | `pnpm add ./dsh-profile-config-sync-0.6.49.tgz`(内网机器用这个) |
|
|
67
67
|
|
|
68
|
-
**发布状态**:`v0.7.
|
|
68
|
+
**发布状态**:`v0.7.5`(deleteCloud 跨引擎对齐 + 单项排除清旧副本)已发布;`v0.7.4` 反馈列表读全 + 根外路径体检剥注释;`v0.7.2` 工作区登记表双入口守护 + dry-run 计划修正;`v0.7.1` 修 Windows 自更新必失败;`v0.7.0` macOS 全面可用 + 平台分区。npm 同名包同步(`npm i dsh-profile-config-sync`)。多端测试安装:`pnpm add dsh-profile-config-sync@0.7.5`。
|
|
69
69
|
|
|
70
70
|
要正式发布时(需要有权限的账号,我不会擅自 push):
|
|
71
71
|
|
|
@@ -439,7 +439,7 @@ push 失败时会**按真实远端地址归因**:https 走 `ls-remote` 检查
|
|
|
439
439
|
|
|
440
440
|
| 日期 | 版本 | 要点 |
|
|
441
441
|
|---|---|---|
|
|
442
|
-
| 2026-11-28 | 0.6.49 | **macOS 全面可用**(本机切到 macOS 后集中修 Windows 假设):① 客户端根 `isAppRoot` 只认 `<root>/resources`,`.app` bundle 永远认不出 → AppRoot 为空、面板报「定位不到客户端根目录」;改按 `Contents/Resources` 归一。② app / Electron 版本写死 `<root>/resources/app.asar` 与 `<root>/version`;改由 `runtime/platform.mjs` 读(asar 头解析 + Framework 的 Info.plist)。③ 仓库路径只探 `D:/G:/C:`,且 POSIX 上把 `D:\dsh-config` 当相对路径真建目录;改默认 `~/dsh-config` + 按平台校验形状。④ 退出后同步只找 `post-exit.ps1`(macOS 上 spawn powershell 必 ENOENT);新增 `runtime/post-exit.mjs`。⑤ 自更新只找 `install-plugin.ps1`;新增 `runtime/install-plugin.mjs`(sha256/integrity 校验 + 自己解 tarball + 回滚)。⑥ 新机器 pull 缺 `Initialize-RepoIfNeeded` 等价物 →「拉取成功、什么都没落地」;改先 ls-remote 取默认分支再 checkout 跟踪。⑦ capture 不写执行体 → 首次推送后仓库被判「不像仓库」;改与 Windows 版一样把引擎模块写进仓库根。⑧ POSIX 还原脚本裸调 restore;改与 .cmd 对齐(快照信息 → `-DryRun` → 确认 → 真跑,响应带 backup)。⑨ 面板路径占位符 / 执行体名随平台。⑩ 自检改临时隔离 `DSH_HOME`(`--in-place` 才连真机),不再把测试值写进用户配置。⑪ 云端目标卡强制编辑态下 `activeMode` 不跟随下拉框 —— 选 WebDAV 仍显示 Git 字段、保存报「请填写 WebDAV 地址」(用户实测),并停止在 WebDAV 模式下回写 git 设置。⑫ **安全**:私钥名单只有自家文件名,`id_ed25519` / `id_rsa` / `*.ppk` 这类裸名会被原样上传;改按名字 + 内容(PEM / PuTTY 头)双重拦截,上传侧与 capture 共用同一份正则。⑬ 新增 `tools/webdav-selftest.mjs`:进程内最小 WebDAV 服务器,覆盖逐级 MKCOL、sha256 判重、冲突留底、空云端、不可达、明文闸门。⑭ 后台自动拉取(启动 8 秒首检)在 macOS 上也会弹原生框,而那条路径没有请求也没有面板 —— 框被窗口挡住就等于「自动拉取永不发生」;改挂 `status.auto.pullPrompt` + 日志,由面板一键接手,Windows 保持原样。⑮ macOS 上 /var、/tmp 是指向 /private/... 的符号链接,`git rev-parse --show-toplevel` 报真实路径,而引擎按字面量比 —— 仓库放在符号链接目录(/tmp/dsh-config 或链到外置盘)时推送/拉取一进门就报「这个目录不是仓库根」;改成两边 realpath 后再比。⑯ 同步范围卡:非 Windows 只有四组真会同步,范围卡却照样列出十二组可勾 —— 现在按平台带 `supported`,不支持的组禁用并标注「此平台暂不支持」。⑰ 会话记录进 Node 引擎:`--ws-<工作区ID>--` 稳定目录名 + `session-index.json` + 四块数据字节保真;会话日志走 seq 护栏,两台机器同时写同一会话不再互相覆盖出 `seq gap`;默认工作区不参与同步。⑱ 插件数据 / 额外路径也进 Node 引擎:规则(单文件上限 / 排除通配 / 跳过目录 / 安全必需项)收进 `runtime/extra-rules.mjs`,面板与引擎共用一份;顺带修掉「每次 capture 都重写所有文本文件、谎报改动数」。⑲ profile 组补 `cordis.yml`(哪些插件开着)与 `pnpm-workspace.yaml`,入库占位符化、apply 展开成本机路径。⑳「插件设置与工作流」进 Node 引擎(14 个配置文件,清单共用 `runtime/settings-sources.mjs`),易变计数清零;凭据嗅探提到共用模块,名字 + 内容两道门(之前 settings 会把带 apiKey 的配置原样入仓)。㉑ 再补三组:技能市场台账、记忆数据(`<AppRoot>/mnemon`)、本地源码插件(`link:` 目录打包成 `local-plugins/<名字>.zip`,新写的最小 zip 读写只依赖 `node:zlib`;换机解到 `<DshHome>/local-plugins-restore/` 由用户重新 link)。顺带修「源码里出现 apikey 字样就被当凭据」的误判。㉒ 最后一组「工作区资料」进 Node 引擎,但只同步**登记表**(registry-only):仓库里是 `workspace/workspace-registry.json`(id / 标题 / 槽名 / 占位符路径 / 会话 id / 默认工作区),不搬文件树(本机 5 个工作区里有 1.9 GB 的那个);还原按 id 合并且本机优先,另存 `workspace-from-cloud.json` 备查。至此 **12 组全部支持**。㉓ 跨平台拉取护栏:另一套系统传上去的 `profile/*` 与 `prompt/AGENTS.md` 只摊到 `profile-from-cloud/`、`prompt-from-cloud/`,不覆盖本机。㉔ 跨平台时 `settings` 组那份整份工作区登记表也不铺(实测会把本机 5 个工作区换成 19 个 `D:\` 路径)。㉕ 跨平台移植 `runtime/porting.mjs`:路径按「映射表 → 环境变量 → WSL → `C:\Users` → 同名工作区」翻译,`package.json` 本机优先合并、`link:` 目标必须真有 `package.json`、`file:` 缺 tgz 就丢,bundles 同步收敛;工作区登记表翻译后按 id 合并;推送后自动删云端的 `browser-profiles`(Login Data / Cookies)。㉘ 平台分区:`profile/<平台>/`、`prompt/<平台>/AGENTS.md`、`settings/<平台>/dsh-workspaces.json`,读时本平台优先、根目录老位置只读不写 —— 一份仓库给 Windows / macOS / Linux 各用各的。**注意 Windows 仍写根目录那份**(PowerShell 引擎未改),等于「Windows 的区 = 根目录」:Mac / Linux 只读不写根目录,因此谁也不会覆盖谁;等 Windows 侧跑上 Node 引擎后会自动改写成 `profile/win32/`,届时根目录那份成为历史遗留、可删。㉙ 共享配置互相覆盖:`skills`/`presets` 按云端镜像(删掉本机多出来的,删前留底);㉚ 全局提示按平台分开(`prompt/<平台>/AGENTS.md`)。㉛ 契约按平台读(`profile/<平台>/host-contract.json` 优先);㉜ 会话 `session.lock` 不同步(推送时清云端历史锁)。㉝ 修 Windows 更新必失败:TransformBlock 传 FileStream 在 PowerShell 7 无重载(ReadAllBytes 后再算)。验收:`selftest`
|
|
442
|
+
| 2026-11-28 | 0.6.49 | **macOS 全面可用**(本机切到 macOS 后集中修 Windows 假设):① 客户端根 `isAppRoot` 只认 `<root>/resources`,`.app` bundle 永远认不出 → AppRoot 为空、面板报「定位不到客户端根目录」;改按 `Contents/Resources` 归一。② app / Electron 版本写死 `<root>/resources/app.asar` 与 `<root>/version`;改由 `runtime/platform.mjs` 读(asar 头解析 + Framework 的 Info.plist)。③ 仓库路径只探 `D:/G:/C:`,且 POSIX 上把 `D:\dsh-config` 当相对路径真建目录;改默认 `~/dsh-config` + 按平台校验形状。④ 退出后同步只找 `post-exit.ps1`(macOS 上 spawn powershell 必 ENOENT);新增 `runtime/post-exit.mjs`。⑤ 自更新只找 `install-plugin.ps1`;新增 `runtime/install-plugin.mjs`(sha256/integrity 校验 + 自己解 tarball + 回滚)。⑥ 新机器 pull 缺 `Initialize-RepoIfNeeded` 等价物 →「拉取成功、什么都没落地」;改先 ls-remote 取默认分支再 checkout 跟踪。⑦ capture 不写执行体 → 首次推送后仓库被判「不像仓库」;改与 Windows 版一样把引擎模块写进仓库根。⑧ POSIX 还原脚本裸调 restore;改与 .cmd 对齐(快照信息 → `-DryRun` → 确认 → 真跑,响应带 backup)。⑨ 面板路径占位符 / 执行体名随平台。⑩ 自检改临时隔离 `DSH_HOME`(`--in-place` 才连真机),不再把测试值写进用户配置。⑪ 云端目标卡强制编辑态下 `activeMode` 不跟随下拉框 —— 选 WebDAV 仍显示 Git 字段、保存报「请填写 WebDAV 地址」(用户实测),并停止在 WebDAV 模式下回写 git 设置。⑫ **安全**:私钥名单只有自家文件名,`id_ed25519` / `id_rsa` / `*.ppk` 这类裸名会被原样上传;改按名字 + 内容(PEM / PuTTY 头)双重拦截,上传侧与 capture 共用同一份正则。⑬ 新增 `tools/webdav-selftest.mjs`:进程内最小 WebDAV 服务器,覆盖逐级 MKCOL、sha256 判重、冲突留底、空云端、不可达、明文闸门。⑭ 后台自动拉取(启动 8 秒首检)在 macOS 上也会弹原生框,而那条路径没有请求也没有面板 —— 框被窗口挡住就等于「自动拉取永不发生」;改挂 `status.auto.pullPrompt` + 日志,由面板一键接手,Windows 保持原样。⑮ macOS 上 /var、/tmp 是指向 /private/... 的符号链接,`git rev-parse --show-toplevel` 报真实路径,而引擎按字面量比 —— 仓库放在符号链接目录(/tmp/dsh-config 或链到外置盘)时推送/拉取一进门就报「这个目录不是仓库根」;改成两边 realpath 后再比。⑯ 同步范围卡:非 Windows 只有四组真会同步,范围卡却照样列出十二组可勾 —— 现在按平台带 `supported`,不支持的组禁用并标注「此平台暂不支持」。⑰ 会话记录进 Node 引擎:`--ws-<工作区ID>--` 稳定目录名 + `session-index.json` + 四块数据字节保真;会话日志走 seq 护栏,两台机器同时写同一会话不再互相覆盖出 `seq gap`;默认工作区不参与同步。⑱ 插件数据 / 额外路径也进 Node 引擎:规则(单文件上限 / 排除通配 / 跳过目录 / 安全必需项)收进 `runtime/extra-rules.mjs`,面板与引擎共用一份;顺带修掉「每次 capture 都重写所有文本文件、谎报改动数」。⑲ profile 组补 `cordis.yml`(哪些插件开着)与 `pnpm-workspace.yaml`,入库占位符化、apply 展开成本机路径。⑳「插件设置与工作流」进 Node 引擎(14 个配置文件,清单共用 `runtime/settings-sources.mjs`),易变计数清零;凭据嗅探提到共用模块,名字 + 内容两道门(之前 settings 会把带 apiKey 的配置原样入仓)。㉑ 再补三组:技能市场台账、记忆数据(`<AppRoot>/mnemon`)、本地源码插件(`link:` 目录打包成 `local-plugins/<名字>.zip`,新写的最小 zip 读写只依赖 `node:zlib`;换机解到 `<DshHome>/local-plugins-restore/` 由用户重新 link)。顺带修「源码里出现 apikey 字样就被当凭据」的误判。㉒ 最后一组「工作区资料」进 Node 引擎,但只同步**登记表**(registry-only):仓库里是 `workspace/workspace-registry.json`(id / 标题 / 槽名 / 占位符路径 / 会话 id / 默认工作区),不搬文件树(本机 5 个工作区里有 1.9 GB 的那个);还原按 id 合并且本机优先,另存 `workspace-from-cloud.json` 备查。至此 **12 组全部支持**。㉓ 跨平台拉取护栏:另一套系统传上去的 `profile/*` 与 `prompt/AGENTS.md` 只摊到 `profile-from-cloud/`、`prompt-from-cloud/`,不覆盖本机。㉔ 跨平台时 `settings` 组那份整份工作区登记表也不铺(实测会把本机 5 个工作区换成 19 个 `D:\` 路径)。㉕ 跨平台移植 `runtime/porting.mjs`:路径按「映射表 → 环境变量 → WSL → `C:\Users` → 同名工作区」翻译,`package.json` 本机优先合并、`link:` 目标必须真有 `package.json`、`file:` 缺 tgz 就丢,bundles 同步收敛;工作区登记表翻译后按 id 合并;推送后自动删云端的 `browser-profiles`(Login Data / Cookies)。㉘ 平台分区:`profile/<平台>/`、`prompt/<平台>/AGENTS.md`、`settings/<平台>/dsh-workspaces.json`,读时本平台优先、根目录老位置只读不写 —— 一份仓库给 Windows / macOS / Linux 各用各的。**注意 Windows 仍写根目录那份**(PowerShell 引擎未改),等于「Windows 的区 = 根目录」:Mac / Linux 只读不写根目录,因此谁也不会覆盖谁;等 Windows 侧跑上 Node 引擎后会自动改写成 `profile/win32/`,届时根目录那份成为历史遗留、可删。㉙ 共享配置互相覆盖:`skills`/`presets` 按云端镜像(删掉本机多出来的,删前留底);㉚ 全局提示按平台分开(`prompt/<平台>/AGENTS.md`)。㉛ 契约按平台读(`profile/<平台>/host-contract.json` 优先);㉜ 会话 `session.lock` 不同步(推送时清云端历史锁)。㉝ 修 Windows 更新必失败:TransformBlock 传 FileStream 在 PowerShell 7 无重载(ReadAllBytes 后再算)。验收:`selftest` 489 条 / `webdav-selftest` 26 条 / `clientcheck` 57 条全绿 |
|
|
443
443
|
| 2026-11-28 | 0.6.48 | **修 issue #7 / #8(第三方 WebDAV 连不上)与 #9(反馈带不了截图)**:① WebDAV 卡新增 **User-Agent** 输入项(issue #8)——部分第三方 DAV(群晖 / 坚果云 / 自建)按客户端名放行或拦截,没有这一项就只能看到「连不上」。UA 留空 = **完全不发这个头**(实测:Node 的 `fetch` 永远自带 `node` 这个 UA、无法表达「不发」,所以传输层从 `fetch` 换成 `node:http`/`node:https`,并自己处理重定向与 `Content-Length`;Windows 的 PowerShell 与 macOS/Linux 的 Node 引擎都走同一个 `webdav.mjs`,行为一致)。UA 只接受单行可见 ASCII(≤ 200 字符、不含换行 / 中文 / 制表符),非法值保存时直接报错,不静默存成空。② 连不上时**按状态码分开说原因**(issue #7)——原来一律是「连不上或认证失败(PROPFIND 无响应)」,用户既不知道是密码错、还是服务不支持 PROPFIND、也不知道该改哪一项;现在 401 / 403 / 404 / 405 / 重定向 / 超时 / 证书各有一句话,并给出「该改哪一项」;「测试连接」还会报出**实际发出去的 UA**,方便区分「服务端按客户端过滤」与别的原因。③ **问题反馈支持图片 / 视频 / 日志附件**(issue #9)——走 GitHub 的 release asset 接口传成反馈仓库自己的资产,正文引用它(图片内联、视频与日志给链接),不借道第三方图床,换机器与别人看都能打开;asset 接口只有 release 有(Issue 没有),所以附件挂在草稿 release(tag `feedback-assets`)上,不会出现在 Releases 页面;上限 4 个 / 单个 20 MB、类型白名单;不合格的附件逐条报错,**没有令牌时明确告知「附件没上传、请手动拖进网页」而不是静默丢弃**;建 Issue 失败时已上传的附件 URL 存进待发队列,补发时直接引用不重复上传。④ 顺带把 README 里「宿主挂 7 条路由」的陈旧数字改成实际的 13 条。验收:`tools/selftest.mjs` 374 条断言全绿(含 40 条新增:UA 真发出去 / 留空不发 / 四类非法值被拒 / 401·403·405 原因分得开 / 404 仍算「云端是空的」 / WebDAV 上传→跳过→下载整条通路实测 / 附件白名单与正文引用)、`tools/clientcheck.mjs` 全绿;另有 6 条与本次改动无关的既有失败(需要真实远端与真实客户端安装目录的用例)在改动前后完全一致 |
|
|
444
444
|
| 2026-11-27 | 0.6.47 | **更新只查 npm + 在线安装**:更新检查整体换成读 npm registry(dist-tags 定版本、单版本文档取 dist.tarball / dist.integrity、说明取包内 version.json),GitHub 的 raw / API / gh-proxy / ghfast 四条清单源与「更新清单 / 更新令牌」两项设置一起退休;市场索引 `source.type` 从 git 改成 npm,装的就是在线版。顺带修两个真 bug:① 旧「清单记 pnpm pack 的 sha256、npm 当兜底下载」在校验那步必然失败(实测 npm pack 与 registry 上的 tarball 逐字节一致,但与 pnpm pack 的资产不同),现在校验值取自 registry 自己;② 市场索引 publishTimestamp 写成毫秒而非 Unix 秒,DSH 的 parseMarketIndex 会拒掉整个索引——插件市场里此前根本读不出这个插件。功能代码改动集中在更新链路,同步/还原逻辑未动。验收:64 套隔离夹具共 1064 条断言全绿(不含检查这份 README 的文档对账套件本身;另有 1 条权限断言在 Windows 上标 SKIP,不会假装通过) |
|
|
445
445
|
| 2026-11-27 | 0.6.46 | **徽章数字接回计数**:0.6.41 手工写死的「64 套 · 1065 条」两版没再动,与同页验收声明(1061)打脸;现在 finalize 从 `last-count.json` 直接生成,口径与验收声明一模一样(只算非元套件:64 套 · 1061 条),人手不再参与。功能代码无改动。验收:64 套隔离夹具共 1061 条断言全绿(不含检查这份 README 的文档对账套件本身;另有 1 条权限断言在 Windows 上标 SKIP,不会假装通过) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-profile-config-sync",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DeepSeek Harness 客户端的多端配置备份、同步与还原插件:把本机配置按 12 组内容抓取成 Git 仓库快照(profile、全局提示、Skills、Agent 预设、插件设置与工作流、插件数据、工作区、会话记录等),可推送到 GitHub / Gitee / GitLab 或上传 WebDAV;换机重装后一条命令拉回并铺开,误改可选档回滚。同步动作在客户端退出后执行(PowerShell on Windows,Node 引擎 on macOS / Linux),面板与文案跟随客户端语言。",
|
|
6
6
|
"main": "./index.js",
|
package/release-notes.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.5",
|
|
3
3
|
"releasedAt": "2026-11-28",
|
|
4
|
-
"notes": "0.6.49:macOS 全面可用(本机切到 macOS 后集中修的一批 Windows 假设)。① 客户端根:isAppRoot 只认 <root>/resources,macOS 的 .app bundle 永远认不出 → AppRoot 为空、面板报「定位不到客户端根目录」、脚本生成不了。现在按 Contents/Resources 归一,并把 .app 内部路径的输入也归一回来。② 版本:app 版本与 Electron 版本写死 <root>/resources/app.asar 与 <root>/version;macOS 上 asar 在 Contents/Resources、没有 version 文件 → 两个格子恒为空、版本契约形同虚设。现在统一由 runtime/platform.mjs 读(asar 头解析 + Electron Framework 的 Info.plist)。③ 仓库路径:自动探测只试 D:/G:/C: 盘符,macOS 上必然失败;更糟的是 POSIX 上把 D:\\dsh-config 当相对路径,mkdir 会在当前目录真建一个叫 D:\\dsh-config 的目录(本仓库根就留了一个)。现在默认 ~/dsh-config,并按平台校验路径形状,跨平台写法当场 400 而不是静默存成别的意思。④ 退出后同步:执行体只找 post-exit.ps1,macOS 上 spawn powershell.exe 必 ENOENT → 「退出后推送/拉取/还原/更新」整条链路死掉,面板只显示排队中。新增 runtime/post-exit.mjs(等 pid → 跑引擎 → 写 auto-sync-result.json → 可选重启),锁文件两个平台共用。⑤ 自更新:运行中安装只找 install-plugin.ps1。新增 runtime/install-plugin.mjs(下载 → sha256/sha1/integrity 校验 → 用 zlib 自己解 npm tarball → 备份 → 覆盖 → 失败回滚),输出与 PowerShell 版同形的 RESULT:{json}。⑥ 首次拉取:Node 引擎没有 Windows 版 Initialize-RepoIfNeeded 的等价物,全新目录 pull 必停在「fatal: no such branch: 'main'」然后拿空仓库照跑一遍 —— 结果「拉取成功、什么都没落地」。现在先 ls-remote 取默认分支、fetch、无提交时 checkout -B 跟踪远端。⑦ 仓库自愈:POSIX 的 capture 只写内容不写执行体,第一次推送成功后仓库立刻被判成「不像仓库」并禁掉后续动作。现在 capture 把 sync-engine.mjs 及依赖模块写进仓库根(Windows 版一直这么干)。⑧ 还原脚本:POSIX 版是裸调一次 restore —— 不显示用的是哪份快照、不 dry-run、不确认,响应里也没有 backup 字段。现在与 .cmd 版对齐:快照信息 → 引擎 -DryRun → 确认 → 真跑,并返回 backup。⑨ 面板:仓库路径占位符、post-exit 名称、~/.dsh 路径随平台显示,不再一律写 D:\\ 与 .cmd。⑩ 自检:tools/selftest.mjs 不再往用户真实 ~/.dsh 里写测试值(改成临时隔离 DSH_HOME + 夹具,--in-place 才连真机),并新增 22 条平台回归断言;原来是「跑完靠备份还原兜底」,中途崩一次就把用户配置留在测试值上。⑪ 云端目标卡:在「什么云端都还没配」时会强制进入编辑态,但 activeMode 只认 editing、不认这个强制态 —— 选了 WebDAV 后字段不跟着切(还显示 Git 的远端地址 / SSH 私钥),保存时按 webdav 校验,报「请填写 WebDAV 地址」,而那个输入框根本不在页面上(用户实测截图)。现在由 isEditing 决定,强制态也跟随下拉框;同时选了 WebDAV 就不再回写 git 设置,免得先前填在「远端地址」里的 DAV 地址被当成 git 远端存下去、set-url 失败后整套回滚。⑫ 安全:私钥拦截名单只有 dsh-ssh-master.key 这类自家名字,ssh-keygen 的默认产物 id_ed25519 / id_rsa / *.ppk 是裸名,既无 .key 后缀也不在名单里 —— 用户把 ~/.ssh 加进额外路径就会把私钥原样传上云端(WebDAV 自检实测抓到)。现在按名字(id_rsa/id_dsa/id_ecdsa/id_ed25519(_sk)/identity/*.ppk)与内容(PEM / PuTTY 私钥头)双重拦截,上传侧与 capture 侧共用同一份正则,不再各写一套。⑬ 新增 tools/webdav-selftest.mjs:进程内起一个最小 WebDAV 服务器(真 HTTP / 真 XML / 真落盘、只连 127.0.0.1),覆盖首次上传逐级 MKCOL、按 sha256 判重(同长度不同内容必须重传)、冲突留底、空云端、不可达服务器、明文地址闸门,24 条断言,已接入 package.json 的 verify 与 CI。⑭ 后台自动拉取:启动 8 秒后的首检在 macOS 上也会弹 osascript 原生确认框,而那条路径既没有请求也没有面板 —— 框常常落在应用窗口后面甚至不出现在前台,用户看不见就等于「自动拉取永远不会发生」,DSH 还一直以为在等确认。现在 POSIX 只在 status.auto.pullPrompt 里挂提示(并写logs/auto-sync-pull-prompt.log),面板显示「云端领先 N 个提交,请点立即拉取」,排队或拉平后自动清除;Windows 保持原 MessageBox。面板侧的 /config-sync/auto 调用也收口到一处 autoFetch,支持两段式确认(宿主回 needConfirm → 面板自己问 → 带 confirmed:true 重发),用户点取消不抛错而显示「已取消」。⑮ 符号链接形式的仓库路径:macOS 上 /var 与 /tmp 都指向 /private/var、/private/tmp,`git rev-parse --show-toplevel` 报的是真实路径,而引擎拿用户填的路径去比字面量 —— 只要仓库在一个符号链接目录下(/tmp/dsh-config,或把仓库链到外置盘),推送/拉取一进门就报「这个目录不是仓库根」,面板的「立即推送」直接失败(新自检实测抓到)。现在两边都 realpath 一次再比,任一边解析失败退回字面量。⑯ 同步范围卡说实话:非 Windows 的引擎只同步 profile / 提示 / Skills / 预设四组,但范围卡照样列出十二组、勾选也照样能点 —— 用户勾上「会话记录」却永远不生效(待推送计数其实已经按四组算了,所以界面上是「待推送 0」+「勾选着会话记录」这种自相矛盾)。现在 GET /scope 给每组带 supported,不支持的组禁用心选框并标注「此平台暂不支持」。⑰ 会话记录进 macOS / Linux 引擎:这一组以前只有 Windows 的 PowerShell 会做,换了 Mac 之后勾着「会话记录」等于勾着好看。现在 Node 引擎按同一套目录命名(已登记工作区用 --ws-<工作区ID>--,im 用 --im--,认不出的原名穿透)抓取 sessions / attachments / session_projcache / vision_router_session_policy 四块数据,写 session-index.json,换机按本机工作区 ID 重新编码目录名;会话日志走 seq 护栏(两台机器各 append 一段时不会互相覆盖出 seq gap),护栏不可用时退回整文件覆盖并在面板写明。默认工作区始终不参与同步。⑱ 插件数据 / 额外路径也进 Node 引擎:这两组的规则(单文件上限、排除通配、跳过的目录、安全必需项)原先只写在面板代码里,引擎不知道也就抓不了。现在规则收进 runtime/extra-rules.mjs,面板与引擎共用一份,引擎按同一套规则抓 plugin-data/<槽>/ 与 extra/<id>/(含 manifest.json),apply 按占位符回到本机路径。顺手修掉「每次 capture 都重写所有文本文件」:内容归一后没变就不写,也不再谎报「本轮改了 N 个文件」。⑲ profile 组补上 `cordis.yml` 与 `pnpm-workspace.yaml`:前者是「哪些插件开着」的名单,丢了换台机器就不是同一套插件;后者是 hoisted 布局。Windows 版一直抓这两个,Node 引擎之前只抓 package.json / cordis.patch.yml / 两个 lock 文件。入库前同样做占位符化,apply 时展开成本机路径。⑳「插件设置与工作流」进 Node 引擎:14 个插件各自的配置文件(清单收进 runtime/settings-sources.mjs,面板与引擎共用一份),逐个文件抓取而不是整目录(周围都是 .db / 缓存 / 会话);our-free-model 的 catalogSyncedAt / reloadCount 这类每秒刷新的字段清零,否则每次抓取都「有改动」。凭据嗅探也提到共用模块 runtime/extra-rules.mjs:名字(.env / *.pem / *.key / 自家私有 json)与内容(GitHub 令牌前缀、accessToken / apiKey / password 等字段名、PEM / PuTTY 头)两道门,读不出来的文件一律当凭据 —— 之前 settings 组会把带 apiKey 的配置文件原样入仓。㉑ 又补三组进 Node 引擎:技能市场台账(storages-record,两个小 json)、记忆数据(mnemon,`<AppRoot>/mnemon` 整棵 + 镜像删除)、本地源码插件(local-plugins,profile 里 `link:` 指向的目录打包成 `local-plugins/<名字>.zip`)。打包走新写的 runtime/zip.mjs(只用 node:zlib,不引第三方),跳过 .git / node_modules / releases / .cache 与凭据文件,顶层必须是 `<名字>/package.json`(否则换个机器解出坏目录);换机 apply 解到 `<DshHome>/local-plugins-restore/<名字>/`,由用户重新 link —— 不硬写进客户端包(macOS 上那是签名过的 .app)。另修:源码文件里出现 \"apikey\" 这类**字段名字样**不再算凭据(本仓库自己的 selftest 因此被打包跳过过),真实 GitHub 令牌与私钥头照拦;需要豁免时可在文件里写 dsh-sync-allow-secret。㉒ 最后一组「工作区资料」也进 Node 引擎,但**只同步登记表**(mode: registry-only):仓库里写 `workspace/workspace-registry.json`(工作区 id / 标题 / 槽名 / 占位符化路径 / 会话 id / 钉住 / 默认工作区),**不搬工作区里的文件树** —— 实测这台机器 5 个登记工作区里 `~/projects` 就 1.9 GB,全搬等于把 NAS 当网盘。还原时按 id 合并进 `storages/workspace.json`(本机已有的工作区一律不动、只补缺的,写前留底),并把云端清单另存一份 `workspace-from-cloud.json` 供参考;`settings` 组里那份整份快照这时跳过,避免两处打架。至此 12 组在 macOS / Linux 上全部支持。㉓ 跨平台拉取护栏:仓库是另一套系统传上去的时候,`profile/package.json`、`profile/cordis.patch.yml`、`prompt/AGENTS.md` **一律不覆盖本机**,只摊到 `<DshHome>/profile-from-cloud/` 与 `<DshHome>/prompt-from-cloud/`,面板写明原因(判据:契约里的 platformFamily、package.json 里的盘符/AppData、cordis.patch.yml 里的 `X:\\`)。实测 Windows 仓库里 `\"@local/dsh-personal\": \"link:{{ROOT:userHome}}/AppData/Local/dsh-personal\"` 会在 macOS 上展开成不存在的路径,pnpm 解不出来、profile 起不来 —— 这条护栏挡的就是它。工作区登记表合并也会跳过本机形态不合法的路径。㉔ 真机拉取实测补一刀:`settings` 组里那份「整份工作区登记表」在跨平台时也不铺 —— 实测被 Windows 机器的快照覆盖后,本机 21 个工作区里 19 个是 `D:\\project\\...`(本机原来的 5 个被顶掉,面板里多出一堆点开就报错的行)。现在跨平台直接跳过并说明;同平台仍按原样铺。㉕ 跨平台移植(`runtime/porting.mjs`):拉回来的另一套系统配置不再只是「摊到暂存目录」,而是**改成本机能用的样子**。路径翻译按优先级找对应物(`config-sync-port.json` 映射表 → `%USERPROFILE%`/`%LOCALAPPDATA%` → WSL `/mnt/c/...` → `C:\\Users\\<U>` → 同名工作区 / `~/projects/<同名>` / `~/<同名>` / `~/Documents/<同名>`),一个都命中不了才放弃。`profile/package.json` 走「本机优先 + link 改写 + 不可装的丢弃」合并(`link:` 目标目录必须真有 `package.json`,`file:` 的 tgz 不在仓库里就丢),bundles 同步收敛;工作区登记表翻译后按 id 合并,同名去重、家目录本身不当工作区;`prompt/AGENTS.md` 翻译路径后放进 `prompt-from-cloud/`(本机已有自己那份就不覆盖)。实测云端那份 Windows profile 合并后 42 个依赖 `pnpm install --lockfile-only` 全解析通过。另:推送后自动删云端的历史浏览器剖面(`plugin-data/browser-profiles`,含 Login Data / Cookies),不用用户自己找。㉖ 修「覆盖前留底」形同虚设:几处 `backupBeforeWrite(dst, dst)` 把目标文件跟它自己比,永远判「内容相同」→ 备份根本没做(真机上覆盖 profile/package.json 时一点痕迹都没留)。改成传仓库那份作比对、本机那份作复制,并补断言钉住。㉗ 仓库自带执行体补齐:原先只往仓库里放 6 个 `.mjs`,0.6.49 新增的组用到的 `zip.mjs` / `extra-rules.mjs` / `settings-sources.mjs` / `porting.mjs` 和会话护栏 `tools/session-log-*.mjs` 没跟着走 —— 另一台机器没有插件副本时,拿仓库里那份跑 apply 会 `ERR_MODULE_NOT_FOUND`,或者静默降级成「不比对会话日志」。现在一次推齐,且内容没变不重写。㉘ 平台分区:机器相关的文件按平台分目录存,**一份仓库三端共用**。`profile/<平台>/`(package.json、cordis.patch.yml、cordis.yml、pnpm-*.yaml、host-contract.json)、`prompt/<平台>/AGENTS.md`、`settings/<平台>/dsh-workspaces.json`,平台取 `process.platform`(win32 / darwin / linux)。读的时候本平台优先,没有才回落到根目录那份老位置(回落到老位置就按移植层处理);根目录那份**只读不写**,留给还没升级的老客户端 —— 两边各写各的,谁也不覆盖谁。插件数据槽另外硬拦 `profile-from-cloud` / `prompt-from-cloud` / `local-plugins-restore`(自己产出的暂存目录不该被当成别人的插件数据再传上去,实测会被当成槽抓进 manifest)。㉙ 共享配置改成真正的「互相覆盖」:`skills` / `presets` 拉取时按云端镜像 —— 仓库里没有的本机条目会被删掉(删前留底到 `backups/apply-*`),否则在一台机器上删掉的技能永远删不掉,两边越用越分叉。全局提示 `prompt/AGENTS.md` 从平台分区回到共享(提示是配置,三端要一致),早期版本写出来的 `prompt/<平台>/AGENTS.md` 会在下次抓取时清掉。㉚ 全局提示按平台分开存(用户选择 B):`prompt/<平台>/AGENTS.md`。理由是里面写的是各系统的运行时路径与 shell 命令 —— 共享一份的话,Mac 推一次就把 Windows 的 `pwsh` 路由换成 macOS 的 `~/.dsh/dsh-runtimes/...`,反之亦然。技能、预设、模型设置、插件数据、会话、工作区登记表仍然共享并互相覆盖。㉛ 契约按平台读:`profile/<平台>/host-contract.json` 优先,根目录那份(老客户端写的,缺 platforms/platformFamily)只在没有分区副本时用。之前 macOS 上读到的是 Windows 那份不完整契约,`status` 里 platforms/platformFamily 全是空,面板会误报「契约缺失」。㉜ 会话锁文件不再同步:`session.lock` 只是「这个会话正被某个进程打开」的运行期标记,之前被当普通文件抓进仓库,铺到另一台机器就成了一条指向不存在 pid 的陈旧锁(DSH 可能据此以为会话被占用)。capture 跳过、apply 跳过,推送时顺带把云端历史 `session.lock` 精确清掉(只删这个后缀,不动其它文件)。㉝ 插件更新在 Windows 上必失败(0.6.47~0.7.0 全中):install 包校验用 `$sha.TransformBlock($fs, 0, $fs.Length, $null, 0)`,但 .NET 的签名是 `TransformBlock(byte[], int, int, byte[], int)`——第一参传 FileStream 在 PowerShell 7 找不到重载直接异常,catch 又把错误文案写成「Get-FileHash 不可用且 .NET 回退也失败」,方向整个带偏。修复:先 `ReadAllBytes` 成 byte[] 再 TransformBlock;post-exit.ps1 与 install-plugin.ps1 两处同修,并用真实 npm 0.7.0 包对 dist.integrity 验证(sha512-base64 匹配)。㉞ 工作区登记表两个入口全守住:`storages/workspace.json` 在 Node 引擎里有两个写入口 —— workspace 组的合并路径,和 settings 组 `dsh-workspaces.json` 那份整份快照(settings-sources.mjs 把它映射到同一个文件)。早先后者只在 workspace 组关闭时裸 pull() 覆盖:本机没有登记表时会写出缺 unit 头的旧格式文档(DSH 的 dsh-storage-json parse() 校验 document.unit.name==='workspace' && typeof unit.version==='number',缺 unit 段直接抛 malformed-medium —— 工作区列表和会话全读不出来),本机自建工作区连同 defaultWorkspaceId 也会被顶掉。修复:两处收进同一个 mergeWorkspaceRegistryDoc —— 补 unit:{name:'workspace',version:2} 头、global.workspaceIds 与表内条目保持一致(按本机原顺序)、同一路径收敛成一条(保留本机 ID,会话并集)、defaultWorkspaceId 以本机为准悬空才退云端值。与 Windows apply.ps1 的既有行为对齐。 ㉟ workspace 组 dry-run 不再被整组跳过:旧条件 `existsSync && !dryRun` 让「只看不动」时报「仓库里没有登记表」,计划里看不到将要并入的工作区;现在 dry-run 会算出计划(written 里出现「计划并入 N 个工作区」)且一个字节不落盘。㊱ 问题反馈列表读全:早先按 `labels=feedback` 过滤,而 GitHub 的 labels= 是 AND 过滤 —— 只有插件自己建的单带这个标签,用户直接在 GitHub 网页上手工建的(以及无令牌走浏览器预填、标签没点上的)一律不带,于是面板「全部」只剩 1 条而仓库里有 4 条(实测 #7/#8/#9 全被挡掉)。改为读仓库最新 50 条 issue(按创建时间倒序,仍排除 PR);客户端渲染上限同步从 20 提到 50(早先后端读 50、前端只画 20,看起来像没读全)。㊲ 根外绝对路径体检不再把注释当配置:capture.ps1 的 Write-OutsideRootReport 对整份文本跑正则,YAML 注释里的历史沿革(「bundle 从 D:\\c\\dsh-personal 搬到 %LOCALAPPDATA%」「根去掉已弃用的 C:/project」)被当成待确认的死路径报出来 —— 实测那份 cordis.patch.yml 报的 5 处全在 # 注释里,最后一条还把中文逗号「C:/project,只留」吞进了路径。改为先按扩展名剥注释再扫:.yml/.yaml 逐字符找不在引号内、且前面是空白的 #;.jsonc 剥 /* */ 与 // 与整行 #;.json 无注释语法原样扫。引号内的 # 不当注释,生效路径照样报。",
|
|
5
|
-
"notesEn": "0.6.49: macOS is fully supported (a batch of Windows-only assumptions fixed after this machine moved to macOS). (1) Client root: isAppRoot only accepted <root>/resources, so a macOS .app bundle never matched -> AppRoot empty, the panel reported \"cannot locate the client root directory\" and no script could be generated. It now normalises through Contents/Resources and also accepts a .app-internal path as input. (2) Versions: the app and Electron versions were read from <root>/resources/app.asar and <root>/version; on macOS the asar lives in Contents/Resources and there is no version file -> both fields empty forever. Both now come from runtime/platform.mjs (asar header parsing plus the Electron Framework Info.plist). (3) Repo path: auto-detection only tried D:/G:/C:, which cannot work on macOS; worse, on POSIX \"D:\\\\dsh-config\" was treated as a relative path and mkdir really created such a directory in the cwd. Default is now ~/dsh-config, path shapes are validated per platform, and a cross-platform path is rejected with 400 instead of being silently reinterpreted. (4) Sync after exit: the runner only looked for post-exit.ps1, so spawning powershell.exe failed with ENOENT and the whole \"push / pull / restore / update after you quit\" chain died while the panel kept saying queued. Added runtime/post-exit.mjs (wait for pid -> run engine -> write auto-sync-result.json -> optional relaunch); the lock file is shared by both platforms. (5) Self-update: in-process install only looked for install-plugin.ps1. Added runtime/install-plugin.mjs (download -> sha256/sha1/integrity verify -> own zlib tarball extraction -> backup -> overwrite -> rollback on failure) emitting the same RESULT:{json}. (6) First pull on a new machine: the Node engine had no equivalent of the Windows Initialize-RepoIfNeeded, so pulling into a fresh directory stopped at \"fatal: no such branch: 'main'\" and then ran against an empty repo -- \"pull succeeded, nothing landed\". It now takes the default branch from ls-remote, fetches, and checks out a tracking branch when there are no commits. (7) Repo self-heal: the POSIX capture wrote content but not the runner files, so right after the first successful push the repo was judged \"not a repo\" and every later action was disabled. capture now writes sync-engine.mjs and its modules into the repo root, as the Windows path always did. (8) Restore script: the POSIX variant was a bare restore call -- no snapshot info, no dry run, no confirmation, and no backup field in the response. It now matches the .cmd script: snapshot info -> engine -DryRun -> confirm -> real run, and the response carries backup. (9) Panel: repo-path placeholder, post-exit runner name and the ~/.dsh path follow the platform instead of always showing D:\\\\ and .cmd. (10) Self-test: tools/selftest.mjs no longer writes test values into the real ~/.dsh (it builds an isolated DSH_HOME plus fixtures; --in-place opts into the real machine) and gained 22 platform regression assertions -- it used to rely on restore-from-backup, so one crash mid-run left the user's config on test values. (11) Cloud target card: when nothing is configured yet the card forces edit mode, but activeMode only honoured `editing`, not that forced state -- picking WebDAV left the Git fields on screen (remote URL / SSH key) and Save then validated as webdav and reported \"please fill in the WebDAV address\" for an input that was not even rendered (reported by a user with a screenshot). activeMode now derives from isEditing, and saving in WebDAV mode no longer writes git settings, so an address typed into the Git field is not stored as a git remote and rolled back on set-url failure. (12) Security: the private-key blocklist only had our own names such as dsh-ssh-master.key, while ssh-keygen's default output (id_ed25519 / id_rsa / *.ppk) is a bare name with no .key suffix -- adding ~/.ssh as an extra path would upload the private key verbatim (caught by the new WebDAV self-test). Keys are now blocked by name (id_rsa/id_dsa/id_ecdsa/id_ed25519(_sk)/identity/*.ppk) and by content (PEM / PuTTY private-key headers), and the upload path and capture share one set of regexes instead of two drifting copies. (13) New tools/webdav-selftest.mjs: starts a minimal WebDAV server in-process (real HTTP, real XML, real disk, 127.0.0.1 only) and covers first upload with per-level MKCOL, sha256-based dedupe (same length different content must be re-uploaded), conflict backups, empty cloud, unreachable server and the plaintext-URL gate -- 24 assertions, wired into package.json verify and CI. (14) Background auto-pull: the first check 8 s after startup also tried to pop the osascript dialog on macOS, and that path has neither a request nor a panel -- the dialog usually lands behind the app window or never reaches the foreground, so the user never sees it and auto-pull simply never happens while DSH believes it is still waiting for confirmation. On POSIX it now only records status.auto.pullPrompt (plus logs/auto-sync-pull-prompt.log) and the panel shows \"the cloud is N commits ahead -- click Pull now\"; the prompt clears once a pull is queued or the sides match. Windows keeps the MessageBox. Panel calls to /config-sync/auto also go through one autoFetch helper with a two-phase confirm (host answers needConfirm -> panel asks -> resend with confirmed:true), and cancelling reports \"cancelled\" instead of throwing. (15) Repo paths that go through a symlink: on macOS /var and /tmp point at /private/var and /private/tmp, while `git rev-parse --show-toplevel` reports the resolved path -- the engine compared it literally against the path the user typed, so any repo living under a symlinked directory (/tmp/dsh-config, or a repo linked to an external disk) failed immediately with \"this directory is not the repo root\" and the panel's live push broke (caught by the new self-test). Both sides are now realpath'd before comparing, falling back to the literal value if either cannot be resolved. (16) The sync-scope card now tells the truth: on non-Windows the engine handles only profile / prompt / skills / presets, yet the card still listed all twelve groups with live checkboxes, so a user could tick \"conversations\" and nothing would ever happen (the pending counter already counted only four groups, which made the panel self-contradictory: \"nothing pending\" next to a ticked conversations group). GET /scope now reports supported per group, and unsupported ones are disabled and labelled \"not on this platform\". (17) Conversations now sync on macOS / Linux too: this group used to be PowerShell-only, so on a Mac ticking \"conversations\" meant nothing. The Node engine now captures the same four blocks (sessions, attachments, session_projcache, vision_router_session_policy) under the same stable directory names (--ws-<workspaceId>-- for registered workspaces, --im--, passthrough otherwise), writes session-index.json, and re-encodes directory names for the target machine's workspace paths on apply. Session logs go through the seq guard so two machines appending to the same session cannot overwrite each other into a seq gap; if the guard is unavailable it falls back to a whole-file copy and says so in the panel. The default workspace is never synced. (18) Plugin data and extra paths now sync on macOS / Linux too. Their rules (per-file cap, exclude globs, skipped dirs, safety-mandatory entries) used to live only in the panel code, so the engine could not apply them; they now live in runtime/extra-rules.mjs shared by both, and the engine captures plugin-data/<slot>/ and extra/<id>/ (with manifest.json) under the same rules, expanding placeholders back to local paths on apply. Also fixed: every capture used to rewrite all text files and report \"N files changed\" — unchanged content is no longer written. (19) The profile group now includes cordis.yml (the list of enabled plugins — without it a new machine ends up with a different plugin set) and pnpm-workspace.yaml (hoisted layout). The Windows scripts always captured these two; the Node engine only took package.json, cordis.patch.yml and the two lockfiles. They are tokenised on capture and expanded back to this machine's paths on apply. (20) The \"plugin settings and workflows\" group now syncs on macOS / Linux: the 14 per-plugin config files (list in runtime/settings-sources.mjs, shared with the panel) are captured file by file rather than directory-wise, because the surrounding tree is full of .db files, caches and sessions. Volatile fields such as our-free-model's catalogSyncedAt / reloadCount are zeroed so a capture is not \"changed\" every single time. Secret sniffing moved into the shared runtime/extra-rules.mjs with two gates — name (.env / *.pem / *.key / private json) and content (GitHub token prefixes, accessToken / apiKey / password keys, PEM / PuTTY headers) — and anything unreadable counts as secret: before this, the settings group would commit a config file containing an apiKey verbatim. (21) Three more groups on macOS / Linux: the skill-market ledger (storages-record, two small json files), memory data (mnemon, the whole <AppRoot>/mnemon tree plus mirror deletion) and local source plugins (local-plugins: directories referenced by `link:` in the profile get packed into local-plugins/<name>.zip). Packing uses a new runtime/zip.mjs built on node:zlib only, skips .git / node_modules / releases / .cache and secret files, and requires <name>/package.json at the archive root so the other machine cannot extract a broken nested directory. On apply the archive is extracted to <DshHome>/local-plugins-restore/<name>/ for the user to link, never written into the client bundle (a signed .app on macOS). Also fixed: source files that merely mention field names like \"apikey\" are no longer treated as credentials (our own selftest was being dropped from the plugin zip); real GitHub tokens and private-key headers are still blocked, and a file may opt out with dsh-sync-allow-secret. (22) The last group, workspace, is now supported on macOS / Linux too, but registry-only (mode: registry-only): the repo gets workspace/workspace-registry.json (id, title, slot, tokenised path, session ids, pinned ids, default workspace) and **no workspace file trees** — on this machine one registered workspace alone is 1.9 GB, so copying them would turn the NAS into a file host. Restore merges by id into storages/workspace.json (existing local workspaces untouched, missing ones added, backup taken first) and keeps a reference copy in workspace-from-cloud.json; the whole-file snapshot in the settings group is skipped in that case so the two sources cannot fight. All twelve groups are now supported on macOS / Linux. (23) Cross-platform pull guard: when the repo came from another OS, profile/package.json, profile/cordis.patch.yml and prompt/AGENTS.md are **never written over the local machine**; they are laid out in <DshHome>/profile-from-cloud/ and <DshHome>/prompt-from-cloud/ with a panel note explaining why (evidence: platformFamily in the contract, drive letters / AppData in package.json, `X:\\` in cordis.patch.yml). Verified against a real Windows repo whose `\"@local/dsh-personal\": \"link:{{ROOT:userHome}}/AppData/Local/dsh-personal\"` would expand to a non-existent macOS path and break the profile. Workspace-registry merging also skips paths that cannot exist here. (24) After a real pull test: the whole-file workspace registry in the settings group is now skipped for cross-platform repos too. It had replaced the local registry with 21 entries, 19 of them `D:\\project\\...` paths, and the local five were gone. Cross-platform pulls now skip it with an explanation; same-platform pulls behave as before. (25) Cross-platform porting (runtime/porting.mjs): a pull from another OS no longer just parks files aside — it rewrites them into something usable here. Path translation tries, in order: the map in config-sync-port.json, %USERPROFILE%/%LOCALAPPDATA%, WSL /mnt/c/..., C:\\Users\\<U>, then same-name workspace / ~/projects/<name> / ~/<name> / ~/Documents/<name>, giving up only when nothing exists. profile/package.json is merged local-first with link: targets rewritten and anything uninstallable dropped (a link: dir must really contain package.json, a file: tgz absent from the repo is dropped), and bundles are pruned to match; the workspace registry is translated and merged by id (same-name entries deduped, the home directory itself never becomes a workspace); prompt/AGENTS.md is translated into prompt-from-cloud/ and only replaces a local file that is itself a previous port. The real Windows profile merged to 42 dependencies that pnpm install --lockfile-only resolves cleanly. Pushing now also deletes the legacy plugin-data/browser-profiles tree (Login Data / Cookies) from the cloud. (26) Fixed a no-op backup: several call sites passed backupBeforeWrite(dst, dst), comparing the target file with itself, so it always decided \"unchanged\" and never copied anything (a real pull overwrote profile/package.json leaving no trace). It now compares against the repo copy and copies the local one, with an assertion to keep it that way. (27) The repo now carries everything the engine imports: the six .mjs files it used to ship were missing zip.mjs, extra-rules.mjs, settings-sources.mjs, porting.mjs and the session guard (tools/session-log-*.mjs), so another machine without a plugin copy would hit ERR_MODULE_NOT_FOUND or silently skip the session-log comparison. All of it ships now, and unchanged files are not rewritten. (28) Platform lanes: machine-specific files now live under a per-platform directory so **one repo serves all three clients**. profile/<platform>/ (package.json, cordis.patch.yml, cordis.yml, pnpm-*.yaml, host-contract.json), prompt/<platform>/AGENTS.md and settings/<platform>/dsh-workspaces.json, where platform is process.platform (win32 / darwin / linux). Reads prefer the local lane and fall back to the legacy root location (which then goes through the porting layer); the root files are read-only for us, left to clients that have not upgraded yet, so neither side overwrites the other. Plugin-data slots additionally hard-skip profile-from-cloud / prompt-from-cloud / local-plugins-restore, since our own staging output was otherwise captured as somebody's plugin data (it showed up in the manifest). (29) Shared config now really overwrites: pulling skills / presets mirrors the cloud, so local entries that no longer exist in the repo are deleted (copied into backups/apply-* first) — otherwise a skill removed on one machine could never be removed on another and the two would drift apart. prompt/AGENTS.md moved back from a per-platform lane to shared (instructions are config and should match on every client), and a stale prompt/<platform>/AGENTS.md from the earlier layout is cleaned up on the next capture. (30) The global prompt is per-platform again (option B chosen): prompt/<platform>/AGENTS.md. It carries each system's runtime paths and shell commands, so sharing one copy meant a Mac push would replace the Windows pwsh routing with macOS ~/.dsh/dsh-runtimes paths and vice versa. Skills, presets, model settings, plugin data, sessions and the workspace registry stay shared and overwrite each other. (31) The contract is read per platform: profile/<platform>/host-contract.json wins, and the root copy (written by older clients, missing platforms/platformFamily) is only a fallback. On macOS the reader used to pick the incomplete Windows file, leaving platforms/platformFamily empty in status and making the panel claim the contract was missing. (32) Session lock files are no longer synced: session.lock is just a runtime marker meaning \"some process has this session open\". It used to be captured like any other file and restored on another machine as a stale lock pointing at a pid that does not exist (DSH could then think the session was still in use). Capture and apply both skip it, and push deletes historical session.lock files from the cloud by exact suffix, leaving everything else alone. (33) Plugin self-update always failed on Windows (0.6.47 through 0.7.0): package verification used $sha.TransformBlock($fs, 0, $fs.Length, $null, 0), but the .NET signature is TransformBlock(byte[], int, int, byte[], int) — passing a FileStream as the first argument has no matching overload in PowerShell 7, the catch then mislabeled the failure as 'Get-FileHash unavailable'. Fix: ReadAllBytes into a byte[] first, then TransformBlock; both post-exit.ps1 and install-plugin.ps1 patched, validated against the real npm 0.7.0 dist.integrity (sha512-base64 match). (34) Both write paths into storages/workspace.json are now guarded: it had two entry points in the Node engine — the workspace group merge path and the settings-group dsh-workspaces.json full snapshot (settings-sources.mjs maps it to the same file). The latter used to wholesale-overwrite when the workspace group was off: on a machine without the registry it wrote a unit-less legacy document (DSH's storage layer throws malformed-medium; the workspace list and sessions become unreadable) and clobbered locally created workspaces together with defaultWorkspaceId. Fix: both paths now share mergeWorkspaceRegistryDoc — ensures the unit:{name:'workspace',version:2} header, keeps global.workspaceIds consistent with the table (local order preserved), collapses duplicate paths into one entry keeping the local id with merged sessions, and keeps defaultWorkspaceId local-first. Matches what apply.ps1 has always done on Windows. (35) The workspace group is no longer skipped entirely in dry-run: the old `existsSync && !dryRun` condition reported 'no registry in the repo' during dry-run so the plan never showed the workspaces it would merge; now dry-run computes the plan (written gains 'planned to merge N workspaces') without touching disk. (36) The feedback list now reads the whole repo: it used to filter by labels=feedback, but GitHub's labels= is an AND filter — only issues created by the plugin carry that label, while ones filed directly on the GitHub web UI (or via the token-less browser prefill where the label was not applied) do not, so the panel showed 1 of 4 issues (#7/#8/#9 were all hidden). Now it reads the repo's latest 50 issues sorted by creation desc (PRs still excluded), and the client render cap rose from 20 to 50 to match. (37) The outside-root absolute-path audit no longer treats comments as config: capture.ps1's Write-OutsideRootReport ran its regex over the whole text, so historical notes inside YAML comments ('bundle moved from D:\\c\\dsh-personal to %LOCALAPPDATA%', 'dropped the deprecated C:/project root') were reported as dead paths needing confirmation — all 5 hits in that cordis.patch.yml were inside # comments, and the last one even swallowed a Chinese comma into the path ('C:/project,只留'). Now comments are stripped by extension before scanning: .yml/.yaml walk characters to find a # that is outside quotes and preceded by whitespace; .jsonc strips /* */, // and whole-line #; .json has no comment syntax and is scanned as-is. A # inside quotes is not a comment, so live paths still get reported.",
|
|
4
|
+
"notes": "0.6.49:macOS 全面可用(本机切到 macOS 后集中修的一批 Windows 假设)。① 客户端根:isAppRoot 只认 <root>/resources,macOS 的 .app bundle 永远认不出 → AppRoot 为空、面板报「定位不到客户端根目录」、脚本生成不了。现在按 Contents/Resources 归一,并把 .app 内部路径的输入也归一回来。② 版本:app 版本与 Electron 版本写死 <root>/resources/app.asar 与 <root>/version;macOS 上 asar 在 Contents/Resources、没有 version 文件 → 两个格子恒为空、版本契约形同虚设。现在统一由 runtime/platform.mjs 读(asar 头解析 + Electron Framework 的 Info.plist)。③ 仓库路径:自动探测只试 D:/G:/C: 盘符,macOS 上必然失败;更糟的是 POSIX 上把 D:\\dsh-config 当相对路径,mkdir 会在当前目录真建一个叫 D:\\dsh-config 的目录(本仓库根就留了一个)。现在默认 ~/dsh-config,并按平台校验路径形状,跨平台写法当场 400 而不是静默存成别的意思。④ 退出后同步:执行体只找 post-exit.ps1,macOS 上 spawn powershell.exe 必 ENOENT → 「退出后推送/拉取/还原/更新」整条链路死掉,面板只显示排队中。新增 runtime/post-exit.mjs(等 pid → 跑引擎 → 写 auto-sync-result.json → 可选重启),锁文件两个平台共用。⑤ 自更新:运行中安装只找 install-plugin.ps1。新增 runtime/install-plugin.mjs(下载 → sha256/sha1/integrity 校验 → 用 zlib 自己解 npm tarball → 备份 → 覆盖 → 失败回滚),输出与 PowerShell 版同形的 RESULT:{json}。⑥ 首次拉取:Node 引擎没有 Windows 版 Initialize-RepoIfNeeded 的等价物,全新目录 pull 必停在「fatal: no such branch: 'main'」然后拿空仓库照跑一遍 —— 结果「拉取成功、什么都没落地」。现在先 ls-remote 取默认分支、fetch、无提交时 checkout -B 跟踪远端。⑦ 仓库自愈:POSIX 的 capture 只写内容不写执行体,第一次推送成功后仓库立刻被判成「不像仓库」并禁掉后续动作。现在 capture 把 sync-engine.mjs 及依赖模块写进仓库根(Windows 版一直这么干)。⑧ 还原脚本:POSIX 版是裸调一次 restore —— 不显示用的是哪份快照、不 dry-run、不确认,响应里也没有 backup 字段。现在与 .cmd 版对齐:快照信息 → 引擎 -DryRun → 确认 → 真跑,并返回 backup。⑨ 面板:仓库路径占位符、post-exit 名称、~/.dsh 路径随平台显示,不再一律写 D:\\ 与 .cmd。⑩ 自检:tools/selftest.mjs 不再往用户真实 ~/.dsh 里写测试值(改成临时隔离 DSH_HOME + 夹具,--in-place 才连真机),并新增 22 条平台回归断言;原来是「跑完靠备份还原兜底」,中途崩一次就把用户配置留在测试值上。⑪ 云端目标卡:在「什么云端都还没配」时会强制进入编辑态,但 activeMode 只认 editing、不认这个强制态 —— 选了 WebDAV 后字段不跟着切(还显示 Git 的远端地址 / SSH 私钥),保存时按 webdav 校验,报「请填写 WebDAV 地址」,而那个输入框根本不在页面上(用户实测截图)。现在由 isEditing 决定,强制态也跟随下拉框;同时选了 WebDAV 就不再回写 git 设置,免得先前填在「远端地址」里的 DAV 地址被当成 git 远端存下去、set-url 失败后整套回滚。⑫ 安全:私钥拦截名单只有 dsh-ssh-master.key 这类自家名字,ssh-keygen 的默认产物 id_ed25519 / id_rsa / *.ppk 是裸名,既无 .key 后缀也不在名单里 —— 用户把 ~/.ssh 加进额外路径就会把私钥原样传上云端(WebDAV 自检实测抓到)。现在按名字(id_rsa/id_dsa/id_ecdsa/id_ed25519(_sk)/identity/*.ppk)与内容(PEM / PuTTY 私钥头)双重拦截,上传侧与 capture 侧共用同一份正则,不再各写一套。⑬ 新增 tools/webdav-selftest.mjs:进程内起一个最小 WebDAV 服务器(真 HTTP / 真 XML / 真落盘、只连 127.0.0.1),覆盖首次上传逐级 MKCOL、按 sha256 判重(同长度不同内容必须重传)、冲突留底、空云端、不可达服务器、明文地址闸门,24 条断言,已接入 package.json 的 verify 与 CI。⑭ 后台自动拉取:启动 8 秒后的首检在 macOS 上也会弹 osascript 原生确认框,而那条路径既没有请求也没有面板 —— 框常常落在应用窗口后面甚至不出现在前台,用户看不见就等于「自动拉取永远不会发生」,DSH 还一直以为在等确认。现在 POSIX 只在 status.auto.pullPrompt 里挂提示(并写logs/auto-sync-pull-prompt.log),面板显示「云端领先 N 个提交,请点立即拉取」,排队或拉平后自动清除;Windows 保持原 MessageBox。面板侧的 /config-sync/auto 调用也收口到一处 autoFetch,支持两段式确认(宿主回 needConfirm → 面板自己问 → 带 confirmed:true 重发),用户点取消不抛错而显示「已取消」。⑮ 符号链接形式的仓库路径:macOS 上 /var 与 /tmp 都指向 /private/var、/private/tmp,`git rev-parse --show-toplevel` 报的是真实路径,而引擎拿用户填的路径去比字面量 —— 只要仓库在一个符号链接目录下(/tmp/dsh-config,或把仓库链到外置盘),推送/拉取一进门就报「这个目录不是仓库根」,面板的「立即推送」直接失败(新自检实测抓到)。现在两边都 realpath 一次再比,任一边解析失败退回字面量。⑯ 同步范围卡说实话:非 Windows 的引擎只同步 profile / 提示 / Skills / 预设四组,但范围卡照样列出十二组、勾选也照样能点 —— 用户勾上「会话记录」却永远不生效(待推送计数其实已经按四组算了,所以界面上是「待推送 0」+「勾选着会话记录」这种自相矛盾)。现在 GET /scope 给每组带 supported,不支持的组禁用心选框并标注「此平台暂不支持」。⑰ 会话记录进 macOS / Linux 引擎:这一组以前只有 Windows 的 PowerShell 会做,换了 Mac 之后勾着「会话记录」等于勾着好看。现在 Node 引擎按同一套目录命名(已登记工作区用 --ws-<工作区ID>--,im 用 --im--,认不出的原名穿透)抓取 sessions / attachments / session_projcache / vision_router_session_policy 四块数据,写 session-index.json,换机按本机工作区 ID 重新编码目录名;会话日志走 seq 护栏(两台机器各 append 一段时不会互相覆盖出 seq gap),护栏不可用时退回整文件覆盖并在面板写明。默认工作区始终不参与同步。⑱ 插件数据 / 额外路径也进 Node 引擎:这两组的规则(单文件上限、排除通配、跳过的目录、安全必需项)原先只写在面板代码里,引擎不知道也就抓不了。现在规则收进 runtime/extra-rules.mjs,面板与引擎共用一份,引擎按同一套规则抓 plugin-data/<槽>/ 与 extra/<id>/(含 manifest.json),apply 按占位符回到本机路径。顺手修掉「每次 capture 都重写所有文本文件」:内容归一后没变就不写,也不再谎报「本轮改了 N 个文件」。⑲ profile 组补上 `cordis.yml` 与 `pnpm-workspace.yaml`:前者是「哪些插件开着」的名单,丢了换台机器就不是同一套插件;后者是 hoisted 布局。Windows 版一直抓这两个,Node 引擎之前只抓 package.json / cordis.patch.yml / 两个 lock 文件。入库前同样做占位符化,apply 时展开成本机路径。⑳「插件设置与工作流」进 Node 引擎:14 个插件各自的配置文件(清单收进 runtime/settings-sources.mjs,面板与引擎共用一份),逐个文件抓取而不是整目录(周围都是 .db / 缓存 / 会话);our-free-model 的 catalogSyncedAt / reloadCount 这类每秒刷新的字段清零,否则每次抓取都「有改动」。凭据嗅探也提到共用模块 runtime/extra-rules.mjs:名字(.env / *.pem / *.key / 自家私有 json)与内容(GitHub 令牌前缀、accessToken / apiKey / password 等字段名、PEM / PuTTY 头)两道门,读不出来的文件一律当凭据 —— 之前 settings 组会把带 apiKey 的配置文件原样入仓。㉑ 又补三组进 Node 引擎:技能市场台账(storages-record,两个小 json)、记忆数据(mnemon,`<AppRoot>/mnemon` 整棵 + 镜像删除)、本地源码插件(local-plugins,profile 里 `link:` 指向的目录打包成 `local-plugins/<名字>.zip`)。打包走新写的 runtime/zip.mjs(只用 node:zlib,不引第三方),跳过 .git / node_modules / releases / .cache 与凭据文件,顶层必须是 `<名字>/package.json`(否则换个机器解出坏目录);换机 apply 解到 `<DshHome>/local-plugins-restore/<名字>/`,由用户重新 link —— 不硬写进客户端包(macOS 上那是签名过的 .app)。另修:源码文件里出现 \"apikey\" 这类**字段名字样**不再算凭据(本仓库自己的 selftest 因此被打包跳过过),真实 GitHub 令牌与私钥头照拦;需要豁免时可在文件里写 dsh-sync-allow-secret。㉒ 最后一组「工作区资料」也进 Node 引擎,但**只同步登记表**(mode: registry-only):仓库里写 `workspace/workspace-registry.json`(工作区 id / 标题 / 槽名 / 占位符化路径 / 会话 id / 钉住 / 默认工作区),**不搬工作区里的文件树** —— 实测这台机器 5 个登记工作区里 `~/projects` 就 1.9 GB,全搬等于把 NAS 当网盘。还原时按 id 合并进 `storages/workspace.json`(本机已有的工作区一律不动、只补缺的,写前留底),并把云端清单另存一份 `workspace-from-cloud.json` 供参考;`settings` 组里那份整份快照这时跳过,避免两处打架。至此 12 组在 macOS / Linux 上全部支持。㉓ 跨平台拉取护栏:仓库是另一套系统传上去的时候,`profile/package.json`、`profile/cordis.patch.yml`、`prompt/AGENTS.md` **一律不覆盖本机**,只摊到 `<DshHome>/profile-from-cloud/` 与 `<DshHome>/prompt-from-cloud/`,面板写明原因(判据:契约里的 platformFamily、package.json 里的盘符/AppData、cordis.patch.yml 里的 `X:\\`)。实测 Windows 仓库里 `\"@local/dsh-personal\": \"link:{{ROOT:userHome}}/AppData/Local/dsh-personal\"` 会在 macOS 上展开成不存在的路径,pnpm 解不出来、profile 起不来 —— 这条护栏挡的就是它。工作区登记表合并也会跳过本机形态不合法的路径。㉔ 真机拉取实测补一刀:`settings` 组里那份「整份工作区登记表」在跨平台时也不铺 —— 实测被 Windows 机器的快照覆盖后,本机 21 个工作区里 19 个是 `D:\\project\\...`(本机原来的 5 个被顶掉,面板里多出一堆点开就报错的行)。现在跨平台直接跳过并说明;同平台仍按原样铺。㉕ 跨平台移植(`runtime/porting.mjs`):拉回来的另一套系统配置不再只是「摊到暂存目录」,而是**改成本机能用的样子**。路径翻译按优先级找对应物(`config-sync-port.json` 映射表 → `%USERPROFILE%`/`%LOCALAPPDATA%` → WSL `/mnt/c/...` → `C:\\Users\\<U>` → 同名工作区 / `~/projects/<同名>` / `~/<同名>` / `~/Documents/<同名>`),一个都命中不了才放弃。`profile/package.json` 走「本机优先 + link 改写 + 不可装的丢弃」合并(`link:` 目标目录必须真有 `package.json`,`file:` 的 tgz 不在仓库里就丢),bundles 同步收敛;工作区登记表翻译后按 id 合并,同名去重、家目录本身不当工作区;`prompt/AGENTS.md` 翻译路径后放进 `prompt-from-cloud/`(本机已有自己那份就不覆盖)。实测云端那份 Windows profile 合并后 42 个依赖 `pnpm install --lockfile-only` 全解析通过。另:推送后自动删云端的历史浏览器剖面(`plugin-data/browser-profiles`,含 Login Data / Cookies),不用用户自己找。㉖ 修「覆盖前留底」形同虚设:几处 `backupBeforeWrite(dst, dst)` 把目标文件跟它自己比,永远判「内容相同」→ 备份根本没做(真机上覆盖 profile/package.json 时一点痕迹都没留)。改成传仓库那份作比对、本机那份作复制,并补断言钉住。㉗ 仓库自带执行体补齐:原先只往仓库里放 6 个 `.mjs`,0.6.49 新增的组用到的 `zip.mjs` / `extra-rules.mjs` / `settings-sources.mjs` / `porting.mjs` 和会话护栏 `tools/session-log-*.mjs` 没跟着走 —— 另一台机器没有插件副本时,拿仓库里那份跑 apply 会 `ERR_MODULE_NOT_FOUND`,或者静默降级成「不比对会话日志」。现在一次推齐,且内容没变不重写。㉘ 平台分区:机器相关的文件按平台分目录存,**一份仓库三端共用**。`profile/<平台>/`(package.json、cordis.patch.yml、cordis.yml、pnpm-*.yaml、host-contract.json)、`prompt/<平台>/AGENTS.md`、`settings/<平台>/dsh-workspaces.json`,平台取 `process.platform`(win32 / darwin / linux)。读的时候本平台优先,没有才回落到根目录那份老位置(回落到老位置就按移植层处理);根目录那份**只读不写**,留给还没升级的老客户端 —— 两边各写各的,谁也不覆盖谁。插件数据槽另外硬拦 `profile-from-cloud` / `prompt-from-cloud` / `local-plugins-restore`(自己产出的暂存目录不该被当成别人的插件数据再传上去,实测会被当成槽抓进 manifest)。㉙ 共享配置改成真正的「互相覆盖」:`skills` / `presets` 拉取时按云端镜像 —— 仓库里没有的本机条目会被删掉(删前留底到 `backups/apply-*`),否则在一台机器上删掉的技能永远删不掉,两边越用越分叉。全局提示 `prompt/AGENTS.md` 从平台分区回到共享(提示是配置,三端要一致),早期版本写出来的 `prompt/<平台>/AGENTS.md` 会在下次抓取时清掉。㉚ 全局提示按平台分开存(用户选择 B):`prompt/<平台>/AGENTS.md`。理由是里面写的是各系统的运行时路径与 shell 命令 —— 共享一份的话,Mac 推一次就把 Windows 的 `pwsh` 路由换成 macOS 的 `~/.dsh/dsh-runtimes/...`,反之亦然。技能、预设、模型设置、插件数据、会话、工作区登记表仍然共享并互相覆盖。㉛ 契约按平台读:`profile/<平台>/host-contract.json` 优先,根目录那份(老客户端写的,缺 platforms/platformFamily)只在没有分区副本时用。之前 macOS 上读到的是 Windows 那份不完整契约,`status` 里 platforms/platformFamily 全是空,面板会误报「契约缺失」。㉜ 会话锁文件不再同步:`session.lock` 只是「这个会话正被某个进程打开」的运行期标记,之前被当普通文件抓进仓库,铺到另一台机器就成了一条指向不存在 pid 的陈旧锁(DSH 可能据此以为会话被占用)。capture 跳过、apply 跳过,推送时顺带把云端历史 `session.lock` 精确清掉(只删这个后缀,不动其它文件)。㉝ 插件更新在 Windows 上必失败(0.6.47~0.7.0 全中):install 包校验用 `$sha.TransformBlock($fs, 0, $fs.Length, $null, 0)`,但 .NET 的签名是 `TransformBlock(byte[], int, int, byte[], int)`——第一参传 FileStream 在 PowerShell 7 找不到重载直接异常,catch 又把错误文案写成「Get-FileHash 不可用且 .NET 回退也失败」,方向整个带偏。修复:先 `ReadAllBytes` 成 byte[] 再 TransformBlock;post-exit.ps1 与 install-plugin.ps1 两处同修,并用真实 npm 0.7.0 包对 dist.integrity 验证(sha512-base64 匹配)。㉞ 工作区登记表两个入口全守住:`storages/workspace.json` 在 Node 引擎里有两个写入口 —— workspace 组的合并路径,和 settings 组 `dsh-workspaces.json` 那份整份快照(settings-sources.mjs 把它映射到同一个文件)。早先后者只在 workspace 组关闭时裸 pull() 覆盖:本机没有登记表时会写出缺 unit 头的旧格式文档(DSH 的 dsh-storage-json parse() 校验 document.unit.name==='workspace' && typeof unit.version==='number',缺 unit 段直接抛 malformed-medium —— 工作区列表和会话全读不出来),本机自建工作区连同 defaultWorkspaceId 也会被顶掉。修复:两处收进同一个 mergeWorkspaceRegistryDoc —— 补 unit:{name:'workspace',version:2} 头、global.workspaceIds 与表内条目保持一致(按本机原顺序)、同一路径收敛成一条(保留本机 ID,会话并集)、defaultWorkspaceId 以本机为准悬空才退云端值。与 Windows apply.ps1 的既有行为对齐。 ㉟ workspace 组 dry-run 不再被整组跳过:旧条件 `existsSync && !dryRun` 让「只看不动」时报「仓库里没有登记表」,计划里看不到将要并入的工作区;现在 dry-run 会算出计划(written 里出现「计划并入 N 个工作区」)且一个字节不落盘。㊱ 问题反馈列表读全:早先按 `labels=feedback` 过滤,而 GitHub 的 labels= 是 AND 过滤 —— 只有插件自己建的单带这个标签,用户直接在 GitHub 网页上手工建的(以及无令牌走浏览器预填、标签没点上的)一律不带,于是面板「全部」只剩 1 条而仓库里有 4 条(实测 #7/#8/#9 全被挡掉)。改为读仓库最新 50 条 issue(按创建时间倒序,仍排除 PR);客户端渲染上限同步从 20 提到 50(早先后端读 50、前端只画 20,看起来像没读全)。㊲ 根外绝对路径体检不再把注释当配置:capture.ps1 的 Write-OutsideRootReport 对整份文本跑正则,YAML 注释里的历史沿革(「bundle 从 D:\\c\\dsh-personal 搬到 %LOCALAPPDATA%」「根去掉已弃用的 C:/project」)被当成待确认的死路径报出来 —— 实测那份 cordis.patch.yml 报的 5 处全在 # 注释里,最后一条还把中文逗号「C:/project,只留」吞进了路径。改为先按扩展名剥注释再扫:.yml/.yaml 逐字符找不在引号内、且前面是空白的 #;.jsonc 剥 /* */ 与 // 与整行 #;.json 无注释语法原样扫。引号内的 # 不当注释,生效路径照样报。㊳ deleteCloud 在 Node 侧真删云端(与 PowerShell 同语义):早先 skipScopedGroup 只 clearDir 本地镜像、不入队,Node 推送路径也没有消费队列的地方 —— 同一个 deleteCloud:true,PS 真删云端、Node 云端一个字节不动。现在复用 PS 那份 config-sync-delete-cloud.json(同形 {prefixes:[...]}),整组跳过时入队,推送前由 deletePrefixes 消费再上传(顺序反了会把刚删的又传回去)。㊴ 单项排除不再留旧副本:gatedItem('settings', id) 命中后只报一句 skipped 就 continue,镜像里那份原样留着,而 uploadRepo 传的是整个镜像目录 —— 被排除的文件照样被推上去(实测 Mac 上那份 21 个工作区的快照一直留在仓库里)。现在 settings/prompt/storages-record/plugin-data/extra/local-plugins/workspace 共 9 处接同一个 skipScopedItem:删镜像那一份 + 入队;分区文件两个位置都入队(Node 写 settings/<平台>/,PS 写 settings/ 根),否则一台排除了另一台那份仍在云端。㊵ 安全拦截的文件同时从镜像剔除(与 sync.ps1 一致):早先只跳过不删,含登录态的浏览器剖面每轮推送都被重新扫到,面板「待推送」计数永远清不干净。体积超限不删(那不是安全问题,换 git 模式还要用)。",
|
|
5
|
+
"notesEn": "0.6.49: macOS is fully supported (a batch of Windows-only assumptions fixed after this machine moved to macOS). (1) Client root: isAppRoot only accepted <root>/resources, so a macOS .app bundle never matched -> AppRoot empty, the panel reported \"cannot locate the client root directory\" and no script could be generated. It now normalises through Contents/Resources and also accepts a .app-internal path as input. (2) Versions: the app and Electron versions were read from <root>/resources/app.asar and <root>/version; on macOS the asar lives in Contents/Resources and there is no version file -> both fields empty forever. Both now come from runtime/platform.mjs (asar header parsing plus the Electron Framework Info.plist). (3) Repo path: auto-detection only tried D:/G:/C:, which cannot work on macOS; worse, on POSIX \"D:\\\\dsh-config\" was treated as a relative path and mkdir really created such a directory in the cwd. Default is now ~/dsh-config, path shapes are validated per platform, and a cross-platform path is rejected with 400 instead of being silently reinterpreted. (4) Sync after exit: the runner only looked for post-exit.ps1, so spawning powershell.exe failed with ENOENT and the whole \"push / pull / restore / update after you quit\" chain died while the panel kept saying queued. Added runtime/post-exit.mjs (wait for pid -> run engine -> write auto-sync-result.json -> optional relaunch); the lock file is shared by both platforms. (5) Self-update: in-process install only looked for install-plugin.ps1. Added runtime/install-plugin.mjs (download -> sha256/sha1/integrity verify -> own zlib tarball extraction -> backup -> overwrite -> rollback on failure) emitting the same RESULT:{json}. (6) First pull on a new machine: the Node engine had no equivalent of the Windows Initialize-RepoIfNeeded, so pulling into a fresh directory stopped at \"fatal: no such branch: 'main'\" and then ran against an empty repo -- \"pull succeeded, nothing landed\". It now takes the default branch from ls-remote, fetches, and checks out a tracking branch when there are no commits. (7) Repo self-heal: the POSIX capture wrote content but not the runner files, so right after the first successful push the repo was judged \"not a repo\" and every later action was disabled. capture now writes sync-engine.mjs and its modules into the repo root, as the Windows path always did. (8) Restore script: the POSIX variant was a bare restore call -- no snapshot info, no dry run, no confirmation, and no backup field in the response. It now matches the .cmd script: snapshot info -> engine -DryRun -> confirm -> real run, and the response carries backup. (9) Panel: repo-path placeholder, post-exit runner name and the ~/.dsh path follow the platform instead of always showing D:\\\\ and .cmd. (10) Self-test: tools/selftest.mjs no longer writes test values into the real ~/.dsh (it builds an isolated DSH_HOME plus fixtures; --in-place opts into the real machine) and gained 22 platform regression assertions -- it used to rely on restore-from-backup, so one crash mid-run left the user's config on test values. (11) Cloud target card: when nothing is configured yet the card forces edit mode, but activeMode only honoured `editing`, not that forced state -- picking WebDAV left the Git fields on screen (remote URL / SSH key) and Save then validated as webdav and reported \"please fill in the WebDAV address\" for an input that was not even rendered (reported by a user with a screenshot). activeMode now derives from isEditing, and saving in WebDAV mode no longer writes git settings, so an address typed into the Git field is not stored as a git remote and rolled back on set-url failure. (12) Security: the private-key blocklist only had our own names such as dsh-ssh-master.key, while ssh-keygen's default output (id_ed25519 / id_rsa / *.ppk) is a bare name with no .key suffix -- adding ~/.ssh as an extra path would upload the private key verbatim (caught by the new WebDAV self-test). Keys are now blocked by name (id_rsa/id_dsa/id_ecdsa/id_ed25519(_sk)/identity/*.ppk) and by content (PEM / PuTTY private-key headers), and the upload path and capture share one set of regexes instead of two drifting copies. (13) New tools/webdav-selftest.mjs: starts a minimal WebDAV server in-process (real HTTP, real XML, real disk, 127.0.0.1 only) and covers first upload with per-level MKCOL, sha256-based dedupe (same length different content must be re-uploaded), conflict backups, empty cloud, unreachable server and the plaintext-URL gate -- 24 assertions, wired into package.json verify and CI. (14) Background auto-pull: the first check 8 s after startup also tried to pop the osascript dialog on macOS, and that path has neither a request nor a panel -- the dialog usually lands behind the app window or never reaches the foreground, so the user never sees it and auto-pull simply never happens while DSH believes it is still waiting for confirmation. On POSIX it now only records status.auto.pullPrompt (plus logs/auto-sync-pull-prompt.log) and the panel shows \"the cloud is N commits ahead -- click Pull now\"; the prompt clears once a pull is queued or the sides match. Windows keeps the MessageBox. Panel calls to /config-sync/auto also go through one autoFetch helper with a two-phase confirm (host answers needConfirm -> panel asks -> resend with confirmed:true), and cancelling reports \"cancelled\" instead of throwing. (15) Repo paths that go through a symlink: on macOS /var and /tmp point at /private/var and /private/tmp, while `git rev-parse --show-toplevel` reports the resolved path -- the engine compared it literally against the path the user typed, so any repo living under a symlinked directory (/tmp/dsh-config, or a repo linked to an external disk) failed immediately with \"this directory is not the repo root\" and the panel's live push broke (caught by the new self-test). Both sides are now realpath'd before comparing, falling back to the literal value if either cannot be resolved. (16) The sync-scope card now tells the truth: on non-Windows the engine handles only profile / prompt / skills / presets, yet the card still listed all twelve groups with live checkboxes, so a user could tick \"conversations\" and nothing would ever happen (the pending counter already counted only four groups, which made the panel self-contradictory: \"nothing pending\" next to a ticked conversations group). GET /scope now reports supported per group, and unsupported ones are disabled and labelled \"not on this platform\". (17) Conversations now sync on macOS / Linux too: this group used to be PowerShell-only, so on a Mac ticking \"conversations\" meant nothing. The Node engine now captures the same four blocks (sessions, attachments, session_projcache, vision_router_session_policy) under the same stable directory names (--ws-<workspaceId>-- for registered workspaces, --im--, passthrough otherwise), writes session-index.json, and re-encodes directory names for the target machine's workspace paths on apply. Session logs go through the seq guard so two machines appending to the same session cannot overwrite each other into a seq gap; if the guard is unavailable it falls back to a whole-file copy and says so in the panel. The default workspace is never synced. (18) Plugin data and extra paths now sync on macOS / Linux too. Their rules (per-file cap, exclude globs, skipped dirs, safety-mandatory entries) used to live only in the panel code, so the engine could not apply them; they now live in runtime/extra-rules.mjs shared by both, and the engine captures plugin-data/<slot>/ and extra/<id>/ (with manifest.json) under the same rules, expanding placeholders back to local paths on apply. Also fixed: every capture used to rewrite all text files and report \"N files changed\" — unchanged content is no longer written. (19) The profile group now includes cordis.yml (the list of enabled plugins — without it a new machine ends up with a different plugin set) and pnpm-workspace.yaml (hoisted layout). The Windows scripts always captured these two; the Node engine only took package.json, cordis.patch.yml and the two lockfiles. They are tokenised on capture and expanded back to this machine's paths on apply. (20) The \"plugin settings and workflows\" group now syncs on macOS / Linux: the 14 per-plugin config files (list in runtime/settings-sources.mjs, shared with the panel) are captured file by file rather than directory-wise, because the surrounding tree is full of .db files, caches and sessions. Volatile fields such as our-free-model's catalogSyncedAt / reloadCount are zeroed so a capture is not \"changed\" every single time. Secret sniffing moved into the shared runtime/extra-rules.mjs with two gates — name (.env / *.pem / *.key / private json) and content (GitHub token prefixes, accessToken / apiKey / password keys, PEM / PuTTY headers) — and anything unreadable counts as secret: before this, the settings group would commit a config file containing an apiKey verbatim. (21) Three more groups on macOS / Linux: the skill-market ledger (storages-record, two small json files), memory data (mnemon, the whole <AppRoot>/mnemon tree plus mirror deletion) and local source plugins (local-plugins: directories referenced by `link:` in the profile get packed into local-plugins/<name>.zip). Packing uses a new runtime/zip.mjs built on node:zlib only, skips .git / node_modules / releases / .cache and secret files, and requires <name>/package.json at the archive root so the other machine cannot extract a broken nested directory. On apply the archive is extracted to <DshHome>/local-plugins-restore/<name>/ for the user to link, never written into the client bundle (a signed .app on macOS). Also fixed: source files that merely mention field names like \"apikey\" are no longer treated as credentials (our own selftest was being dropped from the plugin zip); real GitHub tokens and private-key headers are still blocked, and a file may opt out with dsh-sync-allow-secret. (22) The last group, workspace, is now supported on macOS / Linux too, but registry-only (mode: registry-only): the repo gets workspace/workspace-registry.json (id, title, slot, tokenised path, session ids, pinned ids, default workspace) and **no workspace file trees** — on this machine one registered workspace alone is 1.9 GB, so copying them would turn the NAS into a file host. Restore merges by id into storages/workspace.json (existing local workspaces untouched, missing ones added, backup taken first) and keeps a reference copy in workspace-from-cloud.json; the whole-file snapshot in the settings group is skipped in that case so the two sources cannot fight. All twelve groups are now supported on macOS / Linux. (23) Cross-platform pull guard: when the repo came from another OS, profile/package.json, profile/cordis.patch.yml and prompt/AGENTS.md are **never written over the local machine**; they are laid out in <DshHome>/profile-from-cloud/ and <DshHome>/prompt-from-cloud/ with a panel note explaining why (evidence: platformFamily in the contract, drive letters / AppData in package.json, `X:\\` in cordis.patch.yml). Verified against a real Windows repo whose `\"@local/dsh-personal\": \"link:{{ROOT:userHome}}/AppData/Local/dsh-personal\"` would expand to a non-existent macOS path and break the profile. Workspace-registry merging also skips paths that cannot exist here. (24) After a real pull test: the whole-file workspace registry in the settings group is now skipped for cross-platform repos too. It had replaced the local registry with 21 entries, 19 of them `D:\\project\\...` paths, and the local five were gone. Cross-platform pulls now skip it with an explanation; same-platform pulls behave as before. (25) Cross-platform porting (runtime/porting.mjs): a pull from another OS no longer just parks files aside — it rewrites them into something usable here. Path translation tries, in order: the map in config-sync-port.json, %USERPROFILE%/%LOCALAPPDATA%, WSL /mnt/c/..., C:\\Users\\<U>, then same-name workspace / ~/projects/<name> / ~/<name> / ~/Documents/<name>, giving up only when nothing exists. profile/package.json is merged local-first with link: targets rewritten and anything uninstallable dropped (a link: dir must really contain package.json, a file: tgz absent from the repo is dropped), and bundles are pruned to match; the workspace registry is translated and merged by id (same-name entries deduped, the home directory itself never becomes a workspace); prompt/AGENTS.md is translated into prompt-from-cloud/ and only replaces a local file that is itself a previous port. The real Windows profile merged to 42 dependencies that pnpm install --lockfile-only resolves cleanly. Pushing now also deletes the legacy plugin-data/browser-profiles tree (Login Data / Cookies) from the cloud. (26) Fixed a no-op backup: several call sites passed backupBeforeWrite(dst, dst), comparing the target file with itself, so it always decided \"unchanged\" and never copied anything (a real pull overwrote profile/package.json leaving no trace). It now compares against the repo copy and copies the local one, with an assertion to keep it that way. (27) The repo now carries everything the engine imports: the six .mjs files it used to ship were missing zip.mjs, extra-rules.mjs, settings-sources.mjs, porting.mjs and the session guard (tools/session-log-*.mjs), so another machine without a plugin copy would hit ERR_MODULE_NOT_FOUND or silently skip the session-log comparison. All of it ships now, and unchanged files are not rewritten. (28) Platform lanes: machine-specific files now live under a per-platform directory so **one repo serves all three clients**. profile/<platform>/ (package.json, cordis.patch.yml, cordis.yml, pnpm-*.yaml, host-contract.json), prompt/<platform>/AGENTS.md and settings/<platform>/dsh-workspaces.json, where platform is process.platform (win32 / darwin / linux). Reads prefer the local lane and fall back to the legacy root location (which then goes through the porting layer); the root files are read-only for us, left to clients that have not upgraded yet, so neither side overwrites the other. Plugin-data slots additionally hard-skip profile-from-cloud / prompt-from-cloud / local-plugins-restore, since our own staging output was otherwise captured as somebody's plugin data (it showed up in the manifest). (29) Shared config now really overwrites: pulling skills / presets mirrors the cloud, so local entries that no longer exist in the repo are deleted (copied into backups/apply-* first) — otherwise a skill removed on one machine could never be removed on another and the two would drift apart. prompt/AGENTS.md moved back from a per-platform lane to shared (instructions are config and should match on every client), and a stale prompt/<platform>/AGENTS.md from the earlier layout is cleaned up on the next capture. (30) The global prompt is per-platform again (option B chosen): prompt/<platform>/AGENTS.md. It carries each system's runtime paths and shell commands, so sharing one copy meant a Mac push would replace the Windows pwsh routing with macOS ~/.dsh/dsh-runtimes paths and vice versa. Skills, presets, model settings, plugin data, sessions and the workspace registry stay shared and overwrite each other. (31) The contract is read per platform: profile/<platform>/host-contract.json wins, and the root copy (written by older clients, missing platforms/platformFamily) is only a fallback. On macOS the reader used to pick the incomplete Windows file, leaving platforms/platformFamily empty in status and making the panel claim the contract was missing. (32) Session lock files are no longer synced: session.lock is just a runtime marker meaning \"some process has this session open\". It used to be captured like any other file and restored on another machine as a stale lock pointing at a pid that does not exist (DSH could then think the session was still in use). Capture and apply both skip it, and push deletes historical session.lock files from the cloud by exact suffix, leaving everything else alone. (33) Plugin self-update always failed on Windows (0.6.47 through 0.7.0): package verification used $sha.TransformBlock($fs, 0, $fs.Length, $null, 0), but the .NET signature is TransformBlock(byte[], int, int, byte[], int) — passing a FileStream as the first argument has no matching overload in PowerShell 7, the catch then mislabeled the failure as 'Get-FileHash unavailable'. Fix: ReadAllBytes into a byte[] first, then TransformBlock; both post-exit.ps1 and install-plugin.ps1 patched, validated against the real npm 0.7.0 dist.integrity (sha512-base64 match). (34) Both write paths into storages/workspace.json are now guarded: it had two entry points in the Node engine — the workspace group merge path and the settings-group dsh-workspaces.json full snapshot (settings-sources.mjs maps it to the same file). The latter used to wholesale-overwrite when the workspace group was off: on a machine without the registry it wrote a unit-less legacy document (DSH's storage layer throws malformed-medium; the workspace list and sessions become unreadable) and clobbered locally created workspaces together with defaultWorkspaceId. Fix: both paths now share mergeWorkspaceRegistryDoc — ensures the unit:{name:'workspace',version:2} header, keeps global.workspaceIds consistent with the table (local order preserved), collapses duplicate paths into one entry keeping the local id with merged sessions, and keeps defaultWorkspaceId local-first. Matches what apply.ps1 has always done on Windows. (35) The workspace group is no longer skipped entirely in dry-run: the old `existsSync && !dryRun` condition reported 'no registry in the repo' during dry-run so the plan never showed the workspaces it would merge; now dry-run computes the plan (written gains 'planned to merge N workspaces') without touching disk. (36) The feedback list now reads the whole repo: it used to filter by labels=feedback, but GitHub's labels= is an AND filter — only issues created by the plugin carry that label, while ones filed directly on the GitHub web UI (or via the token-less browser prefill where the label was not applied) do not, so the panel showed 1 of 4 issues (#7/#8/#9 were all hidden). Now it reads the repo's latest 50 issues sorted by creation desc (PRs still excluded), and the client render cap rose from 20 to 50 to match. (37) The outside-root absolute-path audit no longer treats comments as config: capture.ps1's Write-OutsideRootReport ran its regex over the whole text, so historical notes inside YAML comments ('bundle moved from D:\\c\\dsh-personal to %LOCALAPPDATA%', 'dropped the deprecated C:/project root') were reported as dead paths needing confirmation — all 5 hits in that cordis.patch.yml were inside # comments, and the last one even swallowed a Chinese comma into the path ('C:/project,只留'). Now comments are stripped by extension before scanning: .yml/.yaml walk characters to find a # that is outside quotes and preceded by whitespace; .jsonc strips /* */, // and whole-line #; .json has no comment syntax and is scanned as-is. A # inside quotes is not a comment, so live paths still get reported. (38) deleteCloud now really deletes from the cloud on the Node side, matching PowerShell: previously skipScopedGroup only clearDir'd the local mirror without queueing, and the Node push path had no queue consumer — so the same deleteCloud:true deleted on PS but left the cloud untouched on Node. Now it reuses the PS queue file config-sync-delete-cloud.json (same {prefixes:[...]} shape), queues on group skip, and consumes it via deletePrefixes before upload (the reverse order would re-upload what was just deleted). (39) Item-level exclusion no longer leaves stale copies: gatedItem('settings', id) used to push one skipped line and continue, leaving the mirror copy in place while uploadRepo uploads the whole mirror directory — excluded files were still pushed (a 21-workspace snapshot stayed in the Mac repo). Now nine call sites across settings/prompt/storages-record/plugin-data/extra/local-plugins/workspace share skipScopedItem: remove the mirror copy and queue it; laned files queue both locations (Node writes settings/<platform>/, PS writes the settings/ root), otherwise excluding on one machine leaves the other's copy in the cloud. (40) Security-blocked files are now also removed from the mirror, matching sync.ps1: previously they were only skipped, so browser profiles carrying login state were re-scanned every push and the panel's pending count never cleared. Size-limit skips are not removed (not a security issue; still needed in git mode).",
|
|
6
6
|
"minClient": "0.2.2-rc.5"
|
|
7
7
|
}
|
package/runtime/sync-engine.mjs
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
import { buildContract, checkContract, contractPath, contractText, readContract } from './contract.mjs'
|
|
32
32
|
import { listMachines, localMachineInfo, writeMachineInfo } from './machines.mjs'
|
|
33
33
|
import {
|
|
34
|
-
downloadRepo, isSecureUrl, normalizeWebdav, testConnection, uploadRepo, webdavActive, purgeForbiddenFromCloud, purgeStaleLocksFromCloud,
|
|
34
|
+
downloadRepo, isSecureUrl, normalizeWebdav, testConnection, uploadRepo, webdavActive, purgeForbiddenFromCloud, purgeStaleLocksFromCloud, deletePrefixes,
|
|
35
35
|
PRIVATE_KEY_BODY_RE, SSH_KEY_NAME_RE,
|
|
36
36
|
} from './webdav.mjs'
|
|
37
37
|
import { applyConversations, captureConversations, conversationPendingRoots, resolveGuardScript } from './conversations.mjs'
|
|
@@ -190,12 +190,74 @@ function scopeItemEnabled(scope, group, item) {
|
|
|
190
190
|
return !g.excluded.includes(item)
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
/**
|
|
194
|
-
|
|
193
|
+
/** 「删除云端副本」队列:与 PowerShell 侧同一个文件名、同一个形状,两台互通。 */
|
|
194
|
+
const DELETE_CLOUD_QUEUE = 'config-sync-delete-cloud.json'
|
|
195
|
+
|
|
196
|
+
/** 读队列(`{prefixes:[...]}`)。损坏/不存在都当空,不让它挡住推送。 */
|
|
197
|
+
export function readCloudDeleteQueue(dshHome) {
|
|
198
|
+
const empty = { prefixes: [] }
|
|
199
|
+
if (!dshHome) return empty
|
|
200
|
+
try {
|
|
201
|
+
const obj = JSON.parse(readFileSync(join(dshHome, DELETE_CLOUD_QUEUE), 'utf8'))
|
|
202
|
+
const list = Array.isArray(obj && obj.prefixes) ? obj.prefixes : []
|
|
203
|
+
return { prefixes: [...new Set(list.map((x) => String(x || '').replace(/\\/g, '/').replace(/^\/+|\/+$/g, '')).filter(Boolean))] }
|
|
204
|
+
} catch { return empty }
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** 入队一条前缀(文件或目录都可以;目录会删掉它下面全部)。 */
|
|
208
|
+
function queueCloudDelete(dshHome, rel) {
|
|
209
|
+
const norm = String(rel || '').replace(/\\/g, '/').replace(/^\/+|\/+$/g, '')
|
|
210
|
+
if (!norm || !dshHome) return
|
|
211
|
+
const q = readCloudDeleteQueue(dshHome)
|
|
212
|
+
if (q.prefixes.includes(norm)) return
|
|
213
|
+
q.prefixes.push(norm)
|
|
214
|
+
try {
|
|
215
|
+
mkdirSync(dshHome, { recursive: true })
|
|
216
|
+
writeFileSync(join(dshHome, DELETE_CLOUD_QUEUE), JSON.stringify({ prefixes: q.prefixes }, null, 2) + '\n', 'utf8')
|
|
217
|
+
} catch { /* 队列写不进去只影响云端清理,不挡推送 */ }
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** 清空队列(推送把前缀消费完,或用户重置时)。 */
|
|
221
|
+
export function clearCloudDeleteQueue(dshHome) {
|
|
222
|
+
if (!dshHome) return
|
|
223
|
+
try { rmSync(join(dshHome, DELETE_CLOUD_QUEUE), { force: true }) } catch { /* 删不掉下次重来 */ }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 整组被跳过时:deleteCloud 打开就删掉仓库里那份,**并把组名入队**。
|
|
228
|
+
*
|
|
229
|
+
* 早先这里只 clearDir 本地镜像、不入队 —— 而 Node 侧又没有消费队列的地方,
|
|
230
|
+
* 于是同一个 `deleteCloud: true` 在 PowerShell 侧真删云端、在 Node 侧云端一个字节不动
|
|
231
|
+
* (实测:Mac 上开了 deleteCloud,云端那份 18KB 的工作区快照照样活着)。
|
|
232
|
+
* 现在与 PS 的 Skip-SyncGroup 对齐:镜像清 + 入队,推送前由 deletePrefixes 消费。
|
|
233
|
+
*/
|
|
234
|
+
function skipScopedGroup(scope, repoRoot, group, skipped, dshHome) {
|
|
195
235
|
skipped.push(`${group}: 未勾选同步`)
|
|
196
236
|
if (!scope || scope.deleteCloud !== true) return
|
|
197
|
-
const
|
|
198
|
-
|
|
237
|
+
const rel = fromRepoPath(group)
|
|
238
|
+
queueCloudDelete(dshHome, rel)
|
|
239
|
+
const target = join(repoRoot, rel)
|
|
240
|
+
try {
|
|
241
|
+
if (existsSync(target)) { clearDir(target); skipped.push(`${group}: 已按「删除云端副本」移除(镜像 + 云端队列)`) }
|
|
242
|
+
} catch { /* 删不掉不影响其余 */ }
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 单项被排除时:与 PS 的 Skip-SyncItem 同语义 —— 删镜像那一份 + 入队。
|
|
247
|
+
*
|
|
248
|
+
* 早先 `gatedItem('settings', id)` 命中后只 push 一句 skipped 就 continue:
|
|
249
|
+
* 镜像里的旧副本原样留着,而 uploadRepo 传的是整个镜像目录 —— 于是被排除的文件
|
|
250
|
+
* 照样会被推上去(Mac 上那份 21 个工作区的快照就是这么一直留在仓库里的)。
|
|
251
|
+
*/
|
|
252
|
+
function skipScopedItem(scope, repoRoot, rel, skipped, dshHome) {
|
|
253
|
+
const norm = String(rel || '').replace(/\\/g, '/').replace(/^\/+|\/+$/g, '')
|
|
254
|
+
skipped.push(`${norm}: 未勾选`)
|
|
255
|
+
if (!scope || scope.deleteCloud !== true || !norm) return
|
|
256
|
+
queueCloudDelete(dshHome, norm)
|
|
257
|
+
try {
|
|
258
|
+
const target = join(repoRoot, norm)
|
|
259
|
+
if (existsSync(target)) { rmSync(target, { recursive: true, force: true }); skipped.push(`${norm}: 已按「删除云端副本」移除(镜像 + 云端队列)`) }
|
|
260
|
+
} catch { /* 删不掉不影响其余 */ }
|
|
199
261
|
}
|
|
200
262
|
|
|
201
263
|
/** 本机路径列表 → 归一化的根集合(capture 用)。 */
|
|
@@ -647,7 +709,11 @@ function capturePluginData({ repoRoot, dshHome, cfg, scope, roots }) {
|
|
|
647
709
|
mkdirSync(dstRoot, { recursive: true })
|
|
648
710
|
const slots = []
|
|
649
711
|
for (const slot of listPluginDataSlots(dshHome, cfg)) {
|
|
650
|
-
if (!scopeItemEnabled(scope, 'plugin-data', slot.id)) {
|
|
712
|
+
if (!scopeItemEnabled(scope, 'plugin-data', slot.id)) {
|
|
713
|
+
result.notes.push(`插件数据 ${slot.id}: 未勾选`)
|
|
714
|
+
skipScopedItem(scope, repoRoot, `plugin-data/${slot.id}`, result.notes, dshHome)
|
|
715
|
+
continue
|
|
716
|
+
}
|
|
651
717
|
const r = mirrorSlotInto({ srcRoot: slot.src, dstRoot: join(dstRoot, slot.id), cfg, roots, label: `plugin-data/${slot.id}` })
|
|
652
718
|
result.files += r.files
|
|
653
719
|
result.bytes += r.bytes
|
|
@@ -680,7 +746,11 @@ function captureExtraPaths({ repoRoot, dshHome, cfg, scope, roots }) {
|
|
|
680
746
|
if (!paths.length) { result.notes.push('额外路径:没有登记任何路径'); return result }
|
|
681
747
|
mkdirSync(dstRoot, { recursive: true })
|
|
682
748
|
for (const p of paths) {
|
|
683
|
-
if (!scopeItemEnabled(scope, 'extra', p.id)) {
|
|
749
|
+
if (!scopeItemEnabled(scope, 'extra', p.id)) {
|
|
750
|
+
result.notes.push(`额外路径 ${p.id}: 未勾选`)
|
|
751
|
+
skipScopedItem(scope, repoRoot, `extra/${p.id}`, result.notes, dshHome)
|
|
752
|
+
continue
|
|
753
|
+
}
|
|
684
754
|
if (!existsSync(p.src)) { result.notes.push(`额外路径本机不存在,跳过:${p.src}`); continue }
|
|
685
755
|
const isDir = isDir2(p.src)
|
|
686
756
|
const label = `extra/${p.id}`
|
|
@@ -781,7 +851,11 @@ function captureLocalPlugins({ repoRoot, profileDir, dshHome, scope }) {
|
|
|
781
851
|
mkdirSync(dstRoot, { recursive: true })
|
|
782
852
|
const kept = new Set()
|
|
783
853
|
for (const link of links) {
|
|
784
|
-
if (!scopeItemEnabled(scope, 'local-plugins', link.dirName)) {
|
|
854
|
+
if (!scopeItemEnabled(scope, 'local-plugins', link.dirName)) {
|
|
855
|
+
result.notes.push(`本地插件 ${link.dirName}: 未勾选`)
|
|
856
|
+
skipScopedItem(scope, repoRoot, `local-plugins/${link.dirName}.zip`, result.notes, dshHome)
|
|
857
|
+
continue
|
|
858
|
+
}
|
|
785
859
|
if (!existsSync(link.abs)) { result.notes.push(`link 目标不存在,跳过:${link.abs}`); continue }
|
|
786
860
|
kept.add(`${link.dirName}.zip`)
|
|
787
861
|
const entries = []
|
|
@@ -848,7 +922,12 @@ function captureWorkspaceRegistry({ repoRoot, dshHome, scope, roots }) {
|
|
|
848
922
|
const usedSlots = new Map()
|
|
849
923
|
for (const [id, w] of Object.entries(table)) {
|
|
850
924
|
if (!w || typeof w !== 'object') continue
|
|
851
|
-
if (!scopeItemEnabled(scope, 'workspace', id)) {
|
|
925
|
+
if (!scopeItemEnabled(scope, 'workspace', id)) {
|
|
926
|
+
result.notes.push(`工作区 ${id}: 未勾选`)
|
|
927
|
+
const title0 = typeof w.title === 'string' && w.title ? w.title : id
|
|
928
|
+
skipScopedItem(scope, repoRoot, `workspace/${workspaceSlotName(title0, id)}`, result.notes, dshHome)
|
|
929
|
+
continue
|
|
930
|
+
}
|
|
852
931
|
const title = typeof w.title === 'string' && w.title ? w.title : id
|
|
853
932
|
let slot = workspaceSlotName(title, id)
|
|
854
933
|
if (usedSlots.has(slot)) slot = workspaceSlotName(id, id)
|
|
@@ -961,12 +1040,20 @@ export function capture({ repoRoot, dshHome, appRoot, workspaceHome, profileName
|
|
|
961
1040
|
}
|
|
962
1041
|
|
|
963
1042
|
// 1.2) 插件设置与工作流(14 个插件各自的配置文件;散落在 <DshHome> 树里,不能整目录抓)
|
|
964
|
-
if (gated('settings')) skipScopedGroup(scope, repoRoot, 'settings', skippedByScope)
|
|
1043
|
+
if (gated('settings')) skipScopedGroup(scope, repoRoot, 'settings', skippedByScope, local.dshHome)
|
|
965
1044
|
else {
|
|
966
1045
|
try {
|
|
967
1046
|
let wrote = 0
|
|
968
1047
|
for (const entry of SETTINGS_SOURCES) {
|
|
969
|
-
if (gatedItem('settings', entry.id)) {
|
|
1048
|
+
if (gatedItem('settings', entry.id)) {
|
|
1049
|
+
// 分区文件在 Node 侧写进 settings/<平台>/,PS 侧写进 settings/ 根 ——
|
|
1050
|
+
// 两个位置都入队,否则 Mac 排除了、Windows 那份仍留在云端。
|
|
1051
|
+
const rels = LANED_SETTINGS.has(entry.id)
|
|
1052
|
+
? [`settings/${PLATFORM_LANE}/${entry.id}`, `settings/${entry.id}`]
|
|
1053
|
+
: [`settings/${entry.id}`]
|
|
1054
|
+
for (const rel of rels) skipScopedItem(scope, repoRoot, rel, skippedByScope, local.dshHome)
|
|
1055
|
+
continue
|
|
1056
|
+
}
|
|
970
1057
|
const src = settingsSourcePath(local.dshHome, profileDir, entry)
|
|
971
1058
|
if (!existsSync(src)) continue
|
|
972
1059
|
const setDir = LANED_SETTINGS.has(entry.id) ? join(repoRoot, 'settings', PLATFORM_LANE) : join(repoRoot, 'settings')
|
|
@@ -1039,24 +1126,26 @@ export function capture({ repoRoot, dshHome, appRoot, workspaceHome, profileName
|
|
|
1039
1126
|
}
|
|
1040
1127
|
|
|
1041
1128
|
// 3) 提示词 / 技能 / 预设(逐组、逐项按勾选门控)
|
|
1042
|
-
if (gated('prompt')) skipScopedGroup(scope, repoRoot, 'prompt', skippedByScope)
|
|
1129
|
+
if (gated('prompt')) skipScopedGroup(scope, repoRoot, 'prompt', skippedByScope, local.dshHome)
|
|
1043
1130
|
else {
|
|
1044
|
-
if (gatedItem('prompt', 'AGENTS.md'))
|
|
1131
|
+
if (gatedItem('prompt', 'AGENTS.md')) {
|
|
1132
|
+
for (const rel of [`prompt/${PLATFORM_LANE}/AGENTS.md`, 'prompt/AGENTS.md']) skipScopedItem(scope, repoRoot, rel, skippedByScope, local.dshHome)
|
|
1133
|
+
}
|
|
1045
1134
|
// 全局提示按平台分开存:里面写的是各系统的运行时路径与 shell 命令,
|
|
1046
1135
|
// 共享一份的话 Mac 推一次就把 Windows 的 pwsh 路径换成了 macOS 的(反之亦然)。
|
|
1047
1136
|
else copy(join(local.dshHome, 'AGENTS.md'), lanePathOf('prompt/AGENTS.md'))
|
|
1048
|
-
if (gatedItem('prompt', 'prompt-inject.md'))
|
|
1137
|
+
if (gatedItem('prompt', 'prompt-inject.md')) skipScopedItem(scope, repoRoot, 'prompt/prompt-inject.md', skippedByScope, local.dshHome)
|
|
1049
1138
|
else copy(join(local.dshHome, 'prompt-inject.md'), 'prompt/prompt-inject.md')
|
|
1050
1139
|
}
|
|
1051
|
-
if (gated('skills')) skipScopedGroup(scope, repoRoot, 'skills', skippedByScope)
|
|
1140
|
+
if (gated('skills')) skipScopedGroup(scope, repoRoot, 'skills', skippedByScope, local.dshHome)
|
|
1052
1141
|
else copy(join(local.dshHome, 'skills'), 'skills')
|
|
1053
|
-
if (gated('presets')) skipScopedGroup(scope, repoRoot, 'presets', skippedByScope)
|
|
1142
|
+
if (gated('presets')) skipScopedGroup(scope, repoRoot, 'presets', skippedByScope, local.dshHome)
|
|
1054
1143
|
else copy(join(local.dshHome, '.agent-presets'), 'presets')
|
|
1055
1144
|
|
|
1056
1145
|
// 3.5) 会话记录(0.6.49 起 Node 引擎也做,见 runtime/conversations.mjs):
|
|
1057
1146
|
// 四块数据字节保真 + 仓库稳定目录名(--ws-<id>--)+ session-index.json;
|
|
1058
1147
|
// 会话日志走 seq 护栏,避免两台机器各 append 一段后互相覆盖出 seq gap。
|
|
1059
|
-
if (gated('conversations')) skipScopedGroup(scope, repoRoot, 'conversations', skippedByScope)
|
|
1148
|
+
if (gated('conversations')) skipScopedGroup(scope, repoRoot, 'conversations', skippedByScope, local.dshHome)
|
|
1060
1149
|
else {
|
|
1061
1150
|
try {
|
|
1062
1151
|
const conv = captureConversations({
|
|
@@ -1075,7 +1164,7 @@ export function capture({ repoRoot, dshHome, appRoot, workspaceHome, profileName
|
|
|
1075
1164
|
}
|
|
1076
1165
|
|
|
1077
1166
|
// 3.3) 本地源码插件(profile 里 link: 指向的目录,打包成 zip 随仓库走)
|
|
1078
|
-
if (gated('local-plugins')) skipScopedGroup(scope, repoRoot, 'local-plugins', skippedByScope)
|
|
1167
|
+
if (gated('local-plugins')) skipScopedGroup(scope, repoRoot, 'local-plugins', skippedByScope, local.dshHome)
|
|
1079
1168
|
else {
|
|
1080
1169
|
try {
|
|
1081
1170
|
const r = captureLocalPlugins({ repoRoot, profileDir, dshHome: local.dshHome, scope })
|
|
@@ -1090,13 +1179,13 @@ export function capture({ repoRoot, dshHome, appRoot, workspaceHome, profileName
|
|
|
1090
1179
|
}
|
|
1091
1180
|
|
|
1092
1181
|
// 3.4) 技能市场台账(两个小 json;装在 storages/@montersy123/dsh-skill-market/data 下)
|
|
1093
|
-
if (gated('storages-record')) skipScopedGroup(scope, repoRoot, 'storages-record', skippedByScope)
|
|
1182
|
+
if (gated('storages-record')) skipScopedGroup(scope, repoRoot, 'storages-record', skippedByScope, local.dshHome)
|
|
1094
1183
|
else {
|
|
1095
1184
|
const dataDir = join(local.dshHome, 'storages', '@montersy123', 'dsh-skill-market', 'data')
|
|
1096
1185
|
const pairs = [['installed.json', 'skill-market-installed.json'], ['panel.json', 'skill-market-panel.json']]
|
|
1097
1186
|
let any = false
|
|
1098
1187
|
for (const [leaf, repoLeaf] of pairs) {
|
|
1099
|
-
if (gatedItem('storages-record', repoLeaf)) {
|
|
1188
|
+
if (gatedItem('storages-record', repoLeaf)) { skipScopedItem(scope, repoRoot, `storages-record/${repoLeaf}`, skippedByScope, local.dshHome); continue }
|
|
1100
1189
|
if (!existsSync(join(dataDir, leaf))) continue
|
|
1101
1190
|
copy(join(dataDir, leaf), `storages-record/${repoLeaf}`)
|
|
1102
1191
|
any = true
|
|
@@ -1105,7 +1194,7 @@ export function capture({ repoRoot, dshHome, appRoot, workspaceHome, profileName
|
|
|
1105
1194
|
}
|
|
1106
1195
|
|
|
1107
1196
|
// 3.45) 记忆数据:<AppRoot>/mnemon(记忆插件的数据目录,需要跨机一致)
|
|
1108
|
-
if (gated('mnemon')) skipScopedGroup(scope, repoRoot, 'mnemon', skippedByScope)
|
|
1197
|
+
if (gated('mnemon')) skipScopedGroup(scope, repoRoot, 'mnemon', skippedByScope, local.dshHome)
|
|
1109
1198
|
else {
|
|
1110
1199
|
const mnSrc = join(local.appRoot || '', 'mnemon')
|
|
1111
1200
|
if (!local.appRoot || !existsSync(mnSrc)) {
|
|
@@ -1121,7 +1210,7 @@ export function capture({ repoRoot, dshHome, appRoot, workspaceHome, profileName
|
|
|
1121
1210
|
}
|
|
1122
1211
|
|
|
1123
1212
|
// 3.5) 工作区登记表(只登记表,不搬文件树)
|
|
1124
|
-
if (gated('workspace')) skipScopedGroup(scope, repoRoot, 'workspace', skippedByScope)
|
|
1213
|
+
if (gated('workspace')) skipScopedGroup(scope, repoRoot, 'workspace', skippedByScope, local.dshHome)
|
|
1125
1214
|
else {
|
|
1126
1215
|
try {
|
|
1127
1216
|
const r = captureWorkspaceRegistry({ repoRoot, dshHome: local.dshHome, scope, roots })
|
|
@@ -1138,7 +1227,7 @@ export function capture({ repoRoot, dshHome, appRoot, workspaceHome, profileName
|
|
|
1138
1227
|
// 3.6) 插件数据 / 额外路径(规则与面板、PowerShell 共用 runtime/extra-rules.mjs)
|
|
1139
1228
|
try {
|
|
1140
1229
|
const extraCfg = readExtraConfig(local.dshHome)
|
|
1141
|
-
if (gated('plugin-data')) skipScopedGroup(scope, repoRoot, 'plugin-data', skippedByScope)
|
|
1230
|
+
if (gated('plugin-data')) skipScopedGroup(scope, repoRoot, 'plugin-data', skippedByScope, local.dshHome)
|
|
1142
1231
|
else {
|
|
1143
1232
|
const r = capturePluginData({ repoRoot, dshHome: local.dshHome, cfg: extraCfg, scope, roots })
|
|
1144
1233
|
files += r.files
|
|
@@ -1147,7 +1236,7 @@ export function capture({ repoRoot, dshHome, appRoot, workspaceHome, profileName
|
|
|
1147
1236
|
errors.push(...r.errors)
|
|
1148
1237
|
for (const n of r.notes) skippedByScope.push(`plugin-data: ${n}`)
|
|
1149
1238
|
}
|
|
1150
|
-
if (gated('extra')) skipScopedGroup(scope, repoRoot, 'extra', skippedByScope)
|
|
1239
|
+
if (gated('extra')) skipScopedGroup(scope, repoRoot, 'extra', skippedByScope, local.dshHome)
|
|
1151
1240
|
else {
|
|
1152
1241
|
const r = captureExtraPaths({ repoRoot, dshHome: local.dshHome, cfg: extraCfg, scope, roots })
|
|
1153
1242
|
files += r.files
|
|
@@ -2379,6 +2468,15 @@ export async function runCli(argv) {
|
|
|
2379
2468
|
console.log(pushed.err || pushed.out || '已推送')
|
|
2380
2469
|
}
|
|
2381
2470
|
if (useWebdav) {
|
|
2471
|
+
// 「删除云端副本」队列必须在上传**之前**消费:先删掉被排除/关组的那些,
|
|
2472
|
+
// 再传剩下的。顺序反了会把刚删的又传回去(PS 侧 sync.ps1 也是这个顺序)。
|
|
2473
|
+
const delQ = readCloudDeleteQueue(dshHome)
|
|
2474
|
+
if (delQ.prefixes.length) {
|
|
2475
|
+
const del = await deletePrefixes(w, delQ.prefixes)
|
|
2476
|
+
console.log(`云端清理:按「删除云端副本」删除 ${del.deleted.length} 个文件(${delQ.prefixes.length} 条前缀)`)
|
|
2477
|
+
for (const e of del.errors) console.error(` [!] ${e}`)
|
|
2478
|
+
clearCloudDeleteQueue(dshHome)
|
|
2479
|
+
}
|
|
2382
2480
|
const up = await uploadRepo(w, repoRoot)
|
|
2383
2481
|
for (const e of up.errors) console.error(` [!] ${e}`)
|
|
2384
2482
|
console.log(`WebDAV 上传:上传 ${up.uploaded.length} · 跳过 ${up.skipped.length} · 错误 ${up.errors.length}`)
|
package/runtime/webdav.mjs
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
// - 证书校验不可关闭(Node 的 https 默认校验;要放行请走系统信任库)。
|
|
23
23
|
|
|
24
24
|
import { createHash } from 'node:crypto'
|
|
25
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'
|
|
25
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
26
26
|
import { request as httpRequest } from 'node:http'
|
|
27
27
|
import { request as httpsRequest } from 'node:https'
|
|
28
28
|
import { homedir } from 'node:os'
|
|
@@ -653,6 +653,11 @@ export async function uploadRepo(w, localRepo, { dryRun = false, onProgress = nu
|
|
|
653
653
|
if (skipReason === 'secret') console.log(` [!] 安全拦截:跳过含令牌或本机私有凭据的文件 ${rel}(绝不上传)`)
|
|
654
654
|
else if (skipReason === 'profile') console.log(` [!] 安全拦截:跳过浏览器剖面 / 凭据库文件 ${rel}(含登录态,绝不上传)`)
|
|
655
655
|
else console.log(` [!] 体积超限:${rel} 超过单文件上限 ${Math.round(MAX_SYNC_FILE_BYTES / 1048576)}MB,未上传(不是安全问题;需要它请用 git 模式)`)
|
|
656
|
+
// 与 PS 侧 sync.ps1 对齐:安全类拦截要把镜像里那份也剔除,否则每轮推送都重新扫到它、
|
|
657
|
+
// 面板的「待推送」计数永远清不干净。体积超限不删(那不是安全问题,换 git 模式还要用)。
|
|
658
|
+
if (skipReason === 'secret' || skipReason === 'profile') {
|
|
659
|
+
try { rmSync(join(localRepo, fromRepoRel(rel)), { force: true }) } catch { /* 删不掉下轮再拦 */ }
|
|
660
|
+
}
|
|
656
661
|
continue
|
|
657
662
|
}
|
|
658
663
|
// 远端有同名文件:只在内容**真的**相同时跳过。
|