export declare const CORTEX_SECTION_START = ""; export declare const CORTEX_SECTION_END = ""; /** * Back up `filePath` if it exists and is outside the Cortex perimeter. * Returns the backup path, or null when no backup was made. */ export declare function backupFile(filePath: string): string | null; /** * Overwrite `filePath` with `content`, backing up any existing file first. * Use for plain-text files that are legitimately fully rewritten (.env, ...). */ export declare function safeWrite(filePath: string, content: string): string | null; /** * Read → mutate → write a JSON file. Missing or corrupt files parse to `{}` * instead of throwing, so Cortex never wipes a user's config on bad JSON. * `mutate` may return the new object or mutate in place (return void). */ export declare function safeWriteJson(filePath: string, mutate: (data: T) => T | void): string | null; export interface SectionMarkers { start: string; end: string; } /** * Merge `body` into `filePath` as a delimited section instead of overwriting * the file. If a section with the given markers already exists it is replaced * in place; otherwise the section is appended. Backs up any existing file. * * `markers.start` may be a prefix (the real start line can carry a trailing * timestamp/comment) — everything from the first occurrence of `markers.start` * up to and including `markers.end` is treated as the managed section. * When `wrap` is false, `body` is assumed to already contain the markers and * is written verbatim into the managed region. */ export declare function safeMergeSection(filePath: string, body: string, opts?: { markers?: SectionMarkers; wrap?: boolean; }): string | null; /** * Remove a delimited section (everything from the first occurrence of * `markers.start` up to and including `markers.end`) from `filePath`, backing up * the existing file first. The inverse of safeMergeSection — used by * `cortex uninstall` to strip Cortex-managed blocks from a user's CLAUDE.md * without touching the rest of the file. Returns whether a section was removed * and the backup path (null when the file/section was absent). */ export declare function safeRemoveSection(filePath: string, markers: SectionMarkers): { removed: boolean; backup: string | null; };