pi-smart-compact 7.5.2 → 7.9.0

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 (57) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +513 -198
  3. package/dist/constants.d.ts +45 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/core.d.ts +27 -0
  6. package/dist/core.d.ts.map +1 -0
  7. package/dist/index.d.ts +8 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +3131 -0
  10. package/dist/phases/explore.d.ts +35 -0
  11. package/dist/phases/explore.d.ts.map +1 -0
  12. package/dist/phases/synthesize.d.ts +23 -0
  13. package/dist/phases/synthesize.d.ts.map +1 -0
  14. package/dist/phases/verify.d.ts +16 -0
  15. package/dist/phases/verify.d.ts.map +1 -0
  16. package/dist/types.d.ts +265 -0
  17. package/dist/types.d.ts.map +1 -0
  18. package/dist/ui/overlays.d.ts +29 -0
  19. package/dist/ui/overlays.d.ts.map +1 -0
  20. package/dist/utils/cache.d.ts +27 -0
  21. package/dist/utils/cache.d.ts.map +1 -0
  22. package/dist/utils/damage.d.ts +28 -0
  23. package/dist/utils/damage.d.ts.map +1 -0
  24. package/dist/utils/extraction.d.ts +27 -0
  25. package/dist/utils/extraction.d.ts.map +1 -0
  26. package/dist/utils/fingerprint.d.ts +32 -0
  27. package/dist/utils/fingerprint.d.ts.map +1 -0
  28. package/dist/utils/helpers.d.ts +22 -0
  29. package/dist/utils/helpers.d.ts.map +1 -0
  30. package/dist/utils/logger.d.ts +8 -0
  31. package/dist/utils/logger.d.ts.map +1 -0
  32. package/dist/utils/pruning.d.ts +19 -0
  33. package/dist/utils/pruning.d.ts.map +1 -0
  34. package/dist/utils/state.d.ts +62 -0
  35. package/dist/utils/state.d.ts.map +1 -0
  36. package/dist/utils/tokens.d.ts +8 -0
  37. package/dist/utils/tokens.d.ts.map +1 -0
  38. package/dist/utils/type-guards.d.ts +26 -0
  39. package/dist/utils/type-guards.d.ts.map +1 -0
  40. package/docs/assets/pi-smart-compact.png +0 -0
  41. package/package.json +13 -3
  42. package/src/constants.ts +0 -140
  43. package/src/core.ts +0 -360
  44. package/src/index.ts +0 -175
  45. package/src/phases/explore.ts +0 -371
  46. package/src/phases/synthesize.ts +0 -184
  47. package/src/phases/verify.ts +0 -191
  48. package/src/types.ts +0 -176
  49. package/src/ui/overlays.ts +0 -329
  50. package/src/utils/cache.ts +0 -145
  51. package/src/utils/damage.ts +0 -153
  52. package/src/utils/extraction.ts +0 -259
  53. package/src/utils/fingerprint.ts +0 -190
  54. package/src/utils/helpers.ts +0 -161
  55. package/src/utils/message-blocks.ts +0 -21
  56. package/src/utils/pruning.ts +0 -147
  57. package/src/utils/tokens.ts +0 -63
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Phase 2: Targeted LLM Exploration.
3
+ */
4
+ import type { Model, Api } from "@earendil-works/pi-ai";
5
+ import type { LlmMessage, StructuredExtraction, ExplorationReport } from "../types.ts";
6
+ /**
7
+ * Determine whether exploration is worthwhile based on session complexity.
8
+ * Simple sessions (few topics, few errors, few decisions) skip exploration
9
+ * and rely on heuristic boundaries instead — saving 3-8 LLM calls.
10
+ */
11
+ export declare function shouldExplore(extraction: StructuredExtraction): boolean;
12
+ export declare function executeExplorationTool(call: {
13
+ name: string;
14
+ arguments: Record<string, unknown>;
15
+ }, llmMessages: LlmMessage[]): string;
16
+ export declare function parseExplorationReport(text: string, llmMessages: LlmMessage[]): ExplorationReport;
17
+ export declare function buildExplorationReportFromParsed(parsed: any, llmMessages: LlmMessage[]): ExplorationReport;
18
+ export declare function fallbackExplorationReport(llmMessages: LlmMessage[]): ExplorationReport;
19
+ export declare function exploreConversation(llmMessages: LlmMessage[], extraction: StructuredExtraction, model: Model<Api>, auth: {
20
+ apiKey: string;
21
+ headers?: Record<string, string>;
22
+ }, prevSummary: string | undefined, userNote: string | undefined, signal?: AbortSignal, maxRounds?: number, notify?: (msg: string, type?: "info" | "success" | "warning" | "error") => void): Promise<{
23
+ report: ExplorationReport;
24
+ rounds: number;
25
+ toolSupported: boolean;
26
+ }>;
27
+ export declare function explorationRetry(model: Model<Api>, auth: {
28
+ apiKey: string;
29
+ headers?: Record<string, string>;
30
+ }, llmMessages: LlmMessage[], extraction: StructuredExtraction, prevSummary: string | undefined, userNote: string | undefined, signal?: AbortSignal): Promise<ExplorationReport>;
31
+ export declare function directExploration(llmMessages: LlmMessage[], extraction: StructuredExtraction, model: Model<Api>, auth: {
32
+ apiKey: string;
33
+ headers?: Record<string, string>;
34
+ }, prevSummary: string | undefined, userNote: string | undefined, signal?: AbortSignal): Promise<ExplorationReport>;
35
+ //# sourceMappingURL=explore.d.ts.map
@@ -0,0 +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,CAmEpI;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,CAoB1G;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,iBAAiB,CA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AAE,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"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Phase 3: Hierarchical Synthesis.
3
+ */
4
+ import type { Model, Api } from "@earendil-works/pi-ai";
5
+ import type { LlmMessage, LlmChunk, ChunkSummary, StructuredExtraction, ExplorationReport, ProfileConfig } from "../types.ts";
6
+ export declare function chunkLlmMessages(msgs: LlmMessage[], boundaries: import("../types.ts").TopicBoundary[], pc: ProfileConfig): LlmChunk[];
7
+ export declare function singlePassCompact(convText: string, extraction: StructuredExtraction, report: ExplorationReport | null, prevContext: string, model: Model<Api>, auth: {
8
+ apiKey: string;
9
+ headers?: Record<string, string>;
10
+ }, signal?: AbortSignal): Promise<{
11
+ summary: string;
12
+ llmCalls: 1;
13
+ }>;
14
+ export declare function summarizeBatch(batch: LlmChunk[], extraction: StructuredExtraction, model: Model<Api>, auth: {
15
+ apiKey: string;
16
+ headers?: Record<string, string>;
17
+ }, signal?: AbortSignal): Promise<ChunkSummary[]>;
18
+ export declare function assembleLLM(summaries: ChunkSummary[], extraction: StructuredExtraction, report: ExplorationReport | null, model: Model<Api>, auth: {
19
+ apiKey: string;
20
+ headers?: Record<string, string>;
21
+ }, budget: number, prevContext: string, signal?: AbortSignal): Promise<string>;
22
+ export declare function assembleFallback(summaries: ChunkSummary[], extraction: StructuredExtraction): string;
23
+ //# sourceMappingURL=synthesize.d.ts.map
@@ -0,0 +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,YA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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"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Phase 4: Verification + Quality Score.
3
+ */
4
+ import type { Model, Api } from "@earendil-works/pi-ai";
5
+ import type { StructuredExtraction, VerificationResult } from "../types.ts";
6
+ export declare function verifySummary(summary: string, extraction: StructuredExtraction): VerificationResult;
7
+ /**
8
+ * Deterministic patch — injects missing items directly into the summary
9
+ * without an LLM call. Appends gaps to the relevant sections.
10
+ */
11
+ export declare function patchDeterministic(summary: string, gaps: string[], extraction: StructuredExtraction): string;
12
+ export declare function patchSummary(summary: string, gaps: string[], model: Model<Api>, auth: {
13
+ apiKey: string;
14
+ headers?: Record<string, string>;
15
+ }, signal?: AbortSignal): Promise<string>;
16
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/phases/verify.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAqB,MAAM,aAAa,CAAC;AAK/F,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,GAAG,kBAAkB,CAwGnG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAgE5G;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAC/B,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,MAAM,CAAC,CAcjB"}
@@ -0,0 +1,265 @@
1
+ /**
2
+ * Core type definitions for the Smart Compact extension.
3
+ */
4
+ import type { Model, Api } from "@earendil-works/pi-ai";
5
+ /** Session type classification */
6
+ export type SessionType = "implementation" | "review" | "debugging" | "discussion";
7
+ export type CompressionProfile = "light" | "balanced" | "aggressive";
8
+ export interface ProfileConfig {
9
+ summaryBudgetTokens: number;
10
+ keepRecentTokens: number;
11
+ minChunkTokens: number;
12
+ maxChunkTokens: number;
13
+ singlePassMaxTokens: number;
14
+ batchMaxTokens: number;
15
+ }
16
+ export interface CompactConfig {
17
+ profile: CompressionProfile;
18
+ profiles: Record<CompressionProfile, ProfileConfig>;
19
+ summaryModel: string | null;
20
+ segmentationModel: string | null;
21
+ autoTrigger: boolean;
22
+ backupEnabled: boolean;
23
+ backupDir: string;
24
+ }
25
+ export interface ProviderCapabilities {
26
+ maxOutputTokens: number;
27
+ supportsTools: boolean | "probe";
28
+ jsonReliability: "high" | "medium" | "low";
29
+ instructionFollowing: "high" | "medium" | "low";
30
+ tokenRatioEstimate: number;
31
+ concurrencyLimit: number;
32
+ cacheStrategy: "anthropic" | "openai" | "none";
33
+ }
34
+ export interface LLMCallMetric {
35
+ phase: "probe" | "explore" | "explore-loop" | "explore-retry" | "explore-direct" | "single-pass" | "batch" | "assemble" | "patch";
36
+ model: string;
37
+ inputTokens: number;
38
+ outputTokens: number;
39
+ cacheHitTokens: number;
40
+ latencyMs: number;
41
+ success: boolean;
42
+ }
43
+ export interface TopicBoundary {
44
+ afterIndex: number;
45
+ topic: string;
46
+ priority: "critical" | "high" | "normal" | "low";
47
+ confidence: number;
48
+ }
49
+ export interface ChunkSummary {
50
+ topic: string;
51
+ startIndex: number;
52
+ endIndex: number;
53
+ summary: string;
54
+ keyDecisions: string[];
55
+ filesModified: string[];
56
+ filesRead: string[];
57
+ priority: "critical" | "high" | "normal" | "low";
58
+ }
59
+ export interface SmartCompactDetails {
60
+ method: "eesv" | "single-pass" | "heuristic";
61
+ chunkCount: number;
62
+ topics: string[];
63
+ readFiles: string[];
64
+ modifiedFiles: string[];
65
+ totalMessages: number;
66
+ totalTokensSummarized: number;
67
+ llmCalls: number;
68
+ profile: CompressionProfile;
69
+ backupPath: string | null;
70
+ tokensSaved: number;
71
+ verified: boolean;
72
+ gaps: string[];
73
+ explorationRounds: number;
74
+ explorationBoundaries: number;
75
+ model: string;
76
+ qualityScore: number;
77
+ tokensBefore: number;
78
+ compactionState?: CompactionState;
79
+ openLoops?: OpenLoop[];
80
+ }
81
+ export interface PendingCompaction {
82
+ summary: string;
83
+ firstKeptEntryId: string;
84
+ tokensBefore: number;
85
+ details: SmartCompactDetails;
86
+ compactionState?: CompactionState;
87
+ }
88
+ export interface ModelOption {
89
+ value: string;
90
+ label: string;
91
+ model: Model<Api>;
92
+ supportsTools: boolean;
93
+ }
94
+ export interface VerificationResult {
95
+ ok: boolean;
96
+ gaps: string[];
97
+ score: number;
98
+ }
99
+ export interface ExplorationReport {
100
+ boundaries: TopicBoundary[];
101
+ mainGoal: string;
102
+ sessionType: SessionType;
103
+ enrichedConstraints: string[];
104
+ crossReferences: string[];
105
+ statusAssessment: {
106
+ done: string[];
107
+ inProgress: string[];
108
+ blocked: string[];
109
+ };
110
+ criticalContext: string[];
111
+ keyDecisions: string[];
112
+ }
113
+ export interface StructuredExtraction {
114
+ modifiedFiles: Array<{
115
+ path: string;
116
+ toolCalls: number;
117
+ lastModifiedIndex: number;
118
+ }>;
119
+ readFiles: string[];
120
+ deletedFiles: string[];
121
+ errors: Array<{
122
+ index: number;
123
+ tool: string;
124
+ message: string;
125
+ retryAttempted: boolean;
126
+ resolved: boolean;
127
+ }>;
128
+ decisions: Array<{
129
+ index: number;
130
+ type: "explicit" | "implicit";
131
+ summary: string;
132
+ userResponse?: string;
133
+ }>;
134
+ constraints: Array<{
135
+ index: number;
136
+ text: string;
137
+ category: "requirement" | "preference" | "prohibition";
138
+ confidence: number;
139
+ }>;
140
+ topics: Array<{
141
+ startIndex: number;
142
+ endIndex: number;
143
+ primaryFile: string | null;
144
+ type: "implementation" | "debugging" | "exploration" | "review";
145
+ errorDensity: number;
146
+ }>;
147
+ timeline: Array<{
148
+ index: number;
149
+ event: string;
150
+ summary: string;
151
+ }>;
152
+ mainGoal: string | null;
153
+ lastUserMessages: string[];
154
+ lastErrors: string[];
155
+ messageCount: number;
156
+ }
157
+ export interface LlmChunk {
158
+ startIndex: number;
159
+ endIndex: number;
160
+ tokenEstimate: number;
161
+ topic: string;
162
+ priority: "critical" | "high" | "normal" | "low";
163
+ messages: LlmMessage[];
164
+ }
165
+ export interface LlmMessage {
166
+ role: "user" | "assistant" | "toolResult";
167
+ content?: unknown;
168
+ isError?: boolean;
169
+ toolCallId?: string;
170
+ timestamp?: number;
171
+ }
172
+ export interface LlmTextBlock {
173
+ type: "text";
174
+ text: string;
175
+ }
176
+ export interface LlmToolCallBlock {
177
+ type: "toolCall";
178
+ id?: string;
179
+ name: string;
180
+ arguments: Record<string, unknown>;
181
+ }
182
+ export type LlmContentBlock = LlmTextBlock | LlmToolCallBlock | string;
183
+ export interface CacheAwareOptions {
184
+ apiKey?: string;
185
+ headers?: Record<string, string>;
186
+ maxTokens?: number;
187
+ signal?: AbortSignal;
188
+ cacheRetention?: "none" | "short" | "long";
189
+ sessionId?: string;
190
+ }
191
+ export interface CachedExtraction {
192
+ lastMessageIndex: number;
193
+ extraction: StructuredExtraction;
194
+ messageCount: number;
195
+ timestamp: number;
196
+ }
197
+ /** An open loop — unresolved task detected during compaction */
198
+ export interface OpenLoop {
199
+ id: string;
200
+ type: "bugfix" | "follow-up" | "blocked" | "pending" | "retry";
201
+ priority: "critical" | "high" | "normal" | "low";
202
+ status: "open" | "in-progress" | "resolved";
203
+ summary: string;
204
+ files: string[];
205
+ sourceIndex?: number;
206
+ }
207
+ /** Structured machine-readable compaction state */
208
+ export interface CompactionState {
209
+ goal: string | null;
210
+ decisions: Array<{
211
+ id: string;
212
+ summary: string;
213
+ userResponse?: string;
214
+ type: "explicit" | "implicit";
215
+ }>;
216
+ constraints: Array<{
217
+ id: string;
218
+ text: string;
219
+ category: "requirement" | "preference" | "prohibition";
220
+ confidence: number;
221
+ }>;
222
+ modifiedFiles: string[];
223
+ readFiles: string[];
224
+ deletedFiles: string[];
225
+ unresolvedErrors: Array<{
226
+ id: string;
227
+ message: string;
228
+ tool: string;
229
+ files: string[];
230
+ }>;
231
+ resolvedErrors: Array<{
232
+ id: string;
233
+ message: string;
234
+ tool: string;
235
+ }>;
236
+ openLoops: OpenLoop[];
237
+ topics: Array<{
238
+ title: string;
239
+ type: string;
240
+ priority: string;
241
+ }>;
242
+ nextActions: string[];
243
+ criticalContext: string[];
244
+ sessionType: SessionType;
245
+ compactionVersion: string;
246
+ updatedAt?: number;
247
+ }
248
+ /** Shared session message entry type (branch entry filter) */
249
+ export interface SessionMessageEntry {
250
+ type: "message";
251
+ id: string;
252
+ message: unknown;
253
+ }
254
+ export interface ProgressState {
255
+ phase: number;
256
+ phaseName: string;
257
+ detail: string;
258
+ extraction?: StructuredExtraction;
259
+ explorationRounds?: number;
260
+ totalBatches?: number;
261
+ currentBatch?: number;
262
+ model?: string;
263
+ profile?: string;
264
+ }
265
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,Y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AAE,CAAC;IACtB,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAAG,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE;AAEtF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * TUI overlays: model/profile selection, progress, result screen.
3
+ */
4
+ import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
5
+ import type { CompressionProfile, ModelOption, ProgressState, SmartCompactDetails, StructuredExtraction } from "../types.ts";
6
+ export declare function renderContextBar(theme: any, pct: number, tokens: number, barLen?: number): string;
7
+ export declare function renderTokenBar(theme: any, before: number, after: number, label: string, barLen?: number): string;
8
+ export declare function selectModel(ctx: ExtensionCommandContext, opts: {
9
+ contextTokens: number;
10
+ contextPercent: number;
11
+ currentModel: string;
12
+ defaultModelIndex: number;
13
+ }): Promise<ModelOption | null>;
14
+ export declare function selectProfile(ctx: ExtensionCommandContext, selectedModel: ModelOption, opts: {
15
+ contextTokens: number;
16
+ contextPercent: number;
17
+ }): Promise<CompressionProfile | null>;
18
+ export declare function showProgressOverlay(ctx: ExtensionCommandContext, state: ProgressState): void;
19
+ export declare function showResultScreen(ctx: ExtensionCommandContext, details: SmartCompactDetails, extraction: StructuredExtraction): Promise<void>;
20
+ export declare function showCompactUI(ctx: ExtensionCommandContext, opts: {
21
+ contextTokens: number;
22
+ contextPercent: number;
23
+ currentModel: string;
24
+ defaultModelIndex: number;
25
+ }): Promise<{
26
+ model: ModelOption;
27
+ profile: CompressionProfile;
28
+ } | null>;
29
+ //# sourceMappingURL=overlays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlays.d.ts","sourceRoot":"","sources":["../../src/ui/overlays.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAI/E,OAAO,KAAK,EACV,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAC9C,mBAAmB,EAAE,oBAAoB,EAC1C,MAAM,aAAa,CAAC;AAIrB,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAK,GAAG,MAAM,CAM7F;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAK,GAAG,MAAM,CAO5G;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,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,WAAW,GAAG,IAAI,CAAC,CA8C7B;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,uBAAuB,EAC5B,aAAa,EAAE,WAAW,EAC1B,IAAI,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CA4CpC;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,uBAAuB,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAO5F;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,uBAAuB,EAC5B,OAAO,EAAE,mBAAmB,EAC5B,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAqJf;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,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"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Extraction cache, metrics, and cache-aware LLM options.
3
+ */
4
+ import type { LLMCallMetric, StructuredExtraction, CachedExtraction, CacheAwareOptions } from "../types.ts";
5
+ import { type Model, type Api, type AssistantMessage, type Context } from "@earendil-works/pi-ai";
6
+ export declare function getCompactSessionId(): string;
7
+ export declare function resetCompactSessionId(): void;
8
+ export declare function cacheOpts(opts: CacheAwareOptions, provider?: string): CacheAwareOptions & {
9
+ sessionId?: string;
10
+ };
11
+ export declare function resetMetrics(): void;
12
+ export declare function recordMetric(m: LLMCallMetric): void;
13
+ export declare function getMetrics(): LLMCallMetric[];
14
+ export declare function getMetricsSummary(): {
15
+ totalCalls: number;
16
+ totalInput: number;
17
+ totalOutput: number;
18
+ totalCacheHit: number;
19
+ avgLatency: number;
20
+ cacheHitRate: number;
21
+ };
22
+ export declare function trackedComplete(phase: LLMCallMetric["phase"], model: Model<Api>, reqBody: Context, opts: CacheAwareOptions): Promise<AssistantMessage>;
23
+ export declare function saveCachedExtraction(sessionId: string, extraction: StructuredExtraction, msgCount: number): void;
24
+ export declare function loadCachedExtraction(sessionId: string): CachedExtraction | null;
25
+ export declare function mergeExtractions(base: StructuredExtraction, delta: StructuredExtraction, baseMsgCount: number): StructuredExtraction;
26
+ export declare function appendMetricsLog(sessionId: string): void;
27
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +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,EAAE,MAAM,aAAa,CAAC;AAG5G,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;AAGD,wBAAgB,SAAS,CAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,iBAAiB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAOhH;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,CACnC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,gBAAgB,CAAC,CA2B3B;AAQD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAQhH;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAQ/E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,GAAG,oBAAoB,CAepI;AAGD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAOxD"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Post-compaction regression signal detection.
3
+ * Monitors agent behavior after compaction to detect quality issues.
4
+ */
5
+ import type { LlmMessage, SmartCompactDetails } from "../types.ts";
6
+ export interface RegressionSignal {
7
+ type: "re-read" | "re-question" | "contradiction" | "user-complaint";
8
+ severity: "low" | "medium" | "high";
9
+ detail: string;
10
+ }
11
+ export interface DamageReport {
12
+ signals: RegressionSignal[];
13
+ damageScore: number;
14
+ summary: string;
15
+ }
16
+ /**
17
+ * Detect regression signals in messages AFTER compaction.
18
+ * Called with the post-compaction messages (typically 5-20 messages).
19
+ *
20
+ * @param postMessages Messages after compaction was applied
21
+ * @param details The compaction details (contains the files/decisions that were compacted)
22
+ */
23
+ export declare function detectDamage(postMessages: LlmMessage[], details: SmartCompactDetails): DamageReport;
24
+ /**
25
+ * Save a damage report to the metrics log for future analysis.
26
+ */
27
+ export declare function logDamageReport(sessionId: string, report: DamageReport, details: SmartCompactDetails): void;
28
+ //# sourceMappingURL=damage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"damage.d.ts","sourceRoot":"","sources":["../../src/utils/damage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOnE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,eAAe,GAAG,gBAAgB,CAAC;IACrE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AASD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,UAAU,EAAE,EAC1B,OAAO,EAAE,mBAAmB,GAC3B,YAAY,CAiFd;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,mBAAmB,GAC3B,IAAI,CAiBN"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Phase 1: Deterministic extraction — zero LLM calls.
3
+ */
4
+ import type { LlmMessage, ProfileConfig, StructuredExtraction, OpenLoop } from "../types.ts";
5
+ /** Reusable tool call index type */
6
+ export type ToolCallIndex = Map<string, {
7
+ name: string;
8
+ arguments: Record<string, unknown>;
9
+ msgIndex: number;
10
+ }>;
11
+ export declare function extractText(content: unknown): string;
12
+ export declare function buildToolCallIndex(msgs: LlmMessage[]): ToolCallIndex;
13
+ export declare function trackFileOps(msgs: LlmMessage[], _tcIdx?: ToolCallIndex): {
14
+ modified: StructuredExtraction["modifiedFiles"];
15
+ read: string[];
16
+ deleted: string[];
17
+ };
18
+ export declare function catalogErrors(msgs: LlmMessage[], _tcIdx?: ToolCallIndex): StructuredExtraction["errors"];
19
+ export declare function extractDecisions(msgs: LlmMessage[], _tcIdx?: ToolCallIndex): StructuredExtraction["decisions"];
20
+ export declare function mineConstraints(msgs: LlmMessage[]): StructuredExtraction["constraints"];
21
+ export declare function segmentTopicsHeuristic(msgs: LlmMessage[], pc: ProfileConfig, maxSegs?: number, _tcIdx?: ToolCallIndex): StructuredExtraction["topics"];
22
+ export declare function buildTimeline(msgs: LlmMessage[], errors: StructuredExtraction["errors"]): StructuredExtraction["timeline"];
23
+ export declare function extractMainGoal(msgs: LlmMessage[]): string | null;
24
+ /** Extract open loops — unresolved tasks from the conversation */
25
+ export declare function extractOpenLoops(msgs: LlmMessage[], extraction: StructuredExtraction): OpenLoop[];
26
+ export declare function extractStructured(msgs: LlmMessage[], pc: ProfileConfig): StructuredExtraction;
27
+ //# sourceMappingURL=extraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../src/utils/extraction.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK7F,oCAAoC;AACpC,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEhH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAQpD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,aAAa,CAapE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG;IAAE,QAAQ,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAiC/J;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CA2CxG;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAyB9G;AAYD,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAcvF;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,SAAK,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CA8ClJ;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAc1H;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,GAAG,IAAI,CAOjE;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,oBAAoB,GAAG,QAAQ,EAAE,CAoFjG;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,aAAa,GAAG,oBAAoB,CAgB7F"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Lightweight project fingerprint for cross-session context.
3
+ * Stores basic project metadata to improve compaction accuracy.
4
+ */
5
+ import type { StructuredExtraction } from "../types.ts";
6
+ export interface ProjectFingerprint {
7
+ id: string;
8
+ language: string;
9
+ framework: string | null;
10
+ keyDirectories: string[];
11
+ knownFiles: string[];
12
+ sessionCount: number;
13
+ updatedAt: number;
14
+ }
15
+ /**
16
+ * Generate a project ID from file paths in the extraction.
17
+ * Uses the most common root directory as a heuristic.
18
+ */
19
+ export declare function deriveProjectId(extraction: StructuredExtraction): string;
20
+ /**
21
+ * Load project fingerprint from cache.
22
+ */
23
+ export declare function loadProjectFingerprint(projectId: string): ProjectFingerprint | null;
24
+ /**
25
+ * Save/update project fingerprint after compaction.
26
+ */
27
+ export declare function saveProjectFingerprint(projectId: string, extraction: StructuredExtraction): void;
28
+ /**
29
+ * Build a project context string for injection into prompts.
30
+ */
31
+ export declare function buildProjectContext(fingerprint: ProjectFingerprint | null): string;
32
+ //# sourceMappingURL=fingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../src/utils/fingerprint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,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;AAuCD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAkBxE;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,CAuBN;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI,GAAG,MAAM,CAQlF"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * General helpers: config, backup, batching, preprocessing.
3
+ */
4
+ import type { CompactConfig, ChunkSummary, LlmChunk, StructuredExtraction, ExplorationReport, SessionMessageEntry } from "../types.ts";
5
+ export declare function loadConfig(): CompactConfig;
6
+ export declare function backupConversation(convText: string, sessionId: string): string | null;
7
+ export declare function getPreviousCompactionContext(branch: unknown[]): string;
8
+ export declare function smartKeepBoundary(msgs: SessionMessageEntry[], keepFromIndex: number): number;
9
+ export declare function extractUserNote(args: string): string | undefined;
10
+ export declare function createBatches(chunks: LlmChunk[], maxTokens: number): LlmChunk[][];
11
+ export declare function preProcessSummaries(summaries: ChunkSummary[], budgetTokens?: number): {
12
+ decisions: string[];
13
+ modified: string[];
14
+ read: string[];
15
+ text: string;
16
+ };
17
+ export declare function buildExtractionContext(extraction: StructuredExtraction, forRange?: {
18
+ start: number;
19
+ end: number;
20
+ }): string;
21
+ export declare function buildExplorationContext(report: ExplorationReport): string;
22
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvI,wBAAgB,UAAU,IAAI,aAAa,CAiB1C;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUrF;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAQtE;AAID,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CA0B5F;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKhE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,CASjF;AAqCD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM;;;;;EAYnF;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,oBAAoB,EAAE,QAAQ,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAU1H;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAYzE"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Centralized logger for pi-smart-compact.
3
+ * Respects DEBUG environment variable and adds consistent prefix.
4
+ */
5
+ export declare function warn(msg: string, err?: unknown): void;
6
+ export declare function error(msg: string, err?: unknown): void;
7
+ export declare function debug(msg: string, ...args: unknown[]): void;
8
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI,CAGrD;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI,CAGtD;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAE3D"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Pre-compaction redundancy pruning — deterministic, zero LLM cost.
3
+ * Reduces compaction input by collapsing redundant message sequences.
4
+ */
5
+ import type { LlmMessage } from "../types.ts";
6
+ export interface PruningResult {
7
+ messages: LlmMessage[];
8
+ prunedCount: number;
9
+ prunedTokenSaving: number;
10
+ reasons: Array<{
11
+ count: number;
12
+ reason: string;
13
+ }>;
14
+ }
15
+ /**
16
+ * Detect and collapse redundant message sequences.
17
+ */
18
+ export declare function pruneRedundant(msgs: LlmMessage[]): PruningResult;
19
+ //# sourceMappingURL=pruning.d.ts.map
@@ -0,0 +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;AAQD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,aAAa,CAwGhE"}