analyze_file_semantics
Analyze semantic changes and patterns in file history to understand code evolution and detect meaningful modifications in Git repositories.
Instructions
Analyze semantic changes and patterns in file history
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repoPath | Yes | Path to git repository | |
| file | Yes | File to analyze | |
| outputPath | Yes | Path to write analysis output |
Implementation Reference
- src/index.ts:367-387 (handler)The primary handler function that performs semantic analysis on a file's git history by retrieving changes, analyzing patterns, generating a summary, writing JSON output to the specified path, and returning a success message.private async handleFileSemantics(args: FileSemanticArgs) { const changes = this.getSemanticChanges(args.repoPath, args.file); const patterns = this.analyzeChangePatterns(changes); const analysis = { changes, patterns, summary: this.generateSemanticSummary(changes, patterns), }; writeFileSync(args.outputPath, JSON.stringify(analysis, null, 2)); return { content: [ { type: 'text', text: `File semantic analysis written to ${args.outputPath}`, }, ], }; }
- src/index.ts:224-245 (registration)Tool registration in the listTools response, including name, description, and input schema definition.{ name: 'analyze_file_semantics', description: 'Analyze semantic changes and patterns in file history', inputSchema: { type: 'object', properties: { repoPath: { type: 'string', description: 'Path to git repository', }, file: { type: 'string', description: 'File to analyze', }, outputPath: { type: 'string', description: 'Path to write analysis output', }, }, required: ['repoPath', 'file', 'outputPath'], }, },
- src/index.ts:37-41 (schema)TypeScript interface defining the input parameters for the analyze_file_semantics tool.interface FileSemanticArgs { repoPath: string; file: string; outputPath: string; }
- src/index.ts:108-119 (helper)Type guard function used to validate incoming arguments conform to FileSemanticArgs before calling the handler.private isFileSemanticArgs(args: unknown): args is FileSemanticArgs { return ( typeof args === 'object' && args !== null && 'repoPath' in args && 'file' in args && 'outputPath' in args && typeof (args as FileSemanticArgs).repoPath === 'string' && typeof (args as FileSemanticArgs).file === 'string' && typeof (args as FileSemanticArgs).outputPath === 'string' ); }
- src/index.ts:457-465 (helper)Helper function that executes git log with patches to retrieve file history data for semantic change analysis.private getSemanticChanges(repoPath: string, file: string) { const output = execSync( `cd "${repoPath}" && git log --patch --format="%H|%aI|%s" -- "${file}"`, { encoding: 'utf8' } ); // Implement semantic change analysis return []; }