@alequet/dsh-patchkeeper 0.0.0-stage → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 alequet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,68 @@
1
- # Temporary Holding Version
1
+ # dsh-patchkeeper
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 给 DeepSeek Harness 插件的本地魔改一个家。
4
+
5
+ 你改过某个插件的代码(加模型、修 bug、调行为)?官方一升级,改动就被冲掉;带着改动升级,插件可能加载失败、整个客户端起不来。patchkeeper 用**影子副本常驻挂载**解决这个问题。
6
+
7
+ ## 工作原理
8
+
9
+ ```
10
+ 补丁库(git 管理) profile node_modules 数据目录
11
+ patches/<pkg>__<ver>.patch @scope/pkg ──软链──▶ shadows/<pkg>(原版克隆 + 补丁)
12
+ @scope/pkg 的原版 ──备份──▶ shadows/orig/<pkg>
13
+ ```
14
+
15
+ - **常驻挂载**:DSH 启动时用「冻结快照」决定每个包从哪个目录加载,快照早于一切插件代码运行——所以补丁必须在进程启动前就在磁盘上,且**挂载不随退出摘除**
16
+ - **启动时**:保底清除(只收拾崩溃残留/升级替换留下的坏挂载,健康挂载原地不动)→ 版本闸(补丁版本 == 插件版本才挂)→ 副本新鲜度校验(补丁文件改过就重建副本)
17
+ - **版本不匹配**(插件刚升级):不挂载,插件以原版启动保证能开机;插件管理页该插件详情页出「补丁未加载」徽章 + 适配卡片
18
+ - **升级安全**:pnpm/安装器随时可以换掉软链装新包(实测 pnpm 会保留 link),保底清除识别后丢弃过时备份、基于新版重新评估
19
+
20
+ ## 安装
21
+
22
+ 设置 → 插件 → 添加 → 安装第三方插件,输入:
23
+
24
+ ```
25
+ @alequet/dsh-patchkeeper
26
+ ```
27
+
28
+ 重启后生效。
29
+
30
+ ## 可观测性(不靠「没报错」脑补)
31
+
32
+ - **🩹 生效标记**:挂载中的插件在插件管理页的列表描述里带「🩹 补丁生效中」;看不到 = 没生效
33
+ - **开机 toast**:启动后右上角「N 个补丁生效中 ✓」;异常则常驻红/黄牌
34
+ - **补丁管理台**:patchkeeper 自己的详情页——补丁清单、效果说明、版本对照、每补丁启用开关(运行期即时挂载/摘除)、操作结果红绿反馈、失败常驻红字诊断
35
+ - **CLI 失明告警**:补丁在库但 patchkeeper 未启用时,`status` 直接吼出来
36
+
37
+ ## CLI
38
+
39
+ ```bash
40
+ CLI=~/.dsh/profiles/desktop/node_modules/dsh-patchkeeper/bin/cli.mjs
41
+
42
+ node $CLI list # 补丁清单(启用状态/说明/版本/挂载状态)
43
+ node $CLI status # 状态总览 + 失明告警
44
+ node $CLI apply # 保底清除 + 挂载版本匹配的副本
45
+ node $CLI remount --pkg <包名> # 改了补丁文件后一键重建副本
46
+ node $CLI revert [--pkg <包名>] # 手动摘除挂载,恢复原版
47
+ node $CLI extract --pkg <包名> # 把当前代码与 npm 原版的差异收成补丁入库
48
+ node $CLI enable|disable --pkg <包名> # 单个补丁开关(持久化,随 patches 入 git)
49
+ node $CLI note --pkg <包名> <说明> # 写补丁效果说明
50
+ node $CLI risk --pkg <包名> [说明] # 挂/清禁用风险警告(禁用时弹确认)
51
+ node $CLI doctor [--fix] # 检查/修复插件注册
52
+ ```
53
+
54
+ ## 调试循环
55
+
56
+ 1. 改挂载中的副本(node_modules 条目就指向它),重启 DSH 验证
57
+ 2. `extract --pkg <包名>` 从副本提补丁入库(自动剔除生效标记,不污染补丁)
58
+ 3. 改错了:补丁库是 git 仓库,`git checkout -- patches/` 回滚后 `remount`
59
+
60
+ ## 配置与环境变量
61
+
62
+ - 补丁库:默认 `~/.dsh/patch-manager`(用 `DSH_PATCHKEEPER_HOME` 覆盖)
63
+ - 目标 profile:默认 `desktop`(用 `DSH_PROFILE` 覆盖,接受绝对路径或 profiles/ 下的名字)
64
+ - 每补丁的启用/说明/风险:`patches/config.json`(随补丁库入 git)
65
+
66
+ ## License
67
+
68
+ MIT