Skip to content

Commit fe0a7d3

Browse files
committed
refactor: migrate to zod v4
1 parent c502e79 commit fe0a7d3

125 files changed

Lines changed: 1614 additions & 682 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/ZOD_MIGRATION_GUIDE.md

Lines changed: 879 additions & 0 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@sentry/cli": "^2.43.1",
6464
"@sentry/node": "^10.5.0",
6565
"uuid": "^11.1.0",
66-
"zod": "^3.24.2"
66+
"zod": "^4.0.0"
6767
},
6868
"devDependencies": {
6969
"@bacons/xcode": "^1.0.0-alpha.24",

src/core/plugin-types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { z } from 'zod';
1+
import * as z from 'zod';
22
import { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
33
import { ToolResponse } from '../types/common.ts';
44

5+
export type ToolSchemaShape = Record<string, z.ZodType>;
6+
57
export interface PluginMeta {
68
readonly name: string; // Verb used by MCP
7-
readonly schema: Record<string, z.ZodTypeAny>; // Zod validation schema (object schema)
9+
readonly schema: ToolSchemaShape; // Zod validation schema (object schema)
810
readonly description?: string; // One-liner shown in help
911
readonly annotations?: ToolAnnotations; // MCP tool annotations for LLM behavior hints
1012
handler(params: Record<string, unknown>): Promise<ToolResponse>;

src/mcp/resources/__tests__/simulators.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, beforeEach } from 'vitest';
2-
import { z } from 'zod';
2+
import * as z from 'zod';
33

44
import simulatorsResource, { simulatorsResourceLogic } from '../simulators.ts';
55
import { createMockExecutor } from '../../../test-utils/mock-executors.ts';

src/mcp/tools/device/__tests__/build_device.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { describe, it, expect, beforeEach } from 'vitest';
8-
import { z } from 'zod';
8+
import * as z from 'zod';
99
import { createMockExecutor, createNoopExecutor } from '../../../../test-utils/mock-executors.ts';
1010
import buildDevice, { buildDeviceLogic } from '../build_device.ts';
1111
import { sessionStore } from '../../../../utils/session-store.ts';
@@ -29,7 +29,7 @@ describe('build_device plugin', () => {
2929
});
3030

3131
it('should expose only optional build-tuning fields in public schema', () => {
32-
const schema = z.object(buildDevice.schema).strict();
32+
const schema = z.strictObject(buildDevice.schema);
3333
expect(schema.safeParse({}).success).toBe(true);
3434
expect(
3535
schema.safeParse({ derivedDataPath: '/path/to/derived-data', extraArgs: [] }).success,

src/mcp/tools/device/__tests__/get_device_app_path.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { describe, it, expect, beforeEach } from 'vitest';
8-
import { z } from 'zod';
8+
import * as z from 'zod';
99
import { createMockExecutor } from '../../../../test-utils/mock-executors.ts';
1010
import getDeviceAppPath, { get_device_app_pathLogic } from '../get_device_app_path.ts';
1111
import { sessionStore } from '../../../../utils/session-store.ts';
@@ -31,7 +31,7 @@ describe('get_device_app_path plugin', () => {
3131
});
3232

3333
it('should expose only platform in public schema', () => {
34-
const schema = z.object(getDeviceAppPath.schema).strict();
34+
const schema = z.strictObject(getDeviceAppPath.schema);
3535
expect(schema.safeParse({}).success).toBe(true);
3636
expect(schema.safeParse({ platform: 'iOS' }).success).toBe(true);
3737
expect(schema.safeParse({ projectPath: '/path/to/project.xcodeproj' }).success).toBe(false);

src/mcp/tools/device/__tests__/install_app_device.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { describe, it, expect, beforeEach } from 'vitest';
8-
import { z } from 'zod';
8+
import * as z from 'zod';
99
import { createMockExecutor } from '../../../../test-utils/mock-executors.ts';
1010
import installAppDevice, { install_app_deviceLogic } from '../install_app_device.ts';
1111
import { sessionStore } from '../../../../utils/session-store.ts';
@@ -40,7 +40,7 @@ describe('install_app_device plugin', () => {
4040
});
4141

4242
it('should require appPath in public schema', () => {
43-
const schema = z.object(installAppDevice.schema).strict();
43+
const schema = z.strictObject(installAppDevice.schema);
4444
expect(schema.safeParse({ appPath: '/path/to/test.app' }).success).toBe(true);
4545
expect(schema.safeParse({}).success).toBe(false);
4646
expect(schema.safeParse({ deviceId: 'test-device-123' }).success).toBe(false);

src/mcp/tools/device/__tests__/launch_app_device.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import { describe, it, expect, beforeEach } from 'vitest';
11-
import { z } from 'zod';
11+
import * as z from 'zod';
1212
import { createMockExecutor } from '../../../../test-utils/mock-executors.ts';
1313
import launchAppDevice, { launch_app_deviceLogic } from '../launch_app_device.ts';
1414
import { sessionStore } from '../../../../utils/session-store.ts';
@@ -32,14 +32,14 @@ describe('launch_app_device plugin (device-shared)', () => {
3232
});
3333

3434
it('should validate schema with valid inputs', () => {
35-
const schema = z.object(launchAppDevice.schema).strict();
35+
const schema = z.strictObject(launchAppDevice.schema);
3636
expect(schema.safeParse({ bundleId: 'com.example.app' }).success).toBe(true);
3737
expect(schema.safeParse({}).success).toBe(false);
3838
expect(Object.keys(launchAppDevice.schema)).toEqual(['bundleId']);
3939
});
4040

4141
it('should validate schema with invalid inputs', () => {
42-
const schema = z.object(launchAppDevice.schema).strict();
42+
const schema = z.strictObject(launchAppDevice.schema);
4343
expect(schema.safeParse({ bundleId: null }).success).toBe(false);
4444
expect(schema.safeParse({ bundleId: 123 }).success).toBe(false);
4545
});

src/mcp/tools/device/__tests__/stop_app_device.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { describe, it, expect, beforeEach } from 'vitest';
8-
import { z } from 'zod';
8+
import * as z from 'zod';
99
import { createMockExecutor } from '../../../../test-utils/mock-executors.ts';
1010
import stopAppDevice, { stop_app_deviceLogic } from '../stop_app_device.ts';
1111
import { sessionStore } from '../../../../utils/session-store.ts';
@@ -29,7 +29,7 @@ describe('stop_app_device plugin', () => {
2929
});
3030

3131
it('should require processId in public schema', () => {
32-
const schema = z.object(stopAppDevice.schema).strict();
32+
const schema = z.strictObject(stopAppDevice.schema);
3333
expect(schema.safeParse({ processId: 12345 }).success).toBe(true);
3434
expect(schema.safeParse({}).success).toBe(false);
3535
expect(schema.safeParse({ deviceId: 'test-device-123' }).success).toBe(false);

0 commit comments

Comments
 (0)