/** * Line Utilities * * Utility functions for working with line-based content: * - Extract lines by range * - Convert character positions to line numbers * - Format content with line number prefixes */ /** * Line range where content was found */ export interface LineRange { /** Starting line number (1-indexed) */ start: number; /** Ending line number (1-indexed, inclusive) */ end: number; } /** * Extract lines from content by line range. * * @param content - The document content * @param startLine - Starting line number (1-indexed) * @param endLine - Ending line number (1-indexed, inclusive) * @returns Object with extracted content and metadata */ export declare function extractLines(content: string, startLine?: number, endLine?: number): { content: string; lines: { start: number; end: number; }; totalLines: number; }; /** * Extract lines using offset/limit style parameters (like Claude Code). * * @param content - The document content * @param offset - Line number to start from (1-indexed, default: 1) * @param limit - Maximum number of lines to read (default: all remaining) * @returns Object with extracted content and metadata */ export declare function extractLinesWithLimit(content: string, offset?: number, limit?: number): { content: string; lines: { start: number; end: number; }; totalLines: number; }; /** * Format content with line number prefixes. * Output format matches Claude Code: " 1→content here" * * @param content - The content to format * @param startLineNumber - The line number of the first line (1-indexed) * @returns Formatted content with line numbers */ export declare function formatWithLineNumbers(content: string, startLineNumber?: number): string; /** * Convert a character index to a line number. * Useful for converting RAG chunk character offsets to line numbers. * * @param content - The full document content * @param charIndex - The character index (0-indexed) * @returns The line number (1-indexed), or undefined if charIndex is out of bounds */ export declare function charIndexToLineNumber(content: string, charIndex: number): number | undefined; /** * Convert character range to line range. * Useful for converting RAG chunk character offsets to line ranges. * * @param content - The full document content * @param startCharIdx - Start character index (0-indexed) * @param endCharIdx - End character index (0-indexed, exclusive) * @returns LineRange (1-indexed) or undefined if indices are out of bounds */ export declare function charRangeToLineRange(content: string, startCharIdx: number, endCharIdx: number): LineRange | undefined; /** * Count occurrences of a string in content. * * @param content - The content to search * @param searchString - The string to find * @returns Number of occurrences */ export declare function countOccurrences(content: string, searchString: string): number; /** * Replace a string in content, with validation for uniqueness. * * @param content - The content to modify * @param oldString - The string to find and replace * @param newString - The replacement string * @param replaceAll - If true, replace all occurrences; if false, require unique match * @returns Object with result content and metadata * @throws Error if oldString is not found or not unique (when replaceAll is false) */ export declare function replaceString(content: string, oldString: string, newString: string, replaceAll?: boolean): { content: string; replacements: number; }; /** * Error thrown when string is not found during replacement. */ export declare class StringNotFoundError extends Error { readonly searchString: string; constructor(searchString: string); } /** * Error thrown when string appears multiple times but unique match required. */ export declare class StringNotUniqueError extends Error { readonly searchString: string; readonly occurrences: number; constructor(searchString: string, occurrences: number); } //# sourceMappingURL=line-utils.d.ts.map