/** * Shared atomic JSON file I/O utility. * * Previously duplicated across 10+ files with the same * writeFileSync(tmp) + renameSync(tmp, path) pattern: * - mcp-tools/neural-tools.ts * - memory/intelligence.ts * - autopilot-state.ts * - commands/claims.ts * - commands/swarm.ts * - commands/neural-optimize.ts * - commands/neural-registry.ts * - commands/agent-lifecycle.ts * - commands/memory-admin.ts * - commands/memory-list.ts * - commands/security-cve.ts * * This is the single canonical implementation. Uses atomic * rename to prevent partial writes on crash. */ /** * Read and parse a JSON file. Returns `fallback` if file doesn't exist, * exceeds maxBytes, or fails to parse. */ export declare function readJsonFileSync(filePath: string, fallback: T, maxBytes?: number): T; /** * Hardened JSON store loader that distinguishes "absent" from "corrupt". * * - File absent → returns `emptyDefault` (safe to build on and save back) * - File present and valid → returns the parsed value * - File present but corrupt/oversized/__proto__ → returns null * * Write handlers MUST use this and bail on null — otherwise a transient * read failure silently wipes the store on the next save. */ export declare function readJsonStoreOrNull(filePath: string, emptyDefault: T, label: string, maxBytes?: number): T | null; /** * Atomically write a JSON value to disk. * * Writes to a temporary file first (PID + timestamp suffix to avoid * collisions), then renames into place. Ensures the directory exists. */ export declare function writeJsonFileAtomic(filePath: string, data: unknown, pretty?: boolean): void; /** * Merge `incoming` records into `existing` by `id`, keeping existing records * in place and appending only the ones not already present. Shared by * `hooks intelligence import` (file pattern import) and `hooks transfer` * (cross-project pattern transfer) so both use one dedupe rule. */ export declare function mergeRecordsById(existing: T[], incoming: T[]): { merged: T[]; added: T[]; }; //# sourceMappingURL=json-file.d.ts.map