@skyramp/mcp 0.0.32 → 0.0.34
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 +14 -0
- package/build/prompts/code-reuse.js +100 -50
- package/build/prompts/modularization/ui-test-modularization.js +4 -17
- package/build/services/ModularizationService.js +2 -1
- package/build/services/TestGenerationService.js +9 -15
- package/build/tools/codeReuseTool.js +31 -3
- package/build/tools/generateE2ERestTool.js +1 -1
- package/build/tools/generateIntegrationRestTool.js +4 -3
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -61,6 +61,20 @@ async function main() {
|
|
|
61
61
|
const transport = new StdioServerTransport();
|
|
62
62
|
await server.connect(transport);
|
|
63
63
|
logger.info("MCP Server started successfully");
|
|
64
|
+
// Listen for stdin closure (parent process disconnected)
|
|
65
|
+
process.stdin.on("end", () => {
|
|
66
|
+
logger.info("STDIN closed, parent process disconnected. Exiting...");
|
|
67
|
+
process.exit(0);
|
|
68
|
+
});
|
|
69
|
+
// Handle process termination signals
|
|
70
|
+
process.on("SIGTERM", () => {
|
|
71
|
+
logger.info("Received SIGTERM, shutting down gracefully...");
|
|
72
|
+
process.exit(0);
|
|
73
|
+
});
|
|
74
|
+
process.on("SIGINT", () => {
|
|
75
|
+
logger.info("Received SIGINT, shutting down gracefully...");
|
|
76
|
+
process.exit(0);
|
|
77
|
+
});
|
|
64
78
|
}
|
|
65
79
|
main().catch((error) => {
|
|
66
80
|
logger.critical("Fatal error in main()", {
|
|
@@ -1,79 +1,118 @@
|
|
|
1
1
|
import { generateSkyrampHeader, SKYRAMP_UTILS_HEADER } from "../utils/utils.js";
|
|
2
|
-
const
|
|
3
|
-
python:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const LANGUAGE_MAP = {
|
|
3
|
+
python: {
|
|
4
|
+
extension: "py",
|
|
5
|
+
fileName: "SkyrampUtils.py",
|
|
6
|
+
},
|
|
7
|
+
java: {
|
|
8
|
+
extension: "java",
|
|
9
|
+
fileName: "SkyrampUtils.java",
|
|
10
|
+
},
|
|
11
|
+
javascript: {
|
|
12
|
+
extension: "js",
|
|
13
|
+
fileName: "skyrampUtils.js",
|
|
14
|
+
},
|
|
15
|
+
typescript: {
|
|
16
|
+
extension: "ts",
|
|
17
|
+
fileName: "skyrampUtils.ts",
|
|
18
|
+
},
|
|
7
19
|
};
|
|
8
|
-
export function getCodeReusePrompt(testFile, language
|
|
9
|
-
const ext =
|
|
10
|
-
|
|
20
|
+
export function getCodeReusePrompt(testFile, language) {
|
|
21
|
+
const ext = LANGUAGE_MAP[language].extension || "py";
|
|
22
|
+
const fileName = LANGUAGE_MAP[language].fileName || "SkyrampUtils.py";
|
|
23
|
+
return `# CODE REUSE - 6 CLEAR STEPS
|
|
24
|
+
**CRITICAL WARNING: VIOLATION OF THESE RULES WILL RESULT IN ERROR**
|
|
25
|
+
|
|
26
|
+
## DEFINITIONS (READ FIRST):
|
|
27
|
+
**What is a "Helper Function"?**
|
|
28
|
+
- A helper function is a STANDALONE, DISTINCT function that is ALREADY DEFINED in the code
|
|
29
|
+
- It has a clear function signature (e.g., \`async function createProduct(page, data) { ... }\`)
|
|
30
|
+
- It is NOT just repetitive inline test code or patterns
|
|
31
|
+
- Example of helper function: \`async function loginUser(page, email, password) { ... }\`
|
|
32
|
+
- Example of NOT a helper function: Repetitive \`await page.click()\` statements scattered in test
|
|
33
|
+
|
|
34
|
+
**What is "Repetitive Code Pattern"?**
|
|
35
|
+
- Sequential test steps that look similar but are NOT extracted into standalone functions
|
|
36
|
+
- Example: Multiple sequences of \`await page.fill()\`, \`await page.click()\` directly in test body
|
|
37
|
+
- These patterns should NOT be extracted during code reuse - that's what modularization is for
|
|
38
|
+
|
|
39
|
+
🚨 **CODE REUSE ≠ REFACTORING** 🚨
|
|
40
|
+
- Code reuse = Finding EXISTING helper functions and reusing them
|
|
41
|
+
- Refactoring = Creating NEW helper functions from patterns (handled by modularization tool)
|
|
11
42
|
|
|
12
43
|
## STEP 1: READ TEST FILE
|
|
13
|
-
Read ${testFile} and
|
|
44
|
+
Read ${testFile} and look for ALREADY DEFINED helper functions (not just repetitive patterns).
|
|
14
45
|
|
|
15
46
|
## STEP 2: FIND EXISTING UTILS
|
|
16
47
|
Use the Grep tool to search for files containing "${SKYRAMP_UTILS_HEADER}":
|
|
17
48
|
- Pattern: "${SKYRAMP_UTILS_HEADER}"
|
|
18
49
|
- Type: "${ext}"
|
|
19
50
|
- Output mode: "files_with_matches"
|
|
20
|
-
|
|
21
51
|
**CRITICAL: Only look for util files with header ${SKYRAMP_UTILS_HEADER}** - exclude test files (files with "test", "spec", ".test.", ".spec." in the name).
|
|
52
|
+
Read the matching non-test files and check if any helpers can be reused in ${testFile}.
|
|
22
53
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## STEP 3: USE EXISTING HELPERS FROM UTILS SOURCE FILES
|
|
26
|
-
If helpers exist in util files:
|
|
54
|
+
## STEP 3: USE EXISTING HELPERS FROM UTILS SOURCE FILES FOUND IN STEP 2
|
|
55
|
+
If helpers exist in util file that can be reused in ${testFile} without modifying them:
|
|
27
56
|
- Import them into ${testFile}
|
|
28
57
|
- Remove any duplicate code in ${testFile}
|
|
29
58
|
- Test that ${testFile} still works without any errors and logical is same as original test file.
|
|
30
59
|
|
|
31
|
-
## STEP 4: FIND LOCAL HELPERS IN OTHER TEST SOURCE FILES THAT HAS HEADER ${SKYRAMP_UTILS_HEADER}
|
|
60
|
+
## STEP 4: FIND LOCAL HELPERS IN OTHER TEST SOURCE FILES THAT HAS HEADER ${SKYRAMP_UTILS_HEADER}
|
|
32
61
|
Use the Grep tool to search for other test files containing "${SKYRAMP_UTILS_HEADER}":
|
|
33
62
|
- Pattern: "${SKYRAMP_UTILS_HEADER}"
|
|
34
63
|
- Type: "${ext}"
|
|
35
64
|
- Output mode: "files_with_matches"
|
|
36
|
-
|
|
37
65
|
**CRITICAL: Exclude ${testFile} from the results** - only look at OTHER test files, not the current file.
|
|
38
66
|
|
|
67
|
+
🚨 **STOP HERE IF NO OTHER TEST FILES FOUND** 🚨
|
|
39
68
|
**IF NO OTHER TEST FILES ARE FOUND, SKIP TO STEP 6 - DO NOT CREATE ANY UTILS FILES.**
|
|
40
69
|
|
|
41
|
-
If other test files are found, read those files and
|
|
42
|
-
|
|
70
|
+
If other test files are found, read those files and look for ALREADY DEFINED helper functions with clear function signatures.
|
|
71
|
+
|
|
72
|
+
**How to identify helper functions in other test files:**
|
|
73
|
+
✅ HELPER FUNCTION (move to utils):
|
|
74
|
+
- Has function signature: \`async function doSomething(params) { ... }\`
|
|
75
|
+
- Can be called multiple times with different parameters
|
|
76
|
+
- Example: \`async function fillProductForm(page, product) { ... }\`
|
|
77
|
+
|
|
78
|
+
❌ NOT A HELPER FUNCTION (do not extract):
|
|
79
|
+
- Just repetitive inline test code in test body
|
|
80
|
+
- No function definition/signature
|
|
81
|
+
- Example: Multiple \`await page.getByTestId("xyz").click()\` directly in test
|
|
82
|
+
|
|
83
|
+
🚨 **IF OTHER TEST FILES ONLY CONTAIN REPETITIVE PATTERNS (NO ACTUAL HELPER FUNCTIONS), SKIP TO STEP 6** 🚨
|
|
84
|
+
🚨 **IF OTHER TEST FILES ARE ESSENTIALLY IDENTICAL TO CURRENT FILE, SKIP TO STEP 6** 🚨
|
|
43
85
|
|
|
44
86
|
## STEP 5: IF LOCAL HELPERS ARE FOUND IN STEP 4 THAT CAN BE REUSED in ${testFile}, MOVE THOSE LOCAL HELPERS TO UTILS SOURCE FILES AND USE THEM
|
|
45
|
-
**ONLY PROCEED WITH STEP 5 IF:**
|
|
46
|
-
- You found OTHER test files in STEP 4 (not just ${testFile})
|
|
47
|
-
- Those test files contain helper functions that can be reused in ${testFile}
|
|
48
87
|
|
|
49
|
-
**
|
|
88
|
+
🚨 **ONLY PROCEED WITH STEP 5 IF ALL CONDITIONS ARE MET:** 🚨
|
|
89
|
+
- ✅ You found OTHER test files in STEP 4 (not just ${testFile})
|
|
90
|
+
- ✅ Those test files contain ACTUAL HELPER FUNCTIONS with function signatures (not just repetitive patterns)
|
|
91
|
+
- ✅ The helper functions are ALREADY IMPLEMENTED and working in those OTHER test files
|
|
92
|
+
- ✅ The helper functions are DIFFERENT from the current file (not just identical patterns)
|
|
93
|
+
|
|
94
|
+
🚨 **IF ANY CONDITION IS NOT MET, SKIP TO STEP 6 - DO NOT CREATE ANY UTILS FILES.** 🚨
|
|
95
|
+
|
|
96
|
+
**Examples of when to SKIP STEP 5:**
|
|
97
|
+
- ❌ Other test files have identical repetitive code but no helper functions
|
|
98
|
+
- ❌ Other test files are generated from same template and look identical
|
|
99
|
+
- ❌ You see patterns but no actual function definitions
|
|
100
|
+
- ❌ You would need to CREATE new functions to extract the patterns
|
|
50
101
|
|
|
51
102
|
**CRITICAL:** For helpers found in STEP 4:
|
|
52
|
-
1. **CREATE**
|
|
103
|
+
1. **CREATE** \`${fileName}\` file if it doesn't exist with the following header:
|
|
53
104
|
\`\`\`${ext}
|
|
54
105
|
${generateSkyrampHeader(language)}
|
|
55
106
|
\`\`\`
|
|
56
|
-
|
|
107
|
+
**CRITICAL: IF \`${fileName}\` is already big, create a new file with a different name and add the header to the new file.**
|
|
108
|
+
2. **COPY** those local helper functions from original test source files to \`${fileName}\` without modifying them
|
|
57
109
|
3. **DELETE** those local helper functions from test source files (REMOVE THEM COMPLETELY) WITHOUT ANY OTHER CHANGES.
|
|
58
|
-
4. **IMPORT** those local helper functions from
|
|
59
|
-
5. **IMPORT** those local helper functions from
|
|
110
|
+
4. **IMPORT** those local helper functions from \`${fileName}\` back into test source files WITHOUT MAKING ANY OTHER CHANGE.
|
|
111
|
+
5. **IMPORT** those local helper functions from \`${fileName}\` into ${testFile}
|
|
60
112
|
6. **REPLACE** duplicate code in ${testFile} with calls to imported helper functions WITHOUT MAKING ANY OTHER CHANGE.
|
|
61
113
|
|
|
62
|
-
**CRITICAL: DO NOT CREATE UNNECESSARY HELPER FUNCTIONS**
|
|
63
|
-
|
|
64
|
-
- **DO NOT** create granular helper functions that duplicate functionality already covered by existing helpers
|
|
65
|
-
- **DO NOT** create functions that break down existing functionality into smaller pieces just for modularity
|
|
66
|
-
- **ONLY** create helpers that eliminate actual code duplication, not just for the sake of modularity
|
|
67
|
-
- **VERIFY** that each helper function serves a clear purpose and is actually used in the refactored code
|
|
68
|
-
|
|
69
|
-
**CRITICAL: EXPLICIT RULES FOR SOURCE TEST FILES:**
|
|
70
|
-
- **ONLY** remove the helper function definitions (the actual function code) that are needed for ${testFile}
|
|
71
|
-
- **ONLY** add import statements for the helper functions
|
|
72
|
-
- **DO NOT** change any other code in the source test files
|
|
73
|
-
- **DO NOT** change the test logic, test steps, or test flow
|
|
74
|
-
- **DO NOT** add new helper functions that weren't in the original file
|
|
75
|
-
- **DO NOT** modify existing function calls or test assertions
|
|
76
|
-
- **DO NOT** change variable names, test data, or test structure
|
|
114
|
+
🚨 **CRITICAL: DO NOT CREATE UNNECESSARY HELPER FUNCTIONS** 🚨
|
|
115
|
+
🚨 **DO NOT CREATE HELPERS BASED ON PATTERNS IN THE CURRENT FILE** 🚨
|
|
77
116
|
|
|
78
117
|
## STEP 6: VERIFY AND VALIDATE
|
|
79
118
|
1. **BEFORE** making any changes, read the original test file and identify ALL helper functions
|
|
@@ -87,15 +126,26 @@ Look for patterns like: Form filling utilities, Navigation helpers, Authenticati
|
|
|
87
126
|
9. **NEVER** refactor, reorganize, or restructure existing source test files beyond moving helpers
|
|
88
127
|
10. **RUN TESTS** to ensure functionality is preserved after refactoring
|
|
89
128
|
|
|
90
|
-
**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
🚨 **FINAL REMINDER: DO NOT CREATE HELPER FUNCTIONS FROM SCRATCH** 🚨
|
|
130
|
+
🚨 **ONLY MOVE EXISTING HELPERS FROM OTHER TEST FILES** 🚨
|
|
131
|
+
|
|
132
|
+
**IMPORTANT NOTES:**
|
|
133
|
+
- The process is designed to REUSE existing helper functions, not create new ones
|
|
134
|
+
- If no existing helpers are found, the test file should remain unchanged
|
|
135
|
+
- Code reuse is about moving existing, working helper functions between files
|
|
136
|
+
- Never create helper functions based on patterns you see in the current test file
|
|
137
|
+
- Helper functions must have explicit function signatures/definitions
|
|
138
|
+
- Repetitive inline test code is NOT a helper function
|
|
139
|
+
|
|
140
|
+
**DECISION TREE:**
|
|
141
|
+
1. Found existing utils file with helpers? → Import and use them (Step 3)
|
|
142
|
+
2. Found other test files with ACTUAL helper functions? → Move to utils (Step 5)
|
|
143
|
+
3. Found other test files with only repetitive patterns? → SKIP to Step 6, NO utils file
|
|
144
|
+
4. Found no other test files? → SKIP to Step 6, NO utils file
|
|
145
|
+
5. Other test files identical to current? → SKIP to Step 6, NO utils file
|
|
146
|
+
|
|
147
|
+
**MANDATORY**: After code reuse is complete, proceed to modularization by calling skyramp_modularization tool
|
|
98
148
|
|
|
99
|
-
|
|
149
|
+
SUMMARIZE THE CODE REUSE PROCESS AND THE RESULTS.
|
|
100
150
|
`;
|
|
101
151
|
}
|
|
@@ -4,14 +4,14 @@ export function getModularizationPrompt(filePath) {
|
|
|
4
4
|
**WRITE MODULARIZED CODE TO: ${filePath}**
|
|
5
5
|
|
|
6
6
|
**ABSOLUTELY FORBIDDEN:**
|
|
7
|
-
- DO NOT CREATE INTERFACES, CLASSES, TYPES, OR NEW DATA STRUCTURES
|
|
7
|
+
- DO NOT CREATE INTERFACES, CLASSES, TYPES, NEW FILES, OR NEW DATA STRUCTURES
|
|
8
8
|
- DO NOT CHANGE TEST LOGIC, DATA VALUES, CALCULATIONS, OR ASSERTIONS
|
|
9
|
-
- DO NOT CREATE/UPDATE package.json, requirements.txt, pom.xml, build.gradle file
|
|
9
|
+
- DO NOT CREATE/UPDATE DEPENDENCY FILES package.json, requirements.txt, pom.xml, build.gradle file
|
|
10
10
|
|
|
11
11
|
## STEP 1: READ THE ORIGINAL TEST
|
|
12
12
|
Read ${filePath} completely and identify:
|
|
13
13
|
- All test data values (names, prices, quantities, totals)
|
|
14
|
-
- All calculations and expected results
|
|
14
|
+
- All test data including calculations and expected results
|
|
15
15
|
- The exact test flow
|
|
16
16
|
- **Check if code is already modularized** (e.g., \`breakpoint_section_0\`, \`breakpoint_section_1\` functions)
|
|
17
17
|
|
|
@@ -37,13 +37,12 @@ Extract code in TWO scenarios:
|
|
|
37
37
|
- Don't try to "unify" variations with conditional logic
|
|
38
38
|
|
|
39
39
|
**B) LOGICAL SECTIONS** - Self-contained operations (5+ lines) that improve readability
|
|
40
|
-
- Examples: "create product", "fill
|
|
40
|
+
- Examples: "create product", "fill form", "verify result"
|
|
41
41
|
- Must be cohesive - related operations that achieve one goal
|
|
42
42
|
|
|
43
43
|
**Don't extract:**
|
|
44
44
|
- Code less than 5 lines (unless highly repetitive)
|
|
45
45
|
- Navigation sequences (\`navbar-\` clicks, \`page.goto\`)
|
|
46
|
-
- Single operations with no repetition
|
|
47
46
|
|
|
48
47
|
## STEP 3: EXTRACT INTO HELPERS
|
|
49
48
|
|
|
@@ -125,18 +124,6 @@ await addItem(page, "item1");
|
|
|
125
124
|
await addItem(page, "item2");
|
|
126
125
|
await addItem(page, "item3");
|
|
127
126
|
|
|
128
|
-
// ✅ CORRECT - One helper handles all cases
|
|
129
|
-
async function createOrder(page, email, items) {
|
|
130
|
-
// ... setup
|
|
131
|
-
for (const item of items) { // Loop OK if items explicit at call site
|
|
132
|
-
await addItem(page, item.name, item.quantity);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
// Call with explicit items:
|
|
136
|
-
await createOrder(page, "test@email.com", [
|
|
137
|
-
{ name: "item1", quantity: 1 },
|
|
138
|
-
{ name: "item2", quantity: 2 }
|
|
139
|
-
]);
|
|
140
127
|
\`\`\`
|
|
141
128
|
|
|
142
129
|
## STEP 4: CALL HELPERS WITH EXACT SAME VALUES
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SkyrampClient } from "@skyramp/skyramp";
|
|
2
2
|
import { analyzeOpenAPIWithGivenEndpoint } from "../utils/analyze-openapi.js";
|
|
3
|
+
import * as fs from "fs";
|
|
3
4
|
import { getPathParameterValidationError, OUTPUT_DIR_FIELD_NAME, PATH_PARAMS_FIELD_NAME, QUERY_PARAMS_FIELD_NAME, FORM_PARAMS_FIELD_NAME, validateParams, validatePath, validateRequestData, TELEMETRY_entrypoint_FIELD_NAME, } from "../utils/utils.js";
|
|
4
5
|
import { getLanguageSteps } from "../utils/language-helper.js";
|
|
5
6
|
import { logger } from "../utils/logger.js";
|
|
@@ -26,6 +27,11 @@ export class TestGenerationService {
|
|
|
26
27
|
if (apiAnalysisResult) {
|
|
27
28
|
return apiAnalysisResult;
|
|
28
29
|
}
|
|
30
|
+
if (params.scenarioFile) {
|
|
31
|
+
//read file and convert and pass to generateOptions as `rawTrace`
|
|
32
|
+
const scenarioFile = await fs.promises.readFile(params.scenarioFile, "utf8");
|
|
33
|
+
generateOptions.rawTrace = scenarioFile;
|
|
34
|
+
}
|
|
29
35
|
const result = await this.executeGeneration(generateOptions);
|
|
30
36
|
const testType = this.getTestType();
|
|
31
37
|
const languageSteps = getLanguageSteps({
|
|
@@ -35,24 +41,12 @@ export class TestGenerationService {
|
|
|
35
41
|
});
|
|
36
42
|
// Orchestrate code optimization workflow based on flags
|
|
37
43
|
let postGenerationMessage = "";
|
|
38
|
-
if (params.codeReuse
|
|
39
|
-
// Both enabled: Run in sequence (reuse first, then modularize)
|
|
40
|
-
postGenerationMessage += `
|
|
41
|
-
✅ Test generated successfully!
|
|
42
|
-
|
|
43
|
-
📋 **Optimization Workflow:**
|
|
44
|
-
1. **Code Reuse Analysis** - Will identify and extract reusable code patterns
|
|
45
|
-
2. **Code Modularization** - Will then organize code for better maintainability
|
|
46
|
-
|
|
47
|
-
⏭️ Next: Running code reuse analysis with skyramp_code_reuse tool...
|
|
48
|
-
`;
|
|
49
|
-
}
|
|
50
|
-
else if (params.codeReuse) {
|
|
44
|
+
if (params.codeReuse) {
|
|
51
45
|
// Only code reuse
|
|
52
46
|
postGenerationMessage += `
|
|
53
47
|
✅ Test generated successfully!
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
⏭️**CRITICAL NEXT STEP**: Running code reuse analysis with skyramp_reuse_code tool.
|
|
56
50
|
`;
|
|
57
51
|
}
|
|
58
52
|
else if (params.modularizeCode) {
|
|
@@ -60,7 +54,7 @@ export class TestGenerationService {
|
|
|
60
54
|
postGenerationMessage += `
|
|
61
55
|
✅ Test generated successfully!
|
|
62
56
|
|
|
63
|
-
|
|
57
|
+
⏭️**CRITICAL NEXT STEP**: Running modularization with skyramp_modularization tool.
|
|
64
58
|
`;
|
|
65
59
|
}
|
|
66
60
|
return {
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { logger } from "../utils/logger.js";
|
|
3
3
|
import { getCodeReusePrompt } from "../prompts/code-reuse.js";
|
|
4
4
|
import { codeRefactoringSchema, languageSchema } from "../types/TestTypes.js";
|
|
5
|
+
import { SKYRAMP_UTILS_HEADER } from "../utils/utils.js";
|
|
5
6
|
const codeReuseSchema = z.object({
|
|
6
7
|
testFile: z
|
|
7
8
|
.string()
|
|
@@ -14,8 +15,35 @@ const codeReuseSchema = z.object({
|
|
|
14
15
|
.describe("The code content to analyze and optimize for code reuse"),
|
|
15
16
|
});
|
|
16
17
|
export function registerCodeReuseTool(server) {
|
|
17
|
-
server.registerTool("
|
|
18
|
-
description: `Analyzes code for reuse opportunities and enforces code reuse principles.
|
|
18
|
+
server.registerTool("skyramp_reuse_code", {
|
|
19
|
+
description: `Analyzes code for reuse opportunities and enforces code reuse principles.
|
|
20
|
+
|
|
21
|
+
This tool helps identify and reuse ONLY EXISTING helper functions from other test files (grep based on "${SKYRAMP_UTILS_HEADER}").
|
|
22
|
+
|
|
23
|
+
**CRITICAL RULES - VIOLATION WILL RESULT IN ERROR:**
|
|
24
|
+
1. DO NOT create new helper functions - only find and reuse existing ones
|
|
25
|
+
2. ONLY create a utils file if ACTUAL helper functions (with signatures) exist in OTHER test files
|
|
26
|
+
3. DO NOT create utils files for repetitive patterns - that's refactoring, not reuse
|
|
27
|
+
4. DO NOT extract patterns from current or other test files - only move existing functions
|
|
28
|
+
5. If other test files are identical/similar with no helper functions, DO NOTHING
|
|
29
|
+
6. Helper functions must have explicit function definitions, not just patterns
|
|
30
|
+
7. If no existing helper functions found, test file remains unchanged
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
**WORKFLOW SUMMARY:**
|
|
34
|
+
1. Check existing utils with header ${SKYRAMP_UTILS_HEADER} → reuse if found WITHOUT ANY OTHER CHANGES
|
|
35
|
+
2. Search OTHER test files (not current test file) for local helpers with header ${SKYRAMP_UTILS_HEADER}
|
|
36
|
+
3. **ONLY IF** reusable helpers are found in OTHER test files → move to utils and update imports
|
|
37
|
+
4. **IF NO** existing utils or reusable helpers are found in test files then reuse is complete, without creating any files or changes to the test files
|
|
38
|
+
5. Verify no duplicate code remains and tests work as expected
|
|
39
|
+
6. **MANDATORY**: After code reuse is complete, proceed to modularization by calling skyramp_modularization tool
|
|
40
|
+
|
|
41
|
+
**WHEN TO SKIP (DO NOTHING):**
|
|
42
|
+
- Other test files only have repetitive patterns, no helper functions
|
|
43
|
+
- Other test files are essentially identical to current file
|
|
44
|
+
- No actual function definitions found in other test files
|
|
45
|
+
|
|
46
|
+
The tool will provide step-by-step instructions that MUST be followed exactly.`,
|
|
19
47
|
inputSchema: codeReuseSchema.shape,
|
|
20
48
|
annotations: {
|
|
21
49
|
keywords: [
|
|
@@ -32,7 +60,7 @@ export function registerCodeReuseTool(server) {
|
|
|
32
60
|
language: params.language,
|
|
33
61
|
framework: params.framework,
|
|
34
62
|
});
|
|
35
|
-
const codeReusePrompt = getCodeReusePrompt(params.testFile, params.language
|
|
63
|
+
const codeReusePrompt = getCodeReusePrompt(params.testFile, params.language);
|
|
36
64
|
return {
|
|
37
65
|
content: [
|
|
38
66
|
{
|
|
@@ -2,12 +2,12 @@ import { z } from "zod";
|
|
|
2
2
|
import { baseSchema, baseTraceSchema, TestType, codeRefactoringSchema, } from "../types/TestTypes.js";
|
|
3
3
|
import { TestGenerationService, } from "../services/TestGenerationService.js";
|
|
4
4
|
const e2eTestSchema = {
|
|
5
|
-
...baseSchema.shape,
|
|
6
5
|
...baseTraceSchema.shape,
|
|
7
6
|
playwrightInput: z
|
|
8
7
|
.string()
|
|
9
8
|
.describe("MUST be absolute path to the playwright input file like /path/to/playwright-ui-test.zip and MUST be a zip file captured using start_trace_collection tool"),
|
|
10
9
|
...codeRefactoringSchema.shape,
|
|
10
|
+
...baseSchema.shape,
|
|
11
11
|
};
|
|
12
12
|
export class E2ETestService extends TestGenerationService {
|
|
13
13
|
getTestType() {
|
|
@@ -9,9 +9,10 @@ const integrationTestSchema = z
|
|
|
9
9
|
exclude: baseTraceSchema.shape.exclude.optional(),
|
|
10
10
|
endpointURL: baseTestSchema.endpointURL.default(""),
|
|
11
11
|
...codeRefactoringSchema.shape,
|
|
12
|
-
|
|
12
|
+
scenarioFile: z
|
|
13
13
|
.string()
|
|
14
|
-
.describe("
|
|
14
|
+
.describe("Path to the scenario file to be used for test generation. This file is generated by the skyramp_scenario_test_generation tool.")
|
|
15
|
+
.optional(),
|
|
15
16
|
})
|
|
16
17
|
.omit({ method: true }).shape;
|
|
17
18
|
export class IntegrationTestService extends TestGenerationService {
|
|
@@ -23,7 +24,7 @@ export class IntegrationTestService extends TestGenerationService {
|
|
|
23
24
|
...super.buildBaseGenerationOptions(params),
|
|
24
25
|
responseData: params.responseData,
|
|
25
26
|
playwrightInput: params.playwrightInput,
|
|
26
|
-
|
|
27
|
+
scenarioFile: params.scenarioFile,
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
async handleApiAnalysis(params, generateOptions) {
|