/** * Safe merge of an OpenLore-managed entry into a JSON config file. * * We store our additions under a top-level `_openlore` key for bookkeeping * (fingerprint of the merged subtree, version), while writing the actual * config under whatever path the host tool reads (e.g. `mcpServers.openlore`, * `hooks.SessionStart`). The fingerprint lets us detect hand-edits. */ import { type FormattingOptions } from 'jsonc-parser'; /** A minimal edit into an existing JSON document: set `path` to `value`, or delete it when `value` is undefined. */ export interface JsonPathEdit { path: (string | number)[]; value: unknown; } /** Infer indent unit + line ending from an existing JSON file so edits match the user's style. */ export declare function detectJsonFormatting(text: string): FormattingOptions; /** * Apply path edits to an existing JSON document's TEXT, preserving the formatting of every * region OpenLore does not touch (indent style, key order, spacing, untouched values). Only * the edited paths are re-rendered, using formatting detected from the original. This replaces * reparse→`JSON.stringify` writes, which reformat the user's whole file (decision df27e8ef). */ export declare function editJsonPreservingFormat(originalText: string, edits: JsonPathEdit[]): string; export interface ManagedJsonMeta { managed: true; version: number; fingerprint: string; /** * Dotted paths into the JSON document that OpenLore manages. Used by * `--uninstall` to remove only what we added. */ paths: string[]; } export declare function canonicalJsonHash(value: unknown): string; export interface ManagedEntry { /** Dotted path into the JSON document (e.g. "mcpServers.openlore"). */ path: string; /** Value to write at that path. */ value: unknown; } export interface MergeResult { next: Record; action: 'created' | 'updated' | 'noop'; /** If the existing meta fingerprint didn't match what was on disk. */ handEdited: boolean; } export declare function readMeta(doc: Record): ManagedJsonMeta | null; /** * Verify the meta fingerprint still matches the values we previously wrote. * If not, the user has hand-edited one of our managed paths. */ export declare function isHandEdited(doc: Record, meta: ManagedJsonMeta): boolean; export declare function mergeEntries(existing: Record, entries: ManagedEntry[]): MergeResult; export declare function removeManaged(doc: Record): { next: Record; removed: boolean; }; //# sourceMappingURL=json-managed.d.ts.map