@twinsearth/timemachine-dsh-plugin 0.1.3 → 0.2.1
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/CHANGELOG.md +26 -0
- package/README.md +24 -5
- package/docs/ARCHITECTURE.md +24 -1
- package/docs/DETAIL.en.md +9 -0
- package/docs/DETAIL.zh.md +9 -0
- package/docs/REQUIREMENTS.md +10 -1
- package/docs/TESTPLAN.md +30 -4
- package/lib/client.js +240 -27
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +5 -3
- package/plugin.json +3 -3
- package/src/point.mjs +18 -1
- package/src/service.mjs +3 -2
- package/src/tree.mjs +148 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1 — 2026-12-03
|
|
4
|
+
|
|
5
|
+
### 标题与插件详情
|
|
6
|
+
|
|
7
|
+
- 完整面板标题改为随系统自适应:Windows「DeepSeekHarness:一键还原点」,macOS「DeepSeekHarness:时间机器」;`main` 槽位标签同步使用同一标题。
|
|
8
|
+
- 新增 `locale/en.json`、`locale/zh.json` 与 `docs/DETAIL.en.md`、`docs/DETAIL.zh.md`,插件管理器不再回退到包名 `@twinsearth/timemachine-dsh-plugin`。
|
|
9
|
+
- 中文详情改为五项能力:手动/自动双还原点、会话与工作区完整备份、第三方插件 latest 重装、配置迁移与一键还原、一键修复会话引导。
|
|
10
|
+
- `package.json` 增加 `./locale/*.json` 导出与 `locale` 打包目录;`plugin.json` 名称/描述同步。
|
|
11
|
+
|
|
12
|
+
### 发布
|
|
13
|
+
|
|
14
|
+
- npm 与 GitHub 同步发布 `0.2.1`。
|
|
15
|
+
|
|
16
|
+
## 0.2.0 — 2026-12-03
|
|
17
|
+
|
|
18
|
+
### 文件夹详情
|
|
19
|
+
|
|
20
|
+
- 完整面板新增「文件夹详情」区块,位于还原点列表之后、「说明与边界」之前,即倒数第二个位置。
|
|
21
|
+
- 创建或导入还原点后自动选中该文件,展示归档内的真实文件夹结构树,右侧显示中文说明与文件大小。
|
|
22
|
+
- 多个还原点可通过下拉框或还原点行的「文件夹」按钮切换;同一时间只展开一个目录,切换还原点时重置展开状态。
|
|
23
|
+
- 创建接口直接返回 `tree`;`/inspect` 为已有还原点返回同一棵树,避免 UI 重复解析归档。
|
|
24
|
+
|
|
25
|
+
### 发布
|
|
26
|
+
|
|
27
|
+
- npm 与 GitHub 同步发布 `0.2.0`;保留 `dsh.bundle.patch`、`dsh.client`、`repository` 与可复制安装命令。
|
|
28
|
+
|
|
3
29
|
## 0.1.3 — 2026-12-03
|
|
4
30
|
|
|
5
31
|
### UI
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
DSH 一键还原点(Time Machine)。它把 DSH 客户端的会话、工作区、配置与插件清单打包成一个可迁移的还原点,并在需要时把整台机器上的 DSH 恢复成还原点里的样子。
|
|
4
4
|
|
|
5
|
-
- 版本:`0.1
|
|
5
|
+
- 版本:`0.2.1`
|
|
6
6
|
- 宿主:DeepSeek Harness(DSH)桌面客户端 `0.2.x`
|
|
7
7
|
- 平台:Windows / macOS / Linux(Windows 默认目录,macOS/Linux 由用户选择目录)
|
|
8
8
|
- 许可:MIT
|
|
@@ -32,6 +32,25 @@ DSH 一键还原点(Time Machine)。它把 DSH 客户端的会话、工作
|
|
|
32
32
|
|
|
33
33
|
面板「导入」选择一个 `.tar.zst`,文件会被复制进 `imported/`,源文件保留不动。导入时会校验归档结构、manifest 与文件摘要;损坏或不完整的归档会被拒绝。
|
|
34
34
|
|
|
35
|
+
### 1.4 文件夹详情
|
|
36
|
+
|
|
37
|
+
完整面板倒数第二个区块是「文件夹详情」:创建或导入完成后,自动选中新还原点并读取归档结构;也可以从下拉框或还原点行的「文件夹」按钮切换。树按真实路径展示 `manifest.json`、`README.txt`、`RESTORE-POINT.json`、`sessions/`、`attachments/`、`profiles/` 等目录,右侧逐项给出中文说明和文件大小。同一时间只展开一个目录,切换还原点时会重置展开状态。
|
|
38
|
+
|
|
39
|
+
### 1.5 标题与插件详情
|
|
40
|
+
|
|
41
|
+
完整面板标题按操作系统自适应:Windows 为「DeepSeekHarness:一键还原点」,macOS 为「DeepSeekHarness:时间机器」;左侧栏入口仍保持短标签「一键还原点 / 时间机器」。
|
|
42
|
+
|
|
43
|
+
插件管理器的标题和详情由 `locale/en.json`、`locale/zh.json` 与 `docs/DETAIL.en.md`、`docs/DETAIL.zh.md` 提供。中文详情固定为:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
DSH 一键还原点:
|
|
47
|
+
1.手动/自动双还原点
|
|
48
|
+
2.会话与工作区完整备份
|
|
49
|
+
3.第三方插件 latest 重装
|
|
50
|
+
4.配置迁移与一键还原
|
|
51
|
+
5.一键修复会话引导
|
|
52
|
+
```
|
|
53
|
+
|
|
35
54
|
### 2.1 用户插件:内置与实验性
|
|
36
55
|
|
|
37
56
|
还原点记录 `dsh.profile.bundles`、`dependencies` 与 `cordis.patch.yml` 的插件行,包含:
|
|
@@ -155,16 +174,16 @@ node scripts/host-menu-patch.mjs --app-asar "D:\DSH\resources\app.asar" --restor
|
|
|
155
174
|
```powershell
|
|
156
175
|
# 先在 DSH 客户端菜单「应用 -> 管理 dsh 命令」安装 CLI(如果尚未安装)
|
|
157
176
|
# 从 npm 安装(推荐)
|
|
158
|
-
dsh plugin --profile web add @twinsearth/timemachine-dsh-plugin
|
|
177
|
+
dsh plugin --profile web add @twinsearth/timemachine-dsh-plugin@0.2.1
|
|
159
178
|
|
|
160
179
|
# 桌面客户端 profile 名为 desktop 时
|
|
161
|
-
dsh plugin --profile desktop add @twinsearth/timemachine-dsh-plugin
|
|
180
|
+
dsh plugin --profile desktop add @twinsearth/timemachine-dsh-plugin@0.2.1
|
|
162
181
|
```
|
|
163
182
|
|
|
164
183
|
离线安装可使用 GitHub Release 或本地 tarball:
|
|
165
184
|
|
|
166
185
|
```powershell
|
|
167
|
-
dsh plugin --profile desktop add "file:E:\path\to\twinsearth-timemachine-dsh-plugin-0.1.
|
|
186
|
+
dsh plugin --profile desktop add "file:E:\path\to\twinsearth-timemachine-dsh-plugin-0.2.1.tgz"
|
|
168
187
|
```
|
|
169
188
|
|
|
170
189
|
如果 `dsh` 不在 PATH,也可以直接用 profile 目录里的 pnpm 安装,但安装后必须手动把包名加入 `profiles/desktop/package.json` 的 `dsh.profile.bundles`,否则 Loader 不会加载:
|
|
@@ -208,7 +227,7 @@ npm run check # 静态交付检查
|
|
|
208
227
|
npm run pack-check
|
|
209
228
|
```
|
|
210
229
|
|
|
211
|
-
测试覆盖:手动/自动创建、范围选择、保留份数、计划与还原、跳过插件安装、导入、设置持久化、损坏归档拒绝、HTTP 路由挂载、客户端 bundle 槽位注册、侧栏入口 10 秒自动隐藏与标题栏按钮 30
|
|
230
|
+
测试覆盖:手动/自动创建、范围选择、保留份数、计划与还原、跳过插件安装、导入、设置持久化、损坏归档拒绝、HTTP 路由挂载、客户端 bundle 槽位注册、侧栏入口 10 秒自动隐藏与标题栏按钮 30 秒自动隐藏、标题随系统自适应、locale 五项详情、文件夹结构树与单分支展开、运行中 `workspaceRegistry` 实时注册。真实客户端验收记录见 `docs/TESTPLAN.md`。
|
|
212
231
|
|
|
213
232
|
## 数据与安全
|
|
214
233
|
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -121,12 +121,35 @@ service.restore -> restore.restorePoint
|
|
|
121
121
|
| --- | --- | --- |
|
|
122
122
|
| `settings.general.item` | `timemachine-general` | 通用设置一行:立即备份 / 一键还原(计划确认)/ 打开完整面板 |
|
|
123
123
|
| `sidebar.panellist` | `timemachine` | 左上角侧栏顶部入口(`order: -100`);macOS「时间机器」、Windows「一键还原点」 |
|
|
124
|
-
| `main` | key `timemachine` |
|
|
124
|
+
| `main` | key `timemachine` | 完整面板:创建 / 自动 / 还原点列表 / 文件夹详情 / 说明与边界 |
|
|
125
125
|
|
|
126
126
|
`layout.selectPanel('timemachine')` 依赖 `main` 注册项的 `options.key === 'timemachine'`。客户端必须声明 `inject: ['slots', 'layout']`;缺少 `layout` 时 Cordis 会在访问 `ctx.layout` 时抛 `cannot get property "layout" without inject`,整个客户端模块不会激活。`uiWorkspace` / `sessions` 用 `ctx.get` 可选读取,不加入硬注入;直接属性访问 `ctx.uiWorkspace` 会抛 `cannot get property "uiWorkspace" without inject`,这也是 0.1.0 修复过的坑。
|
|
127
127
|
|
|
128
128
|
除槽位外,`installCaptionEntry` 在 Windows 桌面客户端的 `[data-windows-menu]` open shadowRoot 里追加 `data-timemachine-caption` 按钮。宿主节点不存在(浏览器 Web UI)时用 `MutationObserver` 等 30 秒后静默放弃;组件卸载只移除自己追加的按钮,不碰宿主已有「应用 / 编辑」按钮。
|
|
129
129
|
|
|
130
|
+
### 6.1 完整面板的文件夹详情
|
|
131
|
+
|
|
132
|
+
完整面板的区块顺序固定为:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
页头
|
|
136
|
+
创建卡片
|
|
137
|
+
自动卡片
|
|
138
|
+
还原点列表
|
|
139
|
+
文件夹详情 <- 倒数第二
|
|
140
|
+
说明与边界 <- 最后
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`FolderDetails` 通过下拉框或还原点行的「文件夹」按钮切换目标文件。创建成功后,`POST /create` 的响应直接带 `tree`,UI 无需再次解包;已有还原点通过 `POST /inspect` 读取 `tree`。服务端由 `src/tree.mjs#buildPointTree` 将 `manifest.files` 与三个顶层文件合并成树,每个节点带 `path`、`type`、`description`、`bytes`、`files` 和 `children`。
|
|
144
|
+
|
|
145
|
+
树的前端只保留一个 `expandedPath`。`isTreePathOpen(path, openPath)` 只展开该路径本身及其祖先链,因此同一时间只有一个分支;切换还原点会重置为根节点展开。
|
|
146
|
+
|
|
147
|
+
### 6.2 标题与插件管理元信息
|
|
148
|
+
|
|
149
|
+
`lib/client.js#panelTitle()` 与 `sidebarLabel()` 共用 `isMacPlatform()`:完整面板 `h2`、`main` 槽位 label 使用 `DeepSeekHarness:一键还原点`(Windows)或 `DeepSeekHarness:时间机器`(macOS),侧栏入口仍用短标签。
|
|
150
|
+
|
|
151
|
+
插件管理器读取包根的 `locale/en.json`、`locale/zh.json`:`meta.title` 提供显示标题,`meta.description` 提供五项能力说明,`meta.detail` 指向 `docs/DETAIL.en.md` / `docs/DETAIL.zh.md`。这些资源不参与运行时激活,`package.json#exports` 暴露 `./locale/*.json`,`files` 包含 `locale` 与 `docs`。
|
|
152
|
+
|
|
130
153
|
## 7. 并发与失败
|
|
131
154
|
|
|
132
155
|
- 服务端所有写操作经过 `guarded` 单操作互斥;并发的第二个请求返回 409。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# DeepSeekHarness: Restore Point
|
|
2
|
+
|
|
3
|
+
DSH restore points:
|
|
4
|
+
|
|
5
|
+
1. Manual and automatic restore points
|
|
6
|
+
2. Full session and workspace backup
|
|
7
|
+
3. Reinstall third-party plugins at npm latest
|
|
8
|
+
4. Migrate configuration and restore in one step
|
|
9
|
+
5. Repair session restore guides in one step
|
package/docs/REQUIREMENTS.md
CHANGED
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
| 1 | 支持定时更新还原点 | 已实现 | `src/service.mjs#startAutoScheduler`;`src/plugin.mjs#apply` | `service persists settings...` |
|
|
9
9
|
| 1.2 | 默认保存两份,手动/自动分开存储、分开显示 | 已实现 | `DEFAULT_SETTINGS.keepManual/keepAuto = 2`;`point.mjs#pruneCategory`;`manual/`、`auto/` | `prune keeps only the newest N points` |
|
|
10
10
|
| 1.3 | 手动导入其他机器还原点 | 已实现 | `src/point.mjs#importRestorePoint`;`src/service.mjs#importPoint`;面板「导入」 | `imports a point into the imported store` |
|
|
11
|
+
| 1.4 | 文件夹详情区(倒数第二位置) | 已实现 | `lib/client.js#FolderDetails` 位于还原点列表之后、说明与边界之前;创建/导入后自动展开;下拉框与行内「文件夹」按钮切换 | 客户端 bundle 用例断言 `FolderDetails`、`isTreePathOpen`;创建/检查路由断言 `tree` |
|
|
12
|
+
| 1.5 | 备份文件夹结构树 + 中文说明 | 已实现 | `src/tree.mjs#buildPointTree`;创建返回 `tree`;`src/service.mjs#inspectPoint` 返回同一棵树 | `creates one manual point...` 断言根目录、顶层文件、`sessions/` 与大小;`inspect` 路由断言 |
|
|
13
|
+
| 1.6 | 单分支展开,其余折叠 | 已实现 | `FolderDetails` 单一 `expandedPath`;`isTreePathOpen` 只保留祖先链;切换还原点重置 | `folder details lists every healthy point and opens only one tree branch` |
|
|
14
|
+
| 1.7 | 插件标题随系统自适应 | 已实现 | `lib/client.js#panelTitle`:Windows「DeepSeekHarness:一键还原点」、macOS「DeepSeekHarness:时间机器」;完整面板 `h2` 与 `main` 槽位 label 共用 | `the panel title follows macOS and Windows`;静态检查 `client bundle keeps the adaptive panel title` |
|
|
15
|
+
| 1.8 | 插件详情五项能力 | 已实现 | `locale/zh.json` `meta.description` 与 `docs/DETAIL.zh.md`;`locale/en.json` / `docs/DETAIL.en.md` 为英文对照 | `plugin display metadata is localized and carries the five capabilities`;`pack-check` 包含 `locale` 与详情文档 |
|
|
11
16
|
| 2.1 | 用户插件(内置/实验性)开启、关闭、参数配置 | 已实现 | `src/plugins.mjs#readProfilePlugins` 读取 bundles/rows/disabled;配置原文随 `cordis.patch.yml` 备份;`pluginInventory` 展示 | 创建用例断言 `status.plugins.user` 与实验性插件 |
|
|
12
17
|
| 2.2 | 第三方插件列表,DSH 内由用户手动触发一键自动安装并还原 NPM latest,恢复原配置 | 已实现(真实网络安装待验收) | `lib/client.js` 还原计划弹窗「安装并还原第三方插件」勾选框,默认勾选,可取消;`src/plugins.mjs#reinstallPlugins`;`src/restore.mjs#restorePoint` 安装后重放 package.json 并保留新版本 | 临时 DSH 页面确认 2 个插件时显示勾选框且可切换;`restorePoint skips plugin installation...`;真机 11 个第三方插件清单;联网 latest 仅用假 runner 验证 |
|
|
13
18
|
| 2.2 | 不保存安装包,可手动勾选同时备份安装包 | 已实现 | `includePluginPackages`;`packPluginTarballs`;还原优先 `file:` tarball | 默认 `false` 静态检查 |
|
|
@@ -61,6 +66,9 @@ node scripts/host-menu-patch.mjs --app-asar "D:\DSH\resources\app.asar" --restor
|
|
|
61
66
|
- [x] 通用设置入口 + 左上角侧栏入口
|
|
62
67
|
- [x] 纯插件 Windows 标题栏备用按钮(`installCaptionEntry`;静态检查 + 浏览器无宿主不报错)
|
|
63
68
|
- [x] 原生「应用-开发者工具」菜单补丁器(asar 副本验证)
|
|
69
|
+
- [x] 完整面板「文件夹详情」区与备份结构树(创建后自动展开,单分支)
|
|
70
|
+
- [x] 插件标题随系统自适应(Windows / macOS)
|
|
71
|
+
- [x] 插件管理器五项能力详情(locale + detail 文档)
|
|
64
72
|
- [x] 预还原副本与失败回滚
|
|
65
73
|
|
|
66
74
|
### P1(增强)
|
|
@@ -79,4 +87,5 @@ node scripts/host-menu-patch.mjs --app-asar "D:\DSH\resources\app.asar" --restor
|
|
|
79
87
|
- [x] 真实 `D:\DSH\resources\app.asar` 原生菜单补丁(已 `patched:true`,`app.asar.timemachine-backup` 已保留)
|
|
80
88
|
- [ ] 重启 DSH 后点击「应用 -> 开发者工具 -> DSH一键还原点」验收
|
|
81
89
|
- [ ] 第三方插件真实联网 latest 安装验收
|
|
82
|
-
- [
|
|
90
|
+
- [x] npm 与 GitHub 发布 `0.2.1`
|
|
91
|
+
- [ ] 插件管理器标题/详情在真实 DSH 中的渲染验收
|
package/docs/TESTPLAN.md
CHANGED
|
@@ -13,7 +13,7 @@ npm run pack-check
|
|
|
13
13
|
测试文件:
|
|
14
14
|
|
|
15
15
|
- `test/timemachine.test.mjs`:11 项服务端/路由用例
|
|
16
|
-
- `test/client-bundle.test.mjs`:
|
|
16
|
+
- `test/client-bundle.test.mjs`:8 项浏览器 bundle 用例(合计 19)
|
|
17
17
|
|
|
18
18
|
覆盖矩阵:
|
|
19
19
|
|
|
@@ -35,6 +35,12 @@ npm run pack-check
|
|
|
35
35
|
| 14 | 标题栏备用入口 | bundle 含 `data-windows-menu`、`DSH一键还原点`、`data-timemachine-caption` |
|
|
36
36
|
| 15 | 第三方插件手动开关 | bundle 含「安装并还原第三方插件」、`installPlugins`、`useSavedPackages` |
|
|
37
37
|
| 16 | 通用设置快捷入口 / 侧栏自适应 | bundle 含「立即备份」「一键还原」「打开完整面板」「时间机器」、`order: -100` |
|
|
38
|
+
| 17 | 文件夹结构树 | 创建返回 `tree`;根目录、顶层文件、`sessions/`、中文说明与精确大小;`/inspect` 返回同一棵树 |
|
|
39
|
+
| 18 | 单分支展开 | 所有健康还原点进入下拉框;`isTreePathOpen` 只展开目标路径与祖先链,其他分支折叠 |
|
|
40
|
+
| 19 | 树渲染 | 自定义 `createElement` 断言中文说明、文件大小、切换分支后旧分支折叠 |
|
|
41
|
+
| 20 | 标题自适应 | `panelTitle('Win32')` 返回「DeepSeekHarness:一键还原点」,`panelTitle('MacIntel')` 返回「DeepSeekHarness:时间机器」;`main` 槽位 label 同步 |
|
|
42
|
+
|
|
43
|
+
> 矩阵按断言主题列出,部分用例同时覆盖多个主题;自动化用例总数为 19。
|
|
38
44
|
|
|
39
45
|
## 2. 零残留
|
|
40
46
|
|
|
@@ -135,6 +141,23 @@ npm run pack-check
|
|
|
135
141
|
- 侧栏 `sidebar.panellist` 注册 `order: -100`;`sidebarLabel('MacIntel')` 返回「时间机器」,`sidebarLabel('Win32')` 返回「一键还原点」。
|
|
136
142
|
- 真实宿主内点击「一键还原」并完成还原、macOS 真机侧栏文案仍待人工验收。
|
|
137
143
|
|
|
144
|
+
### 3.9 0.2.0 文件夹详情(静态通过,待真机点击)
|
|
145
|
+
|
|
146
|
+
- `npm test` 18/18、`npm run check` 21/21、`npm run pack-check` 26 个文件。
|
|
147
|
+
- 创建手动还原点后,`POST /create` 返回 `tree`;`buildPointTree` 生成「还原点根目录 → 顶层文件 / sessions / attachments / profiles / registry」,节点带中文说明与大小。
|
|
148
|
+
- `POST /inspect` 对已有还原点返回同一棵树;`inspectPoint` 路由用例断言根目录与 `sessions/`。
|
|
149
|
+
- 完整面板中「文件夹详情」位于还原点列表之后、「说明与边界」之前;创建/导入后自动选中并展开根目录,切换还原点重置展开状态。
|
|
150
|
+
- `isTreePathOpen` 只保留目标路径及祖先链,保证同一时间只展开一个分支。
|
|
151
|
+
- 真实宿主内点击树节点、切换下拉框、创建后自动滚动到文件夹详情仍待人工点击验收。
|
|
152
|
+
|
|
153
|
+
### 3.10 0.2.1 标题与插件详情(静态通过,待真机渲染)
|
|
154
|
+
|
|
155
|
+
- `npm test` 19/19、`npm run check` 23/23、`npm run pack-check` 30 个文件。
|
|
156
|
+
- 完整面板标题与 `main` 槽位 label 使用 `panelTitle()`:Windows「DeepSeekHarness:一键还原点」,macOS「DeepSeekHarness:时间机器」。
|
|
157
|
+
- `locale/zh.json` 的 `meta.description` 与 `docs/DETAIL.zh.md` 保持五项能力原文;`locale/en.json` / `docs/DETAIL.en.md` 提供英文对照。
|
|
158
|
+
- `package.json` 暴露 `./locale/*.json`,`files` 包含 `locale`;`pack-check` 确认 30 个文件。
|
|
159
|
+
- 插件管理器中的标题和详情渲染仍待在真实 DSH 中验收。
|
|
160
|
+
|
|
138
161
|
## 4. 待人工验收
|
|
139
162
|
|
|
140
163
|
- 安装 tarball 到真实 DSH profile `desktop` 后:
|
|
@@ -143,6 +166,9 @@ npm run pack-check
|
|
|
143
166
|
- 点击入口打开 `main` 面板
|
|
144
167
|
- 设置行「一键还原」打开还原计划确认弹窗,确认后完成还原并自动打开会话
|
|
145
168
|
- 创建/还原按钮走真实 HTTP 路由
|
|
169
|
+
- 创建完成后「文件夹详情」自动选中新还原点并显示树;多个还原点切换时只展开一个分支
|
|
170
|
+
- 完整面板标题:Windows「DeepSeekHarness:一键还原点」,macOS「DeepSeekHarness:时间机器」
|
|
171
|
+
- 插件管理器详情显示五项能力,不再回退到包名
|
|
146
172
|
- 真实 DSH 桌面客户端左上角标题栏:
|
|
147
173
|
- 「应用 / 编辑」右侧出现「DSH一键还原点」
|
|
148
174
|
- 点击打开插件面板;关闭/卸载插件后按钮消失
|
|
@@ -158,7 +184,7 @@ npm run pack-check
|
|
|
158
184
|
|
|
159
185
|
## 5. 回归门槛
|
|
160
186
|
|
|
161
|
-
- `npm test`
|
|
162
|
-
- `npm run check`
|
|
163
|
-
- `npm run pack-check` tarball 内容符合 `files`(
|
|
187
|
+
- `npm test` 19/19 通过
|
|
188
|
+
- `npm run check` 23/23 通过
|
|
189
|
+
- `npm run pack-check` tarball 内容符合 `files`(30 个文件)
|
|
164
190
|
- 任何失败先定位到具体断言,不通过放宽断言“修复”
|
package/lib/client.js
CHANGED
|
@@ -56,11 +56,48 @@ window.__ModuleLoader__.load({
|
|
|
56
56
|
return `会话 ${counts.sessions ?? 0} · 配置 ${counts.config ?? 0} · 状态 ${counts.state ?? 0} · 插件 ${counts.plugins ?? 0}`;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
function
|
|
60
|
-
const
|
|
59
|
+
function pointKindLabel(value) {
|
|
60
|
+
const kind = typeof value === 'string' ? value : value?.point?.kind ?? value?.kind;
|
|
61
|
+
return kind === 'auto' ? '自动' : kind === 'imported' ? '导入' : '手动';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function allPointRows(status) {
|
|
65
|
+
const rows = [];
|
|
66
|
+
for (const kind of ['manual', 'auto', 'imported']) {
|
|
67
|
+
for (const row of status?.stores?.[kind]?.points ?? []) {
|
|
68
|
+
if (row?.ok !== false && typeof row.file === 'string') rows.push({ ...row, store_kind: kind });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
rows.sort((a, b) => String(b?.point?.created_at ?? '').localeCompare(String(a?.point?.created_at ?? '')));
|
|
72
|
+
return rows;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isTreePathOpen(path, openPath) {
|
|
76
|
+
if (path === '') return true;
|
|
77
|
+
return typeof openPath === 'string' && (openPath === path || openPath.startsWith(`${path}/`));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function baseName(file) {
|
|
81
|
+
const parts = String(file ?? '').split(/[\\/]/u);
|
|
82
|
+
return parts[parts.length - 1] || '还原点';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function platformName(platform = null) {
|
|
86
|
+
return platform ?? (typeof navigator === 'undefined'
|
|
61
87
|
? ''
|
|
62
88
|
: `${navigator.userAgentData?.platform ?? ''} ${navigator.platform ?? ''} ${navigator.userAgent ?? ''}`);
|
|
63
|
-
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function isMacPlatform(platform = null) {
|
|
92
|
+
return /mac|darwin/iu.test(String(platformName(platform)));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function sidebarLabel(platform = null) {
|
|
96
|
+
return isMacPlatform(platform) ? '时间机器' : '一键还原点';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function panelTitle(platform = null) {
|
|
100
|
+
return isMacPlatform(platform) ? 'DeepSeekHarness:时间机器' : 'DeepSeekHarness:一键还原点';
|
|
64
101
|
}
|
|
65
102
|
|
|
66
103
|
function latestLocalPoint(status) {
|
|
@@ -167,6 +204,17 @@ window.__ModuleLoader__.load({
|
|
|
167
204
|
.tm-plugin{display:flex;align-items:center;gap:8px;padding:5px 0;border-top:1px dashed var(--dsh-border,#e5e7eb);flex-wrap:wrap}
|
|
168
205
|
.tm-plugin:first-child{border-top:0}
|
|
169
206
|
.tm-yaml{margin:0;padding:8px;background:#0f172a;color:#e2e8f0;border-radius:8px;font:11px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace;max-height:220px;overflow:auto;white-space:pre-wrap;word-break:break-word}
|
|
207
|
+
.tm-folderSelect{min-width:260px;flex:1}
|
|
208
|
+
.tm-tree{margin-top:10px;padding-top:6px;border-top:1px solid var(--dsh-border,#e5e7eb);display:flex;flex-direction:column;gap:1px}
|
|
209
|
+
.tm-treeHead{display:grid;grid-template-columns:minmax(150px,.9fr) minmax(160px,1.1fr);gap:8px;padding:0 0 5px 22px;color:var(--dsh-text-secondary,#6b7280);font-size:10px}
|
|
210
|
+
.tm-treeRow{display:grid;grid-template-columns:14px minmax(150px,.9fr) minmax(160px,1.1fr);gap:8px;align-items:start;width:100%;border:0;background:transparent;color:inherit;text-align:left;padding:4px 0;font:inherit;font-size:11px;border-radius:6px}
|
|
211
|
+
.tm-treeRow.dir{cursor:pointer}
|
|
212
|
+
.tm-treeRow.dir:hover{background:var(--dsh-bg-secondary,#f9fafb)}
|
|
213
|
+
.tm-treeGlyph{color:var(--dsh-text-secondary,#6b7280);font-size:10px;line-height:1.7;user-select:none}
|
|
214
|
+
.tm-treeName{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;word-break:break-all;min-width:0}
|
|
215
|
+
.tm-treeDesc{color:var(--dsh-text-secondary,#6b7280);line-height:1.55;min-width:0}
|
|
216
|
+
.tm-treeSize{display:inline-block;margin-left:6px;color:var(--dsh-text-secondary,#9ca3af);white-space:nowrap}
|
|
217
|
+
.tm-point.selected{border-color:#2563eb;box-shadow:0 0 0 1px rgba(37,99,235,.18)}
|
|
170
218
|
.tm-modalMask{position:fixed;inset:0;background:rgba(15,23,42,.45);z-index:1000;display:flex;align-items:center;justify-content:center;padding:18px}
|
|
171
219
|
.tm-modal{background:var(--dsh-bg-primary,#fff);color:var(--dsh-text-primary,#111827);border-radius:14px;max-width:680px;width:100%;max-height:86vh;overflow:auto;padding:18px;box-shadow:0 20px 60px rgba(0,0,0,.25);display:flex;flex-direction:column;gap:12px}
|
|
172
220
|
.tm-modal h3{margin:0;font-size:15px}
|
|
@@ -176,7 +224,7 @@ window.__ModuleLoader__.load({
|
|
|
176
224
|
.tm-sessionRow{display:flex;gap:8px;align-items:center;padding:4px 0;border-top:1px dashed var(--dsh-border,#e5e7eb);font-size:11px;flex-wrap:wrap}
|
|
177
225
|
.tm-sessionRow:first-child{border-top:0}
|
|
178
226
|
.tm-sessionId{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;word-break:break-all}
|
|
179
|
-
@media (max-width:640px){.tm-pointActions{margin-left:0}.tm-card{padding:12px}}
|
|
227
|
+
@media (max-width:640px){.tm-pointActions{margin-left:0}.tm-card{padding:12px}.tm-treeHead{display:none}.tm-treeRow{grid-template-columns:14px minmax(0,1fr);row-gap:2px}.tm-treeDesc{grid-column:2;font-size:11px}}
|
|
180
228
|
`;
|
|
181
229
|
(doc.head ?? doc.documentElement).appendChild(style);
|
|
182
230
|
return () => {
|
|
@@ -221,15 +269,16 @@ window.__ModuleLoader__.load({
|
|
|
221
269
|
return { status, loading, error, refresh, setError };
|
|
222
270
|
}
|
|
223
271
|
|
|
224
|
-
function PointRow({ point, busy, onRestore, onDetails }) {
|
|
272
|
+
function PointRow({ point, busy, onRestore, onDetails, onFolder, selected = false }) {
|
|
225
273
|
const p = point.point ?? {};
|
|
226
|
-
return h('div', { className:
|
|
274
|
+
return h('div', { className: `tm-point${selected ? ' selected' : ''}`, 'data-tm-point': p.kind ?? '' },
|
|
227
275
|
h('div', { className: 'tm-pointTop' }, [
|
|
228
276
|
h('span', { key: 'time', className: 'tm-pointTime' }, formatTime(p.created_at)),
|
|
229
277
|
h('span', { key: 'src', className: 'tm-tag' }, p.source_machine ?? '本机'),
|
|
230
278
|
point.metadata_source === 'sidecar' ? null : h('span', { key: 'v', className: 'tm-tag warn' }, '待校验'),
|
|
231
279
|
h('span', { key: 'size', className: 'tm-tag' }, formatBytes(point.bytes)),
|
|
232
280
|
h('span', { key: 'actions', className: 'tm-pointActions' }, [
|
|
281
|
+
h('button', { key: 'folder', type: 'button', className: 'tm-btn ghost', onClick: () => onFolder(point) }, '文件夹'),
|
|
233
282
|
h('button', { key: 'detail', type: 'button', className: 'tm-btn ghost', onClick: () => onDetails(point) }, '详情'),
|
|
234
283
|
h('button', { key: 'restore', type: 'button', className: 'tm-btn danger', disabled: busy, onClick: () => onRestore(point) }, '还原'),
|
|
235
284
|
]),
|
|
@@ -242,6 +291,87 @@ window.__ModuleLoader__.load({
|
|
|
242
291
|
);
|
|
243
292
|
}
|
|
244
293
|
|
|
294
|
+
function FolderTree({ root, openPath, onToggle }) {
|
|
295
|
+
if (root === null || root === undefined) return null;
|
|
296
|
+
const render = (node, depth) => {
|
|
297
|
+
const path = typeof node.path === 'string' ? node.path : '';
|
|
298
|
+
const key = path === '' ? `root-${node.name}` : path;
|
|
299
|
+
const indent = { paddingLeft: `${2 + depth * 14}px` };
|
|
300
|
+
if (node.type !== 'dir') {
|
|
301
|
+
return h('div', { key, className: 'tm-treeRow file', style: indent, 'data-tm-tree-path': path }, [
|
|
302
|
+
h('span', { key: 'g', className: 'tm-treeGlyph' }, '·'),
|
|
303
|
+
h('span', { key: 'n', className: 'tm-treeName' }, node.name),
|
|
304
|
+
h('span', { key: 'd', className: 'tm-treeDesc' }, [
|
|
305
|
+
node.description ?? '备份文件',
|
|
306
|
+
typeof node.bytes === 'number' ? h('span', { key: 's', className: 'tm-treeSize' }, formatBytes(node.bytes)) : null,
|
|
307
|
+
]),
|
|
308
|
+
]);
|
|
309
|
+
}
|
|
310
|
+
const isRoot = depth === 0;
|
|
311
|
+
const open = isTreePathOpen(path, openPath);
|
|
312
|
+
return h('div', { key, 'data-tm-tree-dir': path }, [
|
|
313
|
+
h('button', {
|
|
314
|
+
key: 'row',
|
|
315
|
+
type: 'button',
|
|
316
|
+
className: 'tm-treeRow dir',
|
|
317
|
+
style: indent,
|
|
318
|
+
'aria-expanded': open,
|
|
319
|
+
onClick: isRoot ? undefined : () => onToggle(path),
|
|
320
|
+
}, [
|
|
321
|
+
h('span', { key: 'g', className: 'tm-treeGlyph' }, open ? '▾' : '▸'),
|
|
322
|
+
h('span', { key: 'n', className: 'tm-treeName' }, node.name),
|
|
323
|
+
h('span', { key: 'd', className: 'tm-treeDesc' }, [
|
|
324
|
+
node.description ?? '目录',
|
|
325
|
+
typeof node.files === 'number' ? h('span', { key: 'c', className: 'tm-treeSize' }, `${node.files} 个文件`) : null,
|
|
326
|
+
]),
|
|
327
|
+
]),
|
|
328
|
+
open ? (node.children ?? []).map((child) => render(child, depth + 1)) : null,
|
|
329
|
+
]);
|
|
330
|
+
};
|
|
331
|
+
return h('div', { className: 'tm-tree', 'data-tm-tree': 'true' }, [
|
|
332
|
+
h('div', { key: 'head', className: 'tm-treeHead' }, [
|
|
333
|
+
h('span', { key: 'path' }, '路径'),
|
|
334
|
+
h('span', { key: 'desc' }, '中文说明'),
|
|
335
|
+
]),
|
|
336
|
+
render(root, 0),
|
|
337
|
+
]);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function FolderDetails({ points, selectedFile, tree, loading, error, openPath, onSelect, onRefresh, onToggle }) {
|
|
341
|
+
const selected = points.find((row) => row.file === selectedFile) ?? null;
|
|
342
|
+
return h('div', { className: 'tm-card', 'data-tm-folder': 'true' }, [
|
|
343
|
+
h('div', { key: 'h', className: 'tm-cardTitle' }, [
|
|
344
|
+
h('span', { key: 't' }, '文件夹详情'),
|
|
345
|
+
h('span', { key: 'tag', className: 'tm-tag' }, selected === null
|
|
346
|
+
? '未选择'
|
|
347
|
+
: `${pointKindLabel(selected)} · ${formatBytes(selected.bytes)}`),
|
|
348
|
+
]),
|
|
349
|
+
h('div', { key: 'pick', className: 'tm-row' }, [
|
|
350
|
+
h('select', {
|
|
351
|
+
key: 'select',
|
|
352
|
+
className: 'tm-input tm-folderSelect',
|
|
353
|
+
value: selectedFile ?? '',
|
|
354
|
+
disabled: loading,
|
|
355
|
+
onChange: (event) => onSelect(event.target.value),
|
|
356
|
+
}, [
|
|
357
|
+
h('option', { key: 'none', value: '' }, points.length === 0 ? '还没有还原点' : '选择还原点查看文件夹结构'),
|
|
358
|
+
...points.map((row) => h('option', { key: row.file, value: row.file }, `${formatTime(row.point?.created_at)} · ${pointKindLabel(row)} · ${formatBytes(row.bytes)} · ${baseName(row.file)}`)),
|
|
359
|
+
]),
|
|
360
|
+
h('button', { key: 'refresh', type: 'button', className: 'tm-btn', disabled: selectedFile === null || loading, onClick: onRefresh }, loading ? '读取中…' : '刷新结构'),
|
|
361
|
+
]),
|
|
362
|
+
selected === null ? null : h('div', { key: 'path', className: 'tm-mono', style: { marginTop: 6 } }, selected.file),
|
|
363
|
+
h('div', { key: 'tip', className: 'tm-muted', style: { marginTop: 4 } }, '选中一个还原点查看结构;同一时间只展开一个目录,其余自动折叠。'),
|
|
364
|
+
error !== null ? h(Banner, { key: 'err', kind: 'error', title: '读取文件夹结构失败', detail: error }) : null,
|
|
365
|
+
loading
|
|
366
|
+
? h('div', { key: 'loading', className: 'tm-empty', style: { marginTop: 10 } }, '正在读取文件夹结构…')
|
|
367
|
+
: selectedFile === null
|
|
368
|
+
? h('div', { key: 'empty', className: 'tm-empty', style: { marginTop: 10 } }, '完成一次备份后,这里会自动显示备份文件的文件夹结构树。')
|
|
369
|
+
: tree === null
|
|
370
|
+
? h('div', { key: 'none', className: 'tm-empty', style: { marginTop: 10 } }, '没有读取到文件夹结构。')
|
|
371
|
+
: h(FolderTree, { key: 'tree', root: tree, openPath, onToggle }),
|
|
372
|
+
]);
|
|
373
|
+
}
|
|
374
|
+
|
|
245
375
|
function PlanModal({ plan, busy, pathMap, setPathMap, installPlugins, setInstallPlugins, onCancel, onConfirm }) {
|
|
246
376
|
if (plan === null) return null;
|
|
247
377
|
const will = plan.will ?? {};
|
|
@@ -357,6 +487,12 @@ window.__ModuleLoader__.load({
|
|
|
357
487
|
const [installPlugins, setInstallPlugins] = useState(true);
|
|
358
488
|
const [notice, setNotice] = useState(null);
|
|
359
489
|
const [details, setDetails] = useState(null);
|
|
490
|
+
const [folderFile, setFolderFile] = useState(null);
|
|
491
|
+
const [folderTree, setFolderTree] = useState(null);
|
|
492
|
+
const [folderLoading, setFolderLoading] = useState(false);
|
|
493
|
+
const [folderError, setFolderError] = useState(null);
|
|
494
|
+
const [expandedPath, setExpandedPath] = useState(null);
|
|
495
|
+
const folderSeq = useRef(0);
|
|
360
496
|
const [autoTime, setAutoTime] = useState('22:00');
|
|
361
497
|
const [autoOn, setAutoOn] = useState(false);
|
|
362
498
|
const [showPlugins, setShowPlugins] = useState(false);
|
|
@@ -379,6 +515,7 @@ window.__ModuleLoader__.load({
|
|
|
379
515
|
|
|
380
516
|
const stores = status?.stores ?? { manual: { points: [] }, auto: { points: [] }, imported: { points: [] } };
|
|
381
517
|
const points = tab === 'auto' ? (stores.auto?.points ?? []) : tab === 'imported' ? (stores.imported?.points ?? []) : (stores.manual?.points ?? []);
|
|
518
|
+
const folderPoints = useMemo(() => allPointRows(status), [status]);
|
|
382
519
|
|
|
383
520
|
const run = async (label, work) => {
|
|
384
521
|
if (busy !== '') return null;
|
|
@@ -401,12 +538,59 @@ window.__ModuleLoader__.load({
|
|
|
401
538
|
await request('/settings', { method: 'POST', body: JSON.stringify(options) });
|
|
402
539
|
};
|
|
403
540
|
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
541
|
+
const loadFolder = async (file, providedTree = null) => {
|
|
542
|
+
if (typeof file !== 'string' || file === '') {
|
|
543
|
+
folderSeq.current += 1;
|
|
544
|
+
setFolderFile(null);
|
|
545
|
+
setFolderTree(null);
|
|
546
|
+
setFolderLoading(false);
|
|
547
|
+
setFolderError(null);
|
|
548
|
+
setExpandedPath(null);
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
const seq = folderSeq.current + 1;
|
|
552
|
+
folderSeq.current = seq;
|
|
553
|
+
setFolderFile(file);
|
|
554
|
+
setFolderError(null);
|
|
555
|
+
setExpandedPath(null);
|
|
556
|
+
setFolderTree(providedTree ?? null);
|
|
557
|
+
if (providedTree !== null && providedTree !== undefined) {
|
|
558
|
+
setFolderLoading(false);
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
setFolderLoading(true);
|
|
562
|
+
try {
|
|
563
|
+
const result = await request('/inspect', { method: 'POST', body: JSON.stringify({ file }) });
|
|
564
|
+
if (folderSeq.current !== seq) return;
|
|
565
|
+
if (result?.tree === undefined || result.tree === null) {
|
|
566
|
+
setFolderError('返回数据缺少文件夹结构');
|
|
567
|
+
} else {
|
|
568
|
+
setFolderTree(result.tree);
|
|
569
|
+
}
|
|
570
|
+
} catch (caught) {
|
|
571
|
+
if (folderSeq.current !== seq) return;
|
|
572
|
+
setFolderError(caught.payload?.detail ?? caught.message);
|
|
573
|
+
} finally {
|
|
574
|
+
if (folderSeq.current === seq) setFolderLoading(false);
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
const showFolder = (point) => {
|
|
579
|
+
if (point !== null && typeof point?.file === 'string') void loadFolder(point.file);
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const create = async () => {
|
|
583
|
+
const result = await run('create', async () => {
|
|
584
|
+
await saveOptions();
|
|
585
|
+
const created = await request('/create', { method: 'POST', body: JSON.stringify({ kind: 'manual' }) });
|
|
586
|
+
setNotice({ kind: 'success', title: '还原点已创建', detail: `${created.file} · ${formatBytes(created.bytes)}` });
|
|
587
|
+
return created;
|
|
588
|
+
});
|
|
589
|
+
if (result !== null && typeof result === 'object') {
|
|
590
|
+
await loadFolder(result.file, result.tree ?? null);
|
|
591
|
+
try { document.querySelector('[data-tm-folder]')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } catch { /* optional layout */ }
|
|
592
|
+
}
|
|
593
|
+
};
|
|
410
594
|
|
|
411
595
|
const changeRoot = () => run('pick', async () => {
|
|
412
596
|
const picked = await pickDirectory();
|
|
@@ -425,17 +609,20 @@ window.__ModuleLoader__.load({
|
|
|
425
609
|
setNotice({ kind: 'success', title: '已使用默认文件夹', detail: root });
|
|
426
610
|
});
|
|
427
611
|
|
|
428
|
-
const importPoint =
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
612
|
+
const importPoint = async () => {
|
|
613
|
+
const result = await run('import', async () => {
|
|
614
|
+
const file = await pickFile();
|
|
615
|
+
if (file === null) {
|
|
616
|
+
setNotice({ kind: 'info', title: '没有选择还原点文件', detail: '也可以把 .tar.zst 文件拖到窗口后再试。' });
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
const imported = await request('/import', { method: 'POST', body: JSON.stringify({ file }) });
|
|
620
|
+
setNotice({ kind: 'success', title: '还原点已导入', detail: imported.file });
|
|
621
|
+
setTab('imported');
|
|
622
|
+
return imported;
|
|
623
|
+
});
|
|
624
|
+
if (result !== null && typeof result === 'object') await loadFolder(result.file);
|
|
625
|
+
};
|
|
439
626
|
|
|
440
627
|
const saveAuto = async (nextOn = autoOn, nextTime = autoTime) => {
|
|
441
628
|
setAutoOn(nextOn);
|
|
@@ -488,7 +675,7 @@ window.__ModuleLoader__.load({
|
|
|
488
675
|
if (status?.root_chosen !== true) {
|
|
489
676
|
return h('div', { className: 'tm-root' },
|
|
490
677
|
h('div', { className: 'tm-head' }, [
|
|
491
|
-
h('div', { key: 't' }, [h('h2', { className: 'tm-title' },
|
|
678
|
+
h('div', { key: 't' }, [h('h2', { className: 'tm-title' }, panelTitle()), h('div', { className: 'tm-sub' }, '先选择保存文件夹,之后所有还原点都放在这里。')]),
|
|
492
679
|
]),
|
|
493
680
|
h('div', { className: 'tm-card' }, [
|
|
494
681
|
h('div', { key: 'h', className: 'tm-cardTitle' }, '选择还原点保存文件夹'),
|
|
@@ -509,7 +696,7 @@ window.__ModuleLoader__.load({
|
|
|
509
696
|
return h('div', { className: 'tm-root', 'data-tm-surface': compact ? 'settings' : 'main' },
|
|
510
697
|
h('div', { className: 'tm-head' }, [
|
|
511
698
|
h('div', { key: 't', style: { minWidth: 220 } }, [
|
|
512
|
-
h('h2', { className: 'tm-title' },
|
|
699
|
+
h('h2', { className: 'tm-title' }, panelTitle()),
|
|
513
700
|
h('div', { key: 's', className: 'tm-sub' }, `保存到 ${status?.root ?? ''} · DSH ${status?.dsh_home ?? ''} · ${counts.plugins ?? 0} 个第三方插件`),
|
|
514
701
|
]),
|
|
515
702
|
h('div', { key: 'a', className: 'tm-row' }, [
|
|
@@ -590,9 +777,30 @@ window.__ModuleLoader__.load({
|
|
|
590
777
|
]),
|
|
591
778
|
points.length === 0
|
|
592
779
|
? h('div', { key: 'empty', className: 'tm-empty', style: { marginTop: 10 } }, tab === 'manual' ? '还没有手动还原点。点上面的「一键设置还原点」即可创建第一份。' : tab === 'auto' ? '自动还原点默认关闭;打开上面的开关,或先手动生成一份。' : '还没有导入其他机器的还原点。')
|
|
593
|
-
: h('div', { key: 'list', className: 'tm-list', style: { marginTop: 10 } }, points.map((point) => h(PointRow, {
|
|
780
|
+
: h('div', { key: 'list', className: 'tm-list', style: { marginTop: 10 } }, points.map((point) => h(PointRow, {
|
|
781
|
+
key: point.file,
|
|
782
|
+
point,
|
|
783
|
+
busy: busy !== '',
|
|
784
|
+
selected: folderFile === point.file,
|
|
785
|
+
onRestore: startRestore,
|
|
786
|
+
onDetails: setDetails,
|
|
787
|
+
onFolder: showFolder,
|
|
788
|
+
}))),
|
|
594
789
|
]),
|
|
595
790
|
|
|
791
|
+
h(FolderDetails, {
|
|
792
|
+
key: 'folder',
|
|
793
|
+
points: folderPoints,
|
|
794
|
+
selectedFile: folderFile,
|
|
795
|
+
tree: folderTree,
|
|
796
|
+
loading: folderLoading,
|
|
797
|
+
error: folderError,
|
|
798
|
+
openPath: expandedPath,
|
|
799
|
+
onSelect: (file) => void loadFolder(file),
|
|
800
|
+
onRefresh: () => void loadFolder(folderFile),
|
|
801
|
+
onToggle: (path) => setExpandedPath((current) => (current === path ? null : path)),
|
|
802
|
+
}),
|
|
803
|
+
|
|
596
804
|
h('details', { key: 'adv', className: 'tm-details' }, [
|
|
597
805
|
h('summary', { key: 's' }, '说明与边界'),
|
|
598
806
|
h('div', { key: 'b', className: 'tm-detailsBody' }, [
|
|
@@ -927,7 +1135,7 @@ window.__ModuleLoader__.load({
|
|
|
927
1135
|
mountSlot('settings.general.item', { id: 'timemachine-general', order: 80, label: () => 'DSH 一键还原点', inject: () => ({ open: openPanel, onRestoreDone: openRestored }) }, SettingsGeneralRow, 'the general-settings row');
|
|
928
1136
|
const sidebarDisposer = mountSlot('sidebar.panellist', { id: PANEL_ID, order: -100, label: () => sidebarLabel() }, SidebarEntry, 'the sidebar entry');
|
|
929
1137
|
scheduleAutoHide(sidebarDisposer, SIDEBAR_AUTO_HIDE_MS);
|
|
930
|
-
mountSlot('main', { key: PANEL_ID, label: () =>
|
|
1138
|
+
mountSlot('main', { key: PANEL_ID, label: () => panelTitle(), inject: () => ({ onRestoreDone: openRestored }) }, MainPage, 'the main panel');
|
|
931
1139
|
return () => {
|
|
932
1140
|
try {
|
|
933
1141
|
if (window.__DSH_TIMEMACHINE_OPEN__ === openPanel) delete window.__DSH_TIMEMACHINE_OPEN__;
|
|
@@ -945,9 +1153,14 @@ window.__ModuleLoader__.load({
|
|
|
945
1153
|
exports.SettingsGeneralRow = SettingsGeneralRow;
|
|
946
1154
|
exports.SidebarEntry = SidebarEntry;
|
|
947
1155
|
exports.sidebarLabel = sidebarLabel;
|
|
1156
|
+
exports.panelTitle = panelTitle;
|
|
948
1157
|
exports.SIDEBAR_AUTO_HIDE_MS = SIDEBAR_AUTO_HIDE_MS;
|
|
949
1158
|
exports.CAPTION_AUTO_HIDE_MS = CAPTION_AUTO_HIDE_MS;
|
|
950
1159
|
exports.latestLocalPoint = latestLocalPoint;
|
|
1160
|
+
exports.allPointRows = allPointRows;
|
|
1161
|
+
exports.isTreePathOpen = isTreePathOpen;
|
|
1162
|
+
exports.FolderDetails = FolderDetails;
|
|
1163
|
+
exports.FolderTree = FolderTree;
|
|
951
1164
|
exports.injectStyle = injectStyle;
|
|
952
1165
|
exports.formatBytes = formatBytes;
|
|
953
1166
|
exports.formatTime = formatTime;
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "DeepSeekHarness: Restore Point",
|
|
4
|
+
"description": "DSH restore points:\n1. Manual and automatic restore points\n2. Full session and workspace backup\n3. Reinstall third-party plugins at npm latest\n4. Migrate configuration and restore in one step\n5. Repair session restore guides in one step",
|
|
5
|
+
"detail": "docs/DETAIL.en.md"
|
|
6
|
+
}
|
|
7
|
+
}
|
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twinsearth/timemachine-dsh-plugin",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "DSH 一键还原点:手动/自动双还原点、会话与工作区完整备份、第三方插件 latest
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "DSH 一键还原点:手动/自动双还原点、会话与工作区完整备份、第三方插件 latest 重装、配置迁移与一键还原、一键修复会话引导。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "./icon.png",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./lib/index.js",
|
|
9
9
|
"./client": "./lib/client.js",
|
|
10
|
-
"./package.json": "./package.json"
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
"./locale/*.json": "./locale/*.json"
|
|
11
12
|
},
|
|
12
13
|
"main": "lib/index.js",
|
|
13
14
|
"files": [
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
"plugin.json",
|
|
17
18
|
"cordis.patch.yml",
|
|
18
19
|
"icon.png",
|
|
20
|
+
"locale",
|
|
19
21
|
"README.md",
|
|
20
22
|
"CHANGELOG.md",
|
|
21
23
|
"docs",
|
package/plugin.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "timemachine",
|
|
3
|
-
"name": "
|
|
4
|
-
"version": "0.1
|
|
5
|
-
"description": "
|
|
3
|
+
"name": "DeepSeekHarness:一键还原点",
|
|
4
|
+
"version": "0.2.1",
|
|
5
|
+
"description": "DSH 一键还原点:手动/自动双还原点、会话与工作区完整备份、第三方插件 latest 重装、配置迁移与一键还原、一键修复会话引导。",
|
|
6
6
|
"entry": "lib/index.js",
|
|
7
7
|
"client": "lib/client.js",
|
|
8
8
|
"bundle": "cordis.patch.yml"
|
package/src/point.mjs
CHANGED
|
@@ -27,6 +27,7 @@ import { readTar, writeTar } from './archive/tar.mjs';
|
|
|
27
27
|
import { inspectSessionBuffer } from './session-log.mjs';
|
|
28
28
|
import { scanExclusions, scanHome } from './scan.mjs';
|
|
29
29
|
import { packPluginTarballs, readProfilePlugins, SELF_PLUGIN } from './plugins.mjs';
|
|
30
|
+
import { buildPointTree } from './tree.mjs';
|
|
30
31
|
import { atomicWriteFile, ensureDir, formatBytes, isSafeArchiveName, readJson, sha256, stamp } from './util/fs.mjs';
|
|
31
32
|
import { encodeSegment, profileDir, projectKey, resolveDshHome } from './util/paths.mjs';
|
|
32
33
|
|
|
@@ -440,7 +441,7 @@ export async function createRestorePoint(input) {
|
|
|
440
441
|
writeSidecar(file, { point, counts, sha256: digest, bytes: zst.length });
|
|
441
442
|
const pruned = pruneCategory(folder, keep, file);
|
|
442
443
|
input.onProgress?.({ phase: 'created', file, bytes: zst.length });
|
|
443
|
-
return { ok: true, file, kind, bytes: zst.length, sha256: digest, point, counts, pruned };
|
|
444
|
+
return { ok: true, file, kind, bytes: zst.length, sha256: digest, point, counts, pruned, tree: buildPointTree(manifest, point, entries) };
|
|
444
445
|
} catch (error) {
|
|
445
446
|
if (error?.code === CODES.TOTAL_TOO_LARGE) return { ok: false, reason_code: error.code, detail: error.message };
|
|
446
447
|
return { ok: false, reason_code: CODES.WRITE_FAILED, detail: error instanceof Error ? error.message : String(error) };
|
|
@@ -575,6 +576,22 @@ export function readRestorePoint(file) {
|
|
|
575
576
|
};
|
|
576
577
|
}
|
|
577
578
|
|
|
579
|
+
/** Metadata plus the human-readable archive tree used by the full panel. */
|
|
580
|
+
export function inspectRestorePoint(file) {
|
|
581
|
+
const archive = readArchive(file);
|
|
582
|
+
if (!archive.ok) return archive;
|
|
583
|
+
return {
|
|
584
|
+
ok: true,
|
|
585
|
+
file: archive.file,
|
|
586
|
+
bytes: archive.bytes,
|
|
587
|
+
sha256: archive.sha256,
|
|
588
|
+
point: archive.point,
|
|
589
|
+
counts: archive.manifest.counts ?? archive.point.counts,
|
|
590
|
+
manifest: archive.manifest,
|
|
591
|
+
tree: buildPointTree(archive.manifest, archive.point, archive.entries),
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
|
|
578
595
|
/** List one store, newest first. Unreadable files become `ok:false` rows, not omissions. */
|
|
579
596
|
export function listCategory(root, kind) {
|
|
580
597
|
const folder = categoryDir(root, kind);
|
package/src/service.mjs
CHANGED
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
defaultRoot,
|
|
18
18
|
estimateRestorePoint,
|
|
19
19
|
importRestorePoint,
|
|
20
|
+
inspectRestorePoint,
|
|
20
21
|
listCategory,
|
|
21
|
-
readRestorePoint,
|
|
22
22
|
resolveRoot,
|
|
23
23
|
rootIsDefaultable,
|
|
24
24
|
selectSessions,
|
|
@@ -378,7 +378,7 @@ export function pickerUnavailable(what) {
|
|
|
378
378
|
export function inspectPoint(rawConfig, body, options = {}) {
|
|
379
379
|
const file = typeof body?.file === 'string' ? body.file.trim() : '';
|
|
380
380
|
if (file === '') return { ok: false, reason_code: 'TIMEMACHINE_FILE_REQUIRED', detail: 'body.file is required' };
|
|
381
|
-
const row =
|
|
381
|
+
const row = inspectRestorePoint(file);
|
|
382
382
|
if (!row.ok) return row;
|
|
383
383
|
const names = new Set((row.manifest.files ?? []).filter((item) => item.kind === 'session').map((item) => item.session_id));
|
|
384
384
|
return {
|
|
@@ -393,6 +393,7 @@ export function inspectPoint(rawConfig, body, options = {}) {
|
|
|
393
393
|
plugins: row.point.plugins ?? [],
|
|
394
394
|
user_plugins: row.point.all_plugins ?? [],
|
|
395
395
|
has_plugin_packages: Object.keys(row.point.plugin_package_files ?? {}).length > 0,
|
|
396
|
+
tree: row.tree,
|
|
396
397
|
};
|
|
397
398
|
}
|
|
398
399
|
|
package/src/tree.mjs
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-readable archive tree for the full panel.
|
|
3
|
+
*
|
|
4
|
+
* The manifest lists the content files but deliberately omits the three
|
|
5
|
+
* top-level files (it describes itself before they are packed). Keep the
|
|
6
|
+
* mapping here so the server and the UI use the same Chinese labels.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const TOP_LEVEL = [
|
|
10
|
+
['manifest.json', 'manifest', '清单文件:记录每个文件的路径、大小与 SHA-256'],
|
|
11
|
+
['README.txt', 'readme', '人读说明:创建时间、备份范围与排除项'],
|
|
12
|
+
['RESTORE-POINT.json', 'point', '还原点元数据:会话、插件、工作区与统计'],
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const KIND_DESCRIPTIONS = {
|
|
16
|
+
manifest: '清单文件:记录每个文件的路径、大小与 SHA-256',
|
|
17
|
+
readme: '人读说明:创建时间、备份范围与排除项',
|
|
18
|
+
point: '还原点元数据:会话、插件、工作区与统计',
|
|
19
|
+
session: '会话原始日志(zstd 压缩)',
|
|
20
|
+
guide: '还原引导:会话来源、工作区与恢复步骤',
|
|
21
|
+
attachment: '会话附件对象',
|
|
22
|
+
config: 'DSH 配置文件(不含账户与凭据)',
|
|
23
|
+
state: 'DSH 界面或状态数据',
|
|
24
|
+
registry: '工作区与会话注册表快照',
|
|
25
|
+
plugin_package: '第三方插件离线安装包(.tgz)',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function describeDir(rel) {
|
|
29
|
+
if (rel === 'sessions') return '会话目录:按项目分组,每个会话一个 Session ID 子目录';
|
|
30
|
+
if (/^sessions\/[^/]+$/u.test(rel)) return '项目分组:由会话工作目录生成';
|
|
31
|
+
if (/^sessions\/[^/]+\/[^/]+$/u.test(rel)) return '单个会话目录:原始日志 + 两份还原引导';
|
|
32
|
+
if (rel === 'attachments') return '附件目录:会话引用的附件对象';
|
|
33
|
+
if (/^attachments\/[^/]+$/u.test(rel)) return '附件对象分片目录';
|
|
34
|
+
if (rel === 'profiles') return 'DSH profile 目录:配置、插件列表与界面状态';
|
|
35
|
+
if (/^profiles\/[^/]+$/u.test(rel)) return 'DSH profile:该配置档的配置与插件状态';
|
|
36
|
+
if (rel === 'storages' || /\/storages$/u.test(rel)) return 'DSH 状态存储:界面与会话状态';
|
|
37
|
+
if (rel === 'registry') return '工作区注册表目录';
|
|
38
|
+
if (rel === 'plugin-packages') return '第三方插件离线安装包目录';
|
|
39
|
+
return '目录';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function describeFile(row) {
|
|
43
|
+
const base = row.rel.split('/').pop() ?? row.rel;
|
|
44
|
+
if (row.kind === 'guide') {
|
|
45
|
+
return base.endsWith('.json')
|
|
46
|
+
? '机器可读还原引导:会话来源、工作区与恢复步骤'
|
|
47
|
+
: '人读还原引导:逐项说明如何恢复该会话';
|
|
48
|
+
}
|
|
49
|
+
if (KIND_DESCRIPTIONS[row.kind] !== undefined) return KIND_DESCRIPTIONS[row.kind];
|
|
50
|
+
if (base === 'package.json') return 'DSH profile 的插件声明与版本信息';
|
|
51
|
+
if (base === 'cordis.patch.yml') return 'DSH 插件启用/参数补丁';
|
|
52
|
+
return row.reason ? `备份文件:${row.reason}` : '备份文件';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function fileSize(row, sizeByRel) {
|
|
56
|
+
if (sizeByRel.has(row.rel)) return sizeByRel.get(row.rel);
|
|
57
|
+
return typeof row.size === 'number' ? row.size : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function finalize(node) {
|
|
61
|
+
if (node.type === 'file') return;
|
|
62
|
+
let bytes = 0;
|
|
63
|
+
let known = false;
|
|
64
|
+
for (const child of node.children.values()) {
|
|
65
|
+
finalize(child);
|
|
66
|
+
if (typeof child.bytes === 'number') {
|
|
67
|
+
bytes += child.bytes;
|
|
68
|
+
known = true;
|
|
69
|
+
}
|
|
70
|
+
node.files += child.files;
|
|
71
|
+
}
|
|
72
|
+
node.bytes = known ? bytes : null;
|
|
73
|
+
node.children = [...node.children.values()].sort((a, b) => {
|
|
74
|
+
if (a.type !== b.type) return a.type === 'dir' ? -1 : 1;
|
|
75
|
+
return a.name.localeCompare(b.name, 'zh-CN');
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {{files?: Array<{rel: string, kind?: string, size?: number, reason?: string}>}} manifest
|
|
81
|
+
* @param {object} [point]
|
|
82
|
+
* @param {Array<{name: string, data: Buffer}>} [entries] exact sizes when available
|
|
83
|
+
* @returns {{name: string, path: string, type: string, description: string, bytes: number|null, files: number, children: Array}}
|
|
84
|
+
*/
|
|
85
|
+
export function buildPointTree(manifest, point = {}, entries = null) {
|
|
86
|
+
const sizeByRel = new Map();
|
|
87
|
+
for (const entry of entries ?? []) {
|
|
88
|
+
if (typeof entry?.name === 'string' && entry?.data !== undefined) {
|
|
89
|
+
sizeByRel.set(entry.name, entry.data.length);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const rows = [...(manifest?.files ?? [])];
|
|
94
|
+
const seen = new Set(rows.map((row) => row.rel));
|
|
95
|
+
for (const [rel, kind, description] of TOP_LEVEL) {
|
|
96
|
+
if (!seen.has(rel)) rows.push({ rel, kind, size: sizeByRel.get(rel) ?? null, description });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const root = {
|
|
100
|
+
name: '还原点根目录',
|
|
101
|
+
path: '',
|
|
102
|
+
type: 'dir',
|
|
103
|
+
description: `整个还原点压缩包${point?.kind ? `(${point.kind === 'auto' ? '自动' : point.kind === 'imported' ? '导入' : '手动'})` : ''}`,
|
|
104
|
+
bytes: null,
|
|
105
|
+
files: 0,
|
|
106
|
+
children: new Map(),
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
for (const row of rows) {
|
|
110
|
+
if (typeof row?.rel !== 'string' || row.rel === '') continue;
|
|
111
|
+
const segments = row.rel.split('/').filter(Boolean);
|
|
112
|
+
let parent = root;
|
|
113
|
+
let current = '';
|
|
114
|
+
for (let index = 0; index < segments.length; index += 1) {
|
|
115
|
+
const segment = segments[index];
|
|
116
|
+
current = current === '' ? segment : `${current}/${segment}`;
|
|
117
|
+
const isFile = index === segments.length - 1;
|
|
118
|
+
let node = parent.children.get(segment);
|
|
119
|
+
if (node === undefined) {
|
|
120
|
+
node = {
|
|
121
|
+
name: segment,
|
|
122
|
+
path: current,
|
|
123
|
+
type: isFile ? 'file' : 'dir',
|
|
124
|
+
description: isFile ? describeFile(row) : describeDir(current),
|
|
125
|
+
bytes: isFile ? fileSize(row, sizeByRel) : null,
|
|
126
|
+
files: isFile ? 1 : 0,
|
|
127
|
+
...(isFile ? { kind: row.kind ?? 'file' } : { children: new Map() }),
|
|
128
|
+
};
|
|
129
|
+
parent.children.set(segment, node);
|
|
130
|
+
}
|
|
131
|
+
parent = node;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
finalize(root);
|
|
136
|
+
return root;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Flatten a built tree for a simple indented list. */
|
|
140
|
+
export function flattenTree(root) {
|
|
141
|
+
const rows = [];
|
|
142
|
+
const walk = (node, depth) => {
|
|
143
|
+
rows.push({ ...node, depth, children: undefined });
|
|
144
|
+
for (const child of node.children ?? []) walk(child, depth + 1);
|
|
145
|
+
};
|
|
146
|
+
walk(root, 0);
|
|
147
|
+
return rows;
|
|
148
|
+
}
|