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 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
- The built-in plugin_manager already installs, removes and toggles plugins. This plugin adds what it does not: a verifiable recovery point before you change anything, a way back when an upgrade goes wrong, and a clear view of which plugins collide.
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 (or let HMR pick it up), then the three tools are available.
50
+ Restart DSH afterwards. Remove with:
12
51
 
13
- ## Tools
52
+ dsh plugin remove dsh-plugin-snapshot
14
53
 
15
- ### plugin_snapshot
54
+ ---
16
55
 
17
- Create, list and restore snapshots of the profile manifests (package.json, pnpm-lock.yaml, pnpm-workspace.yaml).
56
+ ## What a snapshot contains
18
57
 
19
- Every snapshot carries a manifest with the profile fingerprint, creation time, and per-file sha256. 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.
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
- ### plugin_updates
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
- Read-only version check. Compares the version resolved in pnpm-lock.yaml against the registry and reports updatable / major / uptodate / prerelease / failed / manual. Prereleases are never suggested, and GitHub sources are always flagged for manual review.
62
+ Snapshots do **not** include node_modules. Dependencies must be reinstalled after a restore.
24
63
 
25
- ### plugin_doctor
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. node_modules and the bundles list are never touched, and DSH is never started or stopped.
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
- 给 DeepSeek Harness 的插件做**升级前快照、一键回滚和静态体检**。
3
+ **给 DeepSeek Harness 的插件做升级前快照、一键回滚和静态体检。**
4
4
 
5
- DSH 官方的 plugin_manager 已经能装、卸、启停插件;本插件只补它没有的那一块:**改动之前先存一份能验身份的恢复点,出问题能退回来,装完之后能看清谁跟谁冲突**。
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
- 插件升级失败时最难受的不是报错,而是"清单已经改了、依赖没装完、不知道回到了什么状态"。本插件在每次升级前把 profile 的三份清单(package.json / pnpm-lock.yaml / pnpm-workspace.yaml)存成一份带指纹与哈希的快照,任何时候都能退回去。
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
- 装好后重启 DSH(或启用 HMR 时自动生效),三个工具随即可用。
50
+ 装完重启 DSH(启用 HMR 时自动生效),三个工具随即可用。
51
+
52
+ 卸载:
53
+
54
+ dsh plugin remove dsh-plugin-snapshot
16
55
 
17
- ## 提供的工具
56
+ ---
18
57
 
19
- ### plugin_snapshot
58
+ ## 兼容性
20
59
 
21
- 快照的创建、列表与恢复。
60
+ 本插件声明支持 DSH 0.2.0 及以上,并在 0.2.2-rc.1 实测通过:
22
61
 
23
- - action = "create":把当前 profile 的三份清单存成一份快照,返回快照名
24
- - action = "list":列出全部快照(时间、依赖数、是否带 manifest)
25
- - action = "restore" + name:恢复到指定快照;恢复前会先自动给现状再存一份
62
+ 0.2.2-rc.1 compatible
63
+ 0.2.1 compatible
64
+ 0.2.0+ compatible
26
65
 
27
- 每份快照都带 manifest:profile 指纹、创建时间、每个文件的存在性与 sha256。恢复时会先校验指纹——**别的 profile 的快照会被拒绝**;文件摘要对不上只告警(你可能手工改过清单)。
66
+ 如果你在别的 DSH 版本上使用,plugin_doctor 会如实显示为「未验证」而不是假装兼容。
28
67
 
29
- ### plugin_updates
68
+ ---
30
69
 
31
- 只读的版本检测。
70
+ ## 快照里存了什么
32
71
 
33
- - 以 pnpm-lock.yaml 里解析出来的版本为基准,去 registry 查候选版本
34
- - 输出每个插件的状态:updatable / major / uptodate / prerelease / failed / manual
35
- - 预发布版本不会被建议升级;主版本变更、GitHub 源一律标成需人工确认
72
+ profile 目录下的三份清单:
36
73
 
37
- ### plugin_doctor
74
+ package.json
75
+ pnpm-lock.yaml
76
+ pnpm-workspace.yaml
38
77
 
39
- 静态体检。
78
+ 每份快照额外带一个 manifest.json,记录:profile 指纹、创建时间、每个文件是否存在、每个文件的 sha256。
40
79
 
41
- - 已声明 vs 已安装 vs 已启用,三者分开列
42
- - 按插件作者声明判定 DSH 版本兼容性:**明确写 incompatible 的判成不兼容,绝不显示成"大概率可用"**
43
- - 重复的 cordis.patch.yml 行 id、缺失的包、无法解析的清单
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,不改 bundles 清单,不启动或关闭 DSH。
91
+ 只写这两个目录,以及恢复时写回 profile 的三份清单。不碰 node_modules、不改 bundles 清单、不启动或关闭 DSH。
92
+
93
+ ---
52
94
 
53
95
  ## 安全边界
54
96
 
55
- - plugin_updates 与 plugin_doctor 是**纯只读**:只读文件、只发 GET 请求
56
- - plugin_snapshot 的 create 只写自己的数据目录;restore 需要显式传 name,且只覆盖三份清单
57
- - 不实现安装/卸载/启停——那是官方 plugin_manager 的职责,避免两套实现互相打架
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
- 可选,写进 profile 的插件配置:
106
+ ## 配置项
62
107
 
63
- | 字段 | 默认 | 说明 |
64
- | --- | --- | --- |
65
- | profileDir | 自动定位 | 显式指定 profile 目录 |
66
- | registry | registry.npmjs.org | 检测用的源,也可用 DSH_REGISTRY |
67
- | dataDir | ~/.dsh-plugin-snapshot | 快照与日志目录 |
68
- | snapshotsKeep | 7 | 保留份数 |
69
- | concurrency | 8 | 检测并发 |
108
+ 在插件配置里可写:
109
+
110
+ {
111
+ "profileDir": "指定 profile 目录(留空则自动定位)",
112
+ "snapshotsKeep": 7,
113
+ "concurrency": 8,
114
+ "autoUpdate": false,
115
+ "autoUpdateScope": "patch",
116
+ "autoExclude": ["某个不想被自动更新的包"]
117
+ }
70
118
 
71
- profile 定位顺序:配置 > 环境变量 DSH_PROFILE_DIR > ~/.dsh/profiles/desktop > 扫描 profiles 目录取最近修改的。
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
- - 不做定时任务:插件只在 DSH 运行时存在
131
+ - 自动更新**默认关闭**:需在插件配置里显式写 autoUpdate: true 才会启用
132
+ - 插件只在 DSH 运行时存在,DSH 关闭期间不做任何事
133
+
134
+ ---
78
135
 
79
136
  ## 开发
80
137
 
81
- npm test # 5 项自测,用 stub 顶替 @deepseek-ai/dsh-tools
138
+ npm test # 5 项自测,用 stub 顶替 @deepseek-ai/dsh-tools
139
+
140
+ ---
82
141
 
83
142
  ## 许可
84
143