pi-dynamic-context-pruning 0.1.14 → 0.1.16

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.md +12 -2
  2. package/index.ts +17 -16
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -109,7 +109,8 @@ Before any strategy is allowed to propose a prune, several protections apply:
109
109
 
110
110
  - **Protected tool names** (case-insensitive, never pruned): `todo`, `task`,
111
111
  `subagent`, `agent`, `skill`, `oracle`, `librarian`, `contrarian`,
112
- `code_reviewer`, `gnosis`, `triage_comments`.
112
+ `code_reviewer`, `gnosis`, `triage_comments`, `developer`, `diff_summarizer`,
113
+ `repo_scout`, `test_runner`, `web_scout`.
113
114
  - **Protected path globs** (never pruned if any string argument matches):
114
115
  `**/.env`, `**/.env.*`, `**/*.pem`, `**/*.key`, `**/id_rsa*`,
115
116
  `**/id_ed25519*`, `**/secrets/**`, `**/*.p12`, `**/*.pfx`.
@@ -118,6 +119,7 @@ Before any strategy is allowed to propose a prune, several protections apply:
118
119
  what they contain.
119
120
 
120
121
  All three lists/values are configurable (see [Configuration](#configuration)).
122
+ A user-set `protections.toolNames` replaces the default list.
121
123
 
122
124
  ## Savings accounting and the net-benefit gate
123
125
 
@@ -219,7 +221,7 @@ never required to exist. Full shape, with defaults:
219
221
  {
220
222
  "enabled": true,
221
223
  "protections": {
222
- "toolNames": ["todo", "task", "subagent", "agent", "skill", "oracle", "librarian", "contrarian", "code_reviewer", "gnosis", "triage_comments"],
224
+ "toolNames": ["todo", "task", "subagent", "agent", "skill", "oracle", "librarian", "contrarian", "code_reviewer", "gnosis", "triage_comments", "developer", "diff_summarizer", "repo_scout", "test_runner", "web_scout"],
223
225
  "pathGlobs": ["**/.env", "**/.env.*", "**/*.pem", "**/*.key", "**/id_rsa*", "**/id_ed25519*", "**/secrets/**", "**/*.p12", "**/*.pfx"],
224
226
  "recentTurns": 4
225
227
  },
@@ -275,6 +277,14 @@ Notes:
275
277
  warm request prefix between consecutive LLM calls separated only by a
276
278
  toolResult) illustrates cache invalidation, not proof that amortization is
277
279
  impossible. Set `mid_loop` back to `22` to restore the old parity behavior.
280
+ - `gate.breakEvenThreshold` is a deprecated legacy field retained for
281
+ compatibility. Loaded config always resolves through
282
+ `gate.breakEvenThresholdByState`, so a global-only value (including `0`) has
283
+ no runtime effect, and missing or invalid state values use their existing
284
+ normalized defaults rather than inheriting the global value. Direct callers
285
+ of the exported `resolveBreakEvenThreshold` may still use this field as the
286
+ fallback when they pass an unnormalized gate object. Set explicit per-state
287
+ values instead.
278
288
  - `gate.breakEvenThreshold`'s default of `22` is calibrated from the
279
289
  representative-corpus benchmark at `cachedPriceRatio` r=0.1 (aggressive
280
290
  prompt caching, the common case). It is **provider/ratio-
package/index.ts CHANGED
@@ -177,6 +177,11 @@ const DEFAULT_PROTECTED_TOOL_NAMES = [
177
177
  "code_reviewer",
178
178
  "gnosis",
179
179
  "triage_comments",
180
+ "developer",
181
+ "diff_summarizer",
182
+ "repo_scout",
183
+ "test_runner",
184
+ "web_scout",
180
185
  ];
181
186
 
182
187
  /** File globs never pruned by default: secrets/credential-shaped paths. */
@@ -243,13 +248,15 @@ export interface PruneGateConfig {
243
248
  /** Fraction of full price still paid for cached ( r ). Default 0.1. */
244
249
  cachedPriceRatio: number;
245
250
  /**
246
- * Default break-even threshold (max future calls to amortize a cache
247
- * bust) used when no state-specific override applies. Recalibrated from
248
- * the representative-corpus benchmark; see DEFAULT_BREAK_EVEN_THRESHOLD
249
- * for the full rationale and ratio-sensitivity caveats.
251
+ * @deprecated Legacy global fallback retained for direct callers that pass
252
+ * an unnormalized gate object to resolveBreakEvenThreshold. normalizeConfig
253
+ * always supplies per-state values, so loaded config does not use this field
254
+ * to fill missing or invalid state values. Recalibrated from the
255
+ * representative-corpus benchmark; see DEFAULT_BREAK_EVEN_THRESHOLD for the
256
+ * full rationale and ratio-sensitivity caveats.
250
257
  */
251
258
  breakEvenThreshold: number;
252
- /** Per-state overrides. Defaults: idle 22, mid_loop 1. */
259
+ /** Per-state overrides. normalizeConfig defaults to idle 22 and mid_loop 1. */
253
260
  breakEvenThresholdByState: { idle: number; mid_loop: number };
254
261
  }
255
262
 
@@ -1631,11 +1638,6 @@ export function computeFileReadRange(args: Record<string, unknown> | undefined):
1631
1638
  return { start, end };
1632
1639
  }
1633
1640
 
1634
- /** True when a range represents a full-file read (starts at line 1, no limit). */
1635
- export function isFullFileReadRange(range: FileReadRange): boolean {
1636
- return range.start === 1 && range.end === undefined;
1637
- }
1638
-
1639
1641
  /**
1640
1642
  * Conservative range-coverage check: does `later` fully cover `earlier`?
1641
1643
  * Implements rules 1+2 above via one unified representation (a full-file
@@ -2268,11 +2270,9 @@ const STRATEGY_ALIASES: Record<string, StrategyKey> = {
2268
2270
  "error-purge": "errorPurge",
2269
2271
  errorpurge: "errorPurge",
2270
2272
  error_purge: "errorPurge",
2271
- errorPurge: "errorPurge",
2272
2273
  "superseded-file-ops": "supersededFileOps",
2273
2274
  supersededfileops: "supersededFileOps",
2274
2275
  superseded_file_ops: "supersededFileOps",
2275
- supersededFileOps: "supersededFileOps",
2276
2276
  };
2277
2277
 
2278
2278
  const STRATEGY_DISPLAY_NAMES: Record<StrategyKey, string> = {
@@ -2315,9 +2315,11 @@ export function parseContextPruningArgs(rawArgs: string): ContextPruningSubcomma
2315
2315
  return { kind: "toggle" };
2316
2316
  case "strategy": {
2317
2317
  const [nameRaw, valueRaw] = rest;
2318
- const key = nameRaw
2319
- ? (STRATEGY_ALIASES[nameRaw.toLowerCase()] ?? STRATEGY_ALIASES[nameRaw])
2320
- : undefined;
2318
+ const normalizedName = nameRaw?.toLowerCase();
2319
+ const key =
2320
+ normalizedName && Object.hasOwn(STRATEGY_ALIASES, normalizedName)
2321
+ ? STRATEGY_ALIASES[normalizedName]
2322
+ : undefined;
2321
2323
  const value = valueRaw?.toLowerCase();
2322
2324
  if (!key || (value !== "on" && value !== "off")) return { kind: "unknown", raw: rawArgs };
2323
2325
  return { kind: "strategy", strategy: key, value: value === "on" };
@@ -2463,7 +2465,6 @@ function notify(
2463
2465
  }
2464
2466
 
2465
2467
  export const __testing = {
2466
- globToRegExp,
2467
2468
  getConfigPath,
2468
2469
  readConfig,
2469
2470
  writeConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dynamic-context-pruning",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "description": "A pi extension that dynamically prunes stale context to keep sessions lean.",
6
6
  "keywords": [