From 3fffc30560cee0ef99560c2f3e542a15c72d795e Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 15:47:05 -0800 Subject: [PATCH] Use McpbManifestDefault derived from DEFAULT_MANIFEST_VERSION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Create McpbManifestDefault type derived from VERSIONED_MANIFEST_SCHEMAS[DEFAULT_MANIFEST_VERSION] - Update init.ts to use McpbManifestDefault instead of hardcoded v0.2 schema - Import schema types from version matching DEFAULT_MANIFEST_VERSION (0.2) - Update test to match commented-out localization field - Make McpbManifest (deprecated) point to McpbManifestDefault This makes the codebase more maintainable by deriving types from DEFAULT_MANIFEST_VERSION instead of hardcoding version references. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/init.ts | 7 +++---- src/types.ts | 19 ++++++++++++++----- test/init.test.ts | 4 ---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/cli/init.ts b/src/cli/init.ts index 3b2ad80..be8eaa5 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -1,10 +1,9 @@ import { confirm, input, select } from "@inquirer/prompts"; import { existsSync, readFileSync, writeFileSync } from "fs"; import { basename, join, resolve } from "path"; -import type * as z from "zod"; -import type { McpbManifestSchema as McpbManifestSchemaV0_2 } from "../schemas/0.2.js"; import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js"; +import type { McpbManifestDefault } from "../types.js"; interface PackageJson { name?: string; @@ -879,7 +878,7 @@ export function buildManifest( resources: string; default_locale: string; }, -): z.infer { +): McpbManifestDefault { const { name, displayName, version, description, authorName } = basicInfo; const { authorEmail, authorUrl } = authorInfo; const { serverType, entryPoint, mcp_config } = serverConfig; @@ -907,7 +906,7 @@ export function buildManifest( ...(visualAssets.screenshots.length > 0 ? { screenshots: visualAssets.screenshots } : {}), - ...(localization ? { localization } : {}), + // ...(localization ? { localization } : {}), server: { type: serverType, entry_point: entryPoint, diff --git a/src/types.ts b/src/types.ts index 20296af..90c5c1d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,8 @@ import type * as z from "zod"; import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js"; -import type { McpbManifestSchema as McpbManifestSchemaV0_2 } from "./schemas/0.2.js"; +import { VERSIONED_MANIFEST_SCHEMAS } from "./schemas/index.js"; +// Import schema types from the version matching DEFAULT_MANIFEST_VERSION import type { McpbManifestAuthorSchema, McpbManifestCompatibilitySchema, @@ -15,7 +16,8 @@ import type { McpbUserConfigurationOptionSchema, McpbUserConfigValuesSchema, McpServerConfigSchema, -} from "./schemas/0.3.js"; +} from "./schemas/0.2.js"; +import { DEFAULT_MANIFEST_VERSION } from "./shared/constants.js"; export type McpServerConfig = z.infer; @@ -53,10 +55,17 @@ export type McpbUserConfigValues = z.infer; export type McpbManifestAny = z.infer; /** - * McpbManifest type for v0.2 (default version) for backwards compatibility - * @deprecated Use McpbManifestAny instead to support all manifest versions. + * McpbManifest type for the DEFAULT_MANIFEST_VERSION + * Use this for creating new manifests with the default version. */ -export type McpbManifest = z.infer; +export type McpbManifestDefault = z.infer< + (typeof VERSIONED_MANIFEST_SCHEMAS)[typeof DEFAULT_MANIFEST_VERSION] +>; + +/** + * @deprecated Use McpbManifestAny instead to support all manifest versions, or McpbManifestDefault for the default version. + */ +export type McpbManifest = McpbManifestDefault; /** * Information about a MCPB package signature diff --git a/test/init.test.ts b/test/init.test.ts index a9b9bf4..def2e9c 100644 --- a/test/init.test.ts +++ b/test/init.test.ts @@ -351,10 +351,6 @@ describe("init functions", () => { }, ], screenshots: ["screen1.png", "screen2.png"], - localization: { - resources: "resources/${locale}.json", - default_locale: "en-US", - }, server: { type: "python", entry_point: "server/main.py",