/** Default context budget (tokens) above which agent prompts start paying long-context cost. */ export declare const DEFAULT_CONTEXT_BUDGET_TOKENS = 40000; /** One context file's footprint. `tokens` is an estimate (bytes / 4). */ export interface ContextFile { /** Repo-relative path, POSIX separators. */ path: string; bytes: number; tokens: number; } /** Options for {@link scanContextBloat} — keep the scan sync + pure (no async git). */ export interface ScanOptions { /** * Keep only paths this predicate accepts (repo-relative POSIX). Default: keep * all. Callers pass a gitignore-honoring allowlist (computed async via the * Runner) so the footprint doesn't double-count generated copies or ignored files. */ accept?: (rel: string) => boolean; /** * Count OS metadata (`.DS_Store` and peers) as context. Default false — it is never * agent instruction. `--all-files` sets this true to keep its documented * "every file on disk" contract literal (issue #553). */ includeOsMetadata?: boolean; } /** The agent context an AI CLI loads from this repo, with an estimated token footprint. */ export interface ContextBloat { /** Every context file found, sorted by path for deterministic digests. */ files: ContextFile[]; totalBytes: number; totalTokens: number; budgetTokens: number; overBudget: boolean; } export interface TokenOptimizationSlice { paths: string[]; files: number; bytes: number; tokens: number; } export interface TokenOptimizationIndex { legacy: TokenOptimizationSlice; contract: TokenOptimizationSlice; savedTokens: number; reductionPct: number; } /** Rough token estimate for a byte count (~4 chars/token). Shared with the load-group model. */ export declare function estimateTokens(bytes: number): number; /** * One file's footprint, or `undefined` if it is missing / not a regular file. * The single per-file primitive both `scanContextBloat` (full inventory) and the * load-group model build on, so they share one tokenizer. */ export declare function fileFootprint(root: string, rel: string): ContextFile | undefined; /** * Token-Optimization Index (TOI): compare the legacy always-loaded family against * the compact v1 contract target using the SAME `scanContextBloat().files` * inventory. Missing files count in neither side; no contents are read here. */ export declare function tokenOptimizationIndex(files: readonly ContextFile[], contextDir: string): TokenOptimizationIndex; /** * Scan `root` for the agent context an AI CLI loads — root bootloaders, the * canonical context dir (`contextDir`) tree, and every registry-declared rule tree — and * estimate its token footprint (bytes / 4). Pure: reads file *sizes* only (never * contents), touches no network, mutates nothing; returns repo-relative POSIX * paths sorted by path so the rendered digest is byte-stable across runs. */ export declare function scanContextBloat(root: string, contextDir: string, budgetTokens?: number, opts?: ScanOptions): ContextBloat;