From feb022bdbfe81d1759ab01cd959654bada4c3261 Mon Sep 17 00:00:00 2001 From: dyoshikawa-coding Date: Sat, 5 Jul 2025 08:00:41 +0000 Subject: [PATCH] feat: migrate from zod to zod/v4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update all zod imports to use zod/v4 path - Fix z.record() API changes to specify key and value types - Update schema definitions to be compatible with zod v4 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/schemas/index.ts | 61 ++++++++++++++++++++++++++++++++++++++++++++ src/schemas/mcp.ts | 4 +-- 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/schemas/index.ts diff --git a/src/schemas/index.ts b/src/schemas/index.ts new file mode 100644 index 000000000..dab570e71 --- /dev/null +++ b/src/schemas/index.ts @@ -0,0 +1,61 @@ +import { z } from "zod/v4"; + +// Tool target schema +export const ToolTargetSchema = z.enum([ + "copilot", + "cursor", + "cline", + "claudecode", + "roo", + "geminicli", +]); + +// Rule frontmatter schema for validation only +export const RuleFrontmatterSchema = z.object({ + root: z.boolean(), + targets: z.union([z.tuple([z.literal("*")]), z.array(ToolTargetSchema)]), + description: z.string(), + globs: z.array(z.string()), + cursorRuleType: z.enum(["always", "manual", "specificFiles", "intelligently"]).optional(), +}); + +// Generic JSON object schema +export const JsonObjectSchema = z.record(z.string(), z.unknown()); + +// MCP server transport schema +export const TransportSchema = z.enum(["stdio", "sse", "http"]); + +// MCP server schema for validation only +export const RulesyncMcpServerSchema = z.object({ + command: z.string().optional(), + args: z.array(z.string()).optional(), + url: z.string().optional(), + httpUrl: z.string().optional(), + env: z.record(z.string(), z.string()).optional(), + disabled: z.boolean().optional(), + networkTimeout: z.number().optional(), + timeout: z.number().optional(), + trust: z.boolean().optional(), + cwd: z.string().optional(), + transport: TransportSchema.optional(), + type: z.enum(["sse", "streamable-http"]).optional(), + alwaysAllow: z.array(z.string()).optional(), + tools: z.array(z.string()).optional(), + targets: z.union([z.tuple([z.literal("*")]), z.array(ToolTargetSchema)]).optional(), +}); + +// MCP config schema for validation only +export const RulesyncMcpConfigSchema = z.object({ + mcpServers: z.record(z.string(), RulesyncMcpServerSchema), +}); + +// Claude settings permissions schema +export const ClaudePermissionsSchema = z.object({ + deny: z.array(z.string()).optional(), +}); + +// Claude settings schema +export const ClaudeSettingsSchema = z.object({ + permissions: ClaudePermissionsSchema.optional(), + mcpServers: z.record(z.string(), RulesyncMcpServerSchema).optional(), +}); diff --git a/src/schemas/mcp.ts b/src/schemas/mcp.ts index 8c952da43..6273f8aee 100644 --- a/src/schemas/mcp.ts +++ b/src/schemas/mcp.ts @@ -1,4 +1,4 @@ -import { z } from "zod"; +import { z } from "zod/v4"; export const ToolTargetSchema = z.enum([ "copilot", @@ -21,7 +21,7 @@ export const McpServerBaseSchema = z.object({ args: z.array(z.string()).optional(), url: z.string().optional(), httpUrl: z.string().optional(), - env: z.record(z.string()).optional(), + env: z.record(z.string(), z.string()).optional(), disabled: z.boolean().optional(), networkTimeout: z.number().optional(), timeout: z.number().optional(),