/** * Serialized, crash-atomic persistence for the small user-level JSON files * under the DSH home (statusline.json, theme.json). Two guarantees the bare * floating `writeFile` path could not give: * * 1. Every save is appended to ONE chain, so rapid consecutive edits land * in submission order and the last snapshot is the one on disk (parallel * floating writes let an older snapshot finish last and win). * 2. Each write goes to a sibling temp file first and is renamed into * place, so a crash mid-write can never leave a half-written JSON * document behind. * * The chain itself never rejects: a failed write is reported to that * save's caller while later saves keep their turn. * * @module @deepseek-ai/dsh-code/settings-file */ /** * Write one file atomically: create the parent directory, write to a * uniquely named temp file, and rename it into place. A crash midway * can never leave a half-written document behind. Unique temp names * keep concurrent writers (two terminals, two chains in one process) * from sharing one temp path. */ export declare function writeFileAtomically(path: string, text: string): Promise; /** The serialized persistence surface; flush() is handed to the quit sequence. */ export interface UserSettingsPersistence { /** * Queue one file snapshot. Resolves when the chain reaches (and renames) * it; rejects only to THIS caller when its own write failed. */ save(path: string, text: string): Promise; /** Wait for every queued write; safe to call repeatedly. */ flush(): Promise; } /** * Create the shared settings-write chain. One instance per process keeps * every user-level JSON file mutually serialized. * @returns the persistence handle. */ export declare function createUserSettingsPersistence(): UserSettingsPersistence; /** * Read one user-level settings file as a plain object. The callers all treat a * missing file as "unset" and a corrupt one as "warn and fall back", so this * helper owns the one distinction they share: readable JSON that is not an * object is corruption, not an absent preference, and must not surface as a * cryptic property access on `null`. * @param path - absolute path of the settings file. * @returns the parsed object; the caller narrows each field itself. */ export declare function readSettingsObject(path: string): Record;