memory-engineering-mcp
Version:
๐ง AI Memory System powered by MongoDB Atlas & Voyage AI - Autonomous memory management with zero manual work
112 lines โข 4.04 kB
JavaScript
import { runCommand, runTestsWithCoverage } from './commands.js';
import { logger } from './logger.js';
/**
* Run TypeScript compilation check
*/
export async function runTypeScriptCheck(projectPath) {
logger.info('๐ TYPESCRIPT VALIDATION INITIATED - Checking type safety...');
const result = await runCommand('npm run typecheck', projectPath);
const errors = [];
if (!result.success && result.stderr) {
// Extract TypeScript errors
const errorLines = result.stderr.split('\n').filter(line => line.includes('error TS') || line.includes('Error:'));
errors.push(...errorLines);
}
return {
success: result.success,
errors,
};
}
/**
* Run test suite for a feature
*/
export async function runTestSuite(featureName, projectPath) {
logger.info(`๐งช TESTING FEATURE: ${featureName} - Verifying functionality...`);
// Try to run feature-specific tests
let result = await runTestsWithCoverage(`feature-${featureName}`, projectPath);
// If no feature-specific tests, run all tests
if (!result.success && result.errors.some(e => e.includes('No tests found'))) {
logger.info('๐ NO SPECIFIC TESTS - Running FULL test suite...');
result = await runTestsWithCoverage('', projectPath);
}
return {
success: result.success && result.coverage >= 80,
coverage: result.coverage,
errors: result.errors,
};
}
/**
* Check end-to-end integration
*/
export async function checkIntegration(featureName, projectPath) {
logger.info(`๐ INTEGRATION CHECK: ${featureName} - Verifying connections...`);
const errors = [];
// Run integration tests if they exist
const integrationResult = await runCommand(`npm run test:integration -- ${featureName}`, projectPath);
if (!integrationResult.success) {
// Check if command exists
if (integrationResult.stderr.includes('Missing script')) {
// No integration tests defined, check basic build
const buildResult = await runCommand('npm run build', projectPath);
if (!buildResult.success) {
errors.push('๐ BUILD EXPLOSION! Feature has CATASTROPHIC integration failures! FIX IMMEDIATELY!');
}
}
else {
errors.push(...integrationResult.stderr.split('\n').filter(line => line.trim()));
}
}
return {
success: errors.length === 0,
errors,
};
}
/**
* Measure performance impact
*/
export async function measurePerformance(featureName, projectPath) {
logger.info(`โฑ๏ธ PERFORMANCE ANALYSIS: ${featureName} - Measuring impact...`);
// Simple performance check - measure build time
const startTime = Date.now();
const result = await runCommand('npm run build', projectPath);
const buildTime = Date.now() - startTime;
const errors = [];
let impact = 0;
if (!result.success) {
errors.push('๐ฅ PERFORMANCE CHECK EXPLODED! Build completely FAILED! System is BROKEN!');
impact = 999999; // Very high impact
}
else {
// Consider < 100ms impact as acceptable
impact = Math.max(0, buildTime - 5000); // Baseline 5 seconds
if (impact > 100) {
errors.push(`Performance impact too high: ${impact}ms over baseline`);
}
}
return {
success: impact < 100,
impact,
errors,
};
}
/**
* Calculate confidence score based on validation results
*/
export function calculateConfidence(validation) {
let score = 0;
// TypeScript: 3 points
if (validation.typescript.success)
score += 3;
// Tests: 3 points (scaled by coverage)
if (validation.tests.success) {
score += 3 * (validation.tests.coverage / 100);
}
// Integration: 2 points
if (validation.integration.success)
score += 2;
// Performance: 2 points
if (validation.performance.success)
score += 2;
return Math.round(score);
}
//# sourceMappingURL=validation.js.map