dsh-plugin-snapshot 0.1.0 → 0.3.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.en.md +73 -13
- package/README.md +99 -40
- package/client/client.js +476 -0
- package/lib/apply-all.js +73 -0
- package/lib/auto-update.js +286 -0
- package/lib/doctor.js +21 -6
- package/lib/exec.js +101 -0
- package/lib/index.js +46 -9
- package/lib/install-guard.js +51 -0
- package/lib/probe.js +118 -0
- package/lib/profile.js +6 -1
- package/lib/routes.js +244 -0
- package/lib/snapshot.js +78 -9
- package/lib/updates.js +24 -12
- package/lib/util.js +23 -2
- package/package.json +23 -4
package/README.en.md
CHANGED
|
@@ -1,37 +1,95 @@
|
|
|
1
1
|
# dsh-plugin-snapshot
|
|
2
2
|
|
|
3
|
-
Pre-upgrade snapshots, one-step rollback and a static health check for DeepSeek Harness plugins
|
|
3
|
+
**Pre-upgrade snapshots, one-step rollback and a static health check for DeepSeek Harness plugins.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
One plugin, three tools.
|
|
6
|
+
|
|
7
|
+
- npm: https://www.npmjs.com/package/dsh-plugin-snapshot
|
|
8
|
+
- repo: https://github.com/Uesccda/dsh-plugin-snapshot
|
|
9
|
+
- compatible with DSH 0.2.0+ (tested on 0.2.2-rc.1)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What problem it solves
|
|
14
|
+
|
|
15
|
+
| The trouble you hit | What this does |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| A plugin upgrade fails halfway: manifests changed, dependencies not installed, unknown state | Takes a snapshot with fingerprint and hashes before upgrading, so you can always go back |
|
|
18
|
+
| Dozens of plugins installed, no idea which collide or whose compatibility claim is stale | One scan reports installed / enabled / missing / incompatible / untested, plus a review priority |
|
|
19
|
+
| No idea which plugins have newer versions, and afraid of auto-upgrading to a beta | Lists updatable items and marks prereleases separately instead of mixing them in |
|
|
20
|
+
|
|
21
|
+
It deliberately does **not** install, remove or toggle plugins: that is what the built-in plugin_manager is for. Two implementations fighting over the same profile is the most common source of breakage in this ecosystem.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## The three tools
|
|
26
|
+
|
|
27
|
+
| Tool | Does | Writes |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| plugin_snapshot | create / list / restore snapshots of the profile manifests | only its own data dir, plus the three manifests on restore |
|
|
30
|
+
| plugin_doctor | static diagnostic: install state, author-declared compatibility, duplicate patch ids, missing packages | read-only |
|
|
31
|
+
| plugin_updates | compares the version resolved in pnpm-lock.yaml against the registry | read-only |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
Just talk to the model:
|
|
38
|
+
|
|
39
|
+
- "Take a snapshot before upgrading my plugins"
|
|
40
|
+
- "Check my installed plugins for problems"
|
|
41
|
+
- "Which plugins have updates available?"
|
|
42
|
+
- "That upgrade failed, roll back to before it"
|
|
43
|
+
|
|
44
|
+
---
|
|
6
45
|
|
|
7
46
|
## Install
|
|
8
47
|
|
|
9
48
|
dsh plugin add dsh-plugin-snapshot
|
|
10
49
|
|
|
11
|
-
Restart DSH
|
|
50
|
+
Restart DSH afterwards. Remove with:
|
|
12
51
|
|
|
13
|
-
|
|
52
|
+
dsh plugin remove dsh-plugin-snapshot
|
|
14
53
|
|
|
15
|
-
|
|
54
|
+
---
|
|
16
55
|
|
|
17
|
-
|
|
56
|
+
## What a snapshot contains
|
|
18
57
|
|
|
19
|
-
|
|
58
|
+
The three profile manifests (package.json, pnpm-lock.yaml, pnpm-workspace.yaml) plus a manifest.json recording the profile fingerprint, creation time, per-file existence and sha256.
|
|
20
59
|
|
|
21
|
-
|
|
60
|
+
Restoring verifies the fingerprint first, so a snapshot from another profile is rejected. A hash mismatch only warns, because you may have edited the manifest by hand.
|
|
22
61
|
|
|
23
|
-
|
|
62
|
+
Snapshots do **not** include node_modules. Dependencies must be reinstalled after a restore.
|
|
24
63
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Static diagnostic: declared vs installed vs enabled, author-declared DSH compatibility (an explicit incompatible is reported as incompatible, never as probably fine), duplicate cordis.patch.yml ids, missing packages and unparseable manifests. The returned priority is a rule-weighted score, not a crash probability.
|
|
64
|
+
---
|
|
28
65
|
|
|
29
66
|
## Where data lives
|
|
30
67
|
|
|
31
68
|
~/.dsh-plugin-snapshot/snapshots/<timestamp>/
|
|
32
69
|
~/.dsh-plugin-snapshot/logs/
|
|
33
70
|
|
|
34
|
-
Nothing else is written except the three profile manifests on restore.
|
|
71
|
+
Nothing else is written except the three profile manifests on restore.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
{
|
|
78
|
+
"profileDir": "explicit profile directory (auto-detected when empty)",
|
|
79
|
+
"snapshotsKeep": 7,
|
|
80
|
+
"concurrency": 8,
|
|
81
|
+
"autoUpdate": false,
|
|
82
|
+
"autoUpdateScope": "patch",
|
|
83
|
+
"autoExclude": ["package-you-never-want-touched"]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
| Option | Default | Meaning |
|
|
87
|
+
| --- | --- | --- |
|
|
88
|
+
| autoUpdate | false | Disabled by default. Set true to check and update 45 s after DSH starts |
|
|
89
|
+
| autoUpdateScope | patch | patch only / minor / major |
|
|
90
|
+
| autoExclude | [] | packages never touched by auto-update |
|
|
91
|
+
| snapshotsKeep | 7 | how many snapshots to retain |
|
|
92
|
+
| concurrency | 8 | registry query parallelism |
|
|
35
93
|
|
|
36
94
|
## Limitations
|
|
37
95
|
|
|
@@ -39,6 +97,8 @@ Nothing else is written except the three profile manifests on restore. node_modu
|
|
|
39
97
|
- Diagnostics are static evidence, not runtime verification
|
|
40
98
|
- No scheduler: the plugin only exists while DSH runs
|
|
41
99
|
|
|
100
|
+
---
|
|
101
|
+
|
|
42
102
|
## License
|
|
43
103
|
|
|
44
104
|
MIT
|
package/README.md
CHANGED
|
@@ -1,84 +1,143 @@
|
|
|
1
1
|
# dsh-plugin-snapshot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**给 DeepSeek Harness 的插件做升级前快照、一键回滚和静态体检。**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
一个插件,三个工具。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- npm: https://www.npmjs.com/package/dsh-plugin-snapshot
|
|
8
|
+
- 仓库: https://github.com/Uesccda/dsh-plugin-snapshot
|
|
9
|
+
- 兼容: DSH 0.2.0 及以上(已在 0.2.2-rc.1 实测)
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 它解决什么问题
|
|
14
|
+
|
|
15
|
+
| 你会遇到的麻烦 | 这个插件怎么处理 |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| 升级插件失败,清单已经改了、依赖没装完,不知道回到了什么状态 | 升级前先存一份带指纹和哈希的快照,任何时候都能退回去 |
|
|
18
|
+
| 装了几十个插件,不知道谁跟谁冲突、谁的兼容声明已经过期 | 一次扫描给出:已装/已启用/缺失/不兼容/未验证,以及检查优先级 |
|
|
19
|
+
| 不知道哪些插件有新版本,又怕自动升到测试版 | 列出可更新项,预发布版本单独标注、不混进"可升级"里 |
|
|
20
|
+
|
|
21
|
+
它**默认不做**安装、卸载、启停——那是 DSH 自带的 plugin_manager 的事。两套实现打架是插件市场里最常见的坑,这里直接避开。
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 三个工具
|
|
26
|
+
|
|
27
|
+
| 工具 | 做什么 | 会不会写文件 |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| plugin_snapshot | 创建快照 / 列出快照 / 恢复到某个快照 | 只写自己的数据目录,恢复时覆盖 profile 的三份清单 |
|
|
30
|
+
| plugin_doctor | 静态体检:安装状态、作者声明的兼容性、patch id 冲突、缺失的包 | 纯只读 |
|
|
31
|
+
| plugin_updates | 以 lockfile 解析出的版本为基准,查 registry 有没有新版本 | 纯只读 |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 怎么用(对话示例)
|
|
36
|
+
|
|
37
|
+
你不用记命令,直接跟模型说:
|
|
38
|
+
|
|
39
|
+
- **"升级插件前先给我打个快照"** → 调用 plugin_snapshot 的 create,返回快照名
|
|
40
|
+
- **"看看我这些插件有没有问题"** → 调用 plugin_doctor,给出 48 个插件的体检结果
|
|
41
|
+
- **"哪些插件可以升级"** → 调用 plugin_updates,列出可更新项
|
|
42
|
+
- **"刚才那次升级失败了,退回到升级前"** → 调用 plugin_snapshot 的 restore
|
|
43
|
+
|
|
44
|
+
---
|
|
10
45
|
|
|
11
46
|
## 安装
|
|
12
47
|
|
|
13
48
|
dsh plugin add dsh-plugin-snapshot
|
|
14
49
|
|
|
15
|
-
|
|
50
|
+
装完重启 DSH(启用 HMR 时自动生效),三个工具随即可用。
|
|
51
|
+
|
|
52
|
+
卸载:
|
|
53
|
+
|
|
54
|
+
dsh plugin remove dsh-plugin-snapshot
|
|
16
55
|
|
|
17
|
-
|
|
56
|
+
---
|
|
18
57
|
|
|
19
|
-
|
|
58
|
+
## 兼容性
|
|
20
59
|
|
|
21
|
-
|
|
60
|
+
本插件声明支持 DSH 0.2.0 及以上,并在 0.2.2-rc.1 实测通过:
|
|
22
61
|
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
62
|
+
0.2.2-rc.1 compatible
|
|
63
|
+
0.2.1 compatible
|
|
64
|
+
0.2.0+ compatible
|
|
26
65
|
|
|
27
|
-
|
|
66
|
+
如果你在别的 DSH 版本上使用,plugin_doctor 会如实显示为「未验证」而不是假装兼容。
|
|
28
67
|
|
|
29
|
-
|
|
68
|
+
---
|
|
30
69
|
|
|
31
|
-
|
|
70
|
+
## 快照里存了什么
|
|
32
71
|
|
|
33
|
-
|
|
34
|
-
- 输出每个插件的状态:updatable / major / uptodate / prerelease / failed / manual
|
|
35
|
-
- 预发布版本不会被建议升级;主版本变更、GitHub 源一律标成需人工确认
|
|
72
|
+
profile 目录下的三份清单:
|
|
36
73
|
|
|
37
|
-
|
|
74
|
+
package.json
|
|
75
|
+
pnpm-lock.yaml
|
|
76
|
+
pnpm-workspace.yaml
|
|
38
77
|
|
|
39
|
-
|
|
78
|
+
每份快照额外带一个 manifest.json,记录:profile 指纹、创建时间、每个文件是否存在、每个文件的 sha256。
|
|
40
79
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
80
|
+
恢复时会先比对 profile 指纹——**别的 profile 的快照会被拒绝**,避免把 A 环境的清单写进 B。文件摘要对不上只告警,因为你可能手工改过清单。
|
|
81
|
+
|
|
82
|
+
⚠️ 快照**不包含 node_modules**。恢复之后需要让包管理器重新安装依赖。
|
|
83
|
+
|
|
84
|
+
---
|
|
45
85
|
|
|
46
86
|
## 数据放在哪
|
|
47
87
|
|
|
48
88
|
~/.dsh-plugin-snapshot/snapshots/<时间戳>/
|
|
49
89
|
~/.dsh-plugin-snapshot/logs/
|
|
50
90
|
|
|
51
|
-
只写这两个目录,以及恢复时写回 profile 的三份清单。不碰 node_modules
|
|
91
|
+
只写这两个目录,以及恢复时写回 profile 的三份清单。不碰 node_modules、不改 bundles 清单、不启动或关闭 DSH。
|
|
92
|
+
|
|
93
|
+
---
|
|
52
94
|
|
|
53
95
|
## 安全边界
|
|
54
96
|
|
|
55
|
-
-
|
|
56
|
-
- plugin_snapshot 的 create 只写自己的数据目录;restore
|
|
57
|
-
-
|
|
97
|
+
- plugin_doctor 与 plugin_updates 是**纯只读**:只读文件、只发 GET 请求
|
|
98
|
+
- plugin_snapshot 的 create 只写自己的数据目录;restore 必须显式传 name
|
|
99
|
+
- 两个只读工具(plugin_updates、plugin_doctor)只读文件、只发 GET 请求
|
|
100
|
+
- 写操作(快照恢复、更新)会执行 pnpm,但只作用于 profile 中**已安装**的包,
|
|
101
|
+
只允许升到更高版本,拒绝降级与 dist-tag,并一律带 --ignore-scripts
|
|
102
|
+
- 不结束任何进程
|
|
58
103
|
|
|
59
|
-
|
|
104
|
+
---
|
|
60
105
|
|
|
61
|
-
|
|
106
|
+
## 配置项
|
|
62
107
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
108
|
+
在插件配置里可写:
|
|
109
|
+
|
|
110
|
+
{
|
|
111
|
+
"profileDir": "指定 profile 目录(留空则自动定位)",
|
|
112
|
+
"snapshotsKeep": 7,
|
|
113
|
+
"concurrency": 8,
|
|
114
|
+
"autoUpdate": false,
|
|
115
|
+
"autoUpdateScope": "patch",
|
|
116
|
+
"autoExclude": ["某个不想被自动更新的包"]
|
|
117
|
+
}
|
|
70
118
|
|
|
71
|
-
|
|
119
|
+
| 配置 | 默认 | 说明 |
|
|
120
|
+
| --- | --- | --- |
|
|
121
|
+
| autoUpdate | false | 是否在 DSH 启动 45 秒后自动检查并更新 |
|
|
122
|
+
| autoUpdateScope | patch | 升级档位:patch 仅补丁版 / minor 含次版本 / major 含主版本 |
|
|
123
|
+
| autoExclude | [] | 永不参与自动更新的包名列表 |
|
|
124
|
+
| snapshotsKeep | 7 | 保留的快照份数 |
|
|
125
|
+
| concurrency | 8 | 查询 registry 的并发数 |
|
|
72
126
|
|
|
73
127
|
## 已知限制
|
|
74
128
|
|
|
75
|
-
- 快照只覆盖三份清单,不含 node_modules
|
|
129
|
+
- 快照只覆盖三份清单,不含 node_modules
|
|
76
130
|
- 诊断基于静态扫描与作者声明,不代表运行时验证
|
|
77
|
-
-
|
|
131
|
+
- 自动更新**默认关闭**:需在插件配置里显式写 autoUpdate: true 才会启用
|
|
132
|
+
- 插件只在 DSH 运行时存在,DSH 关闭期间不做任何事
|
|
133
|
+
|
|
134
|
+
---
|
|
78
135
|
|
|
79
136
|
## 开发
|
|
80
137
|
|
|
81
|
-
npm test
|
|
138
|
+
npm test # 5 项自测,用 stub 顶替 @deepseek-ai/dsh-tools
|
|
139
|
+
|
|
140
|
+
---
|
|
82
141
|
|
|
83
142
|
## 许可
|
|
84
143
|
|