Skip to main content
Glama

Frontend Test Generation & Code Review MCP Server

analyze-commit-test-matrix.ts2.23 kB
import { FetchCommitChangesTool } from './fetch-commit-changes.js'; import { ResolvePathTool } from './resolve-path.js'; import { TestMatrixAnalyzer } from '../agents/test-matrix-analyzer.js'; import { StateManager } from '../state/manager.js'; import { BaseAnalyzeTestMatrix } from './base-analyze-test-matrix.js'; import { isFrontendFile } from '../schemas/diff.js'; import type { TestMatrixAnalysis } from '../schemas/test-matrix.js'; import { logger } from '../utils/logger.js'; export interface AnalyzeCommitTestMatrixInput { commitHash: string; repoPath?: string; projectRoot?: string; } export class AnalyzeCommitTestMatrixTool { private baseAnalyzer: BaseAnalyzeTestMatrix; constructor( private fetchCommitTool: FetchCommitChangesTool, resolvePathTool: ResolvePathTool, stateManager: StateManager, analyzer: TestMatrixAnalyzer ) { this.baseAnalyzer = new BaseAnalyzeTestMatrix(resolvePathTool, stateManager, analyzer); } async analyze(input: AnalyzeCommitTestMatrixInput): Promise<TestMatrixAnalysis> { // 1. 获取 commit 的变更 const { diff, commitInfo } = await this.fetchCommitTool.fetch({ commitHash: input.commitHash, repoPath: input.repoPath, }); logger.info(`Analyzing test matrix for commit ${commitInfo.hash.substring(0, 7)}`, { message: commitInfo.message, author: commitInfo.author, filesCount: diff.files.length, }); // 2. 过滤前端文件 const frontendFiles = diff.files.filter(file => isFrontendFile(file.path)); if (frontendFiles.length === 0) { throw new Error( `No frontend files found in commit ${input.commitHash}. Total files: ${diff.files.length}` ); } const frontendDiff = { ...diff, files: frontendFiles, }; // 3. 使用基类分析 const stateKey = `commit:${input.commitHash}`; const result = await this.baseAnalyzer.analyze({ diff: frontendDiff, revisionId: stateKey, projectRoot: input.projectRoot, metadata: { commitInfo, }, }); return { ...result, metadata: { ...result.metadata, revisionId: `commit:${commitInfo.hash}`, }, }; } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NorthSeacoder/fe-testgen-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server