pi-patch-keeper 1.0.9 → 1.0.10

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 +13 -0
  2. package/index.ts +4 -5
  3. package/package.json +1 -1
package/README.en.md CHANGED
@@ -23,6 +23,13 @@ Prevents "force-typed" extensions from silently swallowing every section written
23
23
  | `/patch-keeper` | Show order, suspected force packages, fallback packages, codemode status |
24
24
  | `/patch-keeper fix` | Move known force-typed packages to the end (backup written first) |
25
25
 
26
+ ## Install
27
+
28
+ ```bash
29
+ pi install npm:pi-patch-keeper
30
+ pi install ./pi-patch-keeper
31
+ ```
32
+
26
33
  ## Defaults
27
34
 
28
35
  | Key | Default |
@@ -34,6 +41,12 @@ Prevents "force-typed" extensions from silently swallowing every section written
34
41
 
35
42
  Optional config: `~/.pi/patch-keeper.json`
36
43
 
44
+ ## Discipline
45
+
46
+ - Never `return { systemPrompt }` — otherwise it becomes the problem it guards against.
47
+ - Writes only two places: `packages` order in `settings.json` (backup first) and the fingerprint in `~/.pi/patch-keeper.json`; failures are reported, never thrown.
48
+ - Any error is reported as a hint, never thrown; silent when clean.
49
+
37
50
  ## Limits
38
51
 
39
52
  - Detects static forms only; dynamic `systemPrompt` construction is not detected.
package/index.ts CHANGED
@@ -93,7 +93,7 @@ export function normalizeForceOrder(packages: string[], tail: string[] = DEFAULT
93
93
  }
94
94
 
95
95
  /** 读扩展入口源码并分类:无条件 force / section 优先(旧宿主兜底)/ 无。 */
96
- function classifyPackages(packages: string[], tail: string[]): { force: string[]; fallback: string[] } {
96
+ export function classifyForcePackages(packages: string[], tail: string[]): { force: string[]; fallback: string[] } {
97
97
  const force: string[] = [];
98
98
  const fallback: string[] = [];
99
99
  for (const name of packages) {
@@ -127,12 +127,12 @@ function classifyPackages(packages: string[], tail: string[]): { force: string[]
127
127
 
128
128
  /** 疑似无条件 force(会吞掉其后 section)。 */
129
129
  export function scanForcePackages(packages: string[], tail: string[] = DEFAULT_FORCE_TAIL): string[] {
130
- return classifyPackages(packages, tail).force;
130
+ return classifyForcePackages(packages, tail).force;
131
131
  }
132
132
 
133
133
  /** 兼容兜底型(section 优先,仅旧宿主 force)。 */
134
134
  export function scanForceFallbacks(packages: string[], tail: string[] = DEFAULT_FORCE_TAIL): string[] {
135
- return classifyPackages(packages, tail).fallback;
135
+ return classifyForcePackages(packages, tail).fallback;
136
136
  }
137
137
 
138
138
  /** codemode 单点检查:禁用 builtin:codemode 时必须有替代实现,反之亦然。 */
@@ -210,9 +210,8 @@ function report(): string[] {
210
210
  const lines: string[] = [];
211
211
  const fo = forceOrderIssues(packages, tail);
212
212
  lines.push(`force顺序 : ${fo.length ? fo[0] : "OK"}`);
213
- const fe = scanForcePackages(packages, tail);
213
+ const { force: fe, fallback: fb } = classifyForcePackages(packages, tail);
214
214
  lines.push(`疑似force: ${fe.length ? fe.join(" / ") : "无(静态扫描)"}`);
215
- const fb = scanForceFallbacks(packages, tail);
216
215
  lines.push(`兼容兜底 : ${fb.length ? fb.join(" / ") : "无"}`);
217
216
  const cm = consistencyCheck((s.extensions as string[]) ?? [], packages);
218
217
  lines.push(`codemode : ${cm.length ? cm[0] : "单点一致"}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-patch-keeper",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Detect and fix pi extension load-order hazards: force-typed extensions silently swallow later system-prompt sections.",
5
5
  "type": "module",
6
6
  "license": "MIT",