From 761e834ba873c2deabef106d9b66e20715b3a398 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Wed, 3 Dec 2025 20:11:58 -0800 Subject: [PATCH 1/2] feat: add --manifest-version option to init command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow developers to specify which manifest version to use when initializing a new manifest.json file. Usage: mcpb init --manifest-version 0.3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/cli.ts | 36 +++++++++++++++++++++++------------- src/cli/init.ts | 27 ++++++++++++++++++++------- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/cli/cli.ts b/src/cli/cli.ts index ac38b52..7499d89 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -51,19 +51,29 @@ program .command("init [directory]") .description("Create a new MCPB extension manifest") .option("-y, --yes", "Accept all defaults (non-interactive mode)") - .action((directory?: string, options?: { yes?: boolean }) => { - void (async () => { - try { - const success = await initExtension(directory, options?.yes); - process.exit(success ? 0 : 1); - } catch (error) { - console.error( - `ERROR: ${error instanceof Error ? error.message : "Unknown error"}`, - ); - process.exit(1); - } - })(); - }); + .option( + "--manifest-version ", + "Manifest version to use in the generated manifest", + ) + .action( + (directory?: string, options?: { yes?: boolean; manifestVersion?: string }) => { + void (async () => { + try { + const success = await initExtension( + directory, + options?.yes, + options?.manifestVersion, + ); + process.exit(success ? 0 : 1); + } catch (error) { + console.error( + `ERROR: ${error instanceof Error ? error.message : "Unknown error"}`, + ); + process.exit(1); + } + })(); + }, + ); // Validate command program diff --git a/src/cli/init.ts b/src/cli/init.ts index 9e62777..f2dfb53 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -1,12 +1,12 @@ import { confirm, input, select } from "@inquirer/prompts"; import { existsSync, readFileSync, writeFileSync } from "fs"; import { basename, join, resolve } from "path"; -import type { z } from "zod"; -// Import the schema for DEFAULT_MANIFEST_VERSION -// TODO: Allow dynamic manifest version choice -import type { McpbManifestSchema } from "../schemas/0.2.js"; -import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js"; +import { + DEFAULT_MANIFEST_VERSION, + MANIFEST_SCHEMAS, +} from "../shared/constants.js"; +import type { McpbManifestAny } from "../types.js"; interface PackageJson { name?: string; @@ -877,18 +877,19 @@ export function buildManifest( license: string; repository?: { type: string; url: string }; }, + manifestVersion: keyof typeof MANIFEST_SCHEMAS = DEFAULT_MANIFEST_VERSION, // localization?: { // resources: string; // default_locale: string; // }, -): z.infer { +): McpbManifestAny { const { name, displayName, version, description, authorName } = basicInfo; const { authorEmail, authorUrl } = authorInfo; const { serverType, entryPoint, mcp_config } = serverConfig; const { keywords, license, repository } = optionalFields; return { - manifest_version: DEFAULT_MANIFEST_VERSION, + manifest_version: manifestVersion, name, ...(displayName && displayName !== name ? { display_name: displayName } @@ -945,10 +946,21 @@ export function printNextSteps() { export async function initExtension( targetPath: string = process.cwd(), nonInteractive = false, + manifestVersion?: string, ): Promise { const resolvedPath = resolve(targetPath); const manifestPath = join(resolvedPath, "manifest.json"); + // Validate manifest version if provided + if (manifestVersion && !(manifestVersion in MANIFEST_SCHEMAS)) { + console.error( + `ERROR: Invalid manifest version "${manifestVersion}". Supported versions: ${Object.keys(MANIFEST_SCHEMAS).join(", ")}`, + ); + return false; + } + const effectiveManifestVersion = (manifestVersion || + DEFAULT_MANIFEST_VERSION) as keyof typeof MANIFEST_SCHEMAS; + if (existsSync(manifestPath)) { if (nonInteractive) { console.log( @@ -1029,6 +1041,7 @@ export async function initExtension( compatibility, userConfig, optionalFields, + effectiveManifestVersion, ); // Write manifest From 163fa29a1c4c19fa308532d788006deeb021bdfb Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Wed, 3 Dec 2025 21:03:04 -0800 Subject: [PATCH 2/2] style: fix Prettier formatting in cli.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Break function parameters onto separate lines with trailing comma. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/cli.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 7499d89..817b659 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -56,7 +56,10 @@ program "Manifest version to use in the generated manifest", ) .action( - (directory?: string, options?: { yes?: boolean; manifestVersion?: string }) => { + ( + directory?: string, + options?: { yes?: boolean; manifestVersion?: string }, + ) => { void (async () => { try { const success = await initExtension(