/** * Validation result interface */ export interface ValidationResult { valid: boolean; errors: string[]; warnings?: string[]; } /** * Pattern validation utilities for ast-grep patterns * * Validation utilities for ast-grep patterns including metavariable extraction, * naming convention validation, and pattern correctness checks. */ export declare class PatternValidator { /** * Validate metavariable naming convention (must be UPPER_CASE) */ static validateMetavariableName(name: string): boolean; /** * Extract all metavariables from a pattern */ static extractMetavariables(pattern: string): Set; /** * Detect invalid metavariable placements within identifiers or strings * @param pattern - The pattern to check * @returns Array of problematic patterns found */ private static detectInvalidMetavariablePlacement; /** * Detect patterns requiring exact AST structure * @param pattern - The pattern to check * @returns Array of warnings with specific guidance */ private static detectASTStructureRequirements; /** * Calculate pattern complexity score based on metavariables and length * @param pattern - The pattern to analyze * @returns Complexity result with score, counts, and classification */ private static calculateComplexityScore; /** * Get language-specific validation warnings * @param pattern - The pattern to check * @param language - The target programming language (optional) * @returns Array of language-specific warnings */ private static getLanguageSpecificWarnings; /** * Detect if pattern is a simple text search that should use grep instead * @param pattern - The pattern to check * @returns Warning message if pattern is better suited for grep, undefined otherwise */ private static detectSimpleTextSearch; /** * Validate an ast-grep pattern for common issues * @param pattern - The pattern to validate * @param language - Optional language for language-specific validation * @returns Validation result with errors and warnings */ static validatePattern(pattern: string, language?: string): ValidationResult; /** * Compare metavariables between pattern and replacement/fix * Ensures replacement only uses metavariables defined in pattern */ static compareMetavariables(pattern: string, replacement: string): ValidationResult; /** * Type guard to check if a value is a pattern object */ static isPatternObject(pattern: unknown): pattern is { context?: string; selector?: string; strictness?: string; }; /** * Validate a pattern object (selector, context, strictness form) */ static validatePatternObject(patternObj: { context?: string; selector?: string; strictness?: string; }): ValidationResult; } /** * YAML generation and validation utilities for ast-grep rule files. * * Provides utilities for safe YAML string escaping to prevent YAML injection vulnerabilities, * and validation of rule format including rule IDs (kebab-case), severity values, and other * YAML structure requirements. * * Key Features: * - Safe string escaping for special characters, YAML keywords, and whitespace * - Rule ID format validation (kebab-case convention) * - Severity value validation against allowed options (error, warning, info) * - Comprehensive error messages with examples and actionable guidance */ export declare class YamlValidator { /** * Escape a string for safe use in YAML */ static escapeYamlString(str: string): string; /** * Validate rule ID format (should be kebab-case) */ static validateRuleId(id: string): ValidationResult; /** * Validate severity value */ static validateSeverity(severity: string): ValidationResult; } /** * Path normalization and validation utilities for cross-platform path handling. * * Provides utilities for normalizing Windows paths to forward-slash format * (ast-grep preferred format), detecting Windows absolute paths, and handling * paths with spaces that require quoting for shell execution. * * Key Features: * - Windows backslash to forward-slash conversion * - Windows absolute path detection (drive letters) * - UNC path support * - Safe POSIX handling (preserves backslashes in filenames on Unix) */ export declare class PathValidator { /** * Normalize path separators to forward slashes for ast-grep compatibility. * Converts Windows backslashes to forward slashes while preserving path structure. * Normalizes all backslashes since ast-grep expects forward slashes on all platforms. * * Handles: * - Windows absolute paths: C:\Users -> C:/Users * - UNC paths: \\server\share -> //server/share * - Mixed separators: C:\Users/project -> C:/Users/project * - Unix paths: /home/user -> /home/user (unchanged) * - Relative paths with backslashes: src\fixtures -> src/fixtures * * Usage Contexts: * This method is primarily used for internal binary/cache/temp paths created by the * binary manager to ensure cross-platform compatibility. User-provided paths from * MCP agents are validated by WorkspaceManager and may be normalized separately by * individual tools as needed before passing to ast-grep. * * Note: Node.js fs methods accept both separators on Windows, so normalization * is primarily for ast-grep CLI which expects forward slashes on all platforms. */ static normalizePath(inputPath: string): string; /** * Detect if a path is a Windows absolute path with drive letter. * Matches patterns like C:/, D:\, etc. */ static isWindowsAbsolutePath(inputPath: string): boolean; /** * Detect if a path is absolute across all platforms. * * This method validates absolute paths for: * - Unix/Linux/macOS: Paths starting with `/` (e.g., `/home/user/project`) * - Windows: Paths with drive letters (e.g., `C:/Users/project` or `C:\Users\project`) * - Windows UNC: Network paths (e.g., `//server/share` or `\\server\share`) * * Edge cases handled: * - Empty strings return false * - Relative paths like `.` and `..` return false * * @param inputPath - The path to check * @returns true if the path is absolute on any platform, false otherwise * * @example * isAbsolutePath('/home/user/project') // true (Unix) * isAbsolutePath('C:/Users/project') // true (Windows) * isAbsolutePath('//server/share') // true (UNC) * isAbsolutePath('./relative/path') // false * isAbsolutePath('') // false */ static isAbsolutePath(inputPath: string): boolean; } /** * Parameter validation utilities */ export declare class ParameterValidator { /** * Validate context parameter */ static validateContext(context: unknown): ValidationResult; /** * Validate maxMatches parameter */ static validateMaxMatches(maxMatches: unknown): ValidationResult; /** * Validate timeout parameter */ static validateTimeout(timeoutMs: unknown): ValidationResult; /** * Validate code parameter */ static validateCode(code: unknown): ValidationResult; /** * Validate verbose parameter */ static validateVerbose(verbose: unknown): ValidationResult; /** * Validate constraint kind parameter */ static validateConstraintKind(kind: unknown): ValidationResult; /** * Validate globs parameter (array of non-empty strings) */ static validateGlobs(globs: unknown): ValidationResult; /** * Validate noIgnore parameter (array of allowed values) */ static validateNoIgnore(noIgnore: unknown): ValidationResult; /** * Validate boolean parameter with custom name */ static validateBooleanOption(option: unknown, name: string): ValidationResult; /** * Validate threads parameter (-j/--threads) */ static validateThreads(threads: unknown): ValidationResult; /** * Validate inspect parameter (--inspect) */ static validateInspect(inspect: unknown): ValidationResult; /** * Validate jsonStyle parameter (--json=