@sriinnu/fiche 0.0.0-stage → 0.19.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 (196) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/LICENSE +22 -0
  3. package/NOTICE +13 -0
  4. package/PRIVACY.md +41 -0
  5. package/README.md +288 -2
  6. package/SECURITY.md +53 -0
  7. package/assets/JETBRAINS_MONO_LICENSE.txt +89 -0
  8. package/assets/SPLEEN_LICENSE.txt +24 -0
  9. package/assets/UNIFONT_LICENSE.txt +476 -0
  10. package/assets/fiche-logo-dark.svg +61 -0
  11. package/assets/fiche-logo-light.svg +61 -0
  12. package/assets/fiche-logo.svg +71 -0
  13. package/assets/fiche-mark.svg +48 -0
  14. package/bin/cli.js +7 -0
  15. package/bin/mcp.js +8 -0
  16. package/dist/calibrate.d.ts +30 -0
  17. package/dist/calibrate.js +588 -0
  18. package/dist/core/anthropic-vision.d.ts +28 -0
  19. package/dist/core/anthropic-vision.js +34 -0
  20. package/dist/core/applicability.d.ts +63 -0
  21. package/dist/core/applicability.js +151 -0
  22. package/dist/core/atlas-gray-jbmono10.d.ts +26 -0
  23. package/dist/core/atlas-gray-jbmono10.js +64 -0
  24. package/dist/core/atlas-gray-jbmono12.d.ts +26 -0
  25. package/dist/core/atlas-gray-jbmono12.js +64 -0
  26. package/dist/core/atlas-gray-jbmono14.d.ts +26 -0
  27. package/dist/core/atlas-gray-jbmono14.js +64 -0
  28. package/dist/core/atlas-gray.d.ts +26 -0
  29. package/dist/core/atlas-gray.js +64 -0
  30. package/dist/core/atlas-jbmono10.d.ts +34 -0
  31. package/dist/core/atlas-jbmono10.js +71 -0
  32. package/dist/core/atlas-jbmono12.d.ts +34 -0
  33. package/dist/core/atlas-jbmono12.js +71 -0
  34. package/dist/core/atlas-jbmono14.d.ts +34 -0
  35. package/dist/core/atlas-jbmono14.js +71 -0
  36. package/dist/core/atlas.d.ts +34 -0
  37. package/dist/core/atlas.js +71 -0
  38. package/dist/core/baseline.d.ts +121 -0
  39. package/dist/core/baseline.js +200 -0
  40. package/dist/core/calibration.d.ts +86 -0
  41. package/dist/core/calibration.js +547 -0
  42. package/dist/core/casi-delta.d.ts +63 -0
  43. package/dist/core/casi-delta.js +1271 -0
  44. package/dist/core/claude-model-profiles.d.ts +53 -0
  45. package/dist/core/claude-model-profiles.js +160 -0
  46. package/dist/core/client-tool-round.d.ts +31 -0
  47. package/dist/core/client-tool-round.js +58 -0
  48. package/dist/core/codex-cache.d.ts +20 -0
  49. package/dist/core/codex-cache.js +59 -0
  50. package/dist/core/context-mmu.d.ts +350 -0
  51. package/dist/core/context-mmu.js +3028 -0
  52. package/dist/core/cpt-fit.d.ts +70 -0
  53. package/dist/core/cpt-fit.js +197 -0
  54. package/dist/core/env.d.ts +8 -0
  55. package/dist/core/env.js +15 -0
  56. package/dist/core/export.d.ts +127 -0
  57. package/dist/core/export.js +385 -0
  58. package/dist/core/factsheet.d.ts +77 -0
  59. package/dist/core/factsheet.js +494 -0
  60. package/dist/core/gemini-model-profiles.d.ts +20 -0
  61. package/dist/core/gemini-model-profiles.js +134 -0
  62. package/dist/core/google.d.ts +76 -0
  63. package/dist/core/google.js +1380 -0
  64. package/dist/core/gpt-model-profiles.d.ts +218 -0
  65. package/dist/core/gpt-model-profiles.js +570 -0
  66. package/dist/core/gpt-tokens.d.ts +14 -0
  67. package/dist/core/gpt-tokens.js +165 -0
  68. package/dist/core/history.d.ts +197 -0
  69. package/dist/core/history.js +1003 -0
  70. package/dist/core/index.d.ts +16 -0
  71. package/dist/core/index.js +16 -0
  72. package/dist/core/library.d.ts +80 -0
  73. package/dist/core/library.js +131 -0
  74. package/dist/core/measurement.d.ts +34 -0
  75. package/dist/core/measurement.js +280 -0
  76. package/dist/core/messages-chat-bridge.d.ts +23 -0
  77. package/dist/core/messages-chat-bridge.js +747 -0
  78. package/dist/core/messages-responses-bridge.d.ts +11 -0
  79. package/dist/core/messages-responses-bridge.js +893 -0
  80. package/dist/core/openai-history.d.ts +184 -0
  81. package/dist/core/openai-history.js +1279 -0
  82. package/dist/core/openai-savings.d.ts +57 -0
  83. package/dist/core/openai-savings.js +116 -0
  84. package/dist/core/openai.d.ts +68 -0
  85. package/dist/core/openai.js +2523 -0
  86. package/dist/core/pin.d.ts +199 -0
  87. package/dist/core/pin.js +1353 -0
  88. package/dist/core/png.d.ts +14 -0
  89. package/dist/core/png.js +188 -0
  90. package/dist/core/prefix-tape.d.ts +102 -0
  91. package/dist/core/prefix-tape.js +315 -0
  92. package/dist/core/price-id.d.ts +10 -0
  93. package/dist/core/price-id.js +26 -0
  94. package/dist/core/prices.generated.d.ts +36 -0
  95. package/dist/core/prices.generated.js +369 -0
  96. package/dist/core/pricing.d.ts +134 -0
  97. package/dist/core/pricing.js +335 -0
  98. package/dist/core/profile-base.d.ts +30 -0
  99. package/dist/core/profile-base.js +67 -0
  100. package/dist/core/provider-router.d.ts +51 -0
  101. package/dist/core/provider-router.js +121 -0
  102. package/dist/core/proxy.d.ts +252 -0
  103. package/dist/core/proxy.js +2929 -0
  104. package/dist/core/reader-tier.d.ts +24 -0
  105. package/dist/core/reader-tier.js +118 -0
  106. package/dist/core/render.d.ts +280 -0
  107. package/dist/core/render.js +1302 -0
  108. package/dist/core/request-guard.d.ts +31 -0
  109. package/dist/core/request-guard.js +126 -0
  110. package/dist/core/request-transform.d.ts +43 -0
  111. package/dist/core/request-transform.js +173 -0
  112. package/dist/core/schema-compiler.d.ts +64 -0
  113. package/dist/core/schema-compiler.js +1696 -0
  114. package/dist/core/schema-strip.d.ts +29 -0
  115. package/dist/core/schema-strip.js +173 -0
  116. package/dist/core/session-state.d.ts +219 -0
  117. package/dist/core/session-state.js +929 -0
  118. package/dist/core/stage-plugins.d.ts +45 -0
  119. package/dist/core/stage-plugins.js +205 -0
  120. package/dist/core/text-history.d.ts +74 -0
  121. package/dist/core/text-history.js +612 -0
  122. package/dist/core/text-hygiene.d.ts +160 -0
  123. package/dist/core/text-hygiene.js +2259 -0
  124. package/dist/core/toon.d.ts +29 -0
  125. package/dist/core/toon.js +425 -0
  126. package/dist/core/tracker.d.ts +223 -0
  127. package/dist/core/tracker.js +290 -0
  128. package/dist/core/transform.d.ts +589 -0
  129. package/dist/core/transform.js +3153 -0
  130. package/dist/core/types.d.ts +87 -0
  131. package/dist/core/types.js +8 -0
  132. package/dist/core/upstream-hosts.d.ts +127 -0
  133. package/dist/core/upstream-hosts.js +398 -0
  134. package/dist/core/vision-cost.d.ts +63 -0
  135. package/dist/core/vision-cost.js +137 -0
  136. package/dist/dashboard/fragments.d.ts +87 -0
  137. package/dist/dashboard/fragments.js +1515 -0
  138. package/dist/dashboard/types.d.ts +217 -0
  139. package/dist/dashboard/types.js +3 -0
  140. package/dist/dashboard/vendor.d.ts +3 -0
  141. package/dist/dashboard/vendor.js +6 -0
  142. package/dist/dashboard.d.ts +372 -0
  143. package/dist/dashboard.js +2731 -0
  144. package/dist/export-collect.d.ts +36 -0
  145. package/dist/export-collect.js +59 -0
  146. package/dist/file-tracker.d.ts +42 -0
  147. package/dist/file-tracker.js +234 -0
  148. package/dist/kosha-sync.d.ts +74 -0
  149. package/dist/kosha-sync.js +272 -0
  150. package/dist/launchd-socket.d.ts +22 -0
  151. package/dist/launchd-socket.js +210 -0
  152. package/dist/mcp/cli.d.ts +2 -0
  153. package/dist/mcp/cli.js +55 -0
  154. package/dist/mcp/server.d.ts +48 -0
  155. package/dist/mcp/server.js +987 -0
  156. package/dist/mmu-store.d.ts +31 -0
  157. package/dist/mmu-store.js +179 -0
  158. package/dist/node-fetch.d.ts +22 -0
  159. package/dist/node-fetch.js +489 -0
  160. package/dist/node.d.ts +9 -0
  161. package/dist/node.js +244396 -0
  162. package/dist/request-decoding.d.ts +30 -0
  163. package/dist/request-decoding.js +85 -0
  164. package/dist/sessions.d.ts +179 -0
  165. package/dist/sessions.js +837 -0
  166. package/dist/stats.d.ts +114 -0
  167. package/dist/stats.js +439 -0
  168. package/dist/turn-report.d.ts +65 -0
  169. package/dist/turn-report.js +724 -0
  170. package/dist/warp/app-launch.d.ts +26 -0
  171. package/dist/warp/app-launch.js +155 -0
  172. package/dist/warp/ca.d.ts +74 -0
  173. package/dist/warp/ca.js +416 -0
  174. package/dist/warp/connect.d.ts +42 -0
  175. package/dist/warp/connect.js +686 -0
  176. package/dist/warp/der.d.ts +57 -0
  177. package/dist/warp/der.js +151 -0
  178. package/dist/warp/index.d.ts +79 -0
  179. package/dist/warp/index.js +650 -0
  180. package/dist/warp/resolve.d.ts +12 -0
  181. package/dist/warp/resolve.js +49 -0
  182. package/dist/warp/route.d.ts +71 -0
  183. package/dist/warp/route.js +134 -0
  184. package/dist/worker.d.ts +71 -0
  185. package/dist/worker.js +174 -0
  186. package/docs/SECURITY_MODEL.md +84 -0
  187. package/package.json +122 -4
  188. package/plugins/fiche-companion/README.md +42 -0
  189. package/plugins/fiche-companion/assets/logo.svg +48 -0
  190. package/plugins/fiche-companion/hooks.json +11 -0
  191. package/plugins/fiche-companion/mcp_config.json +8 -0
  192. package/plugins/fiche-companion/plugin.json +18 -0
  193. package/plugins/fiche-companion/scripts/claude-statusline.mjs +35 -0
  194. package/plugins/fiche-companion/scripts/post-invocation.mjs +122 -0
  195. package/plugins/fiche-companion/scripts/resolve-turn-report.mjs +132 -0
  196. package/plugins/fiche-companion/skills/fiche/SKILL.md +61 -0
