analyze_file_changes
Track and compare file changes across branches in a Git repository. Input repository path, branches, and files to analyze, and generate detailed output for review and insights.
Instructions
Analyze changes to specific files across branches
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branches | Yes | Branches to analyze | |
| files | Yes | Files to analyze | |
| outputPath | Yes | Path to write analysis output | |
| repoPath | Yes | Path to git repository |
Implementation Reference
- src/index.ts:294-323 (handler)The primary handler function that implements the core logic for the 'analyze_file_changes' tool. It maps over files and branches to gather change history using getFileHistory, analyzes conflicts, generates a summary, writes results to outputPath, and returns a success message.private async handleFileChangesAnalysis(args: FileChangesArgs) { const analysis = args.files.map(file => { const changes = args.branches.map(branch => ({ branch, history: this.getFileHistory(args.repoPath, branch, file), })); return { file, changes, conflicts: this.analyzeConflicts(changes), }; }); const result = { analysis, summary: this.generateFileChangesSummary(analysis), }; writeFileSync(args.outputPath, JSON.stringify(result, null, 2)); return { content: [ { type: 'text', text: `File changes analysis written to ${args.outputPath}`, }, ], }; }
- src/index.ts:125-152 (registration)Tool registration in the ListTools response, including name, description, and input schema definition.{ name: 'analyze_file_changes', description: 'Analyze changes to specific files across branches', inputSchema: { type: 'object', properties: { repoPath: { type: 'string', description: 'Path to git repository', }, branches: { type: 'array', items: { type: 'string' }, description: 'Branches to analyze', }, files: { type: 'array', items: { type: 'string' }, description: 'Files to analyze', }, outputPath: { type: 'string', description: 'Path to write analysis output', }, }, required: ['repoPath', 'branches', 'files', 'outputPath'], }, },
- src/index.ts:30-35 (schema)TypeScript interface defining the input arguments for the analyze_file_changes tool, matching the inputSchema.interface FileChangesArgs { repoPath: string; branches: string[]; files: string[]; outputPath: string; }
- src/index.ts:196-202 (handler)Handler dispatcher in the CallToolRequest switch statement that validates arguments and delegates to the main handleFileChangesAnalysis function.case 'analyze_file_changes': { const args = request.params.arguments as FileChangesArgs; if (!args?.repoPath || !args?.branches || !args?.files || !args?.outputPath) { throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters'); } return await this.handleFileChangesAnalysis(args); }
- src/index.ts:428-434 (helper)Helper function used by the handler to analyze potential conflicts in file changes across branches.private analyzeConflicts(branchChanges: Array<{ branch: string; history: Array<{ hash: string; date: string; message: string }> }>) { const overlaps = this.findOverlappingChanges(branchChanges); return { riskLevel: this.assessRiskLevel(overlaps), reasons: this.generateConflictReasons(overlaps), }; }