UNPKG

socraticode

Version:

SocratiCode — MCP server for local codebase indexing, semantic search, and code dependency graphs. All private, all local via Docker.

62 lines • 3.06 kB
/** * Splitting text at the per-chunk character cap, and the chunk ids that split * produces. * * Shared by the two chunkers — `chunkFileContent` for source files and * `chunkArtifactContent` for context artifacts — which both cut by line count * and then have to honour a cap counted in characters. It lives in its own * module because indexer.ts already imports context-artifacts.ts, so the shared * helper cannot live in either of them. */ /** * The index format version from which the character cap splits instead of * truncating. * * A collection stores the profile it was created with, and keeps it. One stored * below this version keeps truncating — for files that changed and for files * discovered after an upgrade alike — so that what is written never drifts from * what its persisted effective profile says. */ export declare const SPLITTING_INDEX_FORMAT_VERSION = 2; /** Format a sha256 digest as a valid UUID (required by Qdrant): 8-4-4-4-12 */ export declare function uuidFromSeed(seed: string): string; /** * Derive the id of a continuation piece from the id of the chunk it was split * out of. * * Seeded from the parent id rather than from the position it starts at, because * position does not identify a chunk on every path: `chunkByCharacters` gives * every chunk of a single-line minified file the same startLine, and an * artifact chunk is identified by the line its parent began on. Re-deriving * from position would collide across the continuations of one parent, and * Qdrant's upsert would silently keep only the last. Seeding from the parent id * is unique wherever the parent is. */ export declare function continuationId(parentId: string, part: number): string; /** One piece of a split. Line numbers are 1-based within the text given. */ export interface TextPiece { text: string; startLine: number; endLine: number; } /** Boundaries considered while looking backwards inside one capped window. */ export type TextBoundaryMode = "newline" | "code-token"; /** * Split text into pieces of at most `maxChunkChars` characters — one more only * where a surrogate pair or a CRLF would otherwise be divided. * * Every character of the input appears in exactly one piece, in order: * concatenating `text` across the result reproduces the input. * * By default each piece ends at the last newline at or before the cap, so a * line is never divided and the line range stored on the chunk stays true. * Minified code can instead select `code-token`, which also accepts the * released chunker's space, tab, semicolon and comma boundaries so identifiers * are not divided where a safe boundary exists inside the capped window. When * the span holds no eligible boundary, the piece ends at the cap. * * Text at or below the cap comes back as a single piece, so callers can use * this unconditionally. */ export declare function splitTextToCharCap(content: string, maxChunkChars: number, boundaryMode?: TextBoundaryMode): TextPiece[]; //# sourceMappingURL=chunk-split.d.ts.map