@@ -0,0 +1,350 @@
1
+ /**
2
+ * Context-MMU: Virtual Context Memory engine for Fiche (Pure Core — zero `node:` imports).
3
+ *
4
+ * Five deterministic, prefix-cache-safe primitives:
5
+ * 1. `ContextPageStore` + deterministic 64-bit FNV-1a page IDs (`pg_<12hex>`),
6
+ * bounded LRU eviction (`maxPages`, `maxBytes`), inverted symbol/basename index,
7
+ * and pluggable debounced persistence (`MmuPersistenceAdapter`).
8
+ * 2. `extractSymbolSpans` + `inferFilePath` + `extractErrorAnchors`: O(N) line
9
+ * scanner across TS/JS, Python, Go, Rust, Swift, and Java with line-gutter stripping.
10
+ * 3. `computeTailHydration`: read-only speculative live-tail hydration (`±15` lines)
11
+ * from paged-out pages without mutating cached prefixes.
12
+ * 4. `foldMarkovianEpisodes`: Markovian causal episode folding at verified checkpoints
13
+ * (`git commit`, red -> green test passes, PR merge) gated by Kosha payback / cliff avoidance.
14
+ * 5. `linkSessionSkills` & `pruneLowDensityBlob`: Turn-1 pinned skill stubbing with
15
+ * Turn-N auto-hydration, and `<3ms` birth-time information-density prose pruning.
16
+ */
17
+ import type { CacheBreakpointMarker, TextEpochBlock } from './text-history.js';
18
+ /**
19
+ * Horizon-aware online compaction payback gate.
20
+ * At the append frontier (`downstreamCachedTokens <= 0`), admits fast (`>= 16` reads).
21
+ * Mid-prefix (`downstreamCachedTokens > 0`), scales conservatively with observed turns
22
+ * so immature sessions do not pay heavy cache-write penalties prematurely.
23
+ */
24
+ export declare function computeHorizonPaybackLimit(opts: {
25
+ readonly turnsObserved: number;
26
+ readonly baseMaxPayback: number;
27
+ readonly downstreamCachedTokens: number;
28
+ }): number;
29
+ /**
30
+ * Compute deterministic 64-bit FNV-1a digest as 16 lowercase hex chars.
31
+ * Uses two 32-bit lanes with exact IEEE-754 safe integer carry arithmetic
32
+ * (zero `node:crypto`, zero BigInt heap allocations).
33
+ */
34
+ export declare function fnv64Hex(text: string): string;
35
+ /** Deterministic Context-MMU page ID (`pg_<12hex>`) derived from 64-bit FNV-1a. */
36
+ export declare function pageIdForText(text: string): string;
37
+ export type MmuSymbolKind = 'function' | 'method' | 'class' | 'interface' | 'type' | 'struct' | 'enum' | 'trait' | 'impl' | 'protocol' | 'actor' | 'module' | 'const' | 'error' | 'anchor';
38
+ export interface MmuSymbolSpan {
39
+ readonly name: string;
40
+ readonly kind: MmuSymbolKind;
41
+ readonly startLine: number;
42
+ readonly endLine: number;
43
+ }
44
+ /** Infer a source file path from header lines or `refId` if present. */
45
+ export declare function inferFilePath(text: string, refId?: string): string | undefined;
46
+ /** Extract error names and stack frame anchors from text with 1-based line numbers. */
47
+ export declare function extractErrorAnchors(text: string): MmuSymbolSpan[];
48
+ /**
49
+ * O(N) line scanner extracting declarations (TS/JS, Python, Go, Rust, Swift, Java)
50
+ * and error/stack anchors with 1-based `{ name, kind, startLine, endLine }`.
51
+ */
52
+ export declare function extractSymbolSpans(text: string): MmuSymbolSpan[];
53
+ export interface MmuPage {
54
+ readonly id: string;
55
+ readonly sessionKey: string;
56
+ readonly refId: string;
57
+ readonly toolName?: string;
58
+ readonly filePath?: string;
59
+ readonly createdAtMs: number;
60
+ readonly rawText: string;
61
+ readonly lineCount: number;
62
+ readonly symbols: readonly MmuSymbolSpan[];
63
+ readonly factTokens: readonly string[];
64
+ }
65
+ export interface MmuPageSummary extends Omit<MmuPage, 'rawText'> {
66
+ readonly chars: number;
67
+ }
68
+ export interface MmuStats {
69
+ pagesStored: number;
70
+ pagesEvicted: number;
71
+ totalRawChars: number;
72
+ activePages: number;
73
+ activeBytes: number;
74
+ tailHydrations: number;
75
+ tailHydrationTokens: number;
76
+ markovFolds: number;
77
+ markovFoldedChars: number;
78
+ skillsStubbed: number;
79
+ skillStubSavedChars: number;
80
+ densityPrunedBlocks: number;
81
+ densityPrunedChars: number;
82
+ }
83
+ export interface MmuPersistenceAdapter {
84
+ load(): string | undefined;
85
+ save(json: string): void;
86
+ }
87
+ export interface ContextPageStoreOptions {
88
+ readonly maxPages?: number;
89
+ readonly maxBytes?: number;
90
+ readonly debounceMs?: number;
91
+ readonly persistence?: MmuPersistenceAdapter;
92
+ }
93
+ export interface StorePageInput {
94
+ readonly sessionKey?: string;
95
+ readonly refId?: string;
96
+ readonly rawText: string;
97
+ readonly toolName?: string;
98
+ readonly filePath?: string;
99
+ readonly nowMs?: number;
100
+ readonly extraSymbols?: readonly string[];
101
+ }
102
+ export interface DerefPageOptions {
103
+ readonly sessionKey?: string;
104
+ readonly startLine?: number;
105
+ readonly endLine?: number;
106
+ readonly query?: string;
107
+ readonly maxLines?: number;
108
+ }
109
+ export interface DerefPageResult {
110
+ readonly page: MmuPage;
111
+ readonly text: string;
112
+ readonly startLine: number;
113
+ readonly endLine: number;
114
+ }
115
+ export interface MmuPageSearchHit {
116
+ readonly page: MmuPageSummary;
117
+ readonly score: number;
118
+ readonly matchedSymbols: readonly MmuSymbolSpan[];
119
+ readonly matchedLine: number;
120
+ }
121
+ export declare class ContextPageStore {
122
+ maxPages: number;
123
+ maxBytes: number;
124
+ private readonly debounceMs;
125
+ /** LRU map keyed by `${sessionKey}\0${id}` (insertion order = LRU -> MRU). */
126
+ private readonly entries;
127
+ /** Fast pageId -> latest entryKey lookup (one pageId can exist under multiple sessions). */
128
+ private readonly keysByPageId;
129
+ /** Inverted index: lowercased symbol / basename -> page IDs. */
130
+ readonly symbolIndex: Map<string, Set<string>>;
131
+ /** Session index: sessionKey -> page IDs. */
132
+ readonly sessionIndex: Map<string, Set<string>>;
133
+ private totalBytes;
134
+ private stats;
135
+ private persistence;
136
+ private saveTimer;
137
+ private dirty;
138
+ /** Per-session Context-TLB leases: sessionKey -> (pageId -> { startLine, endLine, turn }). */
139
+ private readonly hydrationTlb;
140
+ /** Per-session logical hydration turn counter (bounded to 512 LRU sessions). */
141
+ private readonly hydrationTurn;
142
+ constructor(options?: ContextPageStoreOptions);
143
+ /** Attach or detach persistence adapter, restoring saved pages fail-open. */
144
+ configurePersistence(adapter: MmuPersistenceAdapter | undefined): number;
145
+ private scheduleSave;
146
+ /** Immediately write pending updates to the configured persistence adapter. */
147
+ flush(): boolean;
148
+ /** Serialize current store state in LRU order (oldest first), skipping expired or secret-bearing pages. */
149
+ serialize(nowMs?: number): string;
150
+ /** Restore serialized pages into the store (in-memory entries win on collision; drops expired or secret-bearing records). */
151
+ restore(json: string | undefined, nowMs?: number): number;
152
+ private touchEntry;
153
+ private addIndexes;
154
+ private removeIndexes;
155
+ private evictOldest;
156
+ private insertEntry;
157
+ /**
158
+ * Store a paged-out block into Context-MMU.
159
+ * Reuses an existing entry with identical `id` under `sessionKey` (no-op, refreshes LRU).
160
+ */
161
+ storePage(input: StorePageInput): MmuPage;
162
+ private resolveEntryByPageId;
163
+ /** Dereference a stored page by ID with optional sessionKey boundary, line range, or focused query. */
164
+ derefPage(pageId: string, opts?: DerefPageOptions): DerefPageResult | null;
165
+ /** List stored page metadata (no `rawText`), strictly scoped when `sessionKey` is provided. */
166
+ listPages(sessionKey?: string): MmuPageSummary[];
167
+ /** Search resident pages by symbol name, file path, fact token, or text content. */
168
+ searchPages(query: string, sessionKey?: string): MmuPageSearchHit[];
169
+ /** Lookup page IDs indexed for a lowercased symbol or basename key. */
170
+ lookupSymbolPageIds(symbolOrBasename: string, sessionKey?: string): string[];
171
+ /** O(1) resident page count (optionally scoped to one session). */
172
+ getSessionPageCount(sessionKey?: string): number;
173
+ /** Retrieve raw page object by ID (optional sessionKey preference) without modifying text. */
174
+ getPage(pageId: string, sessionKey?: string): MmuPage | null;
175
+ /**
176
+ * Append a clean, idempotent Virtual Memory page card to a compact digest.
177
+ */
178
+ formatPageCard(page: MmuPage, compactDigest: string): string;
179
+ recordTailHydration(tokens: number): void;
180
+ recordMarkovFold(foldedChars: number): void;
181
+ recordSkillStub(stubbedCount: number, savedChars: number): void;
182
+ recordDensityPrune(prunedChars: number): void;
183
+ getStats(): MmuStats;
184
+ /** Return active page/RAM bounds and whether disk persistence is attached. */
185
+ getLimits(): {
186
+ readonly maxPages: number;
187
+ readonly maxBytes: number;
188
+ readonly persisted: boolean;
189
+ };
190
+ /**
191
+ * Update page/byte bounds dynamically and evict oldest pages if the store
192
+ * currently exceeds the new limits.
193
+ */
194
+ setLimits(opts: {
195
+ maxPages?: number;
196
+ maxBytes?: number;
197
+ }): void;
198
+ /** Increment and return the per-session logical hydration turn counter (LRU-bounded to 512 sessions). */
199
+ nextHydrationTurn(sessionKey: string): number;
200
+ /**
201
+ * Return true iff an overlapping slice on `pageId` (`±4` lines) was already
202
+ * hydrated for `sessionKey` within the last `cooldownTurns` logical turns.
203
+ */
204
+ isTlbSuppressed(sessionKey: string, pageId: string, startLine: number, endLine: number, turn: number, cooldownTurns?: number): boolean;
205
+ /** Record/refresh a Context-TLB hydration lease (LRU-bounded to 64 leases per session). */
206
+ recordHydrationLease(sessionKey: string, pageId: string, startLine: number, endLine: number, turn: number): void;
207
+ reset(): void;
208
+ }
209
+ export declare function getGlobalMmuStore(): ContextPageStore;
210
+ /**
211
+ * Configure the global Context-MMU RAM limits (clamped to `[64, 16384]` pages
212
+ * and `[4 MiB, 256 MiB]` bytes), evicting oldest pages immediately if shrunk.
213
+ */
214
+ export declare function configureMmuLimits(opts: {
215
+ maxPages?: number;
216
+ maxBytes?: number;
217
+ }): {
218
+ maxPages: number;
219
+ maxBytes: number;
220
+ };
221
+ export declare function configureMmuPersistence(adapter?: MmuPersistenceAdapter): number;
222
+ export declare function flushMmuPersistence(): boolean;
223
+ export declare function resetGlobalMmuStore(): void;
224
+ export interface TailHydrationInput {
225
+ readonly store: ContextPageStore;
226
+ readonly sessionKey?: string;
227
+ readonly liveTailTexts: readonly string[];
228
+ readonly recentVerbatimTexts?: readonly string[];
229
+ readonly budgetTokens?: number;
230
+ readonly maxSlices?: number;
231
+ }
232
+ export interface TailHydrationSlice {
233
+ readonly pageId: string;
234
+ readonly refId: string;
235
+ readonly filePath?: string;
236
+ readonly matchedSymbol: string;
237
+ readonly startLine: number;
238
+ readonly endLine: number;
239
+ readonly text: string;
240
+ readonly tokens: number;
241
+ }
242
+ export interface TailHydrationResult {
243
+ readonly text: string;
244
+ readonly changed: boolean;
245
+ readonly slices: readonly TailHydrationSlice[];
246
+ readonly totalTokens: number;
247
+ }
248
+ /**
249
+ * Intent-stratified tool-output filter for SB-SMP: returns the trailing
250
+ * snippet only when a tool output carries an active fault/stack signal or
251
+ * explicit `pg_*` page pointer, preventing routine `read_file` outputs from
252
+ * triggering speculative hydrations on passing turns.
253
+ */
254
+ export declare function extractFaultSignalSnippet(toolText: string, maxChars?: number): string | undefined;
255
+ /**
256
+ * Purely read-only Symbol-Boundary-Aware Speculative MMU Prefetcher (SB-SMP).
257
+ * Fuses `pg_*`, declaration spans, error anchors, basenames, and skill matches
258
+ * with exact session IDF weighting; preserves full enclosing function bodies
259
+ * up to ~45 lines; never modifies cached prefixes; fails closed without `sessionKey`.
260
+ */
261
+ export declare function computeTailHydration(input: TailHydrationInput): TailHydrationResult;
262
+ export interface FoldMarkovianEpisodesArgs {
263
+ readonly blocks: readonly TextEpochBlock[];
264
+ readonly totalMessages: number;
265
+ readonly keepTailMessages?: number;
266
+ readonly sessionKey?: string;
267
+ readonly model?: string;
268
+ readonly sessionCacheCold?: boolean;
269
+ readonly store?: ContextPageStore;
270
+ readonly expectedOutputTokens?: number;
271
+ readonly ttlSec?: number;
272
+ readonly msgTotalTokens?: readonly number[];
273
+ readonly cacheBreakpoints?: readonly CacheBreakpointMarker[];
274
+ readonly totalPromptTokens?: number;
275
+ /** When true, only replay already-folded sticky episodes without folding new spans. */
276
+ readonly stickyOnly?: boolean;
277
+ }
278
+ export interface FoldMarkovianEpisodesResult {
279
+ readonly changed: boolean;
280
+ readonly foldedEpisodes: number;
281
+ readonly foldedBlocks: number;
282
+ readonly savedChars: number;
283
+ readonly savedTokens: number;
284
+ readonly episodeIds: readonly string[];
285
+ }
286
+ /** True when a tool name represents a file/resource read whose contents must not trigger checkpoints or whitespace rewrites. */
287
+ export declare function isFileReadToolName(name: string | undefined): boolean;
288
+ /** O(1) check for whether this session has ever folded a Markovian episode. */
289
+ export declare function hasAnyStickyMarkovEpisode(sessionKey?: string): boolean;
290
+ /** Test helper: clear sticky Markovian episode seal memory. */
291
+ export declare function clearStickyMarkovEpisodesForTests(): void;
292
+ /**
293
+ * Fold completed intermediate debugging spans preceding Markovian checkpoints
294
+ * (`git commit`, red -> green verification, PR merge) into deterministic causal
295
+ * certificates while preserving the checkpoint block and raw pages in `ContextPageStore`.
296
+ */
297
+ export declare function foldMarkovianEpisodes(args: FoldMarkovianEpisodesArgs): FoldMarkovianEpisodesResult;
298
+ export interface PinnedSkillStore {
299
+ get(sessionKey: string, catalogHash: string): readonly string[] | undefined;
300
+ set(sessionKey: string, catalogHash: string, skills: readonly string[]): void;
301
+ }
302
+ export interface LinkSessionSkillsInput {
303
+ readonly text: string;
304
+ readonly firstUserText: string;
305
+ readonly sessionKey?: string;
306
+ readonly store?: ContextPageStore;
307
+ readonly pinnedStore?: PinnedSkillStore;
308
+ readonly maxVerbatim?: number;
309
+ readonly minSkills?: number;
310
+ readonly alwaysKeep?: readonly string[];
311
+ readonly workspaceHints?: readonly string[];
312
+ }
313
+ export interface LinkSessionSkillsResult {
314
+ readonly text: string;
315
+ readonly changed: boolean;
316
+ readonly catalogHash?: string;
317
+ readonly keptSkills: readonly string[];
318
+ readonly stubbedSkills: readonly string[];
319
+ readonly savedChars: number;
320
+ readonly savedTokens: number;
321
+ }
322
+ /**
323
+ * Stub low-relevance skill descriptions in large skill catalogs (`>= 10` skills),
324
+ * pinning Turn-1 selection per `(sessionKey, catalogHash)` and archiving full entries
325
+ * in `ContextPageStore` so mentioning a stubbed skill on Turn N triggers tail hydration.
326
+ */
327
+ export declare function linkSessionSkills(input: LinkSessionSkillsInput): LinkSessionSkillsResult;
328
+ export interface PruneLowDensityOptions {
329
+ readonly store?: ContextPageStore;
330
+ readonly sessionKey?: string;
331
+ readonly refId?: string;
332
+ readonly toolName?: string;
333
+ readonly minChars?: number;
334
+ readonly targetDropRatio?: number;
335
+ }
336
+ export interface PruneLowDensityResult {
337
+ readonly text: string;
338
+ readonly changed: boolean;
339
+ readonly pageId?: string;
340
+ readonly prunedLines: number;
341
+ readonly totalLines: number;
342
+ readonly savedChars: number;
343
+ }
344
+ /**
345
+ * Deterministic, pure-TS `<3ms` birth-time extractive pruner for large
346
+ * unstructured prose/web blobs (`>= 4,000` chars). Archives full raw text in
347
+ * `ContextPageStore` and drops the bottom redundant lines (~45%–55% reduction).
348
+ */
349
+ export declare function pruneLowDensityBlob(text: string, opts?: PruneLowDensityOptions): PruneLowDensityResult;
350
+ //# sourceMappingURL=context-mmu.d.ts.map