/** * Markdown-aware section chunker for the chunk-level search index * (`fs_blob_chunks`). Pure text → chunks; no SQL, no model calls. * * Design (card #2, from the chunking research on card #1): * - The chunk unit is a heading-bounded markdown section; a document with no * headings that fits the budget is a single whole-page chunk. * - Oversized sections split at paragraph boundaries, and a paragraph that * alone exceeds the budget splits at line boundaries — never mid-line, so * every chunk is an exact line slice of the source (`startLine..endLine`, * 1-indexed inclusive) and can be re-read from the file. * - Zero overlap between chunks; adjacency is recoverable from line ranges. * - Each body chunk's indexed `content` is prefixed with its breadcrumb * (document title > heading path) so a chunk that is just a price table * still embeds/searches with its context. The prefix counts against the * token budget (metadata-aware budgeting). * - YAML front matter (`---` fenced block at line 1) becomes chunk 0 as-is * (minus any `volatileFrontmatterKeys` in the indexed content): a * whole-document signal chunk carrying title/summary/keyword fields. */ export interface ChunkingOptions { /** * Token budget per chunk, breadcrumb prefix included. Default 480 — under * the 512-token input ceiling of the strictest multilingual embedding * models, with headroom for tokenizer variance across languages. */ maxTokens?: number; /** * Token estimator. Default: `ceil(length / 4)` — the usual chars-per-token * heuristic; inject a real tokenizer for exact budgets. */ estimateTokens?: (text: string) => number; /** * Top-level front-matter keys to strip from chunk 0's indexed `content` * (the `body` and line range stay exact). For keys that change on every * write without carrying meaning — crawl timestamps like `fetchedAt` — * this keeps chunk 0's content hash stable, so embedding caches keyed by * content survive re-crawls. A stripped key's indented continuation lines * (multi-line values, lists) are stripped with it. */ volatileFrontmatterKeys?: string[]; } export interface MarkdownChunk { /** Position of this chunk in the document, 0-based and gapless. */ index: number; /** First source line of the chunk, 1-indexed, inclusive. */ startLine: number; /** Last source line of the chunk, 1-indexed, inclusive. */ endLine: number; /** Breadcrumb of the enclosing headings ("Title > H2 > H3"), null when * the document gives no title/heading context (or for front matter). */ headingPath: string | null; /** Exact slice of the source: lines `startLine..endLine` joined by `\n`. */ body: string; /** What gets indexed/embedded: the breadcrumb prefix + the body (for the * front-matter chunk: the body minus any `volatileFrontmatterKeys`). */ content: string; } /** * Chunk one markdown document. Returns chunks in document order with exact, * non-overlapping 1-indexed line ranges. Empty/blank input yields no chunks. */ export declare function chunkMarkdown(text: string, options?: ChunkingOptions): MarkdownChunk[]; //# sourceMappingURL=chunking.d.ts.map