@skyramp/mcp 0.3.2-rc.pom-4 → 0.3.2

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.
Files changed (132) hide show
  1. package/build/adapters/jestAdapter.d.ts +14 -0
  2. package/build/adapters/jestAdapter.js +113 -0
  3. package/build/adapters/mochaAdapter.d.ts +13 -0
  4. package/build/adapters/mochaAdapter.js +87 -0
  5. package/build/adapters/playwrightAdapter.d.ts +17 -0
  6. package/build/adapters/playwrightAdapter.js +182 -0
  7. package/build/adapters/pytestAdapter.d.ts +15 -0
  8. package/build/adapters/pytestAdapter.js +108 -0
  9. package/build/commands/commandLibrary.d.ts +1 -0
  10. package/build/commands/commandLibrary.js +19 -13
  11. package/build/commands/localDevTestChangesCommand.d.ts +15 -0
  12. package/build/commands/localDevTestChangesCommand.js +201 -0
  13. package/build/index.js +82 -6
  14. package/build/prompts/code-reuse.js +3 -0
  15. package/build/prompts/enhance-assertions/sharedAssertionRules.d.ts +1 -0
  16. package/build/prompts/enhance-assertions/sharedAssertionRules.js +17 -0
  17. package/build/prompts/initialize-workspace/initializeWorkspacePrompt.js +11 -9
  18. package/build/prompts/local-dev/local-dev-plan.d.ts +35 -0
  19. package/build/prompts/local-dev/local-dev-plan.js +429 -0
  20. package/build/prompts/local-dev/local-dev-prompts.d.ts +4 -0
  21. package/build/prompts/local-dev/local-dev-prompts.js +190 -0
  22. package/build/prompts/prompt-utils.d.ts +8 -0
  23. package/build/prompts/prompt-utils.js +33 -0
  24. package/build/prompts/sut-setup/modes/adaptWorkflowPrompt.js +70 -7
  25. package/build/prompts/sut-setup/modes/dockerComposePrompt.js +1 -1
  26. package/build/prompts/sut-setup/shared.js +19 -17
  27. package/build/prompts/test-maintenance/drift-analysis-prompt.d.ts +10 -1
  28. package/build/prompts/test-maintenance/drift-analysis-prompt.js +54 -1
  29. package/build/prompts/test-recommendation/analysisOutputPrompt.js +21 -29
  30. package/build/prompts/test-recommendation/scopeAssessment.d.ts +5 -2
  31. package/build/prompts/test-recommendation/scopeAssessment.js +78 -6
  32. package/build/prompts/test-recommendation/test-recommendation-prompt.js +41 -4
  33. package/build/prompts/testbot/testbot-prompts.d.ts +0 -5
  34. package/build/prompts/testbot/testbot-prompts.js +39 -55
  35. package/build/recommendation/planRanker.d.ts +15 -2
  36. package/build/recommendation/planRanker.js +76 -5
  37. package/build/resources/testbotResource.js +2 -1
  38. package/build/services/AnalyticsService.d.ts +1 -1
  39. package/build/services/TestExecutionService.d.ts +2 -1
  40. package/build/services/TestExecutionService.js +8 -3
  41. package/build/services/TestGenerationService.d.ts +2 -2
  42. package/build/services/TestGenerationService.js +39 -21
  43. package/build/services/containerEnv.js +3 -1
  44. package/build/tool-phases.js +7 -0
  45. package/build/tools/code-refactor/codeReuseTool.js +43 -4
  46. package/build/tools/code-refactor/enhanceAssertionsTool.js +68 -18
  47. package/build/tools/code-refactor/reuse-outcome.d.ts +109 -0
  48. package/build/tools/code-refactor/reuse-outcome.js +158 -0
  49. package/build/tools/code-refactor/reuse-state.d.ts +45 -0
  50. package/build/tools/code-refactor/reuse-state.js +140 -0
  51. package/build/tools/enrichTestWithMocksTool.d.ts +28 -0
  52. package/build/tools/enrichTestWithMocksTool.js +726 -0
  53. package/build/tools/executeSkyrampTestTool.d.ts +11 -0
  54. package/build/tools/executeSkyrampTestTool.js +62 -21
  55. package/build/tools/generate-tests/batchMockGenerationTool.d.ts +106 -0
  56. package/build/tools/generate-tests/batchMockGenerationTool.js +545 -0
  57. package/build/tools/generate-tests/generateBatchScenarioRestTool.js +25 -23
  58. package/build/tools/generate-tests/generateContractRestTool.js +2 -2
  59. package/build/tools/generate-tests/generateE2ERestTool.d.ts +1 -1
  60. package/build/tools/generate-tests/generateE2ERestTool.js +1 -1
  61. package/build/tools/generate-tests/generateLoadRestTool.d.ts +1 -1
  62. package/build/tools/generate-tests/generateLoadRestTool.js +1 -1
  63. package/build/tools/generate-tests/generateMockRestTool.d.ts +179 -6
  64. package/build/tools/generate-tests/generateMockRestTool.js +391 -22
  65. package/build/tools/generate-tests/loadTestSchema.d.ts +1 -1
  66. package/build/tools/generate-tests/planGuard.js +2 -22
  67. package/build/tools/generateEnrichedIntegrationTestTool.d.ts +25 -0
  68. package/build/tools/generateEnrichedIntegrationTestTool.js +235 -0
  69. package/build/tools/localDevWorkerComposeTool.d.ts +24 -0
  70. package/build/tools/localDevWorkerComposeTool.js +264 -0
  71. package/build/tools/one-click/oneClickTool.d.ts +13 -0
  72. package/build/tools/one-click/oneClickTool.js +195 -24
  73. package/build/tools/preflightMockCheckTool.d.ts +2 -0
  74. package/build/tools/preflightMockCheckTool.js +96 -0
  75. package/build/tools/queryProxyMocksTool.d.ts +70 -0
  76. package/build/tools/queryProxyMocksTool.js +522 -0
  77. package/build/tools/runExistingTestsTool.d.ts +138 -0
  78. package/build/tools/runExistingTestsTool.js +644 -0
  79. package/build/tools/submitReportTool.js +30 -1
  80. package/build/tools/test-management/analyzeChangesTool.d.ts +2 -1
  81. package/build/tools/test-management/analyzeChangesTool.js +63 -40
  82. package/build/tools/test-management/analyzeTestHealthTool.d.ts +11 -0
  83. package/build/tools/test-management/analyzeTestHealthTool.js +63 -1
  84. package/build/tools/test-management/registerTestPlanTool.js +55 -7
  85. package/build/tools/trace/startTraceCollectionTool.js +3 -3
  86. package/build/types/ExternalTestExecution.d.ts +67 -0
  87. package/build/types/ExternalTestExecution.js +8 -0
  88. package/build/types/OneClickCommands.d.ts +1 -1
  89. package/build/types/Recommendation.d.ts +20 -0
  90. package/build/types/Recommendation.js +32 -6
  91. package/build/types/RepositoryAnalysis.d.ts +131 -14
  92. package/build/types/RepositoryAnalysis.js +16 -2
  93. package/build/types/ReuseOutcome.d.ts +63 -0
  94. package/build/types/ReuseOutcome.js +33 -0
  95. package/build/types/TestExecution.d.ts +1 -0
  96. package/build/types/TestTypes.d.ts +25 -7
  97. package/build/types/TestTypes.js +25 -7
  98. package/build/types/TestbotReport.d.ts +7 -0
  99. package/build/types/index.d.ts +2 -0
  100. package/build/types/index.js +1 -0
  101. package/build/utils/AnalysisStateManager.d.ts +33 -0
  102. package/build/utils/AnalysisStateManager.js +36 -2
  103. package/build/utils/analyze-openapi.js +18 -1
  104. package/build/utils/branchDiff.d.ts +17 -1
  105. package/build/utils/branchDiff.js +99 -14
  106. package/build/utils/featureFlags.d.ts +31 -0
  107. package/build/utils/featureFlags.js +37 -0
  108. package/build/utils/grpcMockValidation.d.ts +1 -0
  109. package/build/utils/grpcMockValidation.js +49 -0
  110. package/build/utils/httpMethodValidation.d.ts +4 -0
  111. package/build/utils/httpMethodValidation.js +15 -0
  112. package/build/utils/logger.js +1 -1
  113. package/build/utils/mockCompatibility.d.ts +49 -0
  114. package/build/utils/mockCompatibility.js +82 -0
  115. package/build/utils/pom-verify/verify.d.ts +5 -0
  116. package/build/utils/pom-verify/verify.js +1 -0
  117. package/build/utils/progress.js +10 -5
  118. package/build/utils/proxy-terminal.js +3 -3
  119. package/build/utils/routeParsers.d.ts +3 -9
  120. package/build/utils/routeParsers.js +79 -4
  121. package/build/utils/utils.js +2 -2
  122. package/build/utils/versions.d.ts +4 -3
  123. package/build/utils/versions.js +3 -1
  124. package/build/utils/workspaceAuth.d.ts +46 -0
  125. package/build/utils/workspaceAuth.js +156 -1
  126. package/build/workspace/frameworks.d.ts +11 -0
  127. package/build/workspace/frameworks.js +22 -0
  128. package/build/workspace/testSuites.d.ts +20 -0
  129. package/build/workspace/testSuites.js +17 -0
  130. package/build/workspace/workspace.d.ts +206 -24
  131. package/build/workspace/workspace.js +52 -2
  132. package/package.json +5 -2
@@ -0,0 +1,140 @@
1
+ import * as path from "path";
2
+ import { readFile } from "fs/promises";
3
+ import { logger } from "../../utils/logger.js";
4
+ import { resolveRunStatePath, StateManager, } from "../../utils/AnalysisStateManager.js";
5
+ import { verifyReuse } from "../../utils/pom-verify/index.js";
6
+ import { buildSkipped, findUnparsableKeptInline, flaggedFrom, mergeFlagged, verificationFrom, ReuseVerificationOutcome, } from "./reuse-outcome.js";
7
+ /**
8
+ * Persistence for the server-derived POM-reuse outcome, keyed by test-file
9
+ * basename (what `newTestsCreated[].fileName` carries, so
10
+ * `skyramp_submit_report` can match without path normalization).
11
+ *
12
+ * Every write is best-effort. Reuse observability must never be able to fail a
13
+ * refactor that otherwise succeeded, so a missing/unreadable/unwritable state
14
+ * file degrades to "no reuse summary in the report" — the same outcome as running
15
+ * outside a Testbot run, where there is no run state to record into.
16
+ */
17
+ /**
18
+ * Read-modify-write one spec's outcome. `patch` receives the entry recorded so
19
+ * far, so a caller that needs prior state (the verify pass, which accumulates
20
+ * flagged members) uses the same path as one that does not.
21
+ *
22
+ * Fields the patch omits are preserved: the prompt-generation call knows the
23
+ * candidate count, each verify pass knows the counts and verdict.
24
+ */
25
+ async function updateReuseOutcome(testFile, patch, explicitStateFile) {
26
+ const stateFile = resolveRunStatePath(explicitStateFile);
27
+ if (!stateFile)
28
+ return;
29
+ try {
30
+ const manager = StateManager.fromStatePath(stateFile);
31
+ const data = await manager.readData();
32
+ if (!data)
33
+ return;
34
+ const key = path.basename(testFile);
35
+ const existing = data.reuseOutcomes?.[key] ?? {};
36
+ await manager.writeData({
37
+ ...data,
38
+ reuseOutcomes: { ...data.reuseOutcomes, [key]: { ...existing, ...patch(existing) } },
39
+ });
40
+ }
41
+ catch (err) {
42
+ logger.warning("Could not record POM-reuse outcome — report will omit the reuse summary", {
43
+ testFile,
44
+ error: String(err),
45
+ });
46
+ }
47
+ }
48
+ /** Record the tier-1 candidate count STEP 1 detected. */
49
+ export async function recordCandidates(testFile, candidatesDetected, explicitStateFile) {
50
+ await updateReuseOutcome(testFile, () => ({ candidatesDetected }), explicitStateFile);
51
+ }
52
+ /** The prompt-generation call found no reusable POM layer at all. No candidate
53
+ * count is recorded: "0 candidates" adds nothing to "no POM layer was found",
54
+ * and rendering both produces a redundant zero in the summary. */
55
+ export async function recordNoPomLayer(testFile, explicitStateFile) {
56
+ await updateReuseOutcome(testFile, () => ({ verification: ReuseVerificationOutcome.SkippedNoPom }), explicitStateFile);
57
+ }
58
+ /**
59
+ * Record what one verify pass established: the call counts, the verdict, and the
60
+ * declines read out of the spec the verifier just parsed.
61
+ *
62
+ * `flagged` accumulates across passes because a PASSED verdict has no violations
63
+ * left to inspect — a member that was substituted and then restored survives only
64
+ * as a `// kept inline:` comment, indistinguishable from one the mapper never
65
+ * promoted. Accumulating is what keeps that distinction recoverable at all; it does
66
+ * not by itself establish it, since a flagged member may have been remapped rather
67
+ * than restored (see buildSkipped for how narrowly it is trusted).
68
+ */
69
+ export async function recordVerifyOutcome(testFile, r, gateFired, language, explicitStateFile) {
70
+ if (!resolveRunStatePath(explicitStateFile))
71
+ return;
72
+ await updateReuseOutcome(testFile, (existing) => {
73
+ const flagged = mergeFlagged(existing.flagged, flaggedFrom(r));
74
+ return {
75
+ testFilePath: testFile,
76
+ language,
77
+ verification: verificationFrom(gateFired, r),
78
+ ...(flagged.length > 0 ? { flagged } : {}),
79
+ };
80
+ }, explicitStateFile);
81
+ }
82
+ /**
83
+ * Re-derive a recorded outcome from the spec as it stands NOW, so the report
84
+ * describes the delivered artifact rather than the state at verify time.
85
+ *
86
+ * The two can differ: the execution fix-up may restore `<testFile>.raw.bak` over
87
+ * the spec after verification, reverting every substitution with a plain `cp` that
88
+ * this tool never sees. Trusting the recorded counts there would publish
89
+ * `callsReused: 5, verification: "passed"` for a spec containing no POM calls —
90
+ * a confident false claim, strictly worse than the silence this feature replaced.
91
+ * Re-deriving here rather than requiring a final `verify: true` pass is deliberate:
92
+ * the report step always runs, so the agent cannot skip it.
93
+ *
94
+ * `candidatesDetected` is kept as recorded — it counts POM FILES that detection
95
+ * found, which a restore does not change. Everything else comes from the file.
96
+ *
97
+ * `verification` is dropped when the delivered spec reuses nothing: a PASSED
98
+ * verdict describes a spec that no longer exists, and pairing it with a zero count
99
+ * reads as though the empty result had been blessed.
100
+ *
101
+ * Returns the recorded outcome minus internals when re-derivation is impossible
102
+ * (no path recorded — e.g. only the candidate count was ever written), and
103
+ * `undefined` when it fails outright. Failing closed matters: falling back to the
104
+ * recorded counts is exactly the false claim this exists to prevent.
105
+ */
106
+ export async function rederiveReuseOutcome(record) {
107
+ const { candidatesDetected, verification, flagged, testFilePath, language } = record;
108
+ // No verify pass ran for this spec, so there are no counts to derive — only the
109
+ // detection-time facts, which no spec change can invalidate.
110
+ if (!testFilePath || !language)
111
+ return { candidatesDetected, verification };
112
+ try {
113
+ const r = await verifyReuse(testFilePath, language);
114
+ const specContent = await readFile(testFilePath, "utf8");
115
+ // Diagnose the file the report is actually built from. A marker the zero-reuse
116
+ // gate accepts but this cannot parse satisfies the escape hatch while its
117
+ // decline never reaches the report — silent signal loss is the failure class
118
+ // this feature exists to close.
119
+ const unparsable = findUnparsableKeptInline(specContent);
120
+ if (unparsable.length > 0) {
121
+ logger.warning("Malformed `// kept inline:` marker(s) in the delivered spec — these declines will be missing from the PR report. " +
122
+ "Use `// kept inline: <file basename> — <reason>` (em dash, or a hyphen with spaces around it).", { testFile: testFilePath, markers: unparsable });
123
+ }
124
+ const skipped = buildSkipped(specContent, flagged);
125
+ return {
126
+ candidatesDetected,
127
+ callsReused: r.reusedCalls,
128
+ callsVerified: r.checkedCalls,
129
+ // A PASSED verdict describes a spec that no longer exists once reuse is gone,
130
+ // and pairing it with a zero count reads as though the empty result had been
131
+ // blessed.
132
+ verification: r.reusedCalls > 0 ? verification : undefined,
133
+ skipped: skipped.length > 0 ? skipped : undefined,
134
+ };
135
+ }
136
+ catch (err) {
137
+ logger.warning("Could not re-derive the POM-reuse outcome from the delivered spec — omitting the reuse summary rather than reporting counts that may no longer hold", { testFile: testFilePath, error: String(err) });
138
+ return undefined;
139
+ }
140
+ }
@@ -0,0 +1,28 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { ProgrammingLanguage, MockProtocol } from "../types/TestTypes.js";
3
+ /**
4
+ * skyramp_enrich_test_with_mocks
5
+ *
6
+ * Injects mock imports and apply_mock() calls into a generated test file.
7
+ * The mock files are generated by skyramp_mock_generation — this tool wires
8
+ * them into the test so the mocks are applied before the test runs.
9
+ *
10
+ * No data duplication — the test imports from the generated mock files.
11
+ */
12
+ export declare function registerEnrichTestWithMocksTool(server: McpServer): void;
13
+ declare function injectMockImports(original: string, testFile: string, scenarioName: string, mockFiles: string[], traceComments?: string[], language?: ProgrammingLanguage): string;
14
+ declare function isSupportedMockEnrichmentLanguage(language: ProgrammingLanguage | string): language is ProgrammingLanguage;
15
+ type MockEntry = {
16
+ serviceName: string;
17
+ moduleName: string;
18
+ relativePath: string;
19
+ importPath: string;
20
+ importLabel: string;
21
+ mockFile: string;
22
+ className: string;
23
+ classReference: string;
24
+ targetUrl?: string;
25
+ protocol: MockProtocol;
26
+ };
27
+ declare function buildMockImportBlock(testFile: string, scenarioName: string, mockFiles: string[], traceComments?: string[], language?: ProgrammingLanguage, mockEntries?: MockEntry[]): string;
28
+ export { injectMockImports, buildMockImportBlock, isSupportedMockEnrichmentLanguage };