Use McpbManifestDefault derived from DEFAULT_MANIFEST_VERSION

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 <noreply@anthropic.com>
This commit is contained in:
Joan Xie 2025-11-03 15:47:05 -08:00
commit 3fffc30560
No known key found for this signature in database
3 changed files with 17 additions and 13 deletions

View file

@ -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<typeof McpbManifestSchemaV0_2> {
): 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,

View file

@ -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<typeof McpServerConfigSchema>;
@ -53,10 +55,17 @@ export type McpbUserConfigValues = z.infer<typeof McpbUserConfigValuesSchema>;
export type McpbManifestAny = z.infer<typeof McpbManifestSchemaAny>;
/**
* 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<typeof McpbManifestSchemaV0_2>;
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

View file

@ -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",