@skyramp/mcp 0.2.8 → 0.2.150-rc.ldw-
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/commands/commandLibrary.d.ts +1 -0
- package/build/commands/commandLibrary.js +17 -14
- package/build/commands/localDevTestChangesCommand.d.ts +15 -0
- package/build/commands/localDevTestChangesCommand.js +188 -0
- package/build/index.js +74 -13
- package/build/prompts/enhance-assertions/sharedAssertionRules.d.ts +1 -0
- package/build/prompts/enhance-assertions/sharedAssertionRules.js +17 -0
- package/build/prompts/initialize-workspace/initializeWorkspacePrompt.js +7 -6
- package/build/prompts/local-dev/local-dev-plan.d.ts +25 -0
- package/build/prompts/local-dev/local-dev-plan.js +413 -0
- package/build/prompts/local-dev/local-dev-prompts.d.ts +4 -0
- package/build/prompts/local-dev/local-dev-prompts.js +155 -0
- package/build/prompts/prompt-utils.d.ts +8 -0
- package/build/prompts/prompt-utils.js +33 -0
- package/build/prompts/sut-setup/modes/adaptWorkflowPrompt.js +3 -1
- package/build/prompts/sut-setup/modes/dockerComposePrompt.js +3 -1
- package/build/prompts/sut-setup/shared.d.ts +20 -0
- package/build/prompts/sut-setup/shared.js +69 -7
- package/build/prompts/test-recommendation/analysisOutputPrompt.js +21 -29
- package/build/prompts/test-recommendation/analysisOutputPrompt.test.js +0 -28
- package/build/prompts/test-recommendation/test-recommendation-prompt.js +41 -4
- package/build/prompts/test-recommendation/test-recommendation-prompt.test.js +16 -1
- package/build/prompts/testbot/testbot-prompts.d.ts +0 -5
- package/build/prompts/testbot/testbot-prompts.js +4 -34
- package/build/resources/testbotResource.js +2 -1
- package/build/services/TestExecutionService.d.ts +2 -1
- package/build/services/TestExecutionService.js +9 -9
- package/build/services/TestExecutionService.test.js +42 -1
- package/build/services/TestGenerationService.d.ts +2 -2
- package/build/tool-phases.js +4 -0
- package/build/tools/code-refactor/enhanceAssertionsTool.js +42 -18
- package/build/tools/enrichTestWithMocksTool.d.ts +15 -0
- package/build/tools/enrichTestWithMocksTool.js +413 -0
- package/build/tools/enrichTestWithMocksTool.test.d.ts +1 -0
- package/build/tools/enrichTestWithMocksTool.test.js +60 -0
- package/build/tools/executeSkyrampTestTool.d.ts +4 -0
- package/build/tools/executeSkyrampTestTool.js +39 -18
- package/build/tools/executeSkyrampTestTool.test.d.ts +1 -0
- package/build/tools/executeSkyrampTestTool.test.js +16 -0
- package/build/tools/generate-tests/batchMockGenerationTool.d.ts +79 -0
- package/build/tools/generate-tests/batchMockGenerationTool.js +395 -0
- package/build/tools/generate-tests/generateContractRestTool.js +2 -2
- package/build/tools/generate-tests/generateMockRestTool.d.ts +56 -6
- package/build/tools/generate-tests/generateMockRestTool.js +193 -21
- package/build/tools/generateEnrichedIntegrationTestTool.d.ts +24 -0
- package/build/tools/generateEnrichedIntegrationTestTool.js +209 -0
- package/build/tools/localDevWorkflowFixes.test.d.ts +1 -0
- package/build/tools/localDevWorkflowFixes.test.js +144 -0
- package/build/tools/one-click/oneClickTool.d.ts +10 -0
- package/build/tools/one-click/oneClickTool.js +177 -21
- package/build/tools/one-click/oneClickTool.test.d.ts +1 -0
- package/build/tools/one-click/oneClickTool.test.js +172 -0
- package/build/tools/preflightMockCheckTool.d.ts +2 -0
- package/build/tools/preflightMockCheckTool.js +91 -0
- package/build/tools/test-management/analyzeChangesTool.d.ts +2 -1
- package/build/tools/test-management/analyzeChangesTool.js +59 -38
- package/build/tools/workspace/initializeWorkspaceTool.js +2 -9
- package/build/tools/workspace/initializeWorkspaceTool.test.js +9 -4
- package/build/types/OneClickCommands.d.ts +1 -1
- package/build/types/RepositoryAnalysis.d.ts +117 -0
- package/build/types/RepositoryAnalysis.js +16 -2
- package/build/types/TestTypes.d.ts +11 -2
- package/build/types/TestTypes.js +11 -1
- package/build/utils/analyze-openapi.js +18 -1
- package/build/utils/analyze-openapi.test.d.ts +1 -0
- package/build/utils/analyze-openapi.test.js +19 -0
- package/build/utils/branchDiff.d.ts +17 -1
- package/build/utils/branchDiff.js +96 -14
- package/build/utils/branchDiff.test.d.ts +1 -0
- package/build/utils/branchDiff.test.js +107 -0
- package/build/utils/docker.test.js +1 -1
- package/build/utils/featureFlags.d.ts +15 -1
- package/build/utils/featureFlags.js +19 -2
- package/build/utils/featureFlags.test.js +57 -2
- package/build/utils/grpcMockValidation.d.ts +1 -0
- package/build/utils/grpcMockValidation.js +49 -0
- package/build/utils/grpcMockValidation.test.d.ts +1 -0
- package/build/utils/grpcMockValidation.test.js +41 -0
- package/build/utils/httpMethodValidation.d.ts +4 -0
- package/build/utils/httpMethodValidation.js +13 -0
- package/build/utils/mockCompatibility.d.ts +49 -0
- package/build/utils/mockCompatibility.js +80 -0
- package/build/utils/mockCompatibility.test.d.ts +1 -0
- package/build/utils/mockCompatibility.test.js +88 -0
- package/build/utils/versions.d.ts +3 -3
- package/build/utils/versions.js +1 -1
- package/build/workspace/workspace.d.ts +35 -21
- package/build/workspace/workspace.js +8 -4
- package/build/workspace/workspace.test.js +65 -6
- package/package.json +2 -2
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock Compatibility Pre-flight Check
|
|
3
|
+
*
|
|
4
|
+
* Validates mock protocol combinations BEFORE deployment to surface
|
|
5
|
+
* known incompatibilities early rather than at test execution time.
|
|
6
|
+
*/
|
|
7
|
+
import { MockProtocol } from "../types/TestTypes.js";
|
|
8
|
+
export { MockProtocol };
|
|
9
|
+
function parseRestHostname(endpointURL) {
|
|
10
|
+
try {
|
|
11
|
+
return new URL(endpointURL).hostname.toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isLoopbackRestEndpoint(endpointURL) {
|
|
18
|
+
const hostname = parseRestHostname(endpointURL);
|
|
19
|
+
return (hostname === "localhost" ||
|
|
20
|
+
hostname === "127.0.0.1" ||
|
|
21
|
+
hostname === "0.0.0.0" ||
|
|
22
|
+
hostname === "::1" ||
|
|
23
|
+
hostname === "[::1]" ||
|
|
24
|
+
hostname === "host.docker.internal");
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validates a set of mock specs for known protocol compatibility issues.
|
|
28
|
+
*
|
|
29
|
+
* Rules:
|
|
30
|
+
* - Any gRPC mock present → GRPC_PERSISTENT_CONN warning (DNS hijacking skips persistent conns)
|
|
31
|
+
* - Docker local-dev REST mock using loopback/host.docker.internal → REST_LOOPBACK_URL blocking warning
|
|
32
|
+
*
|
|
33
|
+
* REST mocks work correctly in Docker local-dev mode only when the mock URL uses
|
|
34
|
+
* the real Docker service hostname (e.g. "billing" from "http://billing:5001").
|
|
35
|
+
* The worker adds that hostname as a Docker network alias so DNS resolves to the mock server.
|
|
36
|
+
*
|
|
37
|
+
* `compatible` is false when any warning is blocking and the mock cannot intercept traffic.
|
|
38
|
+
* `hasBlockers` is true when at least one warning is blocking (mock must not be generated/deployed).
|
|
39
|
+
*/
|
|
40
|
+
export function validateMockCompatibility(mocks, options = {}) {
|
|
41
|
+
const warnings = [];
|
|
42
|
+
const restMocks = mocks.filter((m) => m.protocol === MockProtocol.Rest);
|
|
43
|
+
const grpcMocks = mocks.filter((m) => m.protocol === MockProtocol.Grpc);
|
|
44
|
+
const loopbackRestMocks = options.dockerLocalDev
|
|
45
|
+
? restMocks.filter((m) => isLoopbackRestEndpoint(m.endpointURL))
|
|
46
|
+
: [];
|
|
47
|
+
if (loopbackRestMocks.length > 0) {
|
|
48
|
+
warnings.push({
|
|
49
|
+
code: "REST_LOOPBACK_URL",
|
|
50
|
+
message: "REST mocks for Docker local-dev must use the original Docker service hostname. " +
|
|
51
|
+
"Loopback hosts such as localhost, 127.0.0.1, 0.0.0.0, ::1, or host.docker.internal " +
|
|
52
|
+
"do not give the Skyramp worker the downstream service DNS alias it needs to intercept traffic.",
|
|
53
|
+
suggestion: "Use the real Docker service origin in endpointURL, for example http://ams:4000 or " +
|
|
54
|
+
"http://billing:5001. Do not use localhost, host.docker.internal, or the Skyramp worker address " +
|
|
55
|
+
"for deployable REST mocks.",
|
|
56
|
+
affectedMocks: loopbackRestMocks.map((m) => m.endpointURL),
|
|
57
|
+
blocking: true,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Rule: gRPC mocks use DNS hijacking that doesn't intercept persistent connections
|
|
61
|
+
if (grpcMocks.length > 0) {
|
|
62
|
+
warnings.push({
|
|
63
|
+
code: "GRPC_PERSISTENT_CONN",
|
|
64
|
+
message: "gRPC mocks use DNS hijacking which does not intercept persistent connections. " +
|
|
65
|
+
"If the service under test establishes a gRPC connection before mocks are applied, " +
|
|
66
|
+
"the existing connection will bypass the mock.",
|
|
67
|
+
suggestion: "Apply gRPC mocks before the service under test starts, or restart " +
|
|
68
|
+
"the service after applying mocks so it establishes a new connection through the mock DNS. " +
|
|
69
|
+
"For Docker local-dev, also verify the worker has the original downstream hostname alias " +
|
|
70
|
+
"from endpointURL (for example, partner-accounts for partner-accounts:50051).",
|
|
71
|
+
affectedMocks: grpcMocks.map((m) => m.grpcServiceName || m.endpointURL),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const hasBlockers = warnings.some((w) => w.blocking);
|
|
75
|
+
return {
|
|
76
|
+
compatible: !hasBlockers,
|
|
77
|
+
hasBlockers,
|
|
78
|
+
warnings,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { validateMockCompatibility, MockProtocol } from "./mockCompatibility.js";
|
|
2
|
+
describe("validateMockCompatibility", () => {
|
|
3
|
+
it("REST-only mocks produce no warnings (DNS interception works correctly)", () => {
|
|
4
|
+
const mocks = [
|
|
5
|
+
{ protocol: MockProtocol.Rest, endpointURL: "http://billing:5001/api/users", method: "GET" },
|
|
6
|
+
{ protocol: MockProtocol.Rest, endpointURL: "http://ams:4000/api/orders", method: "POST" },
|
|
7
|
+
];
|
|
8
|
+
const result = validateMockCompatibility(mocks);
|
|
9
|
+
expect(result.compatible).toBe(true);
|
|
10
|
+
expect(result.warnings).toHaveLength(0);
|
|
11
|
+
});
|
|
12
|
+
it("REST mocks using loopback URLs get a blocking REST_LOOPBACK_URL warning", () => {
|
|
13
|
+
const mocks = [
|
|
14
|
+
{ protocol: MockProtocol.Rest, endpointURL: "http://localhost:8080/api/users", method: "GET" },
|
|
15
|
+
{ protocol: MockProtocol.Rest, endpointURL: "http://host.docker.internal:4000/api/orders", method: "POST" },
|
|
16
|
+
{ protocol: MockProtocol.Rest, endpointURL: "http://[::1]:8080/api/status", method: "GET" },
|
|
17
|
+
];
|
|
18
|
+
const result = validateMockCompatibility(mocks, { dockerLocalDev: true });
|
|
19
|
+
expect(result.compatible).toBe(false);
|
|
20
|
+
expect(result.hasBlockers).toBe(true);
|
|
21
|
+
const warning = result.warnings.find((w) => w.code === "REST_LOOPBACK_URL");
|
|
22
|
+
expect(warning).toBeDefined();
|
|
23
|
+
expect(warning.blocking).toBe(true);
|
|
24
|
+
expect(warning.affectedMocks).toContain("http://localhost:8080/api/users");
|
|
25
|
+
expect(warning.affectedMocks).toContain("http://host.docker.internal:4000/api/orders");
|
|
26
|
+
expect(warning.affectedMocks).toContain("http://[::1]:8080/api/status");
|
|
27
|
+
});
|
|
28
|
+
it("does not block loopback REST URLs outside Docker local-dev preflight mode", () => {
|
|
29
|
+
const mocks = [
|
|
30
|
+
{ protocol: MockProtocol.Rest, endpointURL: "http://localhost:8080/api/users", method: "GET" },
|
|
31
|
+
];
|
|
32
|
+
const result = validateMockCompatibility(mocks);
|
|
33
|
+
expect(result.compatible).toBe(true);
|
|
34
|
+
expect(result.hasBlockers).toBe(false);
|
|
35
|
+
expect(result.warnings.find((w) => w.code === "REST_LOOPBACK_URL")).toBeUndefined();
|
|
36
|
+
});
|
|
37
|
+
it("Kafka mocks produce no compatibility warning when generation payload shape is valid", () => {
|
|
38
|
+
const mocks = [
|
|
39
|
+
{ protocol: MockProtocol.Kafka, endpointURL: "redpanda:9092", kafkaTopic: "user-events" },
|
|
40
|
+
{ protocol: MockProtocol.Rest, endpointURL: "http://ams:4000/api/users", method: "GET" },
|
|
41
|
+
];
|
|
42
|
+
const result = validateMockCompatibility(mocks);
|
|
43
|
+
expect(result.compatible).toBe(true);
|
|
44
|
+
expect(result.hasBlockers).toBe(false);
|
|
45
|
+
expect(result.warnings.find((w) => w.code === "KAFKA_SDK_INCOMPATIBLE")).toBeUndefined();
|
|
46
|
+
});
|
|
47
|
+
it("gRPC mocks produce GRPC_PERSISTENT_CONN warning", () => {
|
|
48
|
+
const mocks = [
|
|
49
|
+
{ protocol: MockProtocol.Grpc, endpointURL: "grpc://localhost:50051", grpcServiceName: "UserService" },
|
|
50
|
+
{ protocol: MockProtocol.Rest, endpointURL: "http://ams:4000/api/users", method: "GET" },
|
|
51
|
+
];
|
|
52
|
+
const result = validateMockCompatibility(mocks);
|
|
53
|
+
expect(result.compatible).toBe(true);
|
|
54
|
+
const grpcWarning = result.warnings.find((w) => w.code === "GRPC_PERSISTENT_CONN");
|
|
55
|
+
expect(grpcWarning).toBeDefined();
|
|
56
|
+
expect(grpcWarning.affectedMocks).toContain("UserService");
|
|
57
|
+
});
|
|
58
|
+
it("gRPC on non-8080 ports is allowed with only the persistent connection warning", () => {
|
|
59
|
+
const mocks = [
|
|
60
|
+
{ protocol: MockProtocol.Grpc, endpointURL: "partner-accounts:50051", grpcServiceName: "PaymentService" },
|
|
61
|
+
];
|
|
62
|
+
const result = validateMockCompatibility(mocks);
|
|
63
|
+
expect(result.compatible).toBe(true);
|
|
64
|
+
expect(result.hasBlockers).toBe(false);
|
|
65
|
+
expect(result.warnings).toHaveLength(1);
|
|
66
|
+
expect(result.warnings[0].code).toBe("GRPC_PERSISTENT_CONN");
|
|
67
|
+
expect(result.warnings.find((w) => w.code === "GRPC_PORT_MISMATCH")).toBeUndefined();
|
|
68
|
+
});
|
|
69
|
+
it("gRPC on port 8080 also gets only GRPC_PERSISTENT_CONN", () => {
|
|
70
|
+
const mocks = [
|
|
71
|
+
{ protocol: MockProtocol.Grpc, endpointURL: "some-service:8080", grpcServiceName: "ProfileService" },
|
|
72
|
+
];
|
|
73
|
+
const result = validateMockCompatibility(mocks);
|
|
74
|
+
expect(result.compatible).toBe(true);
|
|
75
|
+
expect(result.hasBlockers).toBe(false);
|
|
76
|
+
expect(result.warnings).toHaveLength(1);
|
|
77
|
+
expect(result.warnings[0].code).toBe("GRPC_PERSISTENT_CONN");
|
|
78
|
+
});
|
|
79
|
+
it("REST-only mocks have no blockers", () => {
|
|
80
|
+
const mocks = [
|
|
81
|
+
{ protocol: MockProtocol.Rest, endpointURL: "http://billing:5001/api/pay", method: "POST" },
|
|
82
|
+
];
|
|
83
|
+
const result = validateMockCompatibility(mocks);
|
|
84
|
+
expect(result.compatible).toBe(true);
|
|
85
|
+
expect(result.hasBlockers).toBe(false);
|
|
86
|
+
expect(result.warnings).toHaveLength(0);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const SKYRAMP_IMAGE_VERSION = "v1.3.
|
|
2
|
-
export declare const EXECUTOR_DOCKER_IMAGE = "skyramp/executor:v1.3.
|
|
3
|
-
export declare const WORKER_DOCKER_IMAGE = "skyramp/worker:v1.3.
|
|
1
|
+
export declare const SKYRAMP_IMAGE_VERSION = "v1.3.30";
|
|
2
|
+
export declare const EXECUTOR_DOCKER_IMAGE = "skyramp/executor:v1.3.30";
|
|
3
|
+
export declare const WORKER_DOCKER_IMAGE = "skyramp/worker:v1.3.30";
|
package/build/utils/versions.js
CHANGED
|
@@ -28,6 +28,7 @@ export declare const serviceSchema: z.ZodObject<{
|
|
|
28
28
|
}>>;
|
|
29
29
|
runtimeDetails: z.ZodOptional<z.ZodObject<{
|
|
30
30
|
serverStartCommand: z.ZodOptional<z.ZodString>;
|
|
31
|
+
serverStopCommand: z.ZodOptional<z.ZodString>;
|
|
31
32
|
runtime: z.ZodEnum<["local", "docker", "k8s"]>;
|
|
32
33
|
dockerNetwork: z.ZodOptional<z.ZodString>;
|
|
33
34
|
k8sNamespace: z.ZodOptional<z.ZodString>;
|
|
@@ -38,12 +39,14 @@ export declare const serviceSchema: z.ZodObject<{
|
|
|
38
39
|
k8sNamespace?: string | undefined;
|
|
39
40
|
k8sContext?: string | undefined;
|
|
40
41
|
serverStartCommand?: string | undefined;
|
|
42
|
+
serverStopCommand?: string | undefined;
|
|
41
43
|
}, {
|
|
42
44
|
runtime: "local" | "docker" | "k8s";
|
|
43
45
|
dockerNetwork?: string | undefined;
|
|
44
46
|
k8sNamespace?: string | undefined;
|
|
45
47
|
k8sContext?: string | undefined;
|
|
46
48
|
serverStartCommand?: string | undefined;
|
|
49
|
+
serverStopCommand?: string | undefined;
|
|
47
50
|
}>>;
|
|
48
51
|
}, "strict", z.ZodTypeAny, {
|
|
49
52
|
serviceName: string;
|
|
@@ -64,6 +67,7 @@ export declare const serviceSchema: z.ZodObject<{
|
|
|
64
67
|
k8sNamespace?: string | undefined;
|
|
65
68
|
k8sContext?: string | undefined;
|
|
66
69
|
serverStartCommand?: string | undefined;
|
|
70
|
+
serverStopCommand?: string | undefined;
|
|
67
71
|
} | undefined;
|
|
68
72
|
}, {
|
|
69
73
|
serviceName: string;
|
|
@@ -84,6 +88,7 @@ export declare const serviceSchema: z.ZodObject<{
|
|
|
84
88
|
k8sNamespace?: string | undefined;
|
|
85
89
|
k8sContext?: string | undefined;
|
|
86
90
|
serverStartCommand?: string | undefined;
|
|
91
|
+
serverStopCommand?: string | undefined;
|
|
87
92
|
} | undefined;
|
|
88
93
|
}>;
|
|
89
94
|
export declare const workspaceConfigSchema: z.ZodObject<{
|
|
@@ -99,22 +104,22 @@ export declare const workspaceConfigSchema: z.ZodObject<{
|
|
|
99
104
|
}>>;
|
|
100
105
|
metadata: z.ZodOptional<z.ZodObject<{
|
|
101
106
|
schemaVersion: z.ZodString;
|
|
102
|
-
mcpVersion: z.ZodString
|
|
107
|
+
mcpVersion: z.ZodOptional<z.ZodString>;
|
|
103
108
|
executorVersion: z.ZodString;
|
|
104
|
-
createdAt: z.ZodString
|
|
105
|
-
updatedAt: z.ZodString
|
|
109
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
110
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
106
111
|
}, "strict", z.ZodTypeAny, {
|
|
107
|
-
createdAt: string;
|
|
108
112
|
schemaVersion: string;
|
|
109
|
-
mcpVersion: string;
|
|
110
113
|
executorVersion: string;
|
|
111
|
-
|
|
114
|
+
createdAt?: string | undefined;
|
|
115
|
+
mcpVersion?: string | undefined;
|
|
116
|
+
updatedAt?: string | undefined;
|
|
112
117
|
}, {
|
|
113
|
-
createdAt: string;
|
|
114
118
|
schemaVersion: string;
|
|
115
|
-
mcpVersion: string;
|
|
116
119
|
executorVersion: string;
|
|
117
|
-
|
|
120
|
+
createdAt?: string | undefined;
|
|
121
|
+
mcpVersion?: string | undefined;
|
|
122
|
+
updatedAt?: string | undefined;
|
|
118
123
|
}>>;
|
|
119
124
|
services: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
120
125
|
serviceName: z.ZodString;
|
|
@@ -143,6 +148,7 @@ export declare const workspaceConfigSchema: z.ZodObject<{
|
|
|
143
148
|
}>>;
|
|
144
149
|
runtimeDetails: z.ZodOptional<z.ZodObject<{
|
|
145
150
|
serverStartCommand: z.ZodOptional<z.ZodString>;
|
|
151
|
+
serverStopCommand: z.ZodOptional<z.ZodString>;
|
|
146
152
|
runtime: z.ZodEnum<["local", "docker", "k8s"]>;
|
|
147
153
|
dockerNetwork: z.ZodOptional<z.ZodString>;
|
|
148
154
|
k8sNamespace: z.ZodOptional<z.ZodString>;
|
|
@@ -153,12 +159,14 @@ export declare const workspaceConfigSchema: z.ZodObject<{
|
|
|
153
159
|
k8sNamespace?: string | undefined;
|
|
154
160
|
k8sContext?: string | undefined;
|
|
155
161
|
serverStartCommand?: string | undefined;
|
|
162
|
+
serverStopCommand?: string | undefined;
|
|
156
163
|
}, {
|
|
157
164
|
runtime: "local" | "docker" | "k8s";
|
|
158
165
|
dockerNetwork?: string | undefined;
|
|
159
166
|
k8sNamespace?: string | undefined;
|
|
160
167
|
k8sContext?: string | undefined;
|
|
161
168
|
serverStartCommand?: string | undefined;
|
|
169
|
+
serverStopCommand?: string | undefined;
|
|
162
170
|
}>>;
|
|
163
171
|
}, "strict", z.ZodTypeAny, {
|
|
164
172
|
serviceName: string;
|
|
@@ -179,6 +187,7 @@ export declare const workspaceConfigSchema: z.ZodObject<{
|
|
|
179
187
|
k8sNamespace?: string | undefined;
|
|
180
188
|
k8sContext?: string | undefined;
|
|
181
189
|
serverStartCommand?: string | undefined;
|
|
190
|
+
serverStopCommand?: string | undefined;
|
|
182
191
|
} | undefined;
|
|
183
192
|
}, {
|
|
184
193
|
serviceName: string;
|
|
@@ -199,15 +208,16 @@ export declare const workspaceConfigSchema: z.ZodObject<{
|
|
|
199
208
|
k8sNamespace?: string | undefined;
|
|
200
209
|
k8sContext?: string | undefined;
|
|
201
210
|
serverStartCommand?: string | undefined;
|
|
211
|
+
serverStopCommand?: string | undefined;
|
|
202
212
|
} | undefined;
|
|
203
213
|
}>, "many">>;
|
|
204
214
|
}, "strict", z.ZodTypeAny, {
|
|
205
215
|
metadata?: {
|
|
206
|
-
createdAt: string;
|
|
207
216
|
schemaVersion: string;
|
|
208
|
-
mcpVersion: string;
|
|
209
217
|
executorVersion: string;
|
|
210
|
-
|
|
218
|
+
createdAt?: string | undefined;
|
|
219
|
+
mcpVersion?: string | undefined;
|
|
220
|
+
updatedAt?: string | undefined;
|
|
211
221
|
} | undefined;
|
|
212
222
|
workspace?: {
|
|
213
223
|
repoName?: string | undefined;
|
|
@@ -232,15 +242,16 @@ export declare const workspaceConfigSchema: z.ZodObject<{
|
|
|
232
242
|
k8sNamespace?: string | undefined;
|
|
233
243
|
k8sContext?: string | undefined;
|
|
234
244
|
serverStartCommand?: string | undefined;
|
|
245
|
+
serverStopCommand?: string | undefined;
|
|
235
246
|
} | undefined;
|
|
236
247
|
}[] | undefined;
|
|
237
248
|
}, {
|
|
238
249
|
metadata?: {
|
|
239
|
-
createdAt: string;
|
|
240
250
|
schemaVersion: string;
|
|
241
|
-
mcpVersion: string;
|
|
242
251
|
executorVersion: string;
|
|
243
|
-
|
|
252
|
+
createdAt?: string | undefined;
|
|
253
|
+
mcpVersion?: string | undefined;
|
|
254
|
+
updatedAt?: string | undefined;
|
|
244
255
|
} | undefined;
|
|
245
256
|
workspace?: {
|
|
246
257
|
repoName?: string | undefined;
|
|
@@ -265,6 +276,7 @@ export declare const workspaceConfigSchema: z.ZodObject<{
|
|
|
265
276
|
k8sNamespace?: string | undefined;
|
|
266
277
|
k8sContext?: string | undefined;
|
|
267
278
|
serverStartCommand?: string | undefined;
|
|
279
|
+
serverStopCommand?: string | undefined;
|
|
268
280
|
} | undefined;
|
|
269
281
|
}[] | undefined;
|
|
270
282
|
}>;
|
|
@@ -277,11 +289,11 @@ export type MetadataSection = NonNullable<WorkspaceConfig["metadata"]>;
|
|
|
277
289
|
/** Validates a workspace configuration object against the Zod schema. */
|
|
278
290
|
export declare function validateWorkspaceConfig(config: unknown): z.SafeParseReturnType<{
|
|
279
291
|
metadata?: {
|
|
280
|
-
createdAt: string;
|
|
281
292
|
schemaVersion: string;
|
|
282
|
-
mcpVersion: string;
|
|
283
293
|
executorVersion: string;
|
|
284
|
-
|
|
294
|
+
createdAt?: string | undefined;
|
|
295
|
+
mcpVersion?: string | undefined;
|
|
296
|
+
updatedAt?: string | undefined;
|
|
285
297
|
} | undefined;
|
|
286
298
|
workspace?: {
|
|
287
299
|
repoName?: string | undefined;
|
|
@@ -306,15 +318,16 @@ export declare function validateWorkspaceConfig(config: unknown): z.SafeParseRet
|
|
|
306
318
|
k8sNamespace?: string | undefined;
|
|
307
319
|
k8sContext?: string | undefined;
|
|
308
320
|
serverStartCommand?: string | undefined;
|
|
321
|
+
serverStopCommand?: string | undefined;
|
|
309
322
|
} | undefined;
|
|
310
323
|
}[] | undefined;
|
|
311
324
|
}, {
|
|
312
325
|
metadata?: {
|
|
313
|
-
createdAt: string;
|
|
314
326
|
schemaVersion: string;
|
|
315
|
-
mcpVersion: string;
|
|
316
327
|
executorVersion: string;
|
|
317
|
-
|
|
328
|
+
createdAt?: string | undefined;
|
|
329
|
+
mcpVersion?: string | undefined;
|
|
330
|
+
updatedAt?: string | undefined;
|
|
318
331
|
} | undefined;
|
|
319
332
|
workspace?: {
|
|
320
333
|
repoName?: string | undefined;
|
|
@@ -339,6 +352,7 @@ export declare function validateWorkspaceConfig(config: unknown): z.SafeParseRet
|
|
|
339
352
|
k8sNamespace?: string | undefined;
|
|
340
353
|
k8sContext?: string | undefined;
|
|
341
354
|
serverStartCommand?: string | undefined;
|
|
355
|
+
serverStopCommand?: string | undefined;
|
|
342
356
|
} | undefined;
|
|
343
357
|
}[] | undefined;
|
|
344
358
|
}>;
|
|
@@ -57,6 +57,7 @@ export const serviceSchema = z
|
|
|
57
57
|
runtimeDetails: z
|
|
58
58
|
.object({
|
|
59
59
|
serverStartCommand: z.string().optional(),
|
|
60
|
+
serverStopCommand: z.string().optional(),
|
|
60
61
|
runtime: z.enum(["local", "docker", "k8s"]),
|
|
61
62
|
dockerNetwork: z.string().optional(),
|
|
62
63
|
k8sNamespace: z.string().optional(),
|
|
@@ -78,10 +79,14 @@ export const workspaceConfigSchema = z
|
|
|
78
79
|
metadata: z
|
|
79
80
|
.object({
|
|
80
81
|
schemaVersion: z.string(),
|
|
81
|
-
mcpVersion
|
|
82
|
+
// mcpVersion is no longer written by skyramp_init_workspace (SKYR-3818), but
|
|
83
|
+
// remains an optional, recognized key: testbot reads it from pre-existing
|
|
84
|
+
// workspaces as a fallback MCP-version pin (testbot.git src/config.ts), and
|
|
85
|
+
// older files still carry it. Optional so configs without it validate.
|
|
86
|
+
mcpVersion: z.string().optional(),
|
|
82
87
|
executorVersion: z.string(),
|
|
83
|
-
createdAt: z.string(),
|
|
84
|
-
updatedAt: z.string(),
|
|
88
|
+
createdAt: z.string().optional(),
|
|
89
|
+
updatedAt: z.string().optional(),
|
|
85
90
|
})
|
|
86
91
|
.strict()
|
|
87
92
|
.optional(),
|
|
@@ -121,7 +126,6 @@ export function createDefaultConfig() {
|
|
|
121
126
|
workspace: {},
|
|
122
127
|
metadata: {
|
|
123
128
|
schemaVersion: "v1",
|
|
124
|
-
mcpVersion: "",
|
|
125
129
|
executorVersion: "",
|
|
126
130
|
createdAt: now,
|
|
127
131
|
updatedAt: now,
|
|
@@ -7,9 +7,11 @@ import { serviceSchema, WorkspaceConfigManager, validateWorkspaceConfig, createD
|
|
|
7
7
|
describe("workspace module (ported from @skyramp/skyramp, SKYR-3794)", () => {
|
|
8
8
|
describe("serviceSchema", () => {
|
|
9
9
|
it("accepts an optional repository and rejects a non-string repository", () => {
|
|
10
|
-
expect(serviceSchema.safeParse({ serviceName: "api", repository: "org/api" })
|
|
10
|
+
expect(serviceSchema.safeParse({ serviceName: "api", repository: "org/api" })
|
|
11
|
+
.success).toBe(true);
|
|
11
12
|
expect(serviceSchema.safeParse({ serviceName: "api" }).success).toBe(true);
|
|
12
|
-
expect(serviceSchema.safeParse({ serviceName: "api", repository: 123 })
|
|
13
|
+
expect(serviceSchema.safeParse({ serviceName: "api", repository: 123 })
|
|
14
|
+
.success).toBe(false);
|
|
13
15
|
});
|
|
14
16
|
it("rejects unknown fields (strict)", () => {
|
|
15
17
|
expect(serviceSchema.safeParse({ serviceName: "api", bogus: true }).success).toBe(false);
|
|
@@ -41,15 +43,72 @@ describe("workspace module (ported from @skyramp/skyramp, SKYR-3794)", () => {
|
|
|
41
43
|
it("keeps a same-named service from a different repo distinct, and upserts in place", async () => {
|
|
42
44
|
const mgr = new WorkspaceConfigManager(repoDir);
|
|
43
45
|
await mgr.initialize();
|
|
44
|
-
await mgr.addService({
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
await mgr.addService({
|
|
47
|
+
serviceName: "svc",
|
|
48
|
+
testDirectory: "tests/primary",
|
|
49
|
+
});
|
|
50
|
+
await mgr.addService({
|
|
51
|
+
serviceName: "svc",
|
|
52
|
+
repository: "letsramp/api-insight",
|
|
53
|
+
testDirectory: "tests/py",
|
|
54
|
+
});
|
|
55
|
+
await mgr.addService({
|
|
56
|
+
serviceName: "svc",
|
|
57
|
+
testDirectory: "tests/primary-v2",
|
|
58
|
+
}); // upsert primary
|
|
47
59
|
const cfg = read();
|
|
48
60
|
expect(cfg.services).toHaveLength(2);
|
|
49
61
|
expect(cfg.services.find((s) => !s.repository).testDirectory).toBe("tests/primary-v2");
|
|
50
|
-
expect(cfg.services.find((s) => s.repository === "letsramp/api-insight")
|
|
62
|
+
expect(cfg.services.find((s) => s.repository === "letsramp/api-insight")
|
|
63
|
+
.testDirectory).toBe("tests/py");
|
|
51
64
|
// repoName auto-detected from the git remote.
|
|
52
65
|
expect(cfg.workspace.repoName).toBe("letsramp/primary");
|
|
53
66
|
});
|
|
54
67
|
});
|
|
68
|
+
describe("mcpVersion: no longer written, still accepted (SKYR-3818)", () => {
|
|
69
|
+
let repoDir;
|
|
70
|
+
beforeEach(() => {
|
|
71
|
+
repoDir = fs.mkdtempSync(path.join(os.tmpdir(), "ws-mcpver-"));
|
|
72
|
+
execFileSync("git", ["init", "-q"], { cwd: repoDir });
|
|
73
|
+
execFileSync("git", ["remote", "add", "origin", "https://github.com/letsramp/primary.git"], { cwd: repoDir });
|
|
74
|
+
});
|
|
75
|
+
afterEach(() => {
|
|
76
|
+
fs.rmSync(repoDir, { recursive: true, force: true });
|
|
77
|
+
});
|
|
78
|
+
// Writes a workspace.yml that carries metadata.mcpVersion, emulating a workspace
|
|
79
|
+
// initialized by an older MCP version (which still stamped the field).
|
|
80
|
+
const writeLegacyConfig = () => {
|
|
81
|
+
const dir = path.join(repoDir, WORKSPACE_DIR);
|
|
82
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
83
|
+
const now = new Date().toISOString();
|
|
84
|
+
const legacy = {
|
|
85
|
+
workspace: { repoName: "letsramp/primary" },
|
|
86
|
+
metadata: {
|
|
87
|
+
schemaVersion: "v1",
|
|
88
|
+
mcpVersion: "0.0.64",
|
|
89
|
+
executorVersion: "1.2.3",
|
|
90
|
+
createdAt: now,
|
|
91
|
+
updatedAt: now,
|
|
92
|
+
},
|
|
93
|
+
services: [],
|
|
94
|
+
};
|
|
95
|
+
fs.writeFileSync(path.join(dir, WORKSPACE_FILENAME), yaml.dump(legacy), "utf8");
|
|
96
|
+
};
|
|
97
|
+
const readRaw = () => yaml.load(fs.readFileSync(path.join(repoDir, WORKSPACE_DIR, WORKSPACE_FILENAME), "utf8"), { schema: yaml.JSON_SCHEMA });
|
|
98
|
+
it("does not write mcpVersion into a freshly initialized workspace", async () => {
|
|
99
|
+
const mgr = new WorkspaceConfigManager(repoDir);
|
|
100
|
+
await mgr.initialize();
|
|
101
|
+
const onDisk = readRaw();
|
|
102
|
+
expect(onDisk.metadata.mcpVersion).toBeUndefined();
|
|
103
|
+
});
|
|
104
|
+
it("preserves mcpVersion from a pre-existing workspace.yml on read (testbot fallback)", async () => {
|
|
105
|
+
writeLegacyConfig();
|
|
106
|
+
const mgr = new WorkspaceConfigManager(repoDir);
|
|
107
|
+
const cfg = await mgr.read();
|
|
108
|
+
// Kept as an optional recognized key — not stripped — so testbot's
|
|
109
|
+
// config.ts MCP-version fallback keeps working for existing workspaces.
|
|
110
|
+
expect(cfg.metadata?.mcpVersion).toBe("0.0.64");
|
|
111
|
+
expect(cfg.metadata?.executorVersion).toBe("1.2.3");
|
|
112
|
+
});
|
|
113
|
+
});
|
|
55
114
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyramp/mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.150-rc.ldw-",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./build/index.js",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
69
69
|
"@playwright/test": "^1.55.0",
|
|
70
|
-
"@skyramp/skyramp": "1.3.
|
|
70
|
+
"@skyramp/skyramp": "1.3.30",
|
|
71
71
|
"dockerode": "^5.0.0",
|
|
72
72
|
"fast-glob": "^3.3.3",
|
|
73
73
|
"js-yaml": "^4.1.1",
|