export type Kind = 'text' | 'json'; /** * Returns 'json' for paths whose contents are structurally JSON (.json, * .codeblock). All other extensions are 'text', including .toml — TOML files * are line-oriented enough that text normalization suffices. */ export declare function kindForPath(path: string): Kind; /** * Recursively sort object keys. Arrays and primitives are returned as-is. * Used to canonicalize JSON before hashing so `{"a":1,"b":2}` and * `{"b":2,"a":1}` hash identically. */ export declare function sortKeysDeep(value: T): T; /** * Normalize content for stable cross-platform hashing. * 1. UTF-8 decode + BOM strip * 2. CRLF and standalone CR → LF * 3. Ensure final newline * 4. JSON kind: parse + sortKeysDeep + 2-space stringify (fallback to text on parse fail) */ export declare function normalize(buf: Buffer | string, kind: Kind): string; /** * Normalized sha256 truncated to 16 hex chars (64-bit). Collision probability * 2⁻⁶⁴ — negligible at workspace scale. */ export declare function sha8Normalized(buf: Buffer | string, kind: Kind): string; export declare const MARKER_OPEN = ""; export declare const MARKER_CLOSE = ""; export type MergeAction = 'create' | 'noop' | 'merged' | 'prepended' | 'skip_orphan'; export interface MergeResult { action: MergeAction; /** New file content, or null when action === 'skip_orphan'. */ content: string | null; /** Diagnostic, populated for 'skip_orphan'. */ reason?: string; } /** * Detect orphan markers (an OPEN without matching CLOSE, a CLOSE before OPEN, * nested OPEN markers, or any other unbalanced marker order). Returns true * when the file is unsafe to auto-merge. */ export declare function orphanMarkerDetected(disk: string): boolean; /** * - disk = null → create a fresh file containing only the block. * - block exists in disk → replace its interior with desiredBody. * - block absent + disk non-empty → prepend the block, keep user content below. * - orphan markers → return skip_orphan, content=null, leave caller to surface. */ export declare function mergeMarkerBlock(disk: string | null, desiredBody: string): MergeResult; /** * Items present in `prev` but not in `desired`. Stable string-sorted output. * Generic over string sets — used for hook topics, file paths, skill names. */ export declare function diffOrphans(prev: readonly string[], desired: readonly string[]): string[];