@skyramp/mcp 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +0 -3
- package/build/prompts/modularization-prompts.js +100 -0
- package/build/prompts/startTraceCollectionPrompts.js +4 -1
- package/build/prompts/testGenerationPrompt.js +3 -0
- package/build/services/ModularizationService.js +2 -2
- package/build/tools/executeSkyrampTestTool.js +28 -16
- package/build/tools/fixErrorTool.js +1 -1
- package/build/tools/generateContractRestTool.js +1 -3
- package/build/tools/generateE2ERestTool.js +1 -3
- package/build/tools/generateFuzzRestTool.js +1 -3
- package/build/tools/generateIntegrationRestTool.js +1 -3
- package/build/tools/generateLoadRestTool.js +1 -3
- package/build/tools/generateSmokeRestTool.js +1 -3
- package/build/tools/generateUIRestTool.js +1 -2
- package/build/tools/modularizationTool.js +3 -1
- package/build/tools/stopTraceCollectionTool.js +20 -14
- package/build/utils/language-helper.js +1 -1
- package/package.json +1 -1
- package/build/resources/modulazrizationInstructions.js +0 -15
- package/build/utils/modularization-prompts.js +0 -23
package/build/index.js
CHANGED
|
@@ -16,7 +16,6 @@ import { registerIntegrationTestTool } from "./tools/generateIntegrationRestTool
|
|
|
16
16
|
import { registerE2ETestTool } from "./tools/generateE2ERestTool.js";
|
|
17
17
|
import { registerLoginTool } from "./tools/loginTool.js";
|
|
18
18
|
import { registerLogoutTool } from "./tools/logoutTool.js";
|
|
19
|
-
import { registerModularizationInstructions } from "./resources/modulazrizationInstructions.js";
|
|
20
19
|
import { registerFixErrorTool } from "./tools/fixErrorTool.js";
|
|
21
20
|
import { registerModularizationTool } from "./tools/modularizationTool.js";
|
|
22
21
|
const server = new McpServer({
|
|
@@ -35,8 +34,6 @@ logger.info("Starting prompt registration process");
|
|
|
35
34
|
registerTestGenerationPrompt(server);
|
|
36
35
|
registerStartTraceCollectionPrompt(server);
|
|
37
36
|
logger.info("All prompts registered successfully");
|
|
38
|
-
// Register resources
|
|
39
|
-
registerModularizationInstructions(server);
|
|
40
37
|
// Register test generation tools
|
|
41
38
|
registerSmokeTestTool(server);
|
|
42
39
|
registerFuzzTestTool(server);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export function getModularizationPrompt(filePath, language) {
|
|
2
|
+
return `
|
|
3
|
+
**CRITICAL: Refactor code with modularization principles. Respond with complete, modularized code only WITHOUT ERRORS AND WRITTEN BACK TO THE FILE ${filePath}**
|
|
4
|
+
|
|
5
|
+
**STEP 1: SEARCH & ANALYZE EXISTING CODE BASED ON TEST LANGUAGE AND NOT ALL LANGUAGE FILES - MANDATORY**
|
|
6
|
+
You MUST search for existing test files by language and NOT ALL LANGUAGE FILES:
|
|
7
|
+
${language === "python" ? `Python: .py files with "skyramp"` : ""}
|
|
8
|
+
|
|
9
|
+
${language === "typescript" || language === "javascript"
|
|
10
|
+
? `TypeScript/JavaScript: .ts/.js files with "@skyramp/skyramp"`
|
|
11
|
+
: ""}
|
|
12
|
+
|
|
13
|
+
${language === "java" ? `Java: .java files with "SkyrampClient"` : ""}
|
|
14
|
+
|
|
15
|
+
You MUST look for reusable patterns: authentication, HTTP helpers, data setup, validation, configuration, cleanup functions EXCLUDE current test file from the search.
|
|
16
|
+
|
|
17
|
+
**STEP 2: IMPORT & REUSE (HIGHEST PRIORITY) - MANDATORY**
|
|
18
|
+
You MUST import existing functions instead of duplicating. If you find reusable functions, you MUST import them:
|
|
19
|
+
${language === "python"
|
|
20
|
+
? `\`\`\`python
|
|
21
|
+
from path.to.existing import helper_function
|
|
22
|
+
from utils.auth_helpers import authenticate
|
|
23
|
+
\`\`\``
|
|
24
|
+
: ""}
|
|
25
|
+
|
|
26
|
+
${language === "typescript" || language === "javascript"
|
|
27
|
+
? `\`\`\`typescript/javascript
|
|
28
|
+
import { helperFunction } from './path/to/existing';
|
|
29
|
+
import { authenticate } from './utils/authHelpers';
|
|
30
|
+
\`\`\``
|
|
31
|
+
: ""}
|
|
32
|
+
|
|
33
|
+
${language === "java"
|
|
34
|
+
? `\`\`\`java
|
|
35
|
+
import path.to.existing.helper_function;
|
|
36
|
+
import utils.auth_helpers.authenticate;
|
|
37
|
+
\`\`\``
|
|
38
|
+
: ""}
|
|
39
|
+
|
|
40
|
+
if ${language === "python"
|
|
41
|
+
? `IMPORTANT:
|
|
42
|
+
FOR PYTHON:
|
|
43
|
+
- If functions are in different folders, use relative path manipulation with os.path. NEVER hardcode absolute paths:
|
|
44
|
+
\`\`\`python
|
|
45
|
+
import sys
|
|
46
|
+
import os
|
|
47
|
+
# Add parent directory to path to access sibling folders
|
|
48
|
+
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
|
|
49
|
+
from e2e.e2e_test import helper_function
|
|
50
|
+
|
|
51
|
+
# OR if importing from same directory level
|
|
52
|
+
sys.path.append(os.path.dirname(__file__))
|
|
53
|
+
from e2e_test import helper_function
|
|
54
|
+
\`\`\`
|
|
55
|
+
- Use aliases to avoid naming conflicts and prevent test execution:
|
|
56
|
+
\`\`\`python
|
|
57
|
+
# If importing a test file, use alias to prevent auto-execution
|
|
58
|
+
import e2e_test as e2e_helpers
|
|
59
|
+
# Then call: e2e_helpers.setup_auth_headers()
|
|
60
|
+
\`\`\`
|
|
61
|
+
- CRITICAL: When importing test files, they may auto-execute. Use \`if __name__ == "__main__":\` guards in source files.
|
|
62
|
+
`
|
|
63
|
+
: ""}
|
|
64
|
+
|
|
65
|
+
**STEP 3: REPLACE DUPLICATE CODE - MANDATORY**
|
|
66
|
+
You MUST replace duplicate code with imported function calls. If you imported functions, you MUST use them.
|
|
67
|
+
|
|
68
|
+
**STEP 4: CREATE MINIMAL NEW HELPERS (ONLY IF NEEDED)**
|
|
69
|
+
Only if NO existing function can be reused:
|
|
70
|
+
1. Group related lines logically (e.g., login steps together) to improve readability and parameterize the test function(s) with meaningful parameters to make it more flexible.
|
|
71
|
+
2. If functions are already modularized (like breakpoint_section_0, breakpoint_section_1), then rename them with meaningful names WITHOUT ANY OTHER CHANGES.
|
|
72
|
+
3. KEEP CHANGES TO A MINIMUM. DO NOT MODIFY THE FUNCTIONALITY OF THE TESTS. ONLY MODULARIZE THE CODE.
|
|
73
|
+
4. Parameterize the test function(s) with meaningful parameters to make it more flexible. Preserve the original order of code lines within each function.
|
|
74
|
+
5. Only extract reusable logical sections into helper functions or parameterized structures where applicable. Do not create any new test cases or a new modular file but only helper functions with modularization done in the same file. Do not add any new logic or classes or any other files.
|
|
75
|
+
6. CRITICAL: DO NOT CHANGE THE FUNCTIONALITY OF THE TESTS. ONLY MODULARIZE THE CODE.
|
|
76
|
+
|
|
77
|
+
**EXECUTION CHECKLIST - YOU MUST COMPLETE EACH:**
|
|
78
|
+
- [ ] STEP 1: Searched for existing files using grep_search or file_search
|
|
79
|
+
- [ ] STEP 2: Found reusable functions and imported them at the top of the file
|
|
80
|
+
- [ ] STEP 3: Replaced duplicate code with imported function calls
|
|
81
|
+
- [ ] STEP 4: Created minimal new helpers only where needed
|
|
82
|
+
- [ ] Verified import paths are correct
|
|
83
|
+
- [ ] Verified original functionality is maintained
|
|
84
|
+
|
|
85
|
+
**CRITICAL: If you skip any step, the modularization is incomplete. You MUST complete all steps before proceeding.**
|
|
86
|
+
|
|
87
|
+
**CRITICAL: FIX ERRORS IN MODULARIZED CODE USING skyramp_fix_errors TOOL**
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
export function getFixErrorsPrompt() {
|
|
91
|
+
return `
|
|
92
|
+
**Fix errors in refactored code.**
|
|
93
|
+
|
|
94
|
+
1. **Parameter Passing:** Identify functions using variables from outside scope (like Playwright 'page' object). Pass these as parameters.
|
|
95
|
+
2. **Validate Correctness:** Ensure code is free of reference errors, undefined variables, runtime issues.
|
|
96
|
+
3. **Import Paths:** Ensure import paths are correct and there are no circular imports.
|
|
97
|
+
|
|
98
|
+
**KEY: Variables not defined within function scope MUST be passed as parameters.**
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
@@ -23,7 +23,10 @@ export function registerStartTraceCollectionPrompt(mcpServer) {
|
|
|
23
23
|
|
|
24
24
|
**Example usage prompt for trace collection for playwright trace:**
|
|
25
25
|
* To start a playwright trace collection session using agent, run the following command:
|
|
26
|
-
Start playwright trace collection with default settings
|
|
26
|
+
Start playwright trace collection with default settings.
|
|
27
|
+
|
|
28
|
+
**CRITICAL: FOR UI TESTS ALWAYS SHOW THE ABOVE PROMPT FOR PLAYWRIGHT TRACE COLLECTION. NEVER SHOW THE CLI COMMANDS.**
|
|
29
|
+
`,
|
|
27
30
|
},
|
|
28
31
|
},
|
|
29
32
|
],
|
|
@@ -14,6 +14,7 @@ export function registerTestGenerationPrompt(mcpServer) {
|
|
|
14
14
|
- Guide users through test type selection and parameter collection
|
|
15
15
|
- Provide clear execution instructions for generated tests
|
|
16
16
|
- Answer questions about Skyramp capabilities and testing concepts
|
|
17
|
+
- ALWAYS SHOW STEPS TO GENERATE TEST USING MCP TOOLS AND NEVER SHOW THE CLI COMMANDS.
|
|
17
18
|
|
|
18
19
|
**CONTRACT TEST:**
|
|
19
20
|
- Purpose: Ensures a service is properly communicating with another service
|
|
@@ -106,6 +107,8 @@ Let us generate a UI test with frontend playwright trace file skyramp_playwright
|
|
|
106
107
|
|
|
107
108
|
**IMPORTANT:**
|
|
108
109
|
- WHEN GENERATING TESTS USING TRACE, EXCLUDE THE PATHS THAT ARE NOT API ENDPOINTS.
|
|
110
|
+
|
|
111
|
+
**CRITICAL: SHOW STEPS TO START/STOP PLAYWRIGHT TRACE COLLECTION FOR UI TESTS. NEVER SHOW THE CLI COMMANDS.**
|
|
109
112
|
`,
|
|
110
113
|
},
|
|
111
114
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getModularizationPrompt } from "../
|
|
1
|
+
import { getModularizationPrompt } from "../prompts/modularization-prompts.js";
|
|
2
2
|
export class ModularizationService {
|
|
3
3
|
constructor() { }
|
|
4
4
|
async processModularizationRequest(params) {
|
|
@@ -6,7 +6,7 @@ export class ModularizationService {
|
|
|
6
6
|
content: [
|
|
7
7
|
{
|
|
8
8
|
type: "text",
|
|
9
|
-
text: `${getModularizationPrompt()}`,
|
|
9
|
+
text: `${getModularizationPrompt(params.testFile, params.language)}`,
|
|
10
10
|
},
|
|
11
11
|
],
|
|
12
12
|
};
|
|
@@ -4,13 +4,7 @@ import path from "path";
|
|
|
4
4
|
import { Writable } from "stream";
|
|
5
5
|
import { logger } from "../utils/logger.js";
|
|
6
6
|
import { stripVTControlCharacters } from "util";
|
|
7
|
-
|
|
8
|
-
const LANGUAGE_PATHS = {
|
|
9
|
-
python: "/tmp",
|
|
10
|
-
javascript: "/tmp",
|
|
11
|
-
typescript: "/tmp",
|
|
12
|
-
java: "/app/src",
|
|
13
|
-
};
|
|
7
|
+
import fs from "fs";
|
|
14
8
|
export function registerExecuteSkyrampTestTool(server) {
|
|
15
9
|
server.registerTool("skyramp_execute_test", {
|
|
16
10
|
description: `Execute a Skyramp-generated test in isolated containerized environments for reliable, deterministic testing.
|
|
@@ -39,6 +33,9 @@ IMPORTANT NOTES:
|
|
|
39
33
|
|
|
40
34
|
For detailed documentation visit: https://www.skyramp.dev/docs/quickstart`,
|
|
41
35
|
inputSchema: {
|
|
36
|
+
workspacePath: z
|
|
37
|
+
.string()
|
|
38
|
+
.describe("The path to the workspace directory where the test file is located"),
|
|
42
39
|
language: z
|
|
43
40
|
.string()
|
|
44
41
|
.describe("Programming language of the test file to execute (e.g., python, javascript, typescript, java)"),
|
|
@@ -58,29 +55,34 @@ For detailed documentation visit: https://www.skyramp.dev/docs/quickstart`,
|
|
|
58
55
|
}, async (params) => {
|
|
59
56
|
var docker = new Docker();
|
|
60
57
|
var image = "public.ecr.aws/skyramp/rampup/runner:mcp-v0.0.9";
|
|
58
|
+
const containerMountPath = "/home/user";
|
|
61
59
|
// Use path.basename for safer filename extraction
|
|
62
60
|
const filename = path.basename(params.testFile);
|
|
63
61
|
if (!filename) {
|
|
64
62
|
throw new Error("Invalid test file path: could not extract filename");
|
|
65
63
|
}
|
|
66
|
-
// Use configurable language paths with fallback
|
|
67
|
-
const basePath = LANGUAGE_PATHS[params.language] || "/tmp";
|
|
68
|
-
const filePath = path.join(basePath, filename);
|
|
69
64
|
const dockerSocketPath = "/var/run/docker.sock";
|
|
65
|
+
//remove workspace path from test file path
|
|
66
|
+
let testFilePath = path.relative(params.workspacePath, params.testFile);
|
|
67
|
+
testFilePath = path.resolve(containerMountPath, testFilePath);
|
|
70
68
|
var command = [
|
|
71
69
|
"./root/runner.sh",
|
|
72
70
|
params.language,
|
|
73
|
-
|
|
71
|
+
testFilePath,
|
|
74
72
|
params.testType,
|
|
75
73
|
];
|
|
74
|
+
const workspacePath = path.resolve(params.workspacePath);
|
|
75
|
+
// check if workspace valid path
|
|
76
|
+
// Validate that the workspace path exists and is accessible
|
|
77
|
+
try {
|
|
78
|
+
fs.accessSync(workspacePath, fs.constants.R_OK);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
throw new Error(`Workspace path does not exist or is not readable: ${workspacePath}`);
|
|
82
|
+
}
|
|
76
83
|
const hostConfig = {
|
|
77
84
|
ExtraHosts: ["host.docker.internal:host-gateway"],
|
|
78
85
|
Mounts: [
|
|
79
|
-
{
|
|
80
|
-
Target: filePath,
|
|
81
|
-
Source: path.resolve(params.testFile),
|
|
82
|
-
Type: "bind",
|
|
83
|
-
},
|
|
84
86
|
{
|
|
85
87
|
Type: "bind",
|
|
86
88
|
Target: dockerSocketPath,
|
|
@@ -88,6 +90,16 @@ For detailed documentation visit: https://www.skyramp.dev/docs/quickstart`,
|
|
|
88
90
|
},
|
|
89
91
|
],
|
|
90
92
|
};
|
|
93
|
+
//lets mount the files and directories inside the workspace path to the container and exclude package-lock.json, package.json and node_modules directory
|
|
94
|
+
const workspaceFiles = fs.readdirSync(workspacePath);
|
|
95
|
+
const filesToMount = workspaceFiles.filter((file) => file !== "package-lock.json" &&
|
|
96
|
+
file !== "package.json" &&
|
|
97
|
+
file !== "node_modules");
|
|
98
|
+
hostConfig.Mounts?.push(...filesToMount.map((file) => ({
|
|
99
|
+
Type: "bind",
|
|
100
|
+
Target: path.join(containerMountPath, file),
|
|
101
|
+
Source: path.join(workspacePath, file),
|
|
102
|
+
})));
|
|
91
103
|
const env = [
|
|
92
104
|
"SKYRAMP_TEST_TOKEN=" + params.token,
|
|
93
105
|
"SKYRAMP_IN_DOCKER=true",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { logger } from "../utils/logger.js";
|
|
3
|
-
import { getFixErrorsPrompt } from "../
|
|
3
|
+
import { getFixErrorsPrompt } from "../prompts/modularization-prompts.js";
|
|
4
4
|
import { languageSchema } from "../types/TestTypes.js";
|
|
5
5
|
import { getLanguageSteps } from "../utils/language-helper.js";
|
|
6
6
|
const fixErrorSchema = z.object({
|
|
@@ -27,9 +27,7 @@ export function registerContractTestTool(server) {
|
|
|
27
27
|
server.registerTool("skyramp_contract_test_generation", {
|
|
28
28
|
description: `Generate a contract test using Skyramp's deterministic test generation platform.
|
|
29
29
|
|
|
30
|
-
Contract tests ensure your API implementation matches its OpenAPI/Swagger specification exactly. They validate request/response schemas, status codes, headers, and data types to prevent contract violations and API breaking changes
|
|
31
|
-
|
|
32
|
-
For detailed documentation visit: https://www.skyramp.dev/docs/contract-test`,
|
|
30
|
+
Contract tests ensure your API implementation matches its OpenAPI/Swagger specification exactly. They validate request/response schemas, status codes, headers, and data types to prevent contract violations and API breaking changes.`,
|
|
33
31
|
inputSchema: contractTestSchema,
|
|
34
32
|
}, async (params) => {
|
|
35
33
|
const service = new ContractTestService();
|
|
@@ -30,9 +30,7 @@ export function registerE2ETestTool(server) {
|
|
|
30
30
|
End-to-End tests validate complete user journeys by testing the entire application flow from frontend UI interactions to backend API responses. They ensure that all components work together correctly in realistic user scenarios, providing the highest confidence in application functionality.
|
|
31
31
|
|
|
32
32
|
TRACE & UI INTEGRATION:
|
|
33
|
-
E2E tests require both trace files (capturing backend API interactions) and Playwright recordings (capturing UI interactions) to generate comprehensive tests that validate the complete user experience
|
|
34
|
-
|
|
35
|
-
For detailed documentation visit: https://www.skyramp.dev/docs/e2e-test`,
|
|
33
|
+
E2E tests require both trace files (capturing backend API interactions) and Playwright recordings (capturing UI interactions) to generate comprehensive tests that validate the complete user experience.`,
|
|
36
34
|
inputSchema: e2eTestSchema,
|
|
37
35
|
annotations: {
|
|
38
36
|
keywords: ["e2e test", "end-to-end test"],
|
|
@@ -23,9 +23,7 @@ export function registerFuzzTestTool(server) {
|
|
|
23
23
|
server.registerTool("skyramp_fuzz_test_generation", {
|
|
24
24
|
description: `Generate a fuzz test using Skyramp's deterministic test generation platform.
|
|
25
25
|
|
|
26
|
-
Fuzz tests improve application security and reliability by sending invalid, malformed, or unexpected data to your API endpoints. They help discover edge cases, input validation issues, error handling problems, and potential security vulnerabilities
|
|
27
|
-
|
|
28
|
-
For detailed documentation visit: https://www.skyramp.dev/docs/fuzz-test`,
|
|
26
|
+
Fuzz tests improve application security and reliability by sending invalid, malformed, or unexpected data to your API endpoints. They help discover edge cases, input validation issues, error handling problems, and potential security vulnerabilities.`,
|
|
29
27
|
inputSchema: fuzzTestSchema,
|
|
30
28
|
annotations: {
|
|
31
29
|
keywords: ["negative test", "random test"],
|
|
@@ -29,9 +29,7 @@ export function registerIntegrationTestTool(server) {
|
|
|
29
29
|
server.registerTool("skyramp_integration_test_generation", {
|
|
30
30
|
description: `Generate an integration test using Skyramp's deterministic test generation platform.
|
|
31
31
|
|
|
32
|
-
Integration tests validate that multiple services, components, or modules work together correctly. They test complex user workflows, service interactions, data flow between systems, and ensure that integrated components function as expected in realistic scenarios
|
|
33
|
-
|
|
34
|
-
For detailed documentation visit: https://www.skyramp.dev/docs/integration-test`,
|
|
32
|
+
Integration tests validate that multiple services, components, or modules work together correctly. They test complex user workflows, service interactions, data flow between systems, and ensure that integrated components function as expected in realistic scenarios.`,
|
|
35
33
|
inputSchema: integrationTestSchema,
|
|
36
34
|
}, async (params) => {
|
|
37
35
|
const service = new IntegrationTestService();
|
|
@@ -62,9 +62,7 @@ Load tests evaluate your application's performance, scalability, and stability u
|
|
|
62
62
|
- IF THE USER DOES NOT PROVIDE LOAD PARAMETERS, THEN USE DEFAULT VALUES FOR LOAD TESTS:
|
|
63
63
|
- loadDuration: "5" (5 seconds)
|
|
64
64
|
- loadNumThreads: "1" (1 thread)
|
|
65
|
-
- Other load parameters should remain empty unless explicitly specified by the user
|
|
66
|
-
|
|
67
|
-
For detailed documentation visit: https://www.skyramp.dev/docs/load-test/advanced-generation#start-trace-collection`,
|
|
65
|
+
- Other load parameters should remain empty unless explicitly specified by the user`,
|
|
68
66
|
inputSchema: loadTestSchema,
|
|
69
67
|
annotations: {
|
|
70
68
|
keywords: ["load test", "performance test"],
|
|
@@ -23,9 +23,7 @@ export function registerSmokeTestTool(server) {
|
|
|
23
23
|
server.registerTool("skyramp_smoke_test_generation", {
|
|
24
24
|
description: `Generate a smoke test using Skyramp's deterministic test generation platform.
|
|
25
25
|
|
|
26
|
-
Smoke testing is a preliminary check used to verify that an endpoint is accessible and returns a valid response. Smoke tests are useful for quickly identifying critical defects after significant changes. They provide rapid validation for basic functionality verification and endpoint accessibility testing
|
|
27
|
-
|
|
28
|
-
For detailed documentation visit: https://www.skyramp.dev/docs/smoke-test`,
|
|
26
|
+
Smoke testing is a preliminary check used to verify that an endpoint is accessible and returns a valid response. Smoke tests are useful for quickly identifying critical defects after significant changes. They provide rapid validation for basic functionality verification and endpoint accessibility testing.`,
|
|
29
27
|
inputSchema: smokeTestSchema,
|
|
30
28
|
annotations: {
|
|
31
29
|
keywords: ["smoke test", "quick test"],
|
|
@@ -31,8 +31,7 @@ export function registerUITestTool(server) {
|
|
|
31
31
|
description: `Generate a UI test using Skyramp's deterministic test generation platform.
|
|
32
32
|
|
|
33
33
|
UI tests validate user interface functionality by simulating real user interactions with your web application. They test user workflows, form submissions, navigation, responsive design, and ensure that your frontend works correctly across different browsers and devices. UI tests use Playwright recordings as input to generate comprehensive test suites that replay user interactions, validate UI elements, and verify expected behaviors in browser environments.
|
|
34
|
-
|
|
35
|
-
For detailed documentation visit: https://www.skyramp.dev/docs/ui-test`,
|
|
34
|
+
**CRITICAL: USE TRACE COLLECTION START/STOP TOOLS FOR PLAYWRIGHT TRACE COLLECTION.**`,
|
|
36
35
|
inputSchema: uiTestSchema,
|
|
37
36
|
annotations: {
|
|
38
37
|
keywords: ["ui test", "playwright"],
|
|
@@ -8,6 +8,7 @@ const modularizationSchema = {
|
|
|
8
8
|
testFile: z
|
|
9
9
|
.string()
|
|
10
10
|
.describe("The test file to process with modularization principles applied"),
|
|
11
|
+
language: z.string().describe("The programming language of the test file"),
|
|
11
12
|
};
|
|
12
13
|
export function registerModularizationTool(server) {
|
|
13
14
|
server.registerTool("skyramp_modularization", {
|
|
@@ -24,8 +25,9 @@ export function registerModularizationTool(server) {
|
|
|
24
25
|
},
|
|
25
26
|
}, async (params) => {
|
|
26
27
|
logger.info("Generating modularization", {
|
|
27
|
-
prompt: params.prompt,
|
|
28
28
|
testFile: params.testFile,
|
|
29
|
+
language: params.language,
|
|
30
|
+
prompt: params.prompt,
|
|
29
31
|
});
|
|
30
32
|
const service = new ModularizationService();
|
|
31
33
|
return await service.processModularizationRequest(params);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { SkyrampClient } from "@skyramp/skyramp";
|
|
2
2
|
import { closeProxyTerminal } from "../utils/proxy-terminal.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import {
|
|
4
|
+
import { TELEMETRY_entrypoint_FIELD_NAME, } from "../utils/utils.js";
|
|
5
5
|
import { logger } from "../utils/logger.js";
|
|
6
|
+
import { baseSchema } from "../types/TestTypes.js";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { existsSync, mkdirSync } from "fs";
|
|
6
9
|
export function registerTraceStopTool(server) {
|
|
7
10
|
server.registerTool("skyramp_stop_trace_collection", {
|
|
8
11
|
description: `Stop trace collection and save captured data using Skyramp's comprehensive tracing capabilities.
|
|
@@ -20,13 +23,14 @@ For detailed documentation visit: https://www.skyramp.dev/docs/load-test/advance
|
|
|
20
23
|
inputSchema: {
|
|
21
24
|
traceOutputFile: z
|
|
22
25
|
.string()
|
|
23
|
-
.describe("
|
|
24
|
-
|
|
26
|
+
.describe("File name to save the trace output file (e.g., skyramp-traces.json). This file will contain the collected backend trace data"),
|
|
27
|
+
playwrightEnabled: z
|
|
25
28
|
.boolean()
|
|
26
29
|
.describe("Whether Playwright was used for trace collection. Must match the setting used when starting trace collection"),
|
|
27
30
|
playwrightOutput: z
|
|
28
31
|
.string()
|
|
29
|
-
.describe("
|
|
32
|
+
.describe("File name to save the Playwright output file (e.g., playwright.zip). Only used when playwright is true"),
|
|
33
|
+
outputDir: baseSchema.shape.outputDir,
|
|
30
34
|
prompt: z
|
|
31
35
|
.string()
|
|
32
36
|
.describe("The prompt user provided to stop trace collection"),
|
|
@@ -37,7 +41,7 @@ For detailed documentation visit: https://www.skyramp.dev/docs/load-test/advance
|
|
|
37
41
|
}, async (params) => {
|
|
38
42
|
logger.info("Stopping trace collection", {
|
|
39
43
|
traceOutputFile: params.traceOutputFile,
|
|
40
|
-
playwright: params.
|
|
44
|
+
playwright: params.playwrightEnabled,
|
|
41
45
|
playwrightOutput: params.playwrightOutput,
|
|
42
46
|
prompt: params.prompt,
|
|
43
47
|
});
|
|
@@ -46,10 +50,20 @@ For detailed documentation visit: https://www.skyramp.dev/docs/load-test/advance
|
|
|
46
50
|
const stopTraceOptions = {
|
|
47
51
|
output: params.traceOutputFile ?? "skyramp-traces.json",
|
|
48
52
|
workerContainerName: "skyramp-trace-worker",
|
|
49
|
-
playwright: params.
|
|
53
|
+
playwright: params.playwrightEnabled ?? false,
|
|
50
54
|
playwrightOutput: params.playwrightOutput ?? "playwright.zip",
|
|
51
55
|
entrypoint: TELEMETRY_entrypoint_FIELD_NAME,
|
|
56
|
+
outputDir: params.outputDir,
|
|
52
57
|
};
|
|
58
|
+
// Check if output dir exists and if not create it.
|
|
59
|
+
if (!existsSync(params.outputDir)) {
|
|
60
|
+
mkdirSync(params.outputDir, { recursive: true });
|
|
61
|
+
}
|
|
62
|
+
// Temporary fix until library is updated
|
|
63
|
+
if (params.outputDir) {
|
|
64
|
+
params.traceOutputFile = path.join(params.outputDir, params.traceOutputFile);
|
|
65
|
+
params.playwrightOutput = path.join(params.outputDir, params.playwrightOutput);
|
|
66
|
+
}
|
|
53
67
|
let errList = {
|
|
54
68
|
content: [],
|
|
55
69
|
isError: true,
|
|
@@ -68,14 +82,6 @@ For detailed documentation visit: https://www.skyramp.dev/docs/load-test/advance
|
|
|
68
82
|
logger.info("Playwright disabled for trace collection");
|
|
69
83
|
stopTraceOptions.playwrightOutput = "";
|
|
70
84
|
}
|
|
71
|
-
let err = validatePath(stopTraceOptions.output, TRACE_OUTPUT_FILE_FIELD_NAME);
|
|
72
|
-
if (err && err.content) {
|
|
73
|
-
errList.content.push(err.content[0]);
|
|
74
|
-
}
|
|
75
|
-
err = validatePath(stopTraceOptions.playwrightOutput, PLAYWRIGHT_OUTPUT_FILE_FIELD_NAME);
|
|
76
|
-
if (err && err.content) {
|
|
77
|
-
errList.content.push(err.content[0]);
|
|
78
|
-
}
|
|
79
85
|
// If error is not empty, return error
|
|
80
86
|
if (errList.content.length > 0) {
|
|
81
87
|
return errList;
|
|
@@ -78,7 +78,7 @@ java -jar "./lib/junit-platform-console-standalone-\${JUNIT_PLATFORM_VER}.jar" \
|
|
|
78
78
|
}
|
|
79
79
|
function appendExecutionInstruction() {
|
|
80
80
|
return `
|
|
81
|
-
- Notify the user that they can also use ** Execute with Skyramp ** tool to run the test.If this is your first test you are trying to execute with Skyramp, it may take a little bit longer than usual.
|
|
81
|
+
- Notify the user that they can also use ** Execute with Skyramp ** tool to run the test.If this is your first test you are trying to execute with Skyramp, it may take a little bit longer than usual because we need to build the image for the first time.
|
|
82
82
|
- Before I can execute the test for you, I need to confirm the following information:
|
|
83
83
|
Authentication: Please provide me with your authentication token (by default we assume a Bearer Token). If you don't require any token for your service please just say: 'No token required'
|
|
84
84
|
`;
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getFixErrorsPrompt, getModularizationPrompt, } from "../utils/modularization-prompts.js";
|
|
2
|
-
export function registerModularizationInstructions(mcpServer) {
|
|
3
|
-
mcpServer.resource("modularization_instructions", "mcp://modularization_instructions", async () => ({
|
|
4
|
-
contents: [
|
|
5
|
-
{
|
|
6
|
-
uri: "mcp://modularization_instructions",
|
|
7
|
-
mimeType: "text/markdown",
|
|
8
|
-
text: `
|
|
9
|
-
${getModularizationPrompt()}
|
|
10
|
-
${getFixErrorsPrompt()}
|
|
11
|
-
`,
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
}));
|
|
15
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export function getModularizationPrompt() {
|
|
2
|
-
return `
|
|
3
|
-
**CRITICAL: Please refactor the code with these modularization principles. Respond with the complete, modularized code only in the same file WITHOUT ANY ERRORS**
|
|
4
|
-
|
|
5
|
-
1. Group related lines logically (e.g., login steps together) to improve readability and parameterize the test function(s) with meaningful parameters to make it more flexible.
|
|
6
|
-
2. If functions are already modularized (like breakpoint_section_0, breakpoint_section_1), then rename them with meaningful names WITHOUT ANY OTHER CHANGES.
|
|
7
|
-
3. KEEP CHANGES TO A MINIMUM. DO NOT MODIFY THE FUNCTIONALITY OF THE TESTS. ONLY MODULARIZE THE CODE.
|
|
8
|
-
4. Parameterize the test function(s) with meaningful parameters to make it more flexible. Preserve the original order of code lines within each function.
|
|
9
|
-
5. Only extract reusable logical sections into helper functions or parameterized structures where applicable. Do not create any new test cases or a new modular file but only helper functions with modularization done in the same file. Do not add any new logic or classes or any other files.
|
|
10
|
-
|
|
11
|
-
CRITICAL: FIX ERRORS IN THE MODULARIZED CODE USING skyramp_fix_errors TOOL
|
|
12
|
-
`;
|
|
13
|
-
}
|
|
14
|
-
export function getFixErrorsPrompt() {
|
|
15
|
-
return `
|
|
16
|
-
**Fix errors in the refactored code.**
|
|
17
|
-
|
|
18
|
-
1. **Parameter Passing:** Carefully examine the code. Identify all functions that use variables defined outside their own scope (like a Playwright 'page' object or a shared configuration).
|
|
19
|
-
2. **Validate Correctness:** Ensure the final code is free of any reference errors, undefined variables, or other runtime issues. The code must be ready to execute.
|
|
20
|
-
|
|
21
|
-
**REMEMBER: The key insight is that if a function references any variable that's not defined within its scope, that variable MUST be passed as a parameter. The "page" object is the most common culprit in Playwright tests.**
|
|
22
|
-
`;
|
|
23
|
-
}
|