shariq-pi-extensions 0.2.19 → 0.2.20
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.
|
@@ -54,7 +54,7 @@ Settings are persisted in `~/.pi/agent/smart-compaction.json`:
|
|
|
54
54
|
"version": 1,
|
|
55
55
|
"enabled": true,
|
|
56
56
|
"model": "inherit",
|
|
57
|
-
"thinkingLevel": "inherit"
|
|
58
|
-
"maxSummaryTokens": 8192
|
|
57
|
+
"thinkingLevel": "inherit"
|
|
59
58
|
}
|
|
60
59
|
```
|
|
60
|
+
*Note: `maxSummaryTokens` defaults to `undefined`, dynamically allowing the summarizer model to use its full native output token capacity (e.g. up to 65,536 tokens for Gemini, 32,768 for Codex Luna, 64,000 for Claude 3.7).*
|
|
@@ -7,7 +7,7 @@ export interface SmartCompactionConfig {
|
|
|
7
7
|
enabled: boolean;
|
|
8
8
|
model: string; // "inherit" or "provider/model-id"
|
|
9
9
|
thinkingLevel?: "inherit" | "off" | "low" | "medium" | "high" | "max";
|
|
10
|
-
maxSummaryTokens?: number; //
|
|
10
|
+
maxSummaryTokens?: number; // optional override; defaults to dynamic model maxTokens
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const DEFAULT_SMART_COMPACTION_CONFIG: SmartCompactionConfig = {
|
|
@@ -15,7 +15,6 @@ export const DEFAULT_SMART_COMPACTION_CONFIG: SmartCompactionConfig = {
|
|
|
15
15
|
enabled: true,
|
|
16
16
|
model: "inherit",
|
|
17
17
|
thinkingLevel: "inherit",
|
|
18
|
-
maxSummaryTokens: 8192,
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
export function smartCompactionConfigPath(): string {
|
|
@@ -35,7 +34,7 @@ export function loadSmartCompactionConfig(file = smartCompactionConfigPath()): S
|
|
|
35
34
|
: DEFAULT_SMART_COMPACTION_CONFIG.thinkingLevel,
|
|
36
35
|
maxSummaryTokens: typeof raw.maxSummaryTokens === "number" && raw.maxSummaryTokens > 0
|
|
37
36
|
? raw.maxSummaryTokens
|
|
38
|
-
:
|
|
37
|
+
: undefined,
|
|
39
38
|
};
|
|
40
39
|
} catch {
|
|
41
40
|
return { ...DEFAULT_SMART_COMPACTION_CONFIG };
|
|
@@ -51,7 +50,9 @@ export function saveSmartCompactionConfig(config: SmartCompactionConfig, file =
|
|
|
51
50
|
enabled: config.enabled,
|
|
52
51
|
model: config.model || "inherit",
|
|
53
52
|
thinkingLevel: config.thinkingLevel ?? "inherit",
|
|
54
|
-
maxSummaryTokens
|
|
53
|
+
...(typeof config.maxSummaryTokens === "number" && config.maxSummaryTokens > 0
|
|
54
|
+
? { maxSummaryTokens: config.maxSummaryTokens }
|
|
55
|
+
: {}),
|
|
55
56
|
};
|
|
56
57
|
try {
|
|
57
58
|
fs.writeFileSync(temporary, `${JSON.stringify(document, null, 2)}\n`, { mode: 0o600 });
|
|
@@ -326,14 +326,16 @@ export function computeCompactionTokenCeiling(
|
|
|
326
326
|
if (reserveTokens <= 0) {
|
|
327
327
|
throw new Error("Reserve tokens budget must be positive.");
|
|
328
328
|
}
|
|
329
|
-
const
|
|
330
|
-
? config.maxSummaryTokens
|
|
331
|
-
: 8192;
|
|
329
|
+
const modelMax = model.maxTokens > 0 ? model.maxTokens : 32768;
|
|
332
330
|
|
|
333
|
-
|
|
334
|
-
|
|
331
|
+
// If the user explicitly configured a maxSummaryTokens override, respect it within model's capacity
|
|
332
|
+
if (typeof config.maxSummaryTokens === "number" && config.maxSummaryTokens > 0) {
|
|
333
|
+
return Math.min(config.maxSummaryTokens, modelMax);
|
|
334
|
+
}
|
|
335
335
|
|
|
336
|
-
|
|
336
|
+
// Dynamic model-native output capacity:
|
|
337
|
+
// Take full output capacity directly from the model (e.g., 32k, 64k, 128k+)
|
|
338
|
+
return modelMax;
|
|
337
339
|
}
|
|
338
340
|
|
|
339
341
|
export function isFatalCompactionError(err: unknown): boolean {
|
|
@@ -173,7 +173,9 @@ export function createSmartCompactionExtension(options: SmartCompactionExtension
|
|
|
173
173
|
const currentThinkingDesc = config.thinkingLevel === "inherit"
|
|
174
174
|
? `inherit (${cmdCtx.thinkingLevel ?? "session default"})`
|
|
175
175
|
: (config.thinkingLevel ?? "inherit");
|
|
176
|
-
const maxTokensDesc =
|
|
176
|
+
const maxTokensDesc = typeof config.maxSummaryTokens === "number"
|
|
177
|
+
? `${config.maxSummaryTokens} tokens (custom override)`
|
|
178
|
+
: "dynamic (full model capacity)";
|
|
177
179
|
|
|
178
180
|
const status = [
|
|
179
181
|
`Smart Compaction: ${config.enabled ? "ENABLED" : "DISABLED"}`,
|