pi-dynamic-context-pruning 0.1.14 → 0.1.15
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.md +8 -0
- package/index.ts +12 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -275,6 +275,14 @@ Notes:
|
|
|
275
275
|
warm request prefix between consecutive LLM calls separated only by a
|
|
276
276
|
toolResult) illustrates cache invalidation, not proof that amortization is
|
|
277
277
|
impossible. Set `mid_loop` back to `22` to restore the old parity behavior.
|
|
278
|
+
- `gate.breakEvenThreshold` is a deprecated legacy field retained for
|
|
279
|
+
compatibility. Loaded config always resolves through
|
|
280
|
+
`gate.breakEvenThresholdByState`, so a global-only value (including `0`) has
|
|
281
|
+
no runtime effect, and missing or invalid state values use their existing
|
|
282
|
+
normalized defaults rather than inheriting the global value. Direct callers
|
|
283
|
+
of the exported `resolveBreakEvenThreshold` may still use this field as the
|
|
284
|
+
fallback when they pass an unnormalized gate object. Set explicit per-state
|
|
285
|
+
values instead.
|
|
278
286
|
- `gate.breakEvenThreshold`'s default of `22` is calibrated from the
|
|
279
287
|
representative-corpus benchmark at `cachedPriceRatio` r=0.1 (aggressive
|
|
280
288
|
prompt caching, the common case). It is **provider/ratio-
|
package/index.ts
CHANGED
|
@@ -243,13 +243,15 @@ export interface PruneGateConfig {
|
|
|
243
243
|
/** Fraction of full price still paid for cached ( r ). Default 0.1. */
|
|
244
244
|
cachedPriceRatio: number;
|
|
245
245
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
246
|
+
* @deprecated Legacy global fallback retained for direct callers that pass
|
|
247
|
+
* an unnormalized gate object to resolveBreakEvenThreshold. normalizeConfig
|
|
248
|
+
* always supplies per-state values, so loaded config does not use this field
|
|
249
|
+
* to fill missing or invalid state values. Recalibrated from the
|
|
250
|
+
* representative-corpus benchmark; see DEFAULT_BREAK_EVEN_THRESHOLD for the
|
|
251
|
+
* full rationale and ratio-sensitivity caveats.
|
|
250
252
|
*/
|
|
251
253
|
breakEvenThreshold: number;
|
|
252
|
-
/** Per-state overrides.
|
|
254
|
+
/** Per-state overrides. normalizeConfig defaults to idle 22 and mid_loop 1. */
|
|
253
255
|
breakEvenThresholdByState: { idle: number; mid_loop: number };
|
|
254
256
|
}
|
|
255
257
|
|
|
@@ -1631,11 +1633,6 @@ export function computeFileReadRange(args: Record<string, unknown> | undefined):
|
|
|
1631
1633
|
return { start, end };
|
|
1632
1634
|
}
|
|
1633
1635
|
|
|
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
1636
|
/**
|
|
1640
1637
|
* Conservative range-coverage check: does `later` fully cover `earlier`?
|
|
1641
1638
|
* Implements rules 1+2 above via one unified representation (a full-file
|
|
@@ -2268,11 +2265,9 @@ const STRATEGY_ALIASES: Record<string, StrategyKey> = {
|
|
|
2268
2265
|
"error-purge": "errorPurge",
|
|
2269
2266
|
errorpurge: "errorPurge",
|
|
2270
2267
|
error_purge: "errorPurge",
|
|
2271
|
-
errorPurge: "errorPurge",
|
|
2272
2268
|
"superseded-file-ops": "supersededFileOps",
|
|
2273
2269
|
supersededfileops: "supersededFileOps",
|
|
2274
2270
|
superseded_file_ops: "supersededFileOps",
|
|
2275
|
-
supersededFileOps: "supersededFileOps",
|
|
2276
2271
|
};
|
|
2277
2272
|
|
|
2278
2273
|
const STRATEGY_DISPLAY_NAMES: Record<StrategyKey, string> = {
|
|
@@ -2315,9 +2310,11 @@ export function parseContextPruningArgs(rawArgs: string): ContextPruningSubcomma
|
|
|
2315
2310
|
return { kind: "toggle" };
|
|
2316
2311
|
case "strategy": {
|
|
2317
2312
|
const [nameRaw, valueRaw] = rest;
|
|
2318
|
-
const
|
|
2319
|
-
|
|
2320
|
-
|
|
2313
|
+
const normalizedName = nameRaw?.toLowerCase();
|
|
2314
|
+
const key =
|
|
2315
|
+
normalizedName && Object.hasOwn(STRATEGY_ALIASES, normalizedName)
|
|
2316
|
+
? STRATEGY_ALIASES[normalizedName]
|
|
2317
|
+
: undefined;
|
|
2321
2318
|
const value = valueRaw?.toLowerCase();
|
|
2322
2319
|
if (!key || (value !== "on" && value !== "off")) return { kind: "unknown", raw: rawArgs };
|
|
2323
2320
|
return { kind: "strategy", strategy: key, value: value === "on" };
|
|
@@ -2463,7 +2460,6 @@ function notify(
|
|
|
2463
2460
|
}
|
|
2464
2461
|
|
|
2465
2462
|
export const __testing = {
|
|
2466
|
-
globToRegExp,
|
|
2467
2463
|
getConfigPath,
|
|
2468
2464
|
readConfig,
|
|
2469
2465
|
writeConfig,
|