analyze_repository_patterns
Analyze repository patterns, formats, and validation rules to identify existing features, steps, pages, and components for test automation.
Instructions
Read and analyze repository for existing patterns, formats, and validation rules
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | Path to the repository to analyze | |
| pattern_types | No | Types of patterns to analyze (features, steps, pages, components) |
Implementation Reference
- index.js:152-171 (registration)Tool registration in the toolConfigs array, including name, description, and input schema. This is returned by ListToolsRequestSchema handler.name: 'analyze_repository_patterns', description: 'Read and analyze repository for existing patterns, formats, and validation rules', inputSchema: { type: 'object', properties: { repo_path: { type: 'string', description: 'Path to the repository to analyze', }, pattern_types: { type: 'array', items: { type: 'string' }, description: 'Types of patterns to analyze (features, steps, pages, components)', default: ['features', 'steps', 'pages', 'components'], }, }, required: ['repo_path'], additionalProperties: false, }, },
- index.js:154-170 (schema)Input schema definition for the analyze_repository_patterns tool, used for validation.inputSchema: { type: 'object', properties: { repo_path: { type: 'string', description: 'Path to the repository to analyze', }, pattern_types: { type: 'array', items: { type: 'string' }, description: 'Types of patterns to analyze (features, steps, pages, components)', default: ['features', 'steps', 'pages', 'components'], }, }, required: ['repo_path'], additionalProperties: false, },
- index.js:944-977 (handler)Main execution handler for the tool. Analyzes the repository by scanning for patterns of specified types, utilities, and naming conventions, then returns a formatted JSON analysis.async analyzeRepositoryPatterns(args) { const { repo_path, pattern_types = ['features', 'steps', 'pages', 'components'] } = args; try { const analysis = { patterns: {}, existing_functions: {}, conventions: {}, utils: {} }; for (const patternType of pattern_types) { const patterns = await this.scanForPatterns(repo_path, patternType); analysis.patterns[patternType] = patterns; } // Scan for existing utility functions analysis.utils = await this.scanForUtils(repo_path); // Extract naming conventions analysis.conventions = await this.extractNamingConventions(repo_path); return { content: [ { type: 'text', text: `Repository analysis complete:\n\n${JSON.stringify(analysis, null, 2)}`, }, ], }; } catch (error) { throw new Error(`Failed to analyze repository patterns: ${error.message}`); } }
- index.js:1245-1271 (helper)Helper method called by the handler to scan files matching the pattern type and extract patterns from their contents.async scanForPatterns(repo_path, patternType) { const patterns = []; try { const files = await this.findFilesByPattern(repo_path, patternType); for (const file of files) { try { const content = await fs.readFile(file, 'utf8'); const extractedPatterns = this.extractPatterns(content, patternType); if (extractedPatterns && Object.keys(extractedPatterns).length > 0) { patterns.push({ file: path.relative(repo_path, file), patterns: extractedPatterns }); } } catch (fileError) { console.warn(`Could not read file ${file}: ${fileError.message}`); } } } catch (error) { console.warn(`Could not scan for ${patternType} patterns: ${error.message}`); } return patterns; }
- index.js:1453-1481 (helper)Helper method that extracts specific patterns from file content based on the pattern type (features, steps, etc.).extractPatterns(content, patternType) { const patterns = {}; try { switch (patternType) { case 'features': patterns.features = this.extractFeaturePatterns(content); break; case 'steps': patterns.stepDefinitions = this.extractStepPatterns(content); break; case 'pages': patterns.pageObjects = this.extractPagePatterns(content); break; case 'components': patterns.dataComponents = this.extractDataPatterns(content); break; case 'utils': patterns.utilities = this.extractUtilityPatterns(content); break; default: patterns.general = this.extractGeneralPatterns(content); } } catch (error) { console.warn(`Error extracting patterns for ${patternType}: ${error.message}`); } return patterns; }