/** * src/cache.ts — Local filesystem cache paths + tiny JSON helpers. * * Ownership layout (everything under `~/.skillfm/beacon-mcp/`): * - rules-v{N}.json cached brain rule snapshot (stale-while-revalidate) * - user-prefs.json UserPreferences from contract §9 * - session-cache.db suggestion dedupe + frequency-limit ledger (sqlite stub) * - config.json agent token + apiBaseUrl (read by config.ts) * * Phase 0 keeps everything as JSON files — no real sqlite dependency to keep * the npm tarball minimal. Session dedupe lives in-memory for now. * * TODO Week 5: * - Open session-cache.db with `better-sqlite3` (lazy import to avoid * making it a hard dep on agents that never use frequency limits). * - Add atomic write helper (write to .tmp, rename) so MCP server kill * mid-flush never corrupts user-prefs.json. * - Add file-lock so two parallel MCP servers (Cursor + Claude Code on same * mac) don't race on user-prefs.json — `proper-lockfile` candidate. * - Add migration: rules-v1.json → rules-v2.json when contract version bumps. */ import { type UserPreferences } from './_vendored-contracts/beacon-mcp-tools-v1.js'; export declare const BEACON_HOME: string; export declare const RULES_FILE: string; export declare const USER_PREFS_FILE: string; export declare const SESSION_CACHE_DB: string; export declare const SAVINGS_LEDGER_FILE: string; export declare const DEFAULT_USER_PREFERENCES: UserPreferences; export interface CachedRulesEnvelope { /** ISO 8601 timestamp at which rules were fetched from brain */ fetchedAt: string; /** Brain-issued rule revision */ revision: number; /** Opaque rule blob — schema owned by beacon-rule-protocol-v1 (Week 5) */ rules: Record; } export declare function loadRules(): CachedRulesEnvelope | null; export declare function saveRules(envelope: CachedRulesEnvelope): void; export declare function loadPrefs(): UserPreferences; export declare function savePrefs(prefs: UserPreferences): void; /** * Phase 0 stub — returns a hand-rolled in-memory map. Week 5 will swap to * better-sqlite3. The shape is intentionally minimal so callers can be * rewritten without changing call sites. */ export interface SessionCacheHandle { /** Returns true if the same suggestion fired within the dedupe window. */ hasRecentSuggestion(key: string, withinMs: number): boolean; recordSuggestion(key: string): void; /** Number of suggestions emitted in the current session (for maxPerSession). */ sessionCount(): number; reset(): void; } export declare function openSessionCache(): SessionCacheHandle; //# sourceMappingURL=cache.d.ts.map