import type { TokenCounter } from './types.js'; /** * The prefix length below which unifying buys nothing, and `Infinity` when there * is no answer. * * Lives here rather than in the CLI because it is the gate on this whole report * and a gate with no test is decoration. It was a private function in the CLI * first; a mutation run deleting the `unknown` branch survived, which is what a * function nothing can reach looks like from the outside. * * `unknown` and a missing minimum both yield `Infinity`, so nothing is reported. * That is the direction to fail: telling somebody to unify a preamble across * twelve files to enable caching their provider may not offer spends their * afternoon, and unlike a wrong number on a report nothing later corrects it. */ export declare function cacheableMinimum(model: { caching?: string | null; cacheMinTokens?: number | null; } | undefined): number; export interface PrefixCandidate { /** How the report names it. A path, or a path with a marked prompt's id. */ path: string; text: string; } export interface SharedPrefix { /** Every prompt in the group, in the order they were given. */ paths: string[]; /** Blocks the group has in common, counted from the start. */ blocks: number; /** Estimated tokens in that prefix, as the first prompt writes it. */ tokens: number; /** * What stops the prefixes being byte-identical today. * * `whitespace` — collapsing runs of whitespace makes them equal, so a * formatter fixes it and no wording decision is needed. * `wording` — something else differs: capitalisation, punctuation, word order, * or genuinely different words. Someone has to choose. */ drift: 'whitespace' | 'wording'; /** The shared prefix as the first prompt in the group writes it. */ sample: string; } export interface SharedPrefixOptions { /** * The model's cacheable minimum. A shared prefix below it buys nothing, so it * is not reported — the same refusal `reorder.ts` makes, for the same reason: * a change that recovers nothing is a diff for its own sake. */ minTokens?: number; countTokens?: TokenCounter; } /** * Groups of prompts that could share a cache prefix and do not. * * Grouped by their **first** block, which is not a shortcut. Caching matches from * the beginning of the request, so two prompts whose opening paragraphs differ * share nothing no matter how identical the rest is — a group keyed on anything * later would name prompts that cannot be made to share a prefix without * reordering them, which is a different and far more dangerous change. */ export declare function sharedPrefixes(prompts: readonly PrefixCandidate[], options?: SharedPrefixOptions): SharedPrefix[]; //# sourceMappingURL=shared-prefix.d.ts.map