@skyramp/mcp
Version:
Skyramp MCP (Model Context Protocol) Server - AI-powered test generation and execution
58 lines (56 loc) • 2.36 kB
JavaScript
import { TestType } from "../types/TestTypes.js";
import { getModularizationPrompt as getModularizationPromptForUI } from "../prompts/modularization/ui-test-modularization.js";
import { getModularizationPrompt as getModularizationPromptForIntegration } from "../prompts/modularization/integration-test-modularization.js";
import { logger } from "../utils/logger.js";
export class ModularizationService {
async processModularizationRequest(params) {
logger.info("Processing modularization request", {
testFile: params.testFile,
testType: params.testType,
language: params.language,
});
const testType = params.testType;
// Check if the test type is one that should not be modularized
if (!params.isTraceBased) {
return {
content: [
{
type: "text",
text: `⚠️ **MODULARIZATION NOT APPLICABLE**
Modularization is intentionally NOT applied to ${testType.toUpperCase()} tests if the test is not generated from traces.
The test file \`${params.testFile}\` will remain unchanged. No further action is needed.`,
},
],
isError: false,
};
}
let prompt = "";
switch (testType) {
case TestType.UI:
prompt = getModularizationPromptForUI(params.testFile);
break;
case TestType.E2E:
prompt = getModularizationPromptForUI(params.testFile);
break;
case TestType.INTEGRATION:
prompt = getModularizationPromptForIntegration(params.testFile);
break;
default:
prompt = "";
break;
}
return {
content: [
{
type: "text",
text: prompt +
`\n\n***CRITICAL INSTRUCTIONS:***
1. Read the test file using the 'read_file' tool
2. Create the modularized version following the instructions above
3. Use the 'write' tool (NOT search_replace) to save the complete modularized code to the file
4. After modularization is complete, proceed to skyramp_fix_errors tool if there are any errors`,
},
],
};
}
}