-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(core-schemas): upgrade to Zod v4 for CLI compatibility #5107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Upgrades @kilocode/core-schemas from Zod v3 to Zod v4 to ensure
compatibility with the CLI package.
## Problem
The CLI package uses Zod v4 (^4.3.5) while @kilocode/core-schemas was
using Zod v3 (^3.25.61). This version mismatch caused schema validation
failures because Zod v3 and v4 have incompatible APIs:
- Zod v3: z.function().args().returns() (chained builder pattern)
- Zod v4: z.function({ input, output }) (options object pattern)
- Zod v3: z.record(valueSchema) (single argument)
- Zod v4: z.record(keySchema, valueSchema) (two arguments required)
When the CLI imported schemas from @kilocode/core-schemas, the Zod v3
syntax would fail at runtime because the CLI's Zod v4 doesn't have the
.args() and .returns() methods.
## Solution
Upgraded @kilocode/core-schemas to Zod v4 and updated all schema
definitions to use the new API:
1. Function schemas: Changed from z.function().args(...).returns(...)
to z.function({ input: z.tuple([...]), output: ... })
2. Record schemas: Changed from z.record(valueSchema) to
z.record(z.string(), valueSchema)
## Testing
- @kilocode/core-schemas type checking passes
- CLI builds successfully
- All 1949 CLI tests pass
🦋 Changeset detectedLatest commit: 178a426 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge OverviewThis PR upgrades the
All changes follow the correct Zod v4 migration patterns and maintain the same runtime behavior. Files Reviewed (7 files)
|
…n Zod v4 Fixes DTS build errors introduced in PR Kilo-Org#5107 where z.function() was used with incorrect Zod v4 syntax. ## Problem PR Kilo-Org#5107 upgraded core-schemas to Zod v4 and used z.function({ input, output }) syntax, but this is incorrect for Zod v4: - In Zod v4, z.function() is a function factory, not a schema - It cannot be used inside z.object() - This causes DTS build errors: "Object literal may only specify known properties, but 'input' does not exist" See: - Zod v4 changelog: https://zod.dev/v4/changelog#zfunction - Official workaround: colinhacks/zod#4143 ## Solution Use z.custom<T>() with runtime validator for function types: - pollFn: z.custom<() => Promise<unknown>>((val) => typeof val === "function") - onProgress: z.custom<(current: number, total: number) => void>((val) => typeof val === "function") This approach: - Fixes DTS build errors - Preserves type inference - Adds runtime function validation (following Zod best practices) cc Kilo-Org#5107
…n Zod v4 (#5173) Fixes DTS build errors introduced in PR #5107 where z.function() was used with incorrect Zod v4 syntax. ## Problem PR #5107 upgraded core-schemas to Zod v4 and used z.function({ input, output }) syntax, but this is incorrect for Zod v4: - In Zod v4, z.function() is a function factory, not a schema - It cannot be used inside z.object() - This causes DTS build errors: "Object literal may only specify known properties, but 'input' does not exist" See: - Zod v4 changelog: https://zod.dev/v4/changelog#zfunction - Official workaround: colinhacks/zod#4143 ## Solution Use z.custom<T>() with runtime validator for function types: - pollFn: z.custom<() => Promise<unknown>>((val) => typeof val === "function") - onProgress: z.custom<(current: number, total: number) => void>((val) => typeof val === "function") This approach: - Fixes DTS build errors - Preserves type inference - Adds runtime function validation (following Zod best practices) cc #5107 Co-authored-by: Marius <[email protected]>
Summary
Upgrades
@kilocode/core-schemasfrom Zod v3 to Zod v4 to ensure compatibility with the CLI package.Problem
The CLI package uses Zod v4 (
^4.3.5) while@kilocode/core-schemaswas using Zod v3 (^3.25.61). This version mismatch caused schema validation failures because Zod v3 and v4 have incompatible APIs:Zod v3:
z.function().args().returns()(chained builder pattern)Zod v4:
z.function({ input, output })(options object pattern)Zod v3:
z.record(valueSchema)(single argument)Zod v4:
z.record(keySchema, valueSchema)(two arguments required)When the CLI imported schemas from
@kilocode/core-schemas, the Zod v3 syntax would fail at runtime because the CLI's Zod v4 doesn't have the.args()and.returns()methods.Solution
Upgraded
@kilocode/core-schemasto Zod v4 and updated all schema definitions to use the new API:Function schemas: Changed from
z.function().args(...).returns(...)toz.function({ input: z.tuple([...]), output: ... })Record schemas: Changed from
z.record(valueSchema)toz.record(z.string(), valueSchema)Files Changed
packages/core-schemas/package.json- Updated zod dependency to^4.3.5packages/core-schemas/src/auth/kilocode.ts- Updated function schema syntaxpackages/core-schemas/src/config/cli-config.ts- Updated record schema syntaxpackages/core-schemas/src/config/provider.ts- Updated record schema syntaxpackages/core-schemas/src/mcp/server.ts- Updated record schema syntaxpackages/core-schemas/src/messages/extension.ts- Updated record schema syntaxTesting
@kilocode/core-schemastype checking passes