pi-patch-keeper 1.2.3 → 1.2.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 +16 -61
- package/README.md +57 -51
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -1,85 +1,40 @@
|
|
|
1
|
-
# pi-patch-keeper
|
|
1
|
+
# pi-patch-keeper
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## What it solves
|
|
6
|
-
|
|
7
|
-
Three configuration failures happen silently: the codemode switch disagreeing with the installed guard, a force-type extension sitting mid-list (dropping every later section), and an injected manual that is older than the one on disk. None of them error — behaviour just drifts. This extension checks at startup and fixes what it can.
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- **codemode single-source check**: disabling `builtin:codemode` and installing `pi-codemode-guard` must agree.
|
|
12
|
-
- **force-order guard**: force-type extensions must sit last in `packages`; wrong order is fixed automatically (with a backup).
|
|
13
|
-
- **Environment fingerprint drift**: notifies when key `settings.json` fields change, since manuals or prior verification may be stale.
|
|
14
|
-
- **Injection alignment**: compares injected `APPEND_SYSTEM.md` version with disk and tells the model to trust disk.
|
|
15
|
-
- Commands `/patch-keeper` and `/patch-keeper fix`.
|
|
3
|
+
pi configuration guards: codemode consistency, force order, settings fingerprint drift, injected-manual alignment. **No PiDeck or third-party source patching.**
|
|
16
4
|
|
|
17
5
|
## Install
|
|
18
6
|
|
|
19
7
|
```bash
|
|
20
8
|
pi install npm:pi-patch-keeper
|
|
21
|
-
pi install ./pi-patch-keeper
|
|
22
9
|
```
|
|
23
10
|
|
|
24
11
|
## Configuration
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
**None** — it only reads `settings.json` and the manual.
|
|
13
|
+
No config file (only reads `settings.json` and `APPEND_SYSTEM.md`); no environment variables.
|
|
29
14
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
| State file | Description |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `~/.pi/patch-keeper.json` | Settings fingerprint from the previous start (drift compare) |
|
|
18
|
+
| `~/.pi/patch-keeper-manual.json` | Manual version + content signature |
|
|
19
|
+
| `~/.pi/agent/settings.json.bak-force-order-*` | Backup before a force-order repair |
|
|
33
20
|
|
|
34
|
-
|
|
21
|
+
## Commands
|
|
35
22
|
|
|
36
23
|
| Command | Purpose |
|
|
37
24
|
| --- | --- |
|
|
38
25
|
| `/patch-keeper` | codemode / force / fingerprint / injection-alignment status |
|
|
39
26
|
| `/patch-keeper fix` | Repair force order in `packages` (with backup) |
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
| Item | Path | Description |
|
|
44
|
-
| --- | --- | --- |
|
|
45
|
-
| Fingerprint | `~/.pi/patch-keeper.json` | Settings snapshot for drift detection |
|
|
46
|
-
| Manual sentinel | `~/.pi/patch-keeper-manual.json` | Manual version / content signature |
|
|
47
|
-
| Fix backup | `~/.pi/agent/settings.json.bak-force-order-*` | Backup before repair |
|
|
48
|
-
|
|
49
|
-
### 5 · Not included (local module)
|
|
50
|
-
|
|
51
|
-
PiDeck builtin patch restore, 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**; a local module `patch-keeper-local` provides them (`/patch-keeper-local`).
|
|
52
|
-
|
|
53
|
-
## Where it acts (prompt and config paths)
|
|
54
|
-
|
|
55
|
-
| Stage | Does |
|
|
56
|
-
| --- | --- |
|
|
57
|
-
| factory (startup) | Fingerprint compare, force self-check and auto-repair; failures only notify |
|
|
58
|
-
| `session_start` | Summarises drift / order / manual drift in one notification |
|
|
59
|
-
| `before_agent_start` | Compares injected manual version with disk (**read-only**, never rewrites the prompt) |
|
|
60
|
-
|
|
61
|
-
It never touches thinking or tool calls: it acts on the **system prompt and configuration state**.
|
|
62
|
-
|
|
63
|
-
## Feedback path
|
|
64
|
-
|
|
65
|
-
| Item | Path | Why |
|
|
66
|
-
| --- | --- | --- |
|
|
67
|
-
| Injection-alignment hint | User notification + trailing message `nextTurn`, `display:false` | The user already knows; the model must too, otherwise "use the disk version" stops at the user side |
|
|
68
|
-
| Alignment text | "injected vX != disk vY -> injected is not evidence; action: read disk and continue" | Gives both criterion and action |
|
|
69
|
-
| Never returns systemPrompt | Only its own section / message | Returning it replaces the whole prompt (`forceSystemPrompt`) and silently drops every later section |
|
|
70
|
-
| Drift / force problems | Notification only (once per `session_start`) | Low-frequency information |
|
|
71
|
-
|
|
72
|
-
## How it works
|
|
28
|
+
## What it does (source facts)
|
|
73
29
|
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
30
|
+
- factory: builds the fingerprint from `settings.json`.
|
|
31
|
+
- `session_start`: compares the fingerprint, repairs force order, reports drift and manual drift (notification only).
|
|
32
|
+
- `before_agent_start`: compares the injected manual version with disk; on mismatch it notifies and sends a `nextTurn` message telling the model to trust disk; **never returns `systemPrompt`**.
|
|
33
|
+
- Writes are atomic (temp file + rename); a backup precedes any repair.
|
|
77
34
|
|
|
78
|
-
##
|
|
35
|
+
## Not in this package
|
|
79
36
|
|
|
80
|
-
-
|
|
81
|
-
- Force repair relies on a built-in known-force list.
|
|
82
|
-
- Drift reports what changed, not whether the new value is right.
|
|
37
|
+
PiDeck builtin patch restore, read-only asar checks, pi-lens / pi-memory / pi-tactician source patches, local snapshot restore — they depend on the PiDeck install dir and third-party internals, and live only in the local module `patch-keeper-local` (not published).
|
|
83
38
|
|
|
84
39
|
## License
|
|
85
40
|
|
package/README.md
CHANGED
|
@@ -1,86 +1,92 @@
|
|
|
1
|
-
# pi-patch-keeper
|
|
1
|
+
# pi-patch-keeper
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> 中文 · [English](#english)(页面内折叠)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
pi 的配置有三类静默失效:codemode 开关与插件不一致、force 型扩展排在中途导致其后 section 被丢弃、注入的手册与磁盘版本不同步。它们都不会报错,只会让行为悄悄偏离。本扩展在启动时检查并在能修时自动修。
|
|
8
|
-
|
|
9
|
-
## 功能
|
|
10
|
-
|
|
11
|
-
- **codemode 单点一致性**:禁 `builtin:codemode` 与安装 `pi-codemode-guard` 必须同时成立。
|
|
12
|
-
- **force 顺序守卫**:force 型扩展必须排在 `packages` 末尾,乱序自动修复(先备份)。
|
|
13
|
-
- **环境指纹漂移**:`settings.json` 的关键字段变化时提示「手册或验证结论可能过期」。
|
|
14
|
-
- **注入对齐**:比对注入的 `APPEND_SYSTEM.md` 版本与磁盘版本,不一致时按磁盘版执行。
|
|
15
|
-
- 命令 `/patch-keeper` / `/patch-keeper fix`。
|
|
5
|
+
pi 配置守卫:codemode 一致性、force 顺序、环境指纹漂移、注入手册对齐。**不含 PiDeck 与第三方源码补丁。**
|
|
16
6
|
|
|
17
7
|
## 安装
|
|
18
8
|
|
|
19
9
|
```bash
|
|
20
10
|
pi install npm:pi-patch-keeper
|
|
21
|
-
pi install ./pi-patch-keeper
|
|
22
11
|
```
|
|
23
12
|
|
|
24
13
|
## 配置
|
|
25
14
|
|
|
26
|
-
|
|
15
|
+
无配置文件(只读 `settings.json` 与 `APPEND_SYSTEM.md`);无环境变量。
|
|
27
16
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
| 状态文件 | 说明 |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `~/.pi/patch-keeper.json` | 上次启动的配置指纹(漂移对比) |
|
|
20
|
+
| `~/.pi/patch-keeper-manual.json` | 手册版本 + 内容签名 |
|
|
21
|
+
| `~/.pi/agent/settings.json.bak-force-order-*` | force 顺序修复前的备份 |
|
|
33
22
|
|
|
34
|
-
|
|
23
|
+
## 命令
|
|
35
24
|
|
|
36
25
|
| 命令 | 作用 |
|
|
37
26
|
| --- | --- |
|
|
38
27
|
| `/patch-keeper` | codemode / force / 指纹 / 注入对齐状态 |
|
|
39
28
|
| `/patch-keeper fix` | 修复 `packages` 的 force 顺序(带备份) |
|
|
40
29
|
|
|
41
|
-
|
|
30
|
+
## 作用(源码事实)
|
|
42
31
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
| 修复备份 | `~/.pi/agent/settings.json.bak-force-order-*` | 修复前备份 |
|
|
32
|
+
- factory:读 `settings.json` 建指纹。
|
|
33
|
+
- `session_start`:比对指纹 → 修复 force 顺序 → 报漂移与手册漂移(只通知)。
|
|
34
|
+
- `before_agent_start`:比对注入手册版本与磁盘版本;不一致时通知并以 `nextTurn` 尾部消息提示模型以磁盘为准;**不返回 `systemPrompt`**。
|
|
35
|
+
- 写盘用临时文件 + rename;修复前备份。
|
|
48
36
|
|
|
49
|
-
|
|
37
|
+
## 不在本包内
|
|
50
38
|
|
|
51
|
-
PiDeck builtin
|
|
39
|
+
PiDeck builtin 补丁恢复、asar 只读检测、pi-lens / pi-memory / pi-tactician 源码补丁、本机快照恢复 —— 依赖 PiDeck 安装目录与第三方包内部实现,只在本机模块 `patch-keeper-local` 中,不发布。
|
|
52
40
|
|
|
53
|
-
##
|
|
41
|
+
## License
|
|
54
42
|
|
|
55
|
-
|
|
56
|
-
| --- | --- |
|
|
57
|
-
| factory(启动) | 指纹对比、force 自检与自动修复;失败只提示 |
|
|
58
|
-
| `session_start` | 汇总漂移 / 顺序 / 手册漂移,一次通知 |
|
|
59
|
-
| `before_agent_start` | 比对注入手册版本与磁盘版本(**只读**,不改 prompt) |
|
|
43
|
+
MIT
|
|
60
44
|
|
|
61
|
-
|
|
45
|
+
---
|
|
62
46
|
|
|
63
|
-
|
|
47
|
+
<a id="english"></a>
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
| 注入对齐提示 | 通知用户 + 尾部消息 `nextTurn`、`display:false` | 用户已收到通知,模型也必须知道,否则「以磁盘版执行」只停在用户侧 |
|
|
68
|
-
| 注入对齐文本 | 「注入 vX ≠ 磁盘 vY → 注入版不可作判断依据;动作:读回全文后执行」 | 给出判据与动作,而不是只报事实 |
|
|
69
|
-
| 绝不返回 systemPrompt | 只写自己的 section / 消息 | 返回即 forceSystemPrompt **覆盖式替换**,会静默丢弃其后所有 section 的修改 |
|
|
70
|
-
| 指纹漂移 / force 问题 | 仅通知(`session_start` 一次) | 低频信息,不需要每轮打扰 |
|
|
49
|
+
<details>
|
|
50
|
+
<summary><b>English</b></summary>
|
|
71
51
|
|
|
72
|
-
|
|
52
|
+
pi configuration guards: codemode consistency, force order, settings fingerprint drift, injected-manual alignment. **No PiDeck or third-party source patching.**
|
|
73
53
|
|
|
74
|
-
|
|
75
|
-
- force 顺序修复只移动已知 force 型包到末尾,其余相对顺序不变。
|
|
76
|
-
- 手册漂移用「版本号 + 内容签名」双判据,避免只看版本号漏掉未登记的正文改动。
|
|
54
|
+
## Install
|
|
77
55
|
|
|
78
|
-
|
|
56
|
+
```bash
|
|
57
|
+
pi install npm:pi-patch-keeper
|
|
58
|
+
```
|
|
79
59
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
No config file (only reads `settings.json` and `APPEND_SYSTEM.md`); no environment variables.
|
|
63
|
+
|
|
64
|
+
| State file | Description |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `~/.pi/patch-keeper.json` | Settings fingerprint from the previous start (drift compare) |
|
|
67
|
+
| `~/.pi/patch-keeper-manual.json` | Manual version + content signature |
|
|
68
|
+
| `~/.pi/agent/settings.json.bak-force-order-*` | Backup before a force-order repair |
|
|
69
|
+
|
|
70
|
+
## Commands
|
|
71
|
+
|
|
72
|
+
| Command | Purpose |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `/patch-keeper` | codemode / force / fingerprint / injection-alignment status |
|
|
75
|
+
| `/patch-keeper fix` | Repair force order in `packages` (with backup) |
|
|
76
|
+
|
|
77
|
+
## What it does (source facts)
|
|
78
|
+
|
|
79
|
+
- factory: builds the fingerprint from `settings.json`.
|
|
80
|
+
- `session_start`: compares the fingerprint, repairs force order, reports drift and manual drift (notification only).
|
|
81
|
+
- `before_agent_start`: compares the injected manual version with disk; on mismatch it notifies and sends a `nextTurn` message telling the model to trust disk; **never returns `systemPrompt`**.
|
|
82
|
+
- Writes are atomic (temp file + rename); a backup precedes any repair.
|
|
83
|
+
|
|
84
|
+
## Not in this package
|
|
85
|
+
|
|
86
|
+
PiDeck builtin patch restore, read-only asar checks, pi-lens / pi-memory / pi-tactician source patches, local snapshot restore — they depend on the PiDeck install dir and third-party internals, and live only in the local module `patch-keeper-local` (not published).
|
|
83
87
|
|
|
84
88
|
## License
|
|
85
89
|
|
|
86
90
|
MIT
|
|
91
|
+
|
|
92
|
+
</details>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-patch-keeper",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
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",
|