import type { FileTextEnvelope } from "./types.ts"; /** * Split canonical content into its logical lines — the single shared line * model used by read, edit, and diff. * * A file's lines are the content delimited by "\n", where ONE trailing "\n" * terminates the last line instead of producing an extra empty line: * "" → [] (empty file: zero lines) * "\n" → [""] (one empty line) * "a\nb\n" → ["a", "b"] * "a\nb" → ["a", "b"] * "a\n\n" → ["a", ""] ("a" followed by one blank line) * * Keeping this in one place guarantees hashline_read's totalLines/hashWidth, * anchor validation, and edit application all agree on line identity — the * trailing-newline/line-count mismatch that previously made exactly-1000-line * files uneditable and anchored appends misbehave. */ export declare function splitLines(content: string): string[]; /** * Determine hash width based on file line count. * Auto-escalates: 2 chars (≤1000 lines) → 3 chars (≤10000) → 4 chars (>10000). * Can be overridden by ROLEBOX_HASHLINE_WIDTH env var. */ export declare function hashWidthForLineCount(lineCount: number): number; /** * Compute a content-based hash for a single line. * Uses SHA-256 of the trimmed content, then base-64 encodes to `width` chars. * * The hash is stable: same content + same width → same hash. * Symbol-only lines (whitespace, braces) get line-number-seeded hashing * to differentiate identical-looking lines at different positions. */ export declare function computeLineHash(content: string, width: number, lineNumber?: number): string; /** * Compute the SHA-256 hex digest of entire file content. * Used as a whole-file version guard to detect external modifications. */ export declare function computeFileVersion(content: string): string; /** * Format a single line with its hash annotation. * Output: "LINE#HASH|content" */ export declare function formatHashLine(lineNumber: number, content: string, width: number): string; /** * Format all lines in a file with hash annotations. */ export declare function formatHashLines(lines: string[], width: number): string[]; /** * Canonicalize file text: strip BOM, normalize line endings to \n. * Returns the canonicalized content and metadata for later restoration. */ export declare function canonicalizeFileText(rawContent: string): FileTextEnvelope; /** * Restore file text to its original encoding (re-add BOM, restore line endings). * * Rebuilds from the canonical content's "\n"-split segments: a split point * follows segment i iff it is not the last segment, and that terminator is * lineEols[i] when one was recorded for the original line ("\r\n" or "\n"). * Segments beyond the original line count (inserted/appended content) fall * back to the envelope's uniform line ending — identical to the pre-D10 * restore for those positions. A "" entry (original unterminated last line) * adds no terminator. */ export declare function restoreFileText(content: string, envelope: FileTextEnvelope): string; //# sourceMappingURL=hash.d.ts.map