@duanz/pi-pi-web-patch-keeper 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. package/README.en.md +65 -0
  2. package/README.md +65 -0
  3. package/package.json +8 -4
package/README.en.md ADDED
@@ -0,0 +1,65 @@
1
+ # pi-web-patch-keeper
2
+
3
+ <p align="center"><strong>English</strong> | <a href="./README.md">中文</a></p>
4
+
5
+ <p align="center"><img src="https://raw.githubusercontent.com/DuanZGit/D-Hub/master/docs/covers/pi-web-patch-keeper.png" alt="pi-web-patch-keeper cover" width="880"></p>
6
+
7
+ <p align="center"><strong>Local pi-web patches survive upgrades by replaying themselves on load</strong><br><sub>Checked on load · idempotent · rewrites only what the upgrade wiped</sub></p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@duanz/pi-pi-web-patch-keeper"><img src="https://img.shields.io/npm/v/@duanz%2Fpi-pi-web-patch-keeper.svg?style=flat-square" alt="npm"></a>
11
+ <a href="https://github.com/DuanZGit/D-Hub/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/@duanz%2Fpi-pi-web-patch-keeper.svg?style=flat-square" alt="license"></a>
12
+ <a href="https://github.com/DuanZGit/D-Hub"><img src="https://img.shields.io/badge/GitHub-DuanZGit%2FD--Hub-181717?style=flat-square&logo=github" alt="GitHub"></a>
13
+ <img src="https://img.shields.io/badge/pi-extension-34d399?style=flat-square" alt="pi extension">
14
+ </p>
15
+
16
+ <p align="center">
17
+ <code>pi install npm:@duanz/pi-pi-web-patch-keeper</code>
18
+ </p>
19
+
20
+ ## Why
21
+
22
+ Local pi-web changes (project and session names in completion notifications, UI copy) can only live in build artifacts: `.next/server/chunks`, `.next/static`, `public/sw.js`. An `npm update` or reinstall replaces those files wholesale, the patches vanish, and nothing warns you.
23
+
24
+ ## What it does
25
+
26
+ One thing: run `apply.py` when the extension loads.
27
+
28
+ - All changes are registered in `~/.pi/agent/.cn-patches/patches.json`
29
+ - `apply.py` replays them and is **idempotent**: applied patches are skipped; only ones wiped by an upgrade are written back
30
+ - When a replay happens, the next `agent_start` reminds you to restart pi-web
31
+
32
+ ## Usage
33
+
34
+ 1. Create the patch directory:
35
+
36
+ ```
37
+ ~/.pi/agent/.cn-patches/
38
+ ├── patches.json # patch registry
39
+ └── apply.py # replay script
40
+ ```
41
+
42
+ 2. Install the extension and restart pi-web.
43
+
44
+ The extension does not know how patches are written — only when to run them.
45
+
46
+ ## Configuration
47
+
48
+ | Variable | Default | Description |
49
+ | --- | --- | --- |
50
+ | `PI_WEB_PATCH_OFF` | empty | Set to `1` to disable |
51
+ | `PI_WEB_PATCH_INTERVAL_H` | `6` | Minimum hours between checks |
52
+
53
+ ## State and logs
54
+
55
+ - `~/.pi/agent/.cn-patches/keeper-state.json` — last check time
56
+ - `~/.pi/agent/.cn-patches/keeper.log` — each run and what it replayed
57
+
58
+ ## Limits
59
+
60
+ - You supply `patches.json` and `apply.py`; this is the shell, not the patches.
61
+ - A replay still needs a pi-web restart to take effect (the extension only reminds).
62
+
63
+ ## License
64
+
65
+ MIT © DuanZ
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # pi-web-patch-keeper
2
+
3
+ <p align="center"><a href="./README.en.md">English</a> | <strong>中文</strong></p>
4
+
5
+ <p align="center"><img src="https://raw.githubusercontent.com/DuanZGit/D-Hub/master/docs/covers/pi-web-patch-keeper.png" alt="pi-web-patch-keeper cover" width="880"></p>
6
+
7
+ <p align="center"><strong>pi-web 升级会整包覆盖,本地补丁在下次加载时自动重放</strong><br><sub>加载即检查 · 幂等 · 被冲掉才写回</sub></p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@duanz/pi-pi-web-patch-keeper"><img src="https://img.shields.io/npm/v/@duanz%2Fpi-pi-web-patch-keeper.svg?style=flat-square" alt="npm"></a>
11
+ <a href="https://github.com/DuanZGit/D-Hub/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/@duanz%2Fpi-pi-web-patch-keeper.svg?style=flat-square" alt="license"></a>
12
+ <a href="https://github.com/DuanZGit/D-Hub"><img src="https://img.shields.io/badge/GitHub-DuanZGit%2FD--Hub-181717?style=flat-square&logo=github" alt="GitHub"></a>
13
+ <img src="https://img.shields.io/badge/pi-extension-34d399?style=flat-square" alt="pi extension">
14
+ </p>
15
+
16
+ <p align="center">
17
+ <code>pi install npm:@duanz/pi-pi-web-patch-keeper</code>
18
+ </p>
19
+
20
+ ## 它解决什么
21
+
22
+ pi-web 的本地改动(完成通知显示项目名与会话名、界面文案等)只能改在编译产物里:`.next/server/chunks`、`.next/static`、`public/sw.js`。`npm update` 或重新安装会把这些文件整包覆盖,补丁全丢,而且没人提醒。
23
+
24
+ ## 它做什么
25
+
26
+ 只做一件事:扩展加载时跑一次 `apply.py`。
27
+
28
+ - 所有改动登记在 `~/.pi/agent/.cn-patches/patches.json`
29
+ - `apply.py` 负责重放,**幂等**:已应用的跳过,只有被升级冲掉的才写回
30
+ - 有重放发生时,在下一次 `agent_start` 提醒你重启 pi-web
31
+
32
+ ## 用法
33
+
34
+ 1. 建立补丁目录:
35
+
36
+ ```
37
+ ~/.pi/agent/.cn-patches/
38
+ ├── patches.json # 补丁登记表
39
+ └── apply.py # 重放脚本
40
+ ```
41
+
42
+ 2. 装扩展,重启 pi-web。
43
+
44
+ 扩展本身不判断补丁怎么写,只决定**什么时候跑**。
45
+
46
+ ## 配置
47
+
48
+ | 变量 | 默认 | 说明 |
49
+ | --- | --- | --- |
50
+ | `PI_WEB_PATCH_OFF` | 空 | 设为 `1` 关闭 |
51
+ | `PI_WEB_PATCH_INTERVAL_H` | `6` | 两次检查的最小间隔(小时) |
52
+
53
+ ## 状态与日志
54
+
55
+ - `~/.pi/agent/.cn-patches/keeper-state.json`:上次检查时间
56
+ - `~/.pi/agent/.cn-patches/keeper.log`:每次运行、重放了哪些补丁
57
+
58
+ ## 限制
59
+
60
+ - 需要你自己准备 `patches.json` 与 `apply.py`;这是通用外壳,不含具体补丁内容。
61
+ - 有重放后仍需重启 pi-web 才生效(扩展只提醒,不重启)。
62
+
63
+ ## License
64
+
65
+ MIT © DuanZ
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@duanz/pi-pi-web-patch-keeper",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "pi-web 升级会覆盖本地补丁,这个扩展在启动时把它们重新打上",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "pi-package",
8
- "pi-extension"
8
+ "pi-extension",
9
+ "pi-web"
9
10
  ],
10
11
  "license": "MIT",
11
12
  "author": "DuanZ",
@@ -16,12 +17,15 @@
16
17
  "directory": "extensions/pi-web-patch-keeper"
17
18
  },
18
19
  "files": [
19
- "index.ts"
20
+ "index.ts",
21
+ "README.md",
22
+ "README.en.md"
20
23
  ],
21
24
  "pi": {
22
25
  "extensions": [
23
26
  "./index.ts"
24
- ]
27
+ ],
28
+ "image": "https://raw.githubusercontent.com/DuanZGit/D-Hub/master/docs/covers/pi-web-patch-keeper.png"
25
29
  },
26
30
  "engines": {
27
31
  "node": ">=20"