/** * Heading-aware document chunker. * * `chunk()` is the size-based sliding-window primitive — kept as the * low-level splitter that operates within a single heading section. * * `chunkDocument()` is the real entry point: it walks the document, * splits on heading boundaries first, preserves fenced code blocks * intact, classifies each segment (frontmatter / heading / paragraph / * code / list), attaches the heading_path breadcrumb, and only then * size-splits oversized segments. This gives retrieval real metadata * to rank on (heading_path match, chunk_type filter, title boost). * * Boundaries are preserved in absolute char offsets against the input * text so callers can slice back into the source if needed. The * (char_start, char_end) range is byte-faithful to the original input — * text.slice(char_start, char_end) returns the exact source bytes * including any CR, original line separators, and surrounding whitespace * that the chunker trimmed when building chunk.text. The chunk.text * itself is the trimmed/normalized content; rely on the slice for * byte-exact recovery. */ export type ChunkType = "heading" | "paragraph" | "code" | "list" | "frontmatter"; export interface Chunk { index: number; char_start: number; char_end: number; text: string; heading_path: string[]; chunk_type: ChunkType; } export interface ChunkOptions { chunk_chars: number; chunk_overlap: number; } export declare const DEFAULT_CHUNK: ChunkOptions; export interface ChunkedDocument { title: string | null; chunks: Chunk[]; } interface RawChunk { index: number; char_start: number; char_end: number; text: string; } /** * Primitive size-based sliding-window splitter. Used internally by * chunkDocument() to size-split oversized heading sections; also exposed * so existing tests can exercise window math directly. */ export declare function chunk(text: string, opts?: ChunkOptions): RawChunk[]; /** * Heading-aware document chunker. * * Behavior: * - YAML frontmatter at the very top becomes a single "frontmatter" chunk. * - Every markdown heading (# through ######) updates a depth-indexed * stack; chunks inherit the heading_path of the section they sit in. * - Fenced code blocks (``` or ~~~) are preserved intact — never split. * - Non-code sections are classified as "list" if majority of non-empty * lines are list items, else "paragraph". * - Sections that exceed chunk_chars are size-split via chunk() with * overlap; sub-chunks inherit the parent's heading_path + type. * - Title = first H1 heading after frontmatter, else null. */ export declare function chunkDocument(text: string, opts?: ChunkOptions): ChunkedDocument; export {}; //# sourceMappingURL=chunker.d.ts.map