/** * @license * Copyright 2025 Vybestack LLC * SPDX-License-Identifier: Apache-2.0 * * ## Change Log * - 2025-01-19: Performance Optimization (Phase 2) * - Disabled eager symbol indexing by default (ENABLE_SYMBOL_INDEXING = false). * - Implemented 'Lazy' on-demand `findInFiles` queries with strict limits. * - Added `prioritizeSymbolsFromDeclarations` for smarter symbol selection. * - Added timeout mechanism and `Promise.allSettled` for fault tolerance. * - Added performance metrics logging (duration, memory delta). * - Added env-based override: LLXPRT_ENABLE_SYMBOL_INDEXING. * - Added MAX_WORKSPACE_FILES guard to prevent OOM in large repos. */ import { BaseDeclarativeTool, ToolInvocation, type ToolResult } from './tools.js'; import { Config } from '../config/config.js'; import { ModifiableDeclarativeTool, ModifyContext } from './modifiable-tool.js'; export { LANGUAGE_MAP, JAVASCRIPT_FAMILY_EXTENSIONS, } from '../utils/ast-grep-utils.js'; /** * Code keywords used for pattern matching and analysis. */ export declare const KEYWORDS: { readonly FUNCTION: "function"; readonly DEF: "def"; readonly CLASS: "class"; readonly IF: "if"; readonly FOR: "for"; readonly WHILE: "while"; readonly RETURN: "return"; readonly IMPORT: "import "; readonly FROM: "from "; }; /** * Comment prefixes for various languages. */ export declare const COMMENT_PREFIXES: string[]; /** * Regex patterns for code analysis. */ export declare const REGEX: { readonly IMPORT_MODULE: RegExp; readonly IMPORT_ITEMS: RegExp; }; interface Declaration { name: string; type: 'function' | 'class' | 'variable' | 'import'; line: number; column: number; signature?: string; } interface Position { line: number; column: number; } export interface EnhancedDeclaration extends Declaration { range: { start: Position; end: Position; }; documentation?: string; visibility?: 'public' | 'private' | 'protected'; signature?: string; } export interface ASTEditToolParams { /** * The absolute path to the file to modify */ file_path: string; /** * The text to replace */ old_string: string; /** * The text to replace it with */ new_string: string; /** * Force execution after preview. Default is false. * IMPORTANT: This tool ALWAYS operates in two steps: * 1. First call: Preview changes (force: false or omitted) * 2. Second call: Apply changes (force: true) */ force?: boolean; /** * Timestamp (ms) of the file when last read. * If provided, the tool will verify the file hasn't been modified since this time. */ last_modified?: number; } export interface ASTReadFileToolParams { /** * The absolute path to the file to read */ file_path: string; /** * The line number to start reading from (optional) */ offset?: number; /** * The number of lines to read (optional) */ limit?: number; } export declare class ASTEditTool extends BaseDeclarativeTool implements ModifiableDeclarativeTool { private readonly config; static readonly Name = "ast_edit"; private contextCollector; static applyReplacement(currentContent: string | null, oldString: string, newString: string, isNewFile: boolean): string; constructor(config: Config); protected validateToolParamValues(params: ASTEditToolParams): string | null; protected createInvocation(params: ASTEditToolParams): ToolInvocation; getModifyContext(_: AbortSignal): ModifyContext; } export declare class ASTReadFileTool extends BaseDeclarativeTool { private readonly config; static readonly Name = "ast_read_file"; private contextCollector; constructor(config: Config); protected validateToolParamValues(params: ASTReadFileToolParams): string | null; protected createInvocation(params: ASTReadFileToolParams): ToolInvocation; }