pi-patch-keeper 1.3.2 → 1.3.4
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 +4 -36
- package/README.md +16 -2
- package/index.ts +1 -7
- package/package.json +12 -4
package/README.en.md
CHANGED
|
@@ -1,41 +1,9 @@
|
|
|
1
1
|
# pi-patch-keeper
|
|
2
2
|
|
|
3
|
-
pi configuration guards: codemode consistency, force order, settings fingerprint drift,
|
|
3
|
+
pi configuration guards: codemode consistency, force order, settings fingerprint drift, manual alignment.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**English documentation:** [open the English section](README.md#english) · **中文文档:** [中文](README.md#zh)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
pi install npm:pi-patch-keeper
|
|
9
|
-
```
|
|
7
|
+
pi install npm:pi-patch-keeper
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
No config file (only reads `settings.json` and `APPEND_SYSTEM.md`); no environment variables.
|
|
14
|
-
|
|
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 |
|
|
20
|
-
|
|
21
|
-
## Commands
|
|
22
|
-
|
|
23
|
-
| Command | Purpose |
|
|
24
|
-
| --- | --- |
|
|
25
|
-
| `/patch-keeper` | codemode / force / fingerprint / injection-alignment status |
|
|
26
|
-
| `/patch-keeper fix` | Repair force order in `packages` (with backup) |
|
|
27
|
-
|
|
28
|
-
## What it does (source facts)
|
|
29
|
-
|
|
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.
|
|
34
|
-
|
|
35
|
-
## Not in this package
|
|
36
|
-
|
|
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).
|
|
38
|
-
|
|
39
|
-
## License
|
|
40
|
-
|
|
41
|
-
MIT
|
|
9
|
+
Source: https://github.com/op15066212/pi-plugins-publish
|
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
# pi-patch-keeper
|
|
9
9
|
|
|
10
|
+
> 适用 pi ≥ 0.74 · Node ≥ 20 · MIT · 无运行时依赖(仅 peer: @earendil-works/pi-coding-agent)
|
|
11
|
+
|
|
10
12
|
pi 配置守卫:codemode 一致性、force 顺序、环境指纹漂移、注入手册对齐。**不含 PiDeck 与第三方源码补丁。**
|
|
11
13
|
|
|
12
14
|
## 快速事实
|
|
@@ -56,7 +58,13 @@ pi install npm:pi-patch-keeper
|
|
|
56
58
|
|
|
57
59
|
- factory:读 `settings.json` 建指纹。
|
|
58
60
|
- `session_start`:比对指纹 → 修复 force 顺序 → 报漂移与手册漂移(只通知)。
|
|
59
|
-
- `before_agent_start`:比对注入手册版本与磁盘版本;不一致时通知并以 `nextTurn`
|
|
61
|
+
- `before_agent_start`:比对注入手册版本与磁盘版本;不一致时通知并以 `nextTurn` 尾部消息回灌提示模型以磁盘为准(`display: false`);**不返回 `systemPrompt`**。
|
|
62
|
+
**注入样例(示意,字段可能随版本增删)**
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
注入对齐:注入 v22.172 ≠ 磁盘 v22.173(观察者 = 磁盘版)→ 注入版不可作判断依据;动作:读回全文后执行,重启后自愈。
|
|
66
|
+
```
|
|
67
|
+
|
|
60
68
|
- 写盘用临时文件 + rename;修复前备份。
|
|
61
69
|
|
|
62
70
|
## 原理(专业)
|
|
@@ -145,7 +153,13 @@ Full config:
|
|
|
145
153
|
|
|
146
154
|
- factory: builds the fingerprint from `settings.json`.
|
|
147
155
|
- `session_start`: compares the fingerprint, repairs force order, reports drift and manual drift (notification only).
|
|
148
|
-
- `before_agent_start`: compares the injected manual version with disk; on mismatch it notifies and
|
|
156
|
+
- `before_agent_start`: compares the injected manual version with disk; on mismatch it notifies and feeds back a `nextTurn` message (`display: false`) telling the model to trust disk; **never returns `systemPrompt`**.
|
|
157
|
+
**Sample injection (illustrative; fields may change between versions)**
|
|
158
|
+
|
|
159
|
+
```text
|
|
160
|
+
Injection mismatch: injected v22.172 != disk v22.173 (disk wins) -> the injected copy is not evidence; action: read the full file and continue; self-heals after restart.
|
|
161
|
+
```
|
|
162
|
+
|
|
149
163
|
- Writes are atomic (temp file + rename); a backup precedes any repair.
|
|
150
164
|
|
|
151
165
|
## How it works (technical)
|
package/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
|
|
|
9
9
|
|
|
10
10
|
import { existsSync, readFileSync, writeFileSync, copyFileSync, renameSync } from "node:fs";
|
|
11
11
|
|
|
12
|
+
import { createHash } from "node:crypto";
|
|
12
13
|
import * as os from "node:os";
|
|
13
14
|
|
|
14
15
|
import * as path from "node:path";
|
|
@@ -39,7 +40,6 @@ function manualVer(text: string): string | null {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
type Result = { ok: boolean; detail: string };
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
/** 读文件;失败返回 null(永不抛)。 */
|
|
@@ -54,12 +54,6 @@ function writeAtomic(file: string, data: string | Buffer): void {
|
|
|
54
54
|
renameSync(tmp, file);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
/** 统计 needle 在原串里的出现次数。 */
|
|
58
|
-
function count(hay: string, needle: string): number {
|
|
59
|
-
let n = 0, i = 0;
|
|
60
|
-
while ((i = hay.indexOf(needle, i)) >= 0) { n += 1; i += needle.length; }
|
|
61
|
-
return n;
|
|
62
|
-
}
|
|
63
57
|
|
|
64
58
|
|
|
65
59
|
// ── 环境指纹:settings 关键字段漂移 → 提示「手册 / 验证结论可能过期」
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-patch-keeper",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
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",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"pi-coding-agent",
|
|
12
12
|
"pi-extension",
|
|
13
13
|
"pi-package",
|
|
14
|
-
"pideck"
|
|
14
|
+
"pideck",
|
|
15
|
+
"config-guard",
|
|
16
|
+
"load-order"
|
|
15
17
|
],
|
|
16
18
|
"pi": {
|
|
17
19
|
"extensions": [
|
|
@@ -27,8 +29,11 @@
|
|
|
27
29
|
"peerDependencies": {
|
|
28
30
|
"@earendil-works/pi-coding-agent": "*"
|
|
29
31
|
},
|
|
30
|
-
"author":
|
|
31
|
-
|
|
32
|
+
"author": {
|
|
33
|
+
"name": "15066212pp",
|
|
34
|
+
"url": "https://github.com/op15066212"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/op15066212/pi-plugins-publish/tree/main/pi-patch-keeper#readme",
|
|
32
37
|
"bugs": {
|
|
33
38
|
"url": "https://github.com/op15066212/pi-plugins-publish/issues"
|
|
34
39
|
},
|
|
@@ -39,5 +44,8 @@
|
|
|
39
44
|
},
|
|
40
45
|
"scripts": {
|
|
41
46
|
"prepublishOnly": "node ../publish-check.mjs"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20"
|
|
42
50
|
}
|
|
43
51
|
}
|