pi-patch-keeper 1.1.1 → 1.2.0
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 +40 -27
- package/README.md +36 -42
- package/package.json +2 -2
package/README.en.md
CHANGED
|
@@ -1,44 +1,57 @@
|
|
|
1
|
-
# pi-patch-keeper —
|
|
1
|
+
# pi-patch-keeper — pi configuration guards (pi extension)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Requires pi >= 0.74 · Node >= 20 · MIT · no runtime dependencies · no PiDeck or third-party patching
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Checks three classes of hazards in pi's own configuration at session start: what can be fixed is fixed, the rest is reported clearly.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
| force-typed extension order | auto-moves known force-typed packages to the end, backup first |
|
|
15
|
-
| manual version vs injected version | warns once per mismatch pair |
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **codemode single-source check**: disabling `builtin:codemode` and installing `pi-codemode-guard` must agree.
|
|
10
|
+
- **force-order guard**: force-type extensions (e.g. rtk / cache-optimizer) must sit last in `packages`, otherwise later section writes are silently dropped; wrong order is fixed automatically (with a backup).
|
|
11
|
+
- **Environment fingerprint drift**: notifies when `settings.json` packages / defaultTools / enabledModels / extensions / codemode change, since manuals or prior verification may be stale.
|
|
12
|
+
- **Injection alignment**: compares the injected `APPEND_SYSTEM.md` version with the on-disk version and, on mismatch, tells the model to trust disk.
|
|
13
|
+
- Commands `/patch-keeper` (status) and `/patch-keeper fix` (repair force order).
|
|
16
14
|
|
|
17
15
|
## Install
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
```bash
|
|
18
|
+
pi install npm:pi-patch-keeper
|
|
19
|
+
pi install ./pi-patch-keeper
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
**No config file**: the package only reads `settings.json` and the manual.
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
| Item | Path | Description |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| Fingerprint | `~/.pi/patch-keeper.json` | Settings snapshot from the previous start, used for drift detection (self-maintained) |
|
|
29
|
+
| Manual sentinel | `~/.pi/patch-keeper-manual.json` | Manual version / content signature, catches "content changed without a version bump" |
|
|
30
|
+
| Fix backup | `~/.pi/agent/settings.json.bak-force-order-*` | Backup created before repairing force order |
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
### Commands
|
|
33
|
+
|
|
34
|
+
| Command | Purpose |
|
|
27
35
|
| --- | --- |
|
|
28
|
-
|
|
|
29
|
-
|
|
|
36
|
+
| `/patch-keeper` | Show codemode / force / fingerprint / injection-alignment status |
|
|
37
|
+
| `/patch-keeper fix` | Repair force order in `packages` (with backup) |
|
|
38
|
+
|
|
39
|
+
### Not included (local-only module)
|
|
40
|
+
|
|
41
|
+
PiDeck builtin patch restoration, read-only asar checks, pi-lens / pi-memory / pi-tactician source patches, local snapshot restore — all depend on the PiDeck install directory, third-party internals or local paths, so they are **not shipped** with this package. They live in a local module `patch-keeper-local` (`/patch-keeper-local`).
|
|
30
42
|
|
|
31
|
-
##
|
|
43
|
+
## How it works
|
|
32
44
|
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
- All
|
|
45
|
+
- On factory startup it compares fingerprints and self-checks force order; failures only notify, never throw or disturb the session.
|
|
46
|
+
- Injection alignment compares versions in `before_agent_start` and only writes its own notification and trailing message; it **never returns systemPrompt** (which would replace the whole prompt and drop other sections).
|
|
47
|
+
- All writes are atomic (temp file + rename).
|
|
36
48
|
|
|
37
|
-
##
|
|
49
|
+
## Limitations
|
|
38
50
|
|
|
39
|
-
-
|
|
40
|
-
-
|
|
51
|
+
- Covers pi's own configuration only, not third-party plugin behaviour.
|
|
52
|
+
- Force-order repair targets a built-in list of known force-type packages.
|
|
53
|
+
- Fingerprint drift reports what changed, not whether the new value is correct.
|
|
41
54
|
|
|
42
55
|
## License
|
|
43
56
|
|
|
44
|
-
MIT
|
|
57
|
+
MIT
|
package/README.md
CHANGED
|
@@ -1,63 +1,57 @@
|
|
|
1
|
-
# pi-patch-keeper ——
|
|
1
|
+
# pi-patch-keeper —— pi 配置守卫(pi 扩展)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
npm 发布版:`pi install npm:pi-patch-keeper`
|
|
6
|
-
|
|
7
|
-
本地目录:`pi install <path/to/patch-keeper>`
|
|
8
|
-
|
|
9
|
-
安装后 `/reload` 或重启会话生效(扩展源码改动需重启)。
|
|
3
|
+
> 适用 pi ≥ 0.74 · Node ≥ 20 · MIT · 无运行时依赖 · 不含 PiDeck / 第三方补丁
|
|
10
4
|
|
|
11
|
-
|
|
5
|
+
在每次会话启动时检查 pi 自身配置的三类隐患,能修的直接修,不能修的明确报出来。
|
|
12
6
|
|
|
13
|
-
##
|
|
7
|
+
## 功能
|
|
14
8
|
|
|
15
|
-
|
|
9
|
+
- **codemode 单点一致性**:禁 `builtin:codemode` 与安装 `pi-codemode-guard` 必须同时成立。
|
|
10
|
+
- **force 顺序守卫**:force 型扩展(如 rtk / cache-optimizer)必须排在 `packages` 末尾,否则其后的 section 写入会被静默丢弃;发现乱序自动修复(先备份)。
|
|
11
|
+
- **环境指纹漂移**:`settings.json` 的 packages / defaultTools / enabledModels / extensions / codemode 变化时提示「手册或上轮验证结论可能过期」。
|
|
12
|
+
- **注入对齐**:比对注入的 `APPEND_SYSTEM.md` 版本与磁盘版本,不一致时提示「以磁盘版为准」,并同步回灌模型。
|
|
13
|
+
- 命令 `/patch-keeper` 查看全部状态,`/patch-keeper fix` 修复 force 顺序。
|
|
16
14
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
1. **session_start 自检**(每次 pi 启动):
|
|
20
|
-
- **pi-lens wordindex 补丁:能修的直接修**——本扩展是 user 扩展(加载 rank 2),先于 pi-lens 的 package rank 4;factory 内同步改 `dist/index.js`,pi-lens 随后 import 到的即打过补丁的内容(**当轮生效**);半打状态先还原再重打(幂等)。**上游发版后停手**:dist 出现 `warm_cache_adopted`(#4583 / PR #4586)即视为 A 已修复——跳过 A、只补 B(B 上游未修),`/patch-keeper` 显示「上游已修复 #4583」。
|
|
21
|
-
- **pi-memory exit summary 空行规范化:能修的直接修**——改 npm pi-memory 的 `index.ts`(render 侧规范块级空行;幂等;写前留 `.bak-exitsummary-<stamp>` 备份)。
|
|
22
|
-
- **PiDeck asar 三补丁:只检测不修**——PiDeck 运行中文件被锁、插件无权碰 Electron 主进程;检测到未打补丁时提示跑 `launch-pideck.cmd`(启动前自动重打)或快照 `05-脚本补丁/` 下脚本。
|
|
23
|
-
2. **before_agent_start 注入对齐检测**:比对「本轮注入的手册版本」vs「磁盘版」——不一致提示**一次**(同 pair 去重);方向不限(注入滞后 / 磁盘回滚都可能)。
|
|
24
|
-
3. **环境漂移指纹**:`~/.pi/patch-keeper.json` 记录 settings 关键字段(packages / defaultTools 等)——支撑漂移检测。
|
|
25
|
-
4. **force 顺序守卫(自动修复)**:packages 中条件 force 型(pi-rtk-optimizer / pi-cache-optimizer)须在末尾——启动与 /patch-keeper fix 时自动移到末尾(先备份 settings.json.bak-force-order-*),修复幂等;其后 section 写入不会被静默丢弃。
|
|
26
|
-
5. **force 型扩展扫描(疑似)**:扫描 packages 入口源码中的 return { systemPrompt } / forceSystemPrompt,报告疑似无条件 force 的包(会覆盖 system、使其后 section 静默丢失);位于中间者启动时提示。先写 section、只有旧宿主才 force 的归为「兼容兜底」,不计入疑似。
|
|
27
|
-
|
|
28
|
-
## 自我回灌(条件触发型)
|
|
15
|
+
## 安装
|
|
29
16
|
|
|
30
|
-
|
|
17
|
+
```bash
|
|
18
|
+
pi install npm:pi-patch-keeper
|
|
19
|
+
pi install ./pi-patch-keeper
|
|
20
|
+
```
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
- 不一致(注入滞后 / 磁盘回滚均可能)→ 一次 notify 提示「以磁盘为准、先读回全文」(同 pair 去重,不重复打扰);
|
|
34
|
-
- notify 用户 + 回灌模型(nextTurn,四律②:用户侧收到后模型也须知道,否则「以磁盘为准」停在用户侧);检测失败静默。
|
|
22
|
+
## 配置
|
|
35
23
|
|
|
36
|
-
|
|
24
|
+
**无配置文件**:本包只读 `settings.json` 与手册,不引入自己的配置项。
|
|
37
25
|
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
| 项 | 路径 | 说明 |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| 环境指纹 | `~/.pi/patch-keeper.json` | 上次启动时的配置快照,用于漂移对比(自动维护) |
|
|
29
|
+
| 手册哨兵 | `~/.pi/patch-keeper-manual.json` | 手册版本 / 内容签名,用于检测「改了内容没升版本」 |
|
|
30
|
+
| 自动修复备份 | `~/.pi/agent/settings.json.bak-force-order-*` | 修复 force 顺序前的备份 |
|
|
40
31
|
|
|
41
|
-
|
|
32
|
+
### 命令
|
|
42
33
|
|
|
43
|
-
|
|
|
34
|
+
| 命令 | 作用 |
|
|
44
35
|
| --- | --- |
|
|
45
|
-
|
|
|
46
|
-
|
|
|
36
|
+
| `/patch-keeper` | 输出 codemode / force / 指纹 / 注入对齐状态 |
|
|
37
|
+
| `/patch-keeper fix` | 修复 `packages` 的 force 顺序(带备份) |
|
|
47
38
|
|
|
48
|
-
|
|
39
|
+
### 不包含(本机专用模块)
|
|
49
40
|
|
|
50
|
-
-
|
|
51
|
-
- 回滚:删本目录;已打补丁保持原样(回退用 `05-脚本补丁/` 下脚本各自的 rollback)。
|
|
41
|
+
PiDeck builtin 补丁双份恢复、asar 只读检测、pi-lens / pi-memory / pi-tactician 源码补丁、本机快照恢复 —— 这些依赖 PiDeck 安装目录、第三方包内部实现与本机路径,**不随本包发布**,由本机模块 `patch-keeper-local` 提供,命令 `/patch-keeper-local`。
|
|
52
42
|
|
|
53
|
-
##
|
|
43
|
+
## 机制
|
|
54
44
|
|
|
55
|
-
|
|
45
|
+
- 启动时(factory)执行指纹对比与 force 自检;失败只提示,绝不抛错、不影响会话。
|
|
46
|
+
- 注入对齐在 `before_agent_start` 比较版本,只写自己的通知与尾部消息,**绝不返回 systemPrompt**(避免覆盖式替换丢掉其他 section)。
|
|
47
|
+
- 所有写盘走「临时文件 + rename」原子写。
|
|
56
48
|
|
|
57
|
-
##
|
|
49
|
+
## 限制
|
|
58
50
|
|
|
59
|
-
|
|
51
|
+
- 只覆盖 pi 自身配置;不检查第三方插件行为。
|
|
52
|
+
- force 顺序修复只对已知的 force 型包生效(列表内置,随版本更新)。
|
|
53
|
+
- 指纹对比只报「变了什么」,不判断新值是否正确。
|
|
60
54
|
|
|
61
55
|
## License
|
|
62
56
|
|
|
63
|
-
MIT
|
|
57
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-patch-keeper",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "pi config guards: codemode single-source check, force-order guard (auto-fix), settings fingerprint drift, injected-manual alignment. (PiDeck / third-party source patches are a local-only module, not bundled.)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|