import type { LyseConfig, StoryIndex, TokenMap } from "../types.js"; import type { DesignSystemGraph } from "../graph/types.js"; /** * Repo-level context an `audit_file` call needs: the token registry, the story * index, and the parsed config. Loading these scans the whole project tree, so * on a Carbon-scale repo (~500 components) doing it on EVERY single-file audit * blows the MCP P95 budget. This cache reuses the context across calls within a * short TTL (the MCP hot path is a burst of audits on one project), bounding * staleness while keeping per-call cost flat. */ export interface ProjectContext { tokens: TokenMap | null; storyIndex: StoryIndex | null; config: LyseConfig; graph: DesignSystemGraph; } export interface ContextCacheOptions { /** * Max age (ms) before a cached entry is reloaded. Bounds staleness if tokens * or config change mid-session. A watch daemon can pass a long TTL and call * {@link clearProjectContextCache} on filesystem events instead. */ ttlMs: number; } /** * Returns the (possibly cached) project context for `projectRoot`. Within the * TTL the exact same object is returned; otherwise it is reloaded. Concurrent * calls during a cold load are NOT deduped (kept simple) — the last write wins * and both callers get a valid context. */ export declare function getProjectContext(projectRoot: string, opts?: ContextCacheOptions): Promise; /** Drops all cached contexts. Call on filesystem changes (watch daemon) or in tests. */ export declare function clearProjectContextCache(): void; /** Number of cached project roots (test/diagnostic helper). */ export declare function _contextCacheSize(): number;