/** * CodeBuffer: Accumulates streaming tokens and detects completed code units. * * Tracks brace depth, string/comment state, and semicolons to determine when * a statement, function, block, or line is complete. This lets the streaming * verifier run checks against structurally complete code rather than arbitrary * token boundaries. * * Known limitation: Regex literals are not handled. A regex containing braces * (e.g. /\d{3}/) could desync the brace depth tracker. This is acceptable for * MVP since regex-heavy code units are rare and the conservative emission * strategy means a missed boundary just produces a larger unit later. */ import type { CodeUnit } from './types.js'; export declare class CodeBuffer { private buffer; private readonly lang; private braceDepth; private stringState; private commentState; private templateDepth; private escaped; /** Start offset (in the full buffer) of the current in-progress unit. */ private unitStart; constructor(language: string); /** * Append tokens to the buffer and return any newly completed code units. */ push(tokens: string): CodeUnit[]; /** Return all accumulated text. */ getFullBuffer(): string; /** Return configured language. */ getLanguage(): string; /** Clear all state. */ reset(): void; /** * Build a CodeUnit from unitStart..endIndex (inclusive) and advance unitStart. * Returns null if the text is only whitespace. */ private emitUnit; /** * Try to emit a line unit at a newline character. Only emits if the line * content doesn't end with `{` or `;` (those are handled by block/statement * detectors instead). */ private tryEmitLine; /** * Upgrade a generic 'block' kind to 'function' if the text looks like a * function or method declaration. */ private classifyKind; }