@skyramp/mcp 0.0.17 → 0.0.18
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.
|
@@ -4,6 +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
|
+
import fs from "fs";
|
|
7
8
|
// Configuration for language-specific file paths
|
|
8
9
|
const LANGUAGE_PATHS = {
|
|
9
10
|
python: "/tmp",
|
|
@@ -39,6 +40,9 @@ IMPORTANT NOTES:
|
|
|
39
40
|
|
|
40
41
|
For detailed documentation visit: https://www.skyramp.dev/docs/quickstart`,
|
|
41
42
|
inputSchema: {
|
|
43
|
+
workspacePath: z
|
|
44
|
+
.string()
|
|
45
|
+
.describe("The path to the workspace directory where the test file is located"),
|
|
42
46
|
language: z
|
|
43
47
|
.string()
|
|
44
48
|
.describe("Programming language of the test file to execute (e.g., python, javascript, typescript, java)"),
|
|
@@ -58,6 +62,7 @@ For detailed documentation visit: https://www.skyramp.dev/docs/quickstart`,
|
|
|
58
62
|
}, async (params) => {
|
|
59
63
|
var docker = new Docker();
|
|
60
64
|
var image = "public.ecr.aws/skyramp/rampup/runner:mcp-v0.0.9";
|
|
65
|
+
const containerMountPath = "/home/user";
|
|
61
66
|
// Use path.basename for safer filename extraction
|
|
62
67
|
const filename = path.basename(params.testFile);
|
|
63
68
|
if (!filename) {
|
|
@@ -67,18 +72,30 @@ For detailed documentation visit: https://www.skyramp.dev/docs/quickstart`,
|
|
|
67
72
|
const basePath = LANGUAGE_PATHS[params.language] || "/tmp";
|
|
68
73
|
const filePath = path.join(basePath, filename);
|
|
69
74
|
const dockerSocketPath = "/var/run/docker.sock";
|
|
75
|
+
//remove workspace path from test file path
|
|
76
|
+
let testFilePath = path.relative(params.workspacePath, params.testFile);
|
|
77
|
+
testFilePath = path.resolve(containerMountPath, testFilePath);
|
|
70
78
|
var command = [
|
|
71
79
|
"./root/runner.sh",
|
|
72
80
|
params.language,
|
|
73
|
-
|
|
81
|
+
testFilePath,
|
|
74
82
|
params.testType,
|
|
75
83
|
];
|
|
84
|
+
const workspacePath = path.resolve(params.workspacePath);
|
|
85
|
+
// check if workspace valid path
|
|
86
|
+
// Validate that the workspace path exists and is accessible
|
|
87
|
+
try {
|
|
88
|
+
fs.accessSync(workspacePath, fs.constants.R_OK);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
throw new Error(`Workspace path does not exist or is not readable: ${workspacePath}`);
|
|
92
|
+
}
|
|
76
93
|
const hostConfig = {
|
|
77
94
|
ExtraHosts: ["host.docker.internal:host-gateway"],
|
|
78
95
|
Mounts: [
|
|
79
96
|
{
|
|
80
|
-
Target:
|
|
81
|
-
Source:
|
|
97
|
+
Target: containerMountPath,
|
|
98
|
+
Source: workspacePath,
|
|
82
99
|
Type: "bind",
|
|
83
100
|
},
|
|
84
101
|
{
|
|
@@ -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
|
`;
|
|
@@ -1,23 +1,64 @@
|
|
|
1
1
|
export function getModularizationPrompt() {
|
|
2
2
|
return `
|
|
3
|
-
**CRITICAL:
|
|
3
|
+
**CRITICAL: Refactor code with modularization principles. Respond with complete, modularized code only WITHOUT ERRORS**
|
|
4
4
|
|
|
5
|
+
**STEP 1: SEARCH & ANALYZE EXISTING CODE - MANDATORY**
|
|
6
|
+
You MUST search for existing test files by language:
|
|
7
|
+
- Python: .py files with "skyramp"
|
|
8
|
+
- TypeScript/JavaScript: .ts/.js files with "@skyramp/skyramp"
|
|
9
|
+
- Java: .java files with "SkyrampClient"
|
|
10
|
+
|
|
11
|
+
You MUST look for reusable patterns: authentication, HTTP helpers, data setup, validation, configuration, cleanup functions.
|
|
12
|
+
|
|
13
|
+
**STEP 2: IMPORT & REUSE (HIGHEST PRIORITY) - MANDATORY**
|
|
14
|
+
You MUST import existing functions instead of duplicating. If you find reusable functions, you MUST import them:
|
|
15
|
+
|
|
16
|
+
\`\`\`python
|
|
17
|
+
from path.to.existing import helper_function
|
|
18
|
+
from utils.auth_helpers import authenticate
|
|
19
|
+
\`\`\`
|
|
20
|
+
|
|
21
|
+
\`\`\`typescript/javascript
|
|
22
|
+
import { helperFunction } from './path/to/existing';
|
|
23
|
+
import { authenticate } from './utils/authHelpers';
|
|
24
|
+
\`\`\`
|
|
25
|
+
|
|
26
|
+
\`\`\`java
|
|
27
|
+
import path.to.existing.helper_function;
|
|
28
|
+
import utils.auth_helpers.authenticate;
|
|
29
|
+
\`\`\`
|
|
30
|
+
|
|
31
|
+
**STEP 3: REPLACE DUPLICATE CODE - MANDATORY**
|
|
32
|
+
You MUST replace duplicate code with imported function calls. If you imported functions, you MUST use them.
|
|
33
|
+
|
|
34
|
+
**STEP 4: CREATE MINIMAL NEW HELPERS (ONLY IF NEEDED)**
|
|
35
|
+
Only if NO existing function can be reused:
|
|
5
36
|
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
37
|
2. If functions are already modularized (like breakpoint_section_0, breakpoint_section_1), then rename them with meaningful names WITHOUT ANY OTHER CHANGES.
|
|
7
38
|
3. KEEP CHANGES TO A MINIMUM. DO NOT MODIFY THE FUNCTIONALITY OF THE TESTS. ONLY MODULARIZE THE CODE.
|
|
8
39
|
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
40
|
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
41
|
|
|
11
|
-
|
|
42
|
+
**EXECUTION CHECKLIST - YOU MUST COMPLETE EACH:**
|
|
43
|
+
- [ ] STEP 1: Searched for existing files using grep_search or file_search
|
|
44
|
+
- [ ] STEP 2: Found reusable functions and imported them at the top of the file
|
|
45
|
+
- [ ] STEP 3: Replaced duplicate code with imported function calls
|
|
46
|
+
- [ ] STEP 4: Created minimal new helpers only where needed
|
|
47
|
+
- [ ] Verified import paths are correct
|
|
48
|
+
- [ ] Verified original functionality is maintained
|
|
49
|
+
|
|
50
|
+
**CRITICAL: If you skip any step, the modularization is incomplete. You MUST complete all steps before proceeding.**
|
|
51
|
+
|
|
52
|
+
**CRITICAL: FIX ERRORS IN MODULARIZED CODE USING skyramp_fix_errors TOOL**
|
|
12
53
|
`;
|
|
13
54
|
}
|
|
14
55
|
export function getFixErrorsPrompt() {
|
|
15
56
|
return `
|
|
16
|
-
**Fix errors in
|
|
57
|
+
**Fix errors in refactored code.**
|
|
17
58
|
|
|
18
|
-
1. **Parameter Passing:**
|
|
19
|
-
2. **Validate Correctness:** Ensure
|
|
59
|
+
1. **Parameter Passing:** Identify functions using variables from outside scope (like Playwright 'page' object). Pass these as parameters.
|
|
60
|
+
2. **Validate Correctness:** Ensure code is free of reference errors, undefined variables, runtime issues.
|
|
20
61
|
|
|
21
|
-
**
|
|
62
|
+
**KEY: Variables not defined within function scope MUST be passed as parameters.**
|
|
22
63
|
`;
|
|
23
64
|
}
|