pi-smart-compact 7.12.1 → 7.12.5
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/CHANGELOG.md +37 -0
- package/README.md +5 -1
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +233 -65
- package/dist/phases/explore.d.ts.map +1 -1
- package/dist/phases/synthesize.d.ts.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/overlays.d.ts.map +1 -1
- package/dist/utils/cache.d.ts +17 -3
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/fingerprint.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +4 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/pruning.d.ts +2 -0
- package/dist/utils/pruning.d.ts.map +1 -1
- package/dist/utils/tokens.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [7.12.5] - 2026-05-23
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Extraction cache safety** — Incremental extraction now reuses cache only when both the original entry prefix and the pruned-message prefix still match, preventing corrupted merges when pruning changes or when legacy cache entries lack pruning metadata.
|
|
7
|
+
- **Chunk synthesis robustness** — Batch summarization now emits stable `CHUNK N` ids, includes tool-call context in segment text, parses returned sections by chunk id instead of raw position, and falls back to section/chunk previews when the model omits a clean summary line.
|
|
8
|
+
- **Verification result accuracy** — Metrics and result details now use the post-patch verification result after deterministic/LLM repair instead of the pre-patch score.
|
|
9
|
+
- **Auto-trigger overlap guard** — Hard-timeout cleanup no longer resets `isRunning` early while a timed-out compaction is still unwinding, avoiding overlapping background compactions.
|
|
10
|
+
- **Nested parallel tool boundaries** — Keep-boundary protection now understands nested `multi_tool_use.parallel` tool call ids so compaction does not split wrapper calls from kept tool results.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- **Extraction-cache observability** — Metrics, dashboard/report rows, notifications, and result overlays now distinguish provider prompt-cache hit rate from deterministic extraction-cache hit rate and record extraction-cache miss reasons.
|
|
14
|
+
- **Pending summary visibility** — Expired pending smart summaries now raise a user-visible warning when discarded.
|
|
15
|
+
|
|
16
|
+
## [7.12.4] - 2026-05-20
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- **Manual command override** — Explicit user-run `/smart-compact` commands now bypass the adaptive `minContextPercent` tier gate, while auto-trigger and agent tool calls still respect it. This keeps cache-protective behavior for agents but preserves user control.
|
|
20
|
+
|
|
21
|
+
## [7.12.3] - 2026-05-20
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- **Safer pi-toolkit threshold** — Raised the default `minContextPercent` from 30 to 60 so high `tool=XX%` ratios from pi-auto-context do not trigger smart compaction while actual context usage is still moderate.
|
|
25
|
+
- **Agent guidance** — Updated the `smart_compact` tool description and guidelines to explicitly ignore pi-auto-context `tool=XX%` as a compaction signal and use actual `context=XX%` instead.
|
|
26
|
+
- **Package image metadata** — Switched the package gallery image URL to the stable `main` asset path to avoid version-tag drift.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- **Provider capability mapping** — Added explicit pi-toolkit provider entries for `kimi-coding`, `xiaomi-mimo`, and `crofai` so timeout/concurrency/cache metadata does not fall through to generic defaults.
|
|
30
|
+
- **Open-loop indexing** — Replaced `msgs.indexOf(msg)` with indexed loops in open-loop extraction to avoid O(n²) scans and incorrect source indexes for repeated message references.
|
|
31
|
+
- **Batch summary fallback** — Hardened `summarizeBatch()` so a missing or merged LLM section falls back to the original chunk preview instead of producing an empty segment summary.
|
|
32
|
+
- **Pending summary observability** — Log when an expired pending smart summary is discarded.
|
|
33
|
+
|
|
34
|
+
## [7.12.2] - 2026-05-20
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
- **Context threshold guard completion** — Completed the `minContextPercent` guard across config, types, tier selection, core pipeline, tool handler, and tests.
|
|
38
|
+
- **Precise threshold comparison** — `smart_compact` now compares raw context percentage for the guard and uses rounded percentage only for user-facing text.
|
|
39
|
+
|
|
3
40
|
## [7.12.1] - 2026-05-19
|
|
4
41
|
|
|
5
42
|
### Fixed
|
package/README.md
CHANGED
|
@@ -179,7 +179,9 @@ The tool prepares a pending smart summary and lets Pi consume it on the next nat
|
|
|
179
179
|
|
|
180
180
|
## Usage notes
|
|
181
181
|
|
|
182
|
-
- compaction is skipped when the context is still small enough
|
|
182
|
+
- auto/tool compaction is skipped when the context is still small enough (default: below 60% actual context usage)
|
|
183
|
+
- explicit manual `/smart-compact` commands bypass the 60% adaptive gate because the user intentionally requested compaction
|
|
184
|
+
- pi-toolkit `tool=XX%` status means tool-output ratio, **not** context fullness; smart-compact uses actual `context=XX%`
|
|
183
185
|
- the tool path does **not** compact the conversation mid-turn
|
|
184
186
|
- pending summaries are kept in memory for **5 minutes**
|
|
185
187
|
- exploration is adaptive and may be skipped for simple sessions
|
|
@@ -202,6 +204,7 @@ Add this to `~/.pi/agent/settings.json`:
|
|
|
202
204
|
"segmentationModel": "anthropic/claude-haiku-3",
|
|
203
205
|
"autoTrigger": true,
|
|
204
206
|
"autoTriggerTimeoutMs": 120000,
|
|
207
|
+
"minContextPercent": 60,
|
|
205
208
|
"backupEnabled": true,
|
|
206
209
|
"profiles": {
|
|
207
210
|
"balanced": {
|
|
@@ -222,6 +225,7 @@ Add this to `~/.pi/agent/settings.json`:
|
|
|
222
225
|
| `segmentationModel` | `string \| null` | `null` |
|
|
223
226
|
| `autoTrigger` | `boolean` | `true` |
|
|
224
227
|
| `autoTriggerTimeoutMs` | `number` | `120000` |
|
|
228
|
+
| `minContextPercent` | `number` | `60` |
|
|
225
229
|
| `backupEnabled` | `boolean` | `true` |
|
|
226
230
|
| `backupDir` | `string` | `~/.pi/agent/compact-backups` |
|
|
227
231
|
| `profiles` | partial per-profile overrides | built-ins |
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Constants, prompts, and profile defaults.
|
|
3
3
|
*/
|
|
4
4
|
import type { CompressionProfile, ProfileConfig } from "./types.ts";
|
|
5
|
-
export declare const VERSION = "7.12.
|
|
5
|
+
export declare const VERSION = "7.12.5";
|
|
6
6
|
export declare const CHARS_PER_TOKEN = 3.8;
|
|
7
7
|
export declare const COMPACT_SYSTEM_PREFIX: string;
|
|
8
8
|
export declare const PROFILES: Record<CompressionProfile, ProfileConfig>;
|
|
@@ -15,6 +15,7 @@ export declare const DEFAULT_CONFIG: {
|
|
|
15
15
|
autoTriggerTimeoutMs: number;
|
|
16
16
|
backupEnabled: boolean;
|
|
17
17
|
backupDir: string;
|
|
18
|
+
minContextPercent: number;
|
|
18
19
|
};
|
|
19
20
|
export declare const NO_OP_RE: RegExp;
|
|
20
21
|
export declare const SHIFT_RE: RegExp;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEpE,eAAO,MAAM,OAAO,WAAW,CAAC;AAChC,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,qBAAqB,QAKqB,CAAC;AAExD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAyB9D,CAAC;AAEF,eAAO,MAAM,cAAc;aACF,kBAAkB;;kBAEnB,MAAM,GAAG,IAAI;uBACR,MAAM,GAAG,IAAI
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAA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,CAAC;AAGlE,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAG5C,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAGxC,eAAO,MAAM,UAAU,iBAAiB,CAAC;AACzC,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,sBAAsB,QAU6T,CAAC"}
|
package/dist/core.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export interface SmartCompactOptions {
|
|
|
22
22
|
autoTriggered?: boolean;
|
|
23
23
|
userNote?: string;
|
|
24
24
|
skipCompact?: boolean;
|
|
25
|
+
/** Explicit user command may bypass adaptive context-pressure tier gate. */
|
|
26
|
+
force?: boolean;
|
|
25
27
|
/** Optional hard budget for native auto-trigger only. Manual/tool runs do not time out by default. */
|
|
26
28
|
timeoutMs?: number;
|
|
27
29
|
}
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,kBAAkB,EAAE,iBAAiB,EAEtC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,kBAAkB,EAAE,iBAAiB,EAEtC,MAAM,YAAY,CAAC;AAwBpB,yEAAyE;AACzE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,uBAAuB,CAAC;IAC7B,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE;QAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,SAAS,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sGAAsG;IACtG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiiB9E"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,iCAAiC,CAAC;AA0C7F,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAAE,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,iCAAiC,CAAC;AA0C7F,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAAE,EAAE,YAAY,QA6L7D"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/constants.ts
|
|
3
|
-
var VERSION = "7.12.
|
|
3
|
+
var VERSION = "7.12.5";
|
|
4
4
|
var CHARS_PER_TOKEN = 3.8;
|
|
5
5
|
var COMPACT_SYSTEM_PREFIX = "You are an expert conversation summarizer for a coding agent. " + "Produce structured markdown summaries. " + "Follow output format exactly. " + "Use EXACT names \u2014 never paraphrase code identifiers. " + "Trust deterministic extraction data over intuition.";
|
|
6
6
|
var PROFILES = {
|
|
@@ -37,7 +37,8 @@ var DEFAULT_CONFIG = {
|
|
|
37
37
|
autoTrigger: true,
|
|
38
38
|
autoTriggerTimeoutMs: 120000,
|
|
39
39
|
backupEnabled: true,
|
|
40
|
-
backupDir: ""
|
|
40
|
+
backupDir: "",
|
|
41
|
+
minContextPercent: 60
|
|
41
42
|
};
|
|
42
43
|
var NO_OP_RE = /applied:\s*0|no changes applied|nothing to (?:do|change)|0 edits? applied/i;
|
|
43
44
|
var SHIFT_RE = /simdi|peki|bide|bi de|gecelim|bakalim|yapalim|baska|sonra|tamam simdi|now let|also|next|let's|moving on|switch to/i;
|
|
@@ -94,8 +95,8 @@ Rules for Accuracy:
|
|
|
94
95
|
` + `2. Status: only mark "done" if there's clear evidence (successful test run, user confirmation)
|
|
95
96
|
` + `3. Quote specific values, don't paraphrase code
|
|
96
97
|
|
|
97
|
-
` + `For EACH segment produce:
|
|
98
|
-
` + `### {TOPIC_NAME}
|
|
98
|
+
` + `For EACH segment produce EXACTLY:
|
|
99
|
+
` + `### CHUNK {NUMBER}: {TOPIC_NAME}
|
|
99
100
|
` + `**Priority**: [critical|high|normal|low]
|
|
100
101
|
` + `**Summary**: [2-4 sentences: what happened, errors, code changes with paths]
|
|
101
102
|
` + `**Decisions**: [comma-separated, or "None"]
|
|
@@ -263,6 +264,13 @@ function validateSmartCompactConfig(sc) {
|
|
|
263
264
|
delete sc.autoTriggerTimeoutMs;
|
|
264
265
|
}
|
|
265
266
|
}
|
|
267
|
+
if ("minContextPercent" in sc) {
|
|
268
|
+
const v = sc.minContextPercent;
|
|
269
|
+
if (typeof v !== "number" || !Number.isFinite(v) || v < 0 || v > 100) {
|
|
270
|
+
warn("smart-compact config: minContextPercent must be 0\u2013100, got " + v + ". Using default " + DEFAULT_CONFIG.minContextPercent + ".");
|
|
271
|
+
delete sc.minContextPercent;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
266
274
|
}
|
|
267
275
|
var _cfg = null;
|
|
268
276
|
var _cfgMtime = 0;
|
|
@@ -390,6 +398,25 @@ function smartKeepBoundary(msgs, keepFromIndex, branchEntries) {
|
|
|
390
398
|
}
|
|
391
399
|
return adjusted;
|
|
392
400
|
}
|
|
401
|
+
function collectToolCallIds(blocks, msgIndex, out) {
|
|
402
|
+
for (const b of blocks) {
|
|
403
|
+
const block = b;
|
|
404
|
+
if (block?.type === "toolCall") {
|
|
405
|
+
if (typeof block.id === "string") {
|
|
406
|
+
out.set(block.id, msgIndex);
|
|
407
|
+
}
|
|
408
|
+
const args = block.arguments;
|
|
409
|
+
if (block.name === "multi_tool_use.parallel" && args && Array.isArray(args.tool_uses)) {
|
|
410
|
+
for (const nested of args.tool_uses) {
|
|
411
|
+
const n = nested;
|
|
412
|
+
if (typeof n.id === "string") {
|
|
413
|
+
out.set(n.id, msgIndex);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
393
420
|
function guardToolCallBoundary(msgs, keepFrom) {
|
|
394
421
|
if (keepFrom <= 0 || keepFrom >= msgs.length)
|
|
395
422
|
return keepFrom;
|
|
@@ -399,11 +426,7 @@ function guardToolCallBoundary(msgs, keepFrom) {
|
|
|
399
426
|
if (m?.role !== "assistant")
|
|
400
427
|
continue;
|
|
401
428
|
const blocks = Array.isArray(m?.content) ? m.content : [];
|
|
402
|
-
|
|
403
|
-
if (b?.type === "toolCall" && b.id) {
|
|
404
|
-
tcMap.set(b.id, i);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
429
|
+
collectToolCallIds(blocks, i, tcMap);
|
|
407
430
|
}
|
|
408
431
|
let adjusted = keepFrom;
|
|
409
432
|
let changed = true;
|
|
@@ -538,10 +561,10 @@ function computeToolCharPercentage(branchEntries) {
|
|
|
538
561
|
}
|
|
539
562
|
return totalChars > 0 ? Math.round(toolChars / totalChars * 100) : 0;
|
|
540
563
|
}
|
|
541
|
-
function selectCompactionTier(contextPercent, toolPercent, totalTokens, minThreshold) {
|
|
564
|
+
function selectCompactionTier(contextPercent, toolPercent, totalTokens, minThreshold, minContextPercent = 60) {
|
|
542
565
|
if (totalTokens < minThreshold)
|
|
543
566
|
return "none";
|
|
544
|
-
if (contextPercent <
|
|
567
|
+
if (contextPercent < minContextPercent)
|
|
545
568
|
return "none";
|
|
546
569
|
if (contextPercent < 80)
|
|
547
570
|
return "light";
|
|
@@ -595,6 +618,18 @@ var PROVIDER_MAP = {
|
|
|
595
618
|
singlePassTokenMultiplier: 1,
|
|
596
619
|
multimodal: "metadata-only"
|
|
597
620
|
},
|
|
621
|
+
"kimi-coding": {
|
|
622
|
+
maxOutputTokens: 8192,
|
|
623
|
+
supportsTools: "probe",
|
|
624
|
+
jsonReliability: "high",
|
|
625
|
+
instructionFollowing: "high",
|
|
626
|
+
tokenRatioEstimate: 3.5,
|
|
627
|
+
concurrencyLimit: 2,
|
|
628
|
+
cacheStrategy: "anthropic",
|
|
629
|
+
timeoutMultiplier: 1.5,
|
|
630
|
+
singlePassTokenMultiplier: 0.95,
|
|
631
|
+
multimodal: "metadata-only"
|
|
632
|
+
},
|
|
598
633
|
anthropic: {
|
|
599
634
|
maxOutputTokens: 8192,
|
|
600
635
|
supportsTools: true,
|
|
@@ -667,6 +702,30 @@ var PROVIDER_MAP = {
|
|
|
667
702
|
singlePassTokenMultiplier: 0.9,
|
|
668
703
|
multimodal: "metadata-only"
|
|
669
704
|
},
|
|
705
|
+
"xiaomi-mimo": {
|
|
706
|
+
maxOutputTokens: 8192,
|
|
707
|
+
supportsTools: "probe",
|
|
708
|
+
jsonReliability: "medium",
|
|
709
|
+
instructionFollowing: "medium",
|
|
710
|
+
tokenRatioEstimate: 3.3,
|
|
711
|
+
concurrencyLimit: 2,
|
|
712
|
+
cacheStrategy: "anthropic",
|
|
713
|
+
timeoutMultiplier: 1.35,
|
|
714
|
+
singlePassTokenMultiplier: 0.9,
|
|
715
|
+
multimodal: "metadata-only"
|
|
716
|
+
},
|
|
717
|
+
crofai: {
|
|
718
|
+
maxOutputTokens: 8192,
|
|
719
|
+
supportsTools: "probe",
|
|
720
|
+
jsonReliability: "medium",
|
|
721
|
+
instructionFollowing: "medium",
|
|
722
|
+
tokenRatioEstimate: 3.8,
|
|
723
|
+
concurrencyLimit: 3,
|
|
724
|
+
cacheStrategy: "none",
|
|
725
|
+
timeoutMultiplier: 1.2,
|
|
726
|
+
singlePassTokenMultiplier: 0.95,
|
|
727
|
+
multimodal: "metadata-only"
|
|
728
|
+
},
|
|
670
729
|
mistral: {
|
|
671
730
|
maxOutputTokens: 8192,
|
|
672
731
|
supportsTools: true,
|
|
@@ -694,13 +753,16 @@ var PROVIDER_MAP = {
|
|
|
694
753
|
};
|
|
695
754
|
var PROVIDER_ALIASES = [
|
|
696
755
|
{ pattern: /anthropic/i, provider: "anthropic" },
|
|
756
|
+
{ pattern: /kimi/i, provider: "kimi-coding" },
|
|
697
757
|
{ pattern: /zai/i, provider: "zai-anthropic" },
|
|
698
758
|
{ pattern: /openai/i, provider: "openai" },
|
|
699
759
|
{ pattern: /gpt/i, provider: "openai" },
|
|
700
760
|
{ pattern: /google|gemini/i, provider: "google" },
|
|
701
761
|
{ pattern: /deepseek/i, provider: "deepseek" },
|
|
702
762
|
{ pattern: /minimax/i, provider: "minimax" },
|
|
763
|
+
{ pattern: /xiaomi-mimo/i, provider: "xiaomi-mimo" },
|
|
703
764
|
{ pattern: /xiaomi/i, provider: "xiaomi-token-plan" },
|
|
765
|
+
{ pattern: /crofai/i, provider: "crofai" },
|
|
704
766
|
{ pattern: /mistral/i, provider: "mistral" },
|
|
705
767
|
{ pattern: /xai|grok/i, provider: "xai" }
|
|
706
768
|
];
|
|
@@ -855,7 +917,27 @@ async function trackedComplete(phase, model, reqBody, opts) {
|
|
|
855
917
|
function getCachePath(sessionId) {
|
|
856
918
|
return path2.join(CACHE_DIR, "compact-extraction-" + sessionId.replace(/[^a-zA-Z0-9-]/g, "_") + ".json");
|
|
857
919
|
}
|
|
858
|
-
|
|
920
|
+
var _extractionCacheHits = 0;
|
|
921
|
+
var _extractionCacheMisses = 0;
|
|
922
|
+
function resetExtractionCacheStats() {
|
|
923
|
+
_extractionCacheHits = 0;
|
|
924
|
+
_extractionCacheMisses = 0;
|
|
925
|
+
}
|
|
926
|
+
function getExtractionCacheStats() {
|
|
927
|
+
const total = _extractionCacheHits + _extractionCacheMisses;
|
|
928
|
+
return {
|
|
929
|
+
hits: _extractionCacheHits,
|
|
930
|
+
misses: _extractionCacheMisses,
|
|
931
|
+
hitRate: total > 0 ? _extractionCacheHits / total : 0
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
function recordExtractionCacheHit() {
|
|
935
|
+
_extractionCacheHits++;
|
|
936
|
+
}
|
|
937
|
+
function recordExtractionCacheMiss() {
|
|
938
|
+
_extractionCacheMisses++;
|
|
939
|
+
}
|
|
940
|
+
function saveCachedExtraction(sessionId, extraction, msgCount, firstEntryId, lastEntryId, entryIds, keptEntryIds) {
|
|
859
941
|
try {
|
|
860
942
|
if (!fs2.existsSync(CACHE_DIR))
|
|
861
943
|
fs2.mkdirSync(CACHE_DIR, { recursive: true });
|
|
@@ -865,7 +947,9 @@ function saveCachedExtraction(sessionId, extraction, msgCount, firstEntryId, las
|
|
|
865
947
|
messageCount: msgCount,
|
|
866
948
|
timestamp: Date.now(),
|
|
867
949
|
firstEntryId,
|
|
868
|
-
lastEntryId
|
|
950
|
+
lastEntryId,
|
|
951
|
+
entryIds,
|
|
952
|
+
keptEntryIds
|
|
869
953
|
};
|
|
870
954
|
fs2.writeFileSync(getCachePath(sessionId), JSON.stringify(cached));
|
|
871
955
|
} catch (e) {
|
|
@@ -1102,7 +1186,7 @@ function phaseRows(entry) {
|
|
|
1102
1186
|
}
|
|
1103
1187
|
function recentRunRows(entries) {
|
|
1104
1188
|
if (!entries.length)
|
|
1105
|
-
return `<tr><td colspan="
|
|
1189
|
+
return `<tr><td colspan="12" class="empty">No runs recorded yet</td></tr>`;
|
|
1106
1190
|
return entries.slice(-80).reverse().map((entry) => `<tr>
|
|
1107
1191
|
<td class="mono small">${escapeHtml(entry.ts)}</td>
|
|
1108
1192
|
<td>${escapeHtml(entry.profile)}</td>
|
|
@@ -1114,7 +1198,8 @@ function recentRunRows(entries) {
|
|
|
1114
1198
|
<td class="num">${typeof entry.verificationScore === "number" ? formatNumber(entry.verificationScore) : "\u2014"}</td>
|
|
1115
1199
|
<td class="num">${typeof entry.tokensSaved === "number" ? formatNumber(entry.tokensSaved) : "\u2014"}</td>
|
|
1116
1200
|
<td class="num">${formatNumber(entry.totalCalls)}</td>
|
|
1117
|
-
<td class="
|
|
1201
|
+
<td class="num">${typeof entry.extractionCacheHitRate === "number" ? formatPercent(entry.extractionCacheHitRate) : "\u2014"}</td>
|
|
1202
|
+
<td class="mono small reason">${escapeHtml(entry.fallbackReason ?? entry.extractionCacheMissReason ?? "")}</td>
|
|
1118
1203
|
</tr>`).join(`
|
|
1119
1204
|
`);
|
|
1120
1205
|
}
|
|
@@ -1128,6 +1213,8 @@ function buildMetricsReport(entries = readMetricsLog(100)) {
|
|
|
1128
1213
|
const byProfile = groupMetrics(entries, (e) => e.profile ?? "unknown");
|
|
1129
1214
|
const byProvider = groupMetrics(entries, (e) => e.provider ?? e.model?.split("/")[0] ?? "unknown");
|
|
1130
1215
|
const summarizeGroup = (group) => "- " + group.name + ": n=" + group.runs + ", avg=" + group.avgDuration + "ms, p95=" + group.p95Duration + "ms, score=" + group.avgScore + ", saved=" + group.totalSaved + "t, reliability=" + formatPercent(1 - group.errorRate);
|
|
1216
|
+
const extractionCacheRuns = entries.filter((e) => typeof e.extractionCacheHitRate === "number");
|
|
1217
|
+
const extractionCacheAvg = average(extractionCacheRuns.map((e) => e.extractionCacheHitRate ?? 0));
|
|
1131
1218
|
return [
|
|
1132
1219
|
"# Smart Compact Metrics",
|
|
1133
1220
|
"",
|
|
@@ -1135,6 +1222,7 @@ function buildMetricsReport(entries = readMetricsLog(100)) {
|
|
|
1135
1222
|
"Reliability: " + formatPercent(summary.successRate),
|
|
1136
1223
|
"Latency: avg " + summary.avgDuration + "ms, p95 " + summary.p95Duration + "ms",
|
|
1137
1224
|
"LLM calls: " + summary.totalCalls + ", input " + summary.totalInput + "t, output " + summary.totalOutput + "t",
|
|
1225
|
+
"Extraction cache: avg " + (extractionCacheRuns.length ? formatPercent(extractionCacheAvg) : "\u2014") + " across " + extractionCacheRuns.length + " measured run(s)",
|
|
1138
1226
|
"Tokens saved: " + summary.totalSaved + "t, average verification score: " + summary.avgScore,
|
|
1139
1227
|
"",
|
|
1140
1228
|
"## Profile comparison",
|
|
@@ -1171,7 +1259,7 @@ function writeMetricsDashboard(entries = readMetricsLog(200)) {
|
|
|
1171
1259
|
<div class="panel"><h2>Profile comparison</h2><div class="table-wrap"><table><thead><tr><th>Profile</th><th class="num">Runs</th><th class="num">Avg</th><th class="num">p95</th><th class="num">Score</th><th class="num">Calls</th><th class="num">Saved</th><th>Reliability</th></tr></thead><tbody>${comparisonRows(profileGroups)}</tbody></table></div></div>
|
|
1172
1260
|
<div class="panel"><h2>Provider comparison</h2><div class="table-wrap"><table><thead><tr><th>Provider</th><th class="num">Runs</th><th class="num">Avg</th><th class="num">p95</th><th class="num">Score</th><th class="num">Calls</th><th class="num">Saved</th><th>Reliability</th></tr></thead><tbody>${comparisonRows(providerGroups)}</tbody></table></div></div>
|
|
1173
1261
|
</section>
|
|
1174
|
-
<section class="panel section"><h2>Recent runs</h2><div class="table-wrap"><table><thead><tr><th>Time</th><th>Profile</th><th>Provider</th><th>Method</th><th>Run</th><th>Status</th><th class="num">Duration</th><th class="num">Score</th><th class="num">Saved</th><th class="num">Calls</th><th>Reason</th></tr></thead><tbody>${recentRunRows(entries)}</tbody></table></div></section>
|
|
1262
|
+
<section class="panel section"><h2>Recent runs</h2><div class="table-wrap"><table><thead><tr><th>Time</th><th>Profile</th><th>Provider</th><th>Method</th><th>Run</th><th>Status</th><th class="num">Duration</th><th class="num">Score</th><th class="num">Saved</th><th class="num">Calls</th><th class="num">Ext cache</th><th>Reason</th></tr></thead><tbody>${recentRunRows(entries)}</tbody></table></div></section>
|
|
1175
1263
|
<section class="section"><h2>Raw text report</h2><pre>${escapeHtml(report)}</pre></section>
|
|
1176
1264
|
</main></body></html>`;
|
|
1177
1265
|
const fp = path2.join(CACHE_DIR, "smart-compact-report.html");
|
|
@@ -1559,14 +1647,14 @@ function extractOpenLoops(msgs, extraction) {
|
|
|
1559
1647
|
});
|
|
1560
1648
|
}
|
|
1561
1649
|
const FOLLOWUP_RE = /(?:next\s+(?:step|thing)|todo|action item|follow\s*up|still (?:need|have) to|gotta|gotta|yapalim|yapmamiz|gerekiyor|eklenecek|d\u00FCzeltilecek|bitmedi|kaldi)/i;
|
|
1562
|
-
for (
|
|
1650
|
+
for (let idx = 0;idx < msgs.length; idx++) {
|
|
1651
|
+
const msg = msgs[idx];
|
|
1563
1652
|
if (msg.role !== "user")
|
|
1564
1653
|
continue;
|
|
1565
1654
|
const txt = extractText(msg.content);
|
|
1566
1655
|
if (txt.length < 10 || txt.startsWith("/"))
|
|
1567
1656
|
continue;
|
|
1568
1657
|
if (FOLLOWUP_RE.test(txt)) {
|
|
1569
|
-
const idx = msgs.indexOf(msg);
|
|
1570
1658
|
const isDup = loops.some((l) => Math.abs((l.sourceIndex ?? 0) - idx) < 5);
|
|
1571
1659
|
if (!isDup) {
|
|
1572
1660
|
loops.push({
|
|
@@ -1582,12 +1670,12 @@ function extractOpenLoops(msgs, extraction) {
|
|
|
1582
1670
|
}
|
|
1583
1671
|
}
|
|
1584
1672
|
const BLOCKED_RE = /blocked|waiting for|depend|ba[\u011Fg]li|bekliyor|engell/i;
|
|
1585
|
-
for (
|
|
1673
|
+
for (let idx = 0;idx < msgs.length; idx++) {
|
|
1674
|
+
const msg = msgs[idx];
|
|
1586
1675
|
if (msg.role !== "user")
|
|
1587
1676
|
continue;
|
|
1588
1677
|
const txt = extractText(msg.content);
|
|
1589
1678
|
if (BLOCKED_RE.test(txt)) {
|
|
1590
|
-
const idx = msgs.indexOf(msg);
|
|
1591
1679
|
const isDup = loops.some((l) => Math.abs((l.sourceIndex ?? 0) - idx) < 5);
|
|
1592
1680
|
if (!isDup) {
|
|
1593
1681
|
loops.push({
|
|
@@ -1998,7 +2086,7 @@ var PI_STATUS_RE = /^\[pi-auto-context\]/;
|
|
|
1998
2086
|
var MAX_TOOL_OUTPUT_CHARS = 800;
|
|
1999
2087
|
function pruneRedundant(msgs) {
|
|
2000
2088
|
if (msgs.length < 5)
|
|
2001
|
-
return { messages: msgs, prunedCount: 0, prunedTokenSaving: 0, reasons: [] };
|
|
2089
|
+
return { messages: msgs, keptIndices: msgs.map((_, i2) => i2), prunedCount: 0, prunedTokenSaving: 0, reasons: [] };
|
|
2002
2090
|
const tcIdx = buildToolCallIndex(msgs);
|
|
2003
2091
|
const keep = new Set(msgs.map((_, i2) => i2));
|
|
2004
2092
|
const reasonMap = new Map;
|
|
@@ -2092,13 +2180,22 @@ function pruneRedundant(msgs) {
|
|
|
2092
2180
|
}
|
|
2093
2181
|
return m;
|
|
2094
2182
|
});
|
|
2095
|
-
const
|
|
2183
|
+
const keptIndices = [];
|
|
2184
|
+
const finalMsgs = [];
|
|
2185
|
+
for (let idx = 0;idx < kept.length; idx++) {
|
|
2186
|
+
const m = kept[idx];
|
|
2187
|
+
if (m === null)
|
|
2188
|
+
continue;
|
|
2189
|
+
keptIndices.push(idx);
|
|
2190
|
+
finalMsgs.push(m);
|
|
2191
|
+
}
|
|
2096
2192
|
const prunedCount = msgs.length - finalMsgs.length;
|
|
2097
2193
|
const originalTokens = estimateTokens(msgs.map((m) => extractText(m.content)).join(""));
|
|
2098
2194
|
const prunedTokens = estimateTokens(finalMsgs.map((m) => extractText(m.content)).join(""));
|
|
2099
2195
|
const reasons = [...reasonMap.entries()].map(([reason, count]) => ({ count, reason }));
|
|
2100
2196
|
return {
|
|
2101
2197
|
messages: finalMsgs,
|
|
2198
|
+
keptIndices,
|
|
2102
2199
|
prunedCount,
|
|
2103
2200
|
prunedTokenSaving: Math.max(0, originalTokens - prunedTokens),
|
|
2104
2201
|
reasons
|
|
@@ -2288,10 +2385,12 @@ function saveProjectFingerprint(projectId, extraction) {
|
|
|
2288
2385
|
...extraction.modifiedFiles.map((f) => f.path),
|
|
2289
2386
|
...extraction.readFiles
|
|
2290
2387
|
])].slice(-50);
|
|
2388
|
+
const detectedLanguage = detectLanguage(extraction);
|
|
2389
|
+
const detectedFramework = detectFramework(extraction);
|
|
2291
2390
|
const fingerprint = {
|
|
2292
2391
|
id: projectId,
|
|
2293
|
-
language: existing?.language
|
|
2294
|
-
framework: existing?.framework ??
|
|
2392
|
+
language: existing?.language && existing.language !== "unknown" ? existing.language : detectedLanguage,
|
|
2393
|
+
framework: existing?.framework ?? detectedFramework,
|
|
2295
2394
|
keyDirectories: extractKeyDirs(extraction),
|
|
2296
2395
|
knownFiles: newKnownFiles,
|
|
2297
2396
|
sessionCount: (existing?.sessionCount ?? 0) + 1,
|
|
@@ -2482,14 +2581,21 @@ function executeExplorationTool(call, llmMessages) {
|
|
|
2482
2581
|
}
|
|
2483
2582
|
case "search_conversation": {
|
|
2484
2583
|
const q = (args.query ?? "").toLowerCase();
|
|
2485
|
-
|
|
2584
|
+
const matches = [];
|
|
2585
|
+
for (let i = 0;i < llmMessages.length && matches.length < 10; i++) {
|
|
2586
|
+
const m = llmMessages[i];
|
|
2486
2587
|
const text = extractText(m?.content).toLowerCase();
|
|
2487
|
-
if (text.includes(q))
|
|
2488
|
-
|
|
2588
|
+
if (text.includes(q)) {
|
|
2589
|
+
matches.push({ idx: i, m });
|
|
2590
|
+
continue;
|
|
2591
|
+
}
|
|
2489
2592
|
const tcs = filterToolCalls(m?.content);
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2593
|
+
if (tcs.some((tc) => JSON.stringify(tc.arguments).toLowerCase().includes(q))) {
|
|
2594
|
+
matches.push({ idx: i, m });
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
return JSON.stringify(matches.map(({ idx, m }) => ({
|
|
2598
|
+
idx,
|
|
2493
2599
|
role: m?.role,
|
|
2494
2600
|
preview: extractText(m?.content).slice(0, 150)
|
|
2495
2601
|
})));
|
|
@@ -2889,28 +2995,43 @@ async function summarizeBatch(batch, extraction, model, auth, signal) {
|
|
|
2889
2995
|
## Active Decisions from previous segments (honour these):
|
|
2890
2996
|
` + activeDecisions.join(`
|
|
2891
2997
|
`) : "";
|
|
2892
|
-
const text = batch.map((ch) =>
|
|
2998
|
+
const text = batch.map((ch, i) => {
|
|
2999
|
+
const id = i + 1;
|
|
3000
|
+
return "--- CHUNK " + id + ": " + ch.topic + " (" + ch.priority + `) ---
|
|
2893
3001
|
` + ch.messages.map((m) => {
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
3002
|
+
const role = m?.role ?? "unknown";
|
|
3003
|
+
const content = extractText(m?.content).slice(0, 500);
|
|
3004
|
+
const toolCalls = filterToolCalls(m?.content).map((tc) => tc.name + " " + JSON.stringify(tc.arguments).slice(0, 300)).join("; ");
|
|
3005
|
+
const toolSuffix = toolCalls ? `
|
|
3006
|
+
[tool_calls] ` + toolCalls : "";
|
|
3007
|
+
return "[" + role + "] " + content + toolSuffix;
|
|
3008
|
+
}).join(`
|
|
3009
|
+
`);
|
|
2897
3010
|
}).join(`
|
|
2898
|
-
`)).join(`
|
|
2899
3011
|
|
|
2900
3012
|
`);
|
|
3013
|
+
const promptPrefix = BATCH_PROMPT_PREFIX;
|
|
2901
3014
|
const dynamicSuffix = BATCH_PROMPT_SUFFIX.replace("{EXTRACTION_CONTEXT}", extractionCtx + decisionCtx).replace("{TEXT}", text);
|
|
2902
3015
|
const resp = await trackedComplete("batch", model, {
|
|
2903
3016
|
systemPrompt: COMPACT_SYSTEM_PREFIX,
|
|
2904
3017
|
messages: [
|
|
2905
|
-
{ role: "user", content: [{ type: "text", text:
|
|
3018
|
+
{ role: "user", content: [{ type: "text", text: promptPrefix }], timestamp: Date.now() },
|
|
2906
3019
|
{ role: "user", content: [{ type: "text", text: dynamicSuffix }], timestamp: Date.now() }
|
|
2907
3020
|
]
|
|
2908
|
-
}, { apiKey: auth.apiKey, headers: auth.headers, maxTokens: Math.min(4096, getProviderCaps(model.provider).maxOutputTokens), signal });
|
|
3021
|
+
}, { apiKey: auth.apiKey, headers: auth.headers, maxTokens: Math.min(Math.max(4096, batch.length * 1500), getProviderCaps(model.provider).maxOutputTokens), signal });
|
|
2909
3022
|
const output = resp.content.filter((c) => c.type === "text").map((c) => c.text).join(`
|
|
2910
3023
|
`);
|
|
3024
|
+
const sectionMap = new Map;
|
|
2911
3025
|
const sections = output.split(/^### /m).filter((s) => s.trim());
|
|
3026
|
+
for (const sec of sections) {
|
|
3027
|
+
const m = sec.match(/^CHUNK\s+(\d+):\s*(.*?)\n/i);
|
|
3028
|
+
if (m) {
|
|
3029
|
+
sectionMap.set(parseInt(m[1], 10), sec);
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
2912
3032
|
return batch.map((ch, i) => {
|
|
2913
|
-
const
|
|
3033
|
+
const id = i + 1;
|
|
3034
|
+
const sec = sectionMap.get(id) ?? "";
|
|
2914
3035
|
const f = (n) => {
|
|
2915
3036
|
const m = sec.match(new RegExp("\\*\\*" + n + "\\*\\*:\\s*(.+?)(?:\\n|$)", "i"));
|
|
2916
3037
|
return m ? m[1].trim() : "";
|
|
@@ -2920,13 +3041,16 @@ async function summarizeBatch(batch, extraction, model, auth, signal) {
|
|
|
2920
3041
|
return !v || v === "None" ? [] : v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
2921
3042
|
};
|
|
2922
3043
|
const prio = f("Priority").toLowerCase();
|
|
3044
|
+
const sectionFallback = sec.split(`
|
|
3045
|
+
`).slice(1).join(`
|
|
3046
|
+
`).trim().slice(0, 500);
|
|
3047
|
+
const chunkFallback = ch.messages.map((m) => "[" + (m?.role ?? "unknown") + "] " + extractText(m?.content).slice(0, 180)).join(`
|
|
3048
|
+
`).slice(0, 500);
|
|
2923
3049
|
return {
|
|
2924
3050
|
topic: ch.topic,
|
|
2925
3051
|
startIndex: ch.startIndex,
|
|
2926
3052
|
endIndex: ch.endIndex,
|
|
2927
|
-
summary: f("Summary") ||
|
|
2928
|
-
`).slice(1).join(`
|
|
2929
|
-
`).trim().slice(0, 500),
|
|
3053
|
+
summary: f("Summary") || sectionFallback || chunkFallback || "No summary generated for this segment.",
|
|
2930
3054
|
keyDecisions: l("Decisions"),
|
|
2931
3055
|
filesModified: l("Modified"),
|
|
2932
3056
|
filesRead: l("Read"),
|
|
@@ -3315,10 +3439,12 @@ async function showResultScreen(ctx, details, extraction) {
|
|
|
3315
3439
|
c.addChild(new Text("", 0, 0));
|
|
3316
3440
|
c.addChild(new Text(theme.fg("text", theme.bold(" \uD83D\uDCCB Extraction")), 0, 0));
|
|
3317
3441
|
const ms = getMetricsSummary();
|
|
3442
|
+
const ecs = getExtractionCacheStats();
|
|
3318
3443
|
if (ms.totalCalls > 0) {
|
|
3319
|
-
const
|
|
3320
|
-
const
|
|
3321
|
-
|
|
3444
|
+
const providerCachePct = Math.round(ms.cacheHitRate * 100);
|
|
3445
|
+
const extractionCachePct = Math.round(ecs.hitRate * 100);
|
|
3446
|
+
const cacheColor = extractionCachePct >= 50 ? "success" : extractionCachePct >= 20 ? "warning" : "dim";
|
|
3447
|
+
c.addChild(new Text(theme.fg("dim", " LLM: ") + theme.fg("text", ms.totalCalls + " calls") + theme.fg("dim", " \u2022 ") + theme.fg("text", ms.totalInput.toLocaleString() + "t in") + theme.fg("dim", " \u2022 ") + theme.fg("dim", providerCachePct + "% provider cache") + theme.fg("dim", " \u2022 ") + theme.fg(cacheColor, extractionCachePct + "% extraction cache") + theme.fg("dim", " \u2022 ") + theme.fg("dim", ms.avgLatency + "ms avg"), 0, 0));
|
|
3322
3448
|
}
|
|
3323
3449
|
const modFiles = details.modifiedFiles;
|
|
3324
3450
|
const errCount = extraction.errors.length;
|
|
@@ -3410,7 +3536,7 @@ async function showCompactUI(ctx, opts) {
|
|
|
3410
3536
|
|
|
3411
3537
|
// src/core.ts
|
|
3412
3538
|
async function runSmartCompact(opts) {
|
|
3413
|
-
const { ctx, summaryModel, segModel, profile, verbose = false, dryRun = false, pendingRef, isRunning, autoTriggered = false, userNote, skipCompact, timeoutMs = 0 } = opts;
|
|
3539
|
+
const { ctx, summaryModel, segModel, profile, verbose = false, dryRun = false, pendingRef, isRunning, autoTriggered = false, userNote, skipCompact, force = false, timeoutMs = 0 } = opts;
|
|
3414
3540
|
if (isRunning.value)
|
|
3415
3541
|
return;
|
|
3416
3542
|
isRunning.value = true;
|
|
@@ -3424,6 +3550,7 @@ async function runSmartCompact(opts) {
|
|
|
3424
3550
|
};
|
|
3425
3551
|
resetCompactSessionId();
|
|
3426
3552
|
resetMetrics();
|
|
3553
|
+
resetExtractionCacheStats();
|
|
3427
3554
|
let sessionId = "unknown";
|
|
3428
3555
|
let totalTokens = 0;
|
|
3429
3556
|
let contextPercent = 0;
|
|
@@ -3513,7 +3640,7 @@ async function runSmartCompact(opts) {
|
|
|
3513
3640
|
markPhase("recover");
|
|
3514
3641
|
contextPercent = ctx.model && totalTokens ? totalTokens / ctx.model.contextWindow * 100 : 0;
|
|
3515
3642
|
toolPercent = computeToolCharPercentage(branch);
|
|
3516
|
-
tier = selectCompactionTier(contextPercent, toolPercent, totalTokens, MIN_TOKEN_THRESHOLD);
|
|
3643
|
+
tier = force ? contextPercent >= 80 ? "full" : "light" : selectCompactionTier(contextPercent, toolPercent, totalTokens, MIN_TOKEN_THRESHOLD, config.minContextPercent);
|
|
3517
3644
|
if (tier === "none") {
|
|
3518
3645
|
isRunning.value = false;
|
|
3519
3646
|
if (!autoTriggered)
|
|
@@ -3521,7 +3648,9 @@ async function runSmartCompact(opts) {
|
|
|
3521
3648
|
return;
|
|
3522
3649
|
}
|
|
3523
3650
|
const shouldSkipExplore = tier === "light";
|
|
3651
|
+
const currentEntryIds = toCompact.map((e) => e.id);
|
|
3524
3652
|
const pruning = pruneRedundant(llmMessages);
|
|
3653
|
+
const currentKeptEntryIds = pruning.keptIndices.map((i) => currentEntryIds[i]).filter((id) => typeof id === "string");
|
|
3525
3654
|
if (pruning.prunedCount > 0) {
|
|
3526
3655
|
notify("Pruning: " + pruning.prunedCount + " msgs removed (" + pruning.reasons.map((r) => r.count + "x " + r.reason).join(", ") + ")", "info");
|
|
3527
3656
|
}
|
|
@@ -3534,23 +3663,36 @@ async function runSmartCompact(opts) {
|
|
|
3534
3663
|
const prevContext = getPreviousCompactionContext(branch);
|
|
3535
3664
|
const cachedExt = loadCachedExtraction(sessionId);
|
|
3536
3665
|
let extraction;
|
|
3666
|
+
let extractionCacheMissReason = cachedExt ? "not-incremental" : "no-cache";
|
|
3537
3667
|
const currentFirstId = toCompact[0]?.id;
|
|
3538
3668
|
const currentLastId = toCompact[toCompact.length - 1]?.id;
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3669
|
+
let cacheUsable = false;
|
|
3670
|
+
if (cachedExt?.keptEntryIds && cachedExt.keptEntryIds.length > 0) {
|
|
3671
|
+
const branchPrefixMatch = cachedExt.entryIds?.every((id, i) => id === currentEntryIds[i]) ?? false;
|
|
3672
|
+
const prunedPrefixMatch = cachedExt.keptEntryIds.length <= currentKeptEntryIds.length && cachedExt.keptEntryIds.every((id, i) => id === currentKeptEntryIds[i]);
|
|
3673
|
+
cacheUsable = branchPrefixMatch && prunedPrefixMatch && cachedExt.messageCount === cachedExt.keptEntryIds.length && cachedExt.messageCount < llmMessages.length;
|
|
3674
|
+
if (!cacheUsable) {
|
|
3675
|
+
extractionCacheMissReason = !branchPrefixMatch ? "entry-prefix-mismatch" : !prunedPrefixMatch ? "pruned-prefix-changed" : cachedExt.messageCount !== cachedExt.keptEntryIds.length ? "cache-shape-mismatch" : "no-new-pruned-messages";
|
|
3676
|
+
}
|
|
3677
|
+
} else if (cachedExt) {
|
|
3678
|
+
extractionCacheMissReason = "legacy-no-kept-entryids";
|
|
3679
|
+
vlog("Extraction cache ignored: legacy entry lacks keptEntryIds");
|
|
3680
|
+
}
|
|
3681
|
+
if (cacheUsable && cachedExt) {
|
|
3682
|
+
const newMsgs = llmMessages.slice(cachedExt.messageCount);
|
|
3544
3683
|
const delta = extractStructured(newMsgs, pc);
|
|
3545
3684
|
extraction = mergeExtractions(cachedExt.extraction, delta, cachedExt.messageCount);
|
|
3546
|
-
notify("Phase 1 Incremental: " +
|
|
3547
|
-
vlog("Incremental extraction \u2014 cached messages: " + cachedExt.messageCount + ", current: " + llmMessages.length);
|
|
3685
|
+
notify("Phase 1 Incremental: " + cachedExt.messageCount + " cached + " + newMsgs.length + " new pruned messages", "info");
|
|
3686
|
+
vlog("Incremental extraction \u2014 cached pruned messages: " + cachedExt.messageCount + ", current pruned: " + llmMessages.length);
|
|
3687
|
+
extractionCacheMissReason = undefined;
|
|
3688
|
+
recordExtractionCacheHit();
|
|
3548
3689
|
} else {
|
|
3549
3690
|
extraction = extractStructured(llmMessages, pc);
|
|
3550
3691
|
notify("Phase 1 Full: " + extraction.modifiedFiles.length + " files, " + extraction.errors.length + " errors", "info");
|
|
3551
3692
|
vlog("Full extraction \u2014 " + llmMessages.length + " messages, tier=" + tier);
|
|
3693
|
+
recordExtractionCacheMiss();
|
|
3552
3694
|
}
|
|
3553
|
-
saveCachedExtraction(sessionId, extraction, llmMessages.length, currentFirstId, currentLastId);
|
|
3695
|
+
saveCachedExtraction(sessionId, extraction, llmMessages.length, currentFirstId, currentLastId, currentEntryIds, currentKeptEntryIds);
|
|
3554
3696
|
markPhase("extract");
|
|
3555
3697
|
const projectId = deriveProjectId(findGitRoot(ctx.cwd) ?? ctx.cwd, extraction, sessionId);
|
|
3556
3698
|
const fingerprint = loadProjectFingerprint(projectId);
|
|
@@ -3713,13 +3855,13 @@ async function runSmartCompact(opts) {
|
|
|
3713
3855
|
markPhase("synthesize");
|
|
3714
3856
|
if (!autoTriggered)
|
|
3715
3857
|
showProgressOverlay(ctx, { phase: 4, phaseName: "Verify", detail: "Checking...", model: modelLabel, profile, extraction, explorationRounds });
|
|
3716
|
-
|
|
3858
|
+
let verification = verifySummary(finalSummary, extraction);
|
|
3717
3859
|
vlog("Verification score=" + verification.score + " ok=" + verification.ok + " gaps=" + verification.gaps.length);
|
|
3718
3860
|
if (!verification.ok) {
|
|
3719
3861
|
if (verification.score < 85) {
|
|
3720
3862
|
notify("Phase 4 Verify: " + verification.gaps.length + " gap(s), score=" + verification.score + ", applying deterministic patch", "warning");
|
|
3721
3863
|
finalSummary = patchDeterministic(finalSummary, verification.gaps, extraction);
|
|
3722
|
-
|
|
3864
|
+
let recheck = verifySummary(finalSummary, extraction);
|
|
3723
3865
|
if (!recheck.ok && recheck.score < 75) {
|
|
3724
3866
|
notify("Phase 4 Verify: deterministic patch insufficient (score=" + recheck.score + "), trying LLM patch", "warning");
|
|
3725
3867
|
try {
|
|
@@ -3728,7 +3870,9 @@ async function runSmartCompact(opts) {
|
|
|
3728
3870
|
} catch (err) {
|
|
3729
3871
|
warn("LLM patch failed", err);
|
|
3730
3872
|
}
|
|
3873
|
+
recheck = verifySummary(finalSummary, extraction);
|
|
3731
3874
|
}
|
|
3875
|
+
verification = recheck;
|
|
3732
3876
|
} else {
|
|
3733
3877
|
notify("Phase 4 Verify: " + verification.gaps.length + " gap(s), score=" + verification.score + " \u2265 85 \u2014 skipping patch", "info");
|
|
3734
3878
|
}
|
|
@@ -3783,6 +3927,7 @@ async function runSmartCompact(opts) {
|
|
|
3783
3927
|
openLoops
|
|
3784
3928
|
};
|
|
3785
3929
|
if (dryRun) {
|
|
3930
|
+
const ecs2 = getExtractionCacheStats();
|
|
3786
3931
|
appendMetricsLog(sessionId, {
|
|
3787
3932
|
profile,
|
|
3788
3933
|
tier,
|
|
@@ -3800,7 +3945,11 @@ async function runSmartCompact(opts) {
|
|
|
3800
3945
|
runType: skipCompact ? "tool" : autoTriggered ? "auto" : "manual",
|
|
3801
3946
|
status: "dry-run",
|
|
3802
3947
|
phaseTimings,
|
|
3803
|
-
durationMs: Date.now() - pipelineStart
|
|
3948
|
+
durationMs: Date.now() - pipelineStart,
|
|
3949
|
+
extractionCacheHits: ecs2.hits,
|
|
3950
|
+
extractionCacheMisses: ecs2.misses,
|
|
3951
|
+
extractionCacheHitRate: ecs2.hitRate,
|
|
3952
|
+
extractionCacheMissReason
|
|
3804
3953
|
});
|
|
3805
3954
|
notify("DRY RUN (" + method + ", " + profile + ") \u2014 " + toCompact.length + " msgs, " + llmCalls + " calls", "info");
|
|
3806
3955
|
return;
|
|
@@ -3830,6 +3979,7 @@ async function runSmartCompact(opts) {
|
|
|
3830
3979
|
warn("Damage detection error", err);
|
|
3831
3980
|
}
|
|
3832
3981
|
markPhase("damage");
|
|
3982
|
+
const ecs = getExtractionCacheStats();
|
|
3833
3983
|
appendMetricsLog(sessionId, {
|
|
3834
3984
|
profile,
|
|
3835
3985
|
tier,
|
|
@@ -3847,11 +3997,17 @@ async function runSmartCompact(opts) {
|
|
|
3847
3997
|
runType: skipCompact ? "tool" : autoTriggered ? "auto" : "manual",
|
|
3848
3998
|
status: "success",
|
|
3849
3999
|
phaseTimings,
|
|
3850
|
-
durationMs: Date.now() - pipelineStart
|
|
4000
|
+
durationMs: Date.now() - pipelineStart,
|
|
4001
|
+
extractionCacheHits: ecs.hits,
|
|
4002
|
+
extractionCacheMisses: ecs.misses,
|
|
4003
|
+
extractionCacheHitRate: ecs.hitRate,
|
|
4004
|
+
extractionCacheMissReason
|
|
3851
4005
|
});
|
|
3852
4006
|
const ms = getMetricsSummary();
|
|
3853
4007
|
if (ms.totalCalls > 0) {
|
|
3854
|
-
|
|
4008
|
+
const providerCacheRate = Math.round(ms.cacheHitRate * 100);
|
|
4009
|
+
const extractionCacheRate = Math.round(ecs.hitRate * 100);
|
|
4010
|
+
notify("Metrics: " + ms.totalCalls + " calls, " + ms.totalInput + "t in, " + ms.totalOutput + "t out, provider-cache " + providerCacheRate + "% (internal phases disabled), extraction-cache " + extractionCacheRate + "%, " + ms.avgLatency + "ms avg", "info");
|
|
3855
4011
|
}
|
|
3856
4012
|
if (!autoTriggered) {
|
|
3857
4013
|
try {
|
|
@@ -3983,7 +4139,7 @@ Dashboard: ` + fp : ""), "info");
|
|
|
3983
4139
|
ctx.ui.notify("Could not resolve model", "error");
|
|
3984
4140
|
return;
|
|
3985
4141
|
}
|
|
3986
|
-
await runSmartCompact({ ctx, summaryModel: sumModel2, segModel: segModel2 ?? sumModel2, profile: selected.profile, pendingRef, isRunning });
|
|
4142
|
+
await runSmartCompact({ ctx, summaryModel: sumModel2, segModel: segModel2 ?? sumModel2, profile: selected.profile, pendingRef, isRunning, force: true });
|
|
3987
4143
|
return;
|
|
3988
4144
|
}
|
|
3989
4145
|
const { segModel, sumModel } = resolveModels(ctx, modelArg ? resolveModelArg(ctx, modelArg) : ctx.model, loadConfig());
|
|
@@ -3992,7 +4148,7 @@ Dashboard: ` + fp : ""), "info");
|
|
|
3992
4148
|
return;
|
|
3993
4149
|
}
|
|
3994
4150
|
const note = extractUserNote(args);
|
|
3995
|
-
await runSmartCompact({ ctx, summaryModel: sumModel, segModel: segModel ?? sumModel, profile, verbose, dryRun, pendingRef, isRunning, userNote: note });
|
|
4151
|
+
await runSmartCompact({ ctx, summaryModel: sumModel, segModel: segModel ?? sumModel, profile, verbose, dryRun, pendingRef, isRunning, userNote: note, force: true });
|
|
3996
4152
|
} catch (error) {
|
|
3997
4153
|
const msg = error instanceof Error ? error.message + `
|
|
3998
4154
|
` + error.stack : String(error);
|
|
@@ -4004,6 +4160,8 @@ Dashboard: ` + fp : ""), "info");
|
|
|
4004
4160
|
if (pendingRef.value) {
|
|
4005
4161
|
const age = Date.now() - pendingRef.createdAt;
|
|
4006
4162
|
if (age > PENDING_TTL_MS) {
|
|
4163
|
+
warn("Discarding expired pending smart compaction after " + Math.round(age / 1000) + "s");
|
|
4164
|
+
ctx.ui?.notify?.("Expired pending smart compaction discarded", "warning");
|
|
4007
4165
|
pendingRef.value = null;
|
|
4008
4166
|
pendingRef.createdAt = 0;
|
|
4009
4167
|
} else {
|
|
@@ -4021,6 +4179,9 @@ Dashboard: ` + fp : ""), "info");
|
|
|
4021
4179
|
const totalTokens = usage?.tokens ?? 0;
|
|
4022
4180
|
if (!totalTokens || totalTokens < MIN_TOKEN_THRESHOLD)
|
|
4023
4181
|
return;
|
|
4182
|
+
const pct = ctx.model && totalTokens ? totalTokens / ctx.model.contextWindow * 100 : 0;
|
|
4183
|
+
if (pct < config.minContextPercent)
|
|
4184
|
+
return;
|
|
4024
4185
|
const cur = ctx.model;
|
|
4025
4186
|
if (!cur)
|
|
4026
4187
|
return;
|
|
@@ -4044,7 +4205,6 @@ Dashboard: ` + fp : ""), "info");
|
|
|
4044
4205
|
}
|
|
4045
4206
|
if (result === "timeout") {
|
|
4046
4207
|
warn("Smart compact auto-trigger hard timeout after " + effectiveTimeoutMs + "ms");
|
|
4047
|
-
isRunning.value = false;
|
|
4048
4208
|
pendingRef.value = null;
|
|
4049
4209
|
pendingRef.createdAt = 0;
|
|
4050
4210
|
return;
|
|
@@ -4063,9 +4223,13 @@ Dashboard: ` + fp : ""), "info");
|
|
|
4063
4223
|
pi.registerTool({
|
|
4064
4224
|
name: "smart_compact",
|
|
4065
4225
|
label: "Smart Compact",
|
|
4066
|
-
description: "EESV smart compaction v" + VERSION + " with deterministic extraction, exploration, and verification. Compacts the conversation into a structured summary preserving goals, decisions, open loops, modified files, and critical context. Call
|
|
4226
|
+
description: "EESV smart compaction v" + VERSION + " with deterministic extraction, exploration, and verification. Compacts the conversation into a structured summary preserving goals, decisions, open loops, modified files, and critical context. Call only when actual context usage is high; ignore pi-auto-context tool=XX% because that is tool-output ratio, not context fullness. The tool internally checks context usage and skips if not needed.",
|
|
4067
4227
|
promptSnippet: "Smart compaction",
|
|
4068
|
-
promptGuidelines: [
|
|
4228
|
+
promptGuidelines: [
|
|
4229
|
+
"Use only when actual context usage is high (for example pi-auto-context context>=60%).",
|
|
4230
|
+
"Do NOT call just because pi-auto-context shows tool=XX%; tool% is tool-output ratio, not context fullness.",
|
|
4231
|
+
"Prefer this over default compact only when compaction is actually needed."
|
|
4232
|
+
],
|
|
4069
4233
|
parameters: {
|
|
4070
4234
|
type: "object",
|
|
4071
4235
|
properties: {
|
|
@@ -4092,10 +4256,14 @@ Dashboard: ` + fp : "") }], details: undefined };
|
|
|
4092
4256
|
const cmdCtx = ctx;
|
|
4093
4257
|
const usage = ctx.getContextUsage?.();
|
|
4094
4258
|
const totalTokens = usage?.tokens ?? 0;
|
|
4259
|
+
const rawPct = ctx.model && totalTokens ? totalTokens / ctx.model.contextWindow * 100 : 0;
|
|
4260
|
+
const pct = Math.round(rawPct);
|
|
4095
4261
|
if (!totalTokens || totalTokens < MIN_TOKEN_THRESHOLD) {
|
|
4096
|
-
const pct = ctx.model && totalTokens ? Math.round(totalTokens / ctx.model.contextWindow * 100) : 0;
|
|
4097
4262
|
return { content: [{ type: "text", text: "Context is not large enough for compaction (" + totalTokens.toLocaleString() + " tokens, " + pct + "%). No action needed." }], details: undefined };
|
|
4098
4263
|
}
|
|
4264
|
+
if (rawPct < config.minContextPercent) {
|
|
4265
|
+
return { content: [{ type: "text", text: "Context is only " + pct + "% full (" + totalTokens.toLocaleString() + " tokens). Compaction is not needed yet. The tool=97% in status means tool output ratio, NOT context usage." }], details: undefined };
|
|
4266
|
+
}
|
|
4099
4267
|
const cur = "model" in ctx ? ctx.model : undefined;
|
|
4100
4268
|
const { segModel, sumModel } = resolveModels(cmdCtx, cur, config);
|
|
4101
4269
|
if (!sumModel) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explore.d.ts","sourceRoot":"","sources":["../../src/phases/explore.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAoC,MAAM,aAAa,CAAC;AAYzH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAcvE;AA6BD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"explore.d.ts","sourceRoot":"","sources":["../../src/phases/explore.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAoC,MAAM,aAAa,CAAC;AAYzH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAcvE;AA6BD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,CAwEpI;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,iBAAiB,CA2BjG;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAo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IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAC7E,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC7D,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,iBAAiB,CAAC,CAsB5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../src/phases/synthesize.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EACxD,iBAAiB,EAAE,aAAa,EACjC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../src/phases/synthesize.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EACxD,iBAAiB,EAAE,aAAa,EACjC,MAAM,aAAa,CAAC;AAarB,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,OAAO,aAAa,EAAE,aAAa,EAAE,EAAE,EAAE,EAAE,aAAa,GAAG,QAAQ,EAAE,CAoDrI;AAED,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI,EACpF,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GACxH,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,CAAC,CAAA;CAAE,CAAC,CAuB3C;AAED,wBAAsB,cAAc,CAClC,KAAK,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,oBAAoB,EACnD,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAAE,MAAM,CAAC,EAAE,WAAW,GAClG,OAAO,CAAC,YAAY,EAAE,CAAC,CAgEzB;AAED,wBAAsB,WAAW,CAC/B,SAAS,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI,EAC7F,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAAE,MAAM,EAAE,MAAM,EAC7F,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GACxC,OAAO,CAAC,MAAM,CAAC,CAqBjB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAcpG"}
|
package/dist/types.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface CompactConfig {
|
|
|
22
22
|
autoTriggerTimeoutMs: number;
|
|
23
23
|
backupEnabled: boolean;
|
|
24
24
|
backupDir: string;
|
|
25
|
+
minContextPercent: number;
|
|
25
26
|
}
|
|
26
27
|
export interface ProviderCapabilities {
|
|
27
28
|
maxOutputTokens: number;
|
|
@@ -61,6 +62,11 @@ export interface CompactMetricsEntry {
|
|
|
61
62
|
totalCacheHit: number;
|
|
62
63
|
avgLatency: number;
|
|
63
64
|
cacheHitRate: number;
|
|
65
|
+
/** Deterministic extraction-cache stats, distinct from provider prompt-cache. */
|
|
66
|
+
extractionCacheHits?: number;
|
|
67
|
+
extractionCacheMisses?: number;
|
|
68
|
+
extractionCacheHitRate?: number;
|
|
69
|
+
extractionCacheMissReason?: string;
|
|
64
70
|
profile?: string;
|
|
65
71
|
tier?: string;
|
|
66
72
|
method?: string;
|
|
@@ -245,6 +251,10 @@ export interface CachedExtraction {
|
|
|
245
251
|
/** First/last entry IDs for branch-aware cache invalidation */
|
|
246
252
|
firstEntryId?: string;
|
|
247
253
|
lastEntryId?: string;
|
|
254
|
+
/** Original toCompact entry IDs for branch/pivot detection. */
|
|
255
|
+
entryIds?: string[];
|
|
256
|
+
/** Entry IDs that survived pruning; this is the index domain of `extraction`. */
|
|
257
|
+
keptEntryIds?: string[];
|
|
248
258
|
}
|
|
249
259
|
/** An open loop — unresolved task detected during compaction */
|
|
250
260
|
export interface OpenLoop {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAExD,kCAAkC;AAClC,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,CAAC;AAEnF,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;AAErE,MAAM,WAAW,aAAa;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,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AAE,uBAAuB,EAC5B,IAAI,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACvG,OAAO,CAAC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,GAAG,IAAI,CAAC,CAMrE"}
|
package/dist/utils/cache.d.ts
CHANGED
|
@@ -20,12 +20,26 @@ export declare function getMetricsSummary(): {
|
|
|
20
20
|
cacheHitRate: number;
|
|
21
21
|
};
|
|
22
22
|
export declare function trackedComplete(phase: LLMCallMetric["phase"], model: Model<Api>, reqBody: Context, opts: CacheAwareOptions): Promise<AssistantMessage>;
|
|
23
|
+
export declare function resetExtractionCacheStats(): void;
|
|
24
|
+
export declare function getExtractionCacheStats(): {
|
|
25
|
+
hits: number;
|
|
26
|
+
misses: number;
|
|
27
|
+
hitRate: number;
|
|
28
|
+
};
|
|
29
|
+
export declare function recordExtractionCacheHit(): void;
|
|
30
|
+
export declare function recordExtractionCacheMiss(): void;
|
|
23
31
|
/**
|
|
24
32
|
* Save extraction cache with entry-id bounds for branch-aware invalidation.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
33
|
+
*
|
|
34
|
+
* @param msgCount — Length of the **pruned** llmMessages array. This is the
|
|
35
|
+
* domain for all index-bearing fields inside `extraction` (topics, errors,
|
|
36
|
+
* decisions, etc.). It must NOT be the unpruned toCompact length.
|
|
37
|
+
* @param entryIds — FULL ordered list of original toCompact entry IDs. Used
|
|
38
|
+
* for branch/pivot detection on subsequent incremental runs.
|
|
39
|
+
* @param keptEntryIds — Ordered entry IDs that survived pruning. This is the
|
|
40
|
+
* index domain used for safe incremental extraction prefix matching.
|
|
27
41
|
*/
|
|
28
|
-
export declare function saveCachedExtraction(sessionId: string, extraction: StructuredExtraction, msgCount: number, firstEntryId?: string, lastEntryId?: string): void;
|
|
42
|
+
export declare function saveCachedExtraction(sessionId: string, extraction: StructuredExtraction, msgCount: number, firstEntryId?: string, lastEntryId?: string, entryIds?: string[], keptEntryIds?: string[]): void;
|
|
29
43
|
export declare function loadCachedExtraction(sessionId: string): CachedExtraction | null;
|
|
30
44
|
/**
|
|
31
45
|
* Merge a delta extraction into a base extraction, offsetting all
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/utils/cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAuB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGtJ,OAAO,EAAY,KAAK,KAAK,EAAE,KAAK,GAAG,EAAE,KAAK,gBAAgB,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAO5G,wBAAgB,mBAAmB,IAAI,MAAM,CAK5C;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AASD,wBAAgB,SAAS,CACvB,IAAI,EAAE,iBAAiB,EACvB,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,iBAAiB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAY5C;AAKD,wBAAgB,YAAY,IAAI,IAAI,CAAyB;AAC7D,wBAAgB,YAAY,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,CAA4F;AAChJ,wBAAgB,UAAU,IAAI,aAAa,EAAE,CAA0B;AAEvE,wBAAgB,iBAAiB,IAAI;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAYpK;AAGD,wBAAsB,eAAe,CACn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MAAM,CAwBxE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,wBAAsB,GAAG,MAAM,GAAG,IAAI,CAgClF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../src/utils/fingerprint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAsDD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOtD;AAkED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA+BzG;AAoDD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CASnF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,oBAAoB,GAC/B,IAAI,
|
|
1
|
+
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../src/utils/fingerprint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAsDD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOtD;AAkED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA+BzG;AAoDD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CASnF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,oBAAoB,GAC/B,IAAI,CAyBN;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI,GAAG,MAAM,CAQlF"}
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -20,6 +20,9 @@ export declare function smartKeepBoundary(msgs: SessionMessageEntry[], keepFromI
|
|
|
20
20
|
* If a kept message is a toolResult whose corresponding toolCall would be compacted,
|
|
21
21
|
* pull keepFrom back to include the assistant message containing that toolCall.
|
|
22
22
|
* This prevents "tool_call_id is not found" API errors after compaction.
|
|
23
|
+
*
|
|
24
|
+
* Also handles multi_tool_use.parallel wrappers where the actual tool call IDs are nested
|
|
25
|
+
* inside arguments.tool_uses rather than on the wrapper block itself.
|
|
23
26
|
*/
|
|
24
27
|
export declare function guardToolCallBoundary(msgs: SessionMessageEntry[], keepFrom: number): number;
|
|
25
28
|
export declare function extractUserNote(args: string): string | undefined;
|
|
@@ -54,7 +57,7 @@ export declare function buildExtractionContext(extraction: StructuredExtraction,
|
|
|
54
57
|
*/
|
|
55
58
|
export declare function computeToolCharPercentage(branchEntries: unknown[]): number;
|
|
56
59
|
export type CompactionTier = "none" | "light" | "full";
|
|
57
|
-
export declare function selectCompactionTier(contextPercent: number, toolPercent: number, totalTokens: number, minThreshold: number): CompactionTier;
|
|
60
|
+
export declare function selectCompactionTier(contextPercent: number, toolPercent: number, totalTokens: number, minThreshold: number, minContextPercent?: number): CompactionTier;
|
|
58
61
|
export declare function inferSessionType(extraction: StructuredExtraction, report: ExplorationReport | null): SessionType;
|
|
59
62
|
export declare function buildExplorationContext(report: ExplorationReport): string;
|
|
60
63
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAsB,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOxK;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAsB,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOxK;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAmE5E;AAKD,wBAAgB,UAAU,IAAI,aAAa,CAkB1C;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUrF;AAED,wBAAg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,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAYzE"}
|
package/dist/utils/pruning.d.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
import type { LlmMessage } from "../types.ts";
|
|
6
6
|
export interface PruningResult {
|
|
7
7
|
messages: LlmMessage[];
|
|
8
|
+
/** Original input indexes retained in `messages`; same order as `messages`. */
|
|
9
|
+
keptIndices: number[];
|
|
8
10
|
prunedCount: number;
|
|
9
11
|
prunedTokenSaving: number;
|
|
10
12
|
reasons: Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pruning.d.ts","sourceRoot":"","sources":["../../src/utils/pruning.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9C,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD;AAWD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"pruning.d.ts","sourceRoot":"","sources":["../../src/utils/pruning.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9C,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,+EAA+E;IAC/E,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD;AAWD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,aAAa,CA8HhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/utils/tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/utils/tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAiGxD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,oBAAoB,CAQtE;AAUD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAQtE;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAMhG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-smart-compact",
|
|
3
|
-
"version": "7.12.
|
|
3
|
+
"version": "7.12.5",
|
|
4
4
|
"description": "EESV smart compaction extension for Pi Coding Agent — deterministic extraction, exploration, synthesis, verification with redundancy pruning, project fingerprinting, and damage detection.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"pi": {
|
|
49
49
|
"extensions": ["./dist/index.js"],
|
|
50
|
-
"image": "https://raw.githubusercontent.com/alpertarhan/pi-smart-compact/
|
|
50
|
+
"image": "https://raw.githubusercontent.com/alpertarhan/pi-smart-compact/main/docs/assets/pi-smart-compact.png"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@earendil-works/pi-ai": "*",
|