@skyramp/mcp 0.0.58 → 0.0.59
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.
|
@@ -11,16 +11,30 @@ function getTestbotPrompt(prTitle, prDescription, diffFile, testDirectory, summa
|
|
|
11
11
|
|
|
12
12
|
For all the following work, use the tools offered by Skyramp MCP server.
|
|
13
13
|
|
|
14
|
-
First analyze the pull request title, description, and code changes to determine a business case
|
|
15
|
-
justification for this code change.
|
|
16
|
-
|
|
17
14
|
Then perform ALL of the following tasks. Every task is MANDATORY — do NOT skip any task based on your own judgment unless the task itself gives you an explicit condition to skip.
|
|
18
15
|
|
|
19
|
-
## Task 1: Recommend New Tests (MANDATORY)
|
|
16
|
+
## Task 1: Recommend New Tests (MANDATORY — but skip if no application code changed)
|
|
17
|
+
|
|
18
|
+
Read the diff at \`${diffFile}\`. Classify EVERY changed file using these categories:
|
|
19
|
+
|
|
20
|
+
**Non-application files (DO NOT generate tests for these):**
|
|
21
|
+
- CI/CD workflow files (.github/workflows/*.yml, .gitlab-ci.yml, Jenkinsfile, etc.)
|
|
22
|
+
- Markdown documentation (.md files, README, CHANGELOG, CONTRIBUTING, etc.)
|
|
23
|
+
- Dependency lock files (package-lock.json, yarn.lock, Pipfile.lock, poetry.lock, Gemfile.lock, go.sum, etc.)
|
|
24
|
+
- Configuration-only files (.gitignore, .editorconfig, .prettierrc, renovate.json, dependabot.yml, etc.)
|
|
25
|
+
- License files (LICENSE, NOTICE, etc.)
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
**Application source code (generate tests for these):**
|
|
28
|
+
- Routes, controllers, handlers, API endpoints
|
|
29
|
+
- Models, schemas, validators, serializers, DTOs
|
|
30
|
+
- Business logic, services, middleware, utilities
|
|
31
|
+
- Test helpers and test fixtures
|
|
32
|
+
- Any file with a source extension (.py, .ts, .js, .java, .go, .rb, .cs, .kt, .swift, etc.) that is NOT in the non-application list above
|
|
22
33
|
|
|
23
|
-
**
|
|
34
|
+
**SKIP RULE — THIS IS MANDATORY:**
|
|
35
|
+
If EVERY changed file in the diff falls into the "non-application files" category above, you MUST skip steps 1–6 entirely. Do NOT call \`skyramp_analyze_repository\`, do NOT call \`skyramp_map_tests\`, do NOT generate any tests. Instead, proceed directly to Task 2. In your report, state: "Task 1 skipped: PR contains only non-application changes (CI/docs/config)."
|
|
36
|
+
|
|
37
|
+
**When in doubt:** If even ONE changed file looks like it could be application source code, run steps 1–6.
|
|
24
38
|
|
|
25
39
|
1. Call \`skyramp_analyze_repository\` with:
|
|
26
40
|
- \`repositoryPath\`: "${repositoryPath}"
|
|
@@ -29,21 +43,40 @@ Read the diff at \`${diffFile}\`. Classify each changed file. A file is applicat
|
|
|
29
43
|
3. MANDATORY: Call \`skyramp_recommend_tests\` with the \`stateFile\` returned by \`skyramp_map_tests\`. Use the priority summary and the specific endpoints/files that changed to determine exactly what to test.
|
|
30
44
|
4. Generate tests using the Skyramp MCP generate tools, in priority order (minimum 3 test types).
|
|
31
45
|
5. Use Skyramp MCP to execute the generated tests and validate the results.
|
|
46
|
+
6. **E2E / UI Test Generation from Trace Files**: Search the repository for existing Skyramp trace files that can be used for E2E or UI test generation. Look for:
|
|
47
|
+
- Backend trace files: files matching patterns like \`**/skyramp*trace*.json\`, \`**/skyramp-traces.json\`, or \`**/*trace*.json\` in test directories
|
|
48
|
+
- Playwright UI trace files: files matching patterns like \`**/skyramp*playwright*.zip\`, \`**/*playwright*.zip\`, or \`**/*ui*trace*.zip\`
|
|
49
|
+
Search in the test directory (\`${testDirectory}\`), the repository root, and any \`.skyramp/\` directories.
|
|
50
|
+
- If you find BOTH a backend trace file AND a Playwright trace ZIP, call \`skyramp_e2e_test_generation\` with both files to generate an E2E test.
|
|
51
|
+
- If you find ONLY a Playwright trace ZIP (no backend trace), call \`skyramp_ui_test_generation\` with the Playwright file to generate a UI test.
|
|
52
|
+
- When generating E2E/UI tests, use the same language and framework as other tests in the repository. Default to Python with pytest if no convention is detected.
|
|
53
|
+
- Execute any generated E2E/UI tests to validate them. Note: Playwright browsers are pre-installed in the CI environment.
|
|
32
54
|
|
|
33
55
|
**IMPORTANT — Endpoint Renames:** If the diff shows an endpoint path was renamed (e.g. \`/products\` changed to \`/items\`) and existing tests already cover that endpoint under the old name, do NOT generate new tests for the renamed endpoint. The existing tests will be updated with the new path in Task 2 (Test Maintenance). Only generate new tests for genuinely new endpoints that have no existing test coverage under any name.
|
|
34
56
|
|
|
35
57
|
## Task 2: Existing Test Maintenance (MANDATORY)
|
|
36
58
|
|
|
37
|
-
You MUST always run steps
|
|
59
|
+
You MUST always run the steps below. Do NOT skip this task based on your own assessment of whether tests exist or are relevant — use the tools to determine that.
|
|
38
60
|
|
|
39
61
|
1. Call \`skyramp_discover_tests\` with \`repositoryPath\`: "${repositoryPath}" to find all existing Skyramp-generated tests.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
62
|
+
You may skip the rest of this task ONLY if it explicitly returns zero Skyramp-generated tests.
|
|
63
|
+
|
|
64
|
+
2. **Baseline — check for parallel CI first:**
|
|
65
|
+
a. Read the workflow files in \`.github/workflows/\` and check if any workflow (other than the Skyramp Testbot workflow) is triggered on \`pull_request\` AND runs tests against the test directory (look for commands like \`pytest\`, \`jest\`, \`npm test\`, \`go test\`, \`skyramp test\`, or similar test execution commands).
|
|
66
|
+
b. If such a workflow exists, run: \`gh run list --commit $(git rev-parse HEAD) --workflow <workflow-filename> --json status,conclusion --limit 1\` to check if it has completed for the current commit.
|
|
67
|
+
c. If the parallel workflow completed successfully — record beforeStatus as "Pass" for the discovered tests and note "baseline from CI workflow <workflow-name>" in beforeDetails. Skip to step 3.
|
|
68
|
+
d. If the parallel workflow completed with failure — record beforeStatus as "Fail" and capture the failure context in beforeDetails. Skip to step 3.
|
|
69
|
+
e. If no parallel test workflow exists, it hasn't completed yet, or the \`gh\` command fails for any reason (e.g. permissions, CLI not available) — execute ALL discovered tests AS-IS (before any modifications) using \`skyramp_execute_tests_batch\` or \`skyramp_execute_test\`. Record each test's status and details as the "before" results. In beforeDetails, describe the execution result (e.g. "Pass (10.8s)" or "Fail (404 Not Found)"). If you could not query CI, just note "unable to query existing CI pipeline" — do NOT expose internal details like authentication errors.
|
|
70
|
+
|
|
71
|
+
3. Call \`skyramp_analyze_test_drift\` with the \`stateFile\` returned by \`skyramp_discover_tests\`.
|
|
72
|
+
4. Call \`skyramp_calculate_health_scores\` with the \`stateFile\` from the previous step.
|
|
73
|
+
5. Call \`skyramp_actions\` with the updated \`stateFile\`. This tool returns instructions describing what needs to change in each test file — it does NOT modify the files itself.
|
|
74
|
+
6. **You MUST modify the existing test files in-place using your file editing tools.** Read the instructions from \`skyramp_actions\`, cross-reference with the code diff, and edit each test file directly.
|
|
43
75
|
- If \`skyramp_actions\` returns endpoint rename mappings (old path → new path), apply them as simple find-and-replace on the test file URLs. Do NOT regenerate or restructure the test — only update the paths.
|
|
44
76
|
- If \`skyramp_actions\` suggests file renames (e.g. \`products_smoke_test.py\` → \`items_smoke_test.py\`), rename the files using \`git mv\` after updating their content.
|
|
45
|
-
|
|
46
|
-
|
|
77
|
+
- The goal is to fix the discovered tests so they pass with the new code, preserving the original test structure and logic. Do NOT create new test files as a substitute for fixing existing ones.
|
|
78
|
+
7. Execute the modified tests using Skyramp MCP and validate the results. This includes E2E and UI tests — Playwright browsers are pre-installed in the CI environment, so E2E/UI test execution is fully supported. Record each test's status and details as the "after" results.
|
|
79
|
+
8. For each maintained test, report BOTH the before and after results in the \`testMaintenance\` array of the report (using the fileName, beforeStatus, beforeDetails, afterStatus, afterDetails fields), so the user has full visibility into whether the code change or the existing test was at fault.
|
|
47
80
|
|
|
48
81
|
## Task 3: Submit Report (MANDATORY)
|
|
49
82
|
|
|
@@ -59,6 +92,8 @@ Do NOT write the report to a file yourself. Do NOT skip this step. The skyramp_s
|
|
|
59
92
|
|
|
60
93
|
## Report Guidelines
|
|
61
94
|
|
|
95
|
+
**businessCaseAnalysis:** Base this ONLY on facts from the PR title, description, and what the tools reported. If \`skyramp_analyze_repository\` reported 0 new endpoints, do NOT claim new endpoints were added — instead describe the change accurately (e.g. "frontend changes to consume existing API endpoints", "refactored service layer", "updated test configuration"). Never infer new backend endpoints from frontend fetch/API calls in the diff.
|
|
96
|
+
|
|
62
97
|
When reporting test results, if you chose to skip executing a test, you MUST explain WHY you skipped it.
|
|
63
98
|
NEVER use the phrase "CI timeout" or imply a timeout occurred unless a tool call actually timed out.
|
|
64
99
|
Instead, set the status to "Skipped" and provide an honest reason in the details, for example:
|
|
@@ -19,6 +19,14 @@ const newTestSchema = z.object({
|
|
|
19
19
|
const descriptionSchema = z.object({
|
|
20
20
|
description: z.string().describe("One-line description"),
|
|
21
21
|
});
|
|
22
|
+
const testMaintenanceSchema = z.object({
|
|
23
|
+
fileName: z.string().describe("Test file that was maintained, e.g. 'products_smoke_test.py'"),
|
|
24
|
+
description: z.string().describe("What was changed and why"),
|
|
25
|
+
beforeStatus: z.enum(["Pass", "Fail", "Error"]).describe("Test result BEFORE modification"),
|
|
26
|
+
beforeDetails: z.string().describe("Execution output/timing before modification, or 'baseline from CI workflow <name>' if a parallel workflow provided the baseline"),
|
|
27
|
+
afterStatus: z.enum(["Pass", "Fail", "Error", "Skipped"]).describe("Test result AFTER modification"),
|
|
28
|
+
afterDetails: z.string().describe("Execution output/timing after modification"),
|
|
29
|
+
});
|
|
22
30
|
export function registerSubmitReportTool(server) {
|
|
23
31
|
server.registerTool(TOOL_NAME, {
|
|
24
32
|
description: "Submit the final testbot report. Call this tool once after completing all test analysis, generation, and execution. " +
|
|
@@ -34,8 +42,8 @@ export function registerSubmitReportTool(server) {
|
|
|
34
42
|
.array(newTestSchema)
|
|
35
43
|
.describe("List of new tests created. Use empty array [] if none."),
|
|
36
44
|
testMaintenance: z
|
|
37
|
-
.array(
|
|
38
|
-
.describe("List of existing test modifications. Use empty array [] if none."),
|
|
45
|
+
.array(testMaintenanceSchema)
|
|
46
|
+
.describe("List of existing test modifications with before/after execution results. Use empty array [] if none."),
|
|
39
47
|
testResults: z
|
|
40
48
|
.array(testResultSchema)
|
|
41
49
|
.describe("List of ALL test execution results. One entry per test executed."),
|
|
@@ -137,6 +137,32 @@ ${diff.changedFiles.map((f) => `- \`${f}\``).join("\n")}
|
|
|
137
137
|
.join("\n");
|
|
138
138
|
const highActions = buildActionList(mapping.summary.highPriority);
|
|
139
139
|
const mediumActions = buildActionList(mapping.summary.mediumPriority);
|
|
140
|
+
// Check if E2E or UI tests are in the priority lists
|
|
141
|
+
const allPriority = [
|
|
142
|
+
...mapping.summary.highPriority,
|
|
143
|
+
...mapping.summary.mediumPriority,
|
|
144
|
+
];
|
|
145
|
+
const hasE2EOrUI = allPriority.some((t) => t === TestType.E2E || t === TestType.UI);
|
|
146
|
+
const traceGuidance = hasE2EOrUI
|
|
147
|
+
? `
|
|
148
|
+
### Trace Files for E2E/UI Tests
|
|
149
|
+
|
|
150
|
+
E2E and UI test generation requires pre-recorded trace files. Search the repository for:
|
|
151
|
+
- Backend traces: \`**/skyramp*trace*.json\`, \`**/skyramp-traces.json\`
|
|
152
|
+
- Playwright traces: \`**/skyramp*playwright*.zip\`, \`**/*playwright*.zip\`
|
|
153
|
+
|
|
154
|
+
Look in the test directory, repository root, and \`.skyramp/\` directories.
|
|
155
|
+
|
|
156
|
+
**IMPORTANT — Verify trace relevance before using it:**
|
|
157
|
+
Before passing a trace file to a test generation tool, inspect its contents to confirm it actually exercises the UI components or pages affected by the PR. A trace recorded before the current changes will not cover new UI elements. If the trace does NOT cover the changed UI:
|
|
158
|
+
- Do NOT use it for generating tests for the new changes.
|
|
159
|
+
- Report in \`issuesFound\`: "A Playwright trace file was found (<filename>) but it does not cover the new UI changes in this PR. To generate UI tests for the new functionality, record a new trace that exercises the changed pages/components and commit it, then re-run the Testbot."
|
|
160
|
+
|
|
161
|
+
- **Both found and relevant** → call \`skyramp_e2e_test_generation\` with both trace files
|
|
162
|
+
- **Only Playwright ZIP found and relevant** → call \`skyramp_ui_test_generation\` with the Playwright file
|
|
163
|
+
- **No traces found** → do NOT silently skip. Include in \`issuesFound\` when submitting your report: "E2E/UI tests were recommended but could not be generated because no Playwright trace file (.zip) was found in the repository. To enable E2E/UI test generation, record a Playwright trace and commit the .zip file, then re-run the Testbot."
|
|
164
|
+
`
|
|
165
|
+
: "";
|
|
140
166
|
const nextActionsSection = mapping.summary.highPriority.length > 0 ||
|
|
141
167
|
mapping.summary.mediumPriority.length > 0
|
|
142
168
|
? `
|
|
@@ -148,7 +174,7 @@ Do NOT skip any. Do NOT just run existing tests — generate new ones.
|
|
|
148
174
|
### High Priority (call these first)
|
|
149
175
|
${highActions || "none"}
|
|
150
176
|
|
|
151
|
-
${mediumActions ? `### Medium Priority (call after high)\n${mediumActions}\n` : ""}${isDiffScope && ((analysis?.branchDiffContext?.newEndpoints?.length ?? 0) + (analysis?.branchDiffContext?.modifiedEndpoints?.length ?? 0)) > 0 ? `\nTarget the changed endpoint(s) listed above for each generated test. Use the full URL (including base URL) as the \`endpointURL\` parameter when calling generate tools.` : ""}
|
|
177
|
+
${mediumActions ? `### Medium Priority (call after high)\n${mediumActions}\n` : ""}${isDiffScope && ((analysis?.branchDiffContext?.newEndpoints?.length ?? 0) + (analysis?.branchDiffContext?.modifiedEndpoints?.length ?? 0)) > 0 ? `\nTarget the changed endpoint(s) listed above for each generated test. Use the full URL (including base URL) as the \`endpointURL\` parameter when calling generate tools.` : ""}${traceGuidance}
|
|
152
178
|
`
|
|
153
179
|
: "";
|
|
154
180
|
const output = `# Test Recommendations
|