Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@marius-kilocode
Copy link
Collaborator

Summary

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)

Files Changed

  • packages/core-schemas/package.json - Updated zod dependency to ^4.3.5
  • packages/core-schemas/src/auth/kilocode.ts - Updated function schema syntax
  • packages/core-schemas/src/config/cli-config.ts - Updated record schema syntax
  • packages/core-schemas/src/config/provider.ts - Updated record schema syntax
  • packages/core-schemas/src/mcp/server.ts - Updated record schema syntax
  • packages/core-schemas/src/messages/extension.ts - Updated record schema syntax

Testing

  • @kilocode/core-schemas type checking passes
  • ✅ CLI builds successfully
  • ✅ All 1949 CLI tests pass

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-bot
Copy link

changeset-bot bot commented Jan 16, 2026

🦋 Changeset detected

Latest commit: 178a426

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@kilocode/core-schemas Patch
kilo-code Patch
@kilocode/cli Patch

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

@marius-kilocode marius-kilocode enabled auto-merge (squash) January 16, 2026 12:24
@marius-kilocode marius-kilocode requested a review from a team January 16, 2026 12:24
@kiloconnect
Copy link
Contributor

kiloconnect bot commented Jan 16, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR upgrades the @kilocode/core-schemas package from Zod v3 to Zod v4 for consistency with the CLI package. The changes are straightforward API migrations required by Zod v4:

  1. z.function() syntax change: Zod v4 uses z.function({ input: ..., output: ... }) instead of z.function().args(...).returns(...)
  2. z.record() syntax change: Zod v4 requires explicit key type as first argument: z.record(z.string(), valueSchema) instead of z.record(valueSchema)

All changes follow the correct Zod v4 migration patterns and maintain the same runtime behavior.

Files Reviewed (7 files)
  • .changeset/fix-cli-zod-commander-compat.md - Changeset for patch release
  • packages/core-schemas/package.json - Zod version bump from ^3.25.61 to ^4.3.5
  • packages/core-schemas/src/auth/kilocode.ts - Function schema syntax update
  • packages/core-schemas/src/config/cli-config.ts - Record schema syntax update
  • packages/core-schemas/src/config/provider.ts - Record schema syntax update
  • packages/core-schemas/src/mcp/server.ts - Record schema syntax updates
  • packages/core-schemas/src/messages/extension.ts - Record schema syntax updates
  • pnpm-lock.yaml - Lock file update

@marius-kilocode marius-kilocode merged commit b2e2630 into main Jan 16, 2026
12 checks passed
@marius-kilocode marius-kilocode deleted the can_you_look_into branch January 16, 2026 12:34
@github-actions github-actions bot mentioned this pull request Jan 16, 2026
PeterDaveHello added a commit to PeterDaveHelloKitchen/kilocode that referenced this pull request Jan 17, 2026
…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
marius-kilocode added a commit that referenced this pull request Jan 18, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants