From fefd9e1d2151ebbfd99d71a6a6364210a13d3568 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Wed, 24 Sep 2025 14:12:10 -0700 Subject: [PATCH] fix: add schemas re-export file and update tests to use correct manifest version - Create src/schemas.ts to re-export from schemas/index.ts for test imports - Update test manifests to use manifest_version "0.2" instead of "1.0" or "1.0.0" - Fix import sorting and formatting issues in schema files - Export McpbManifestSchema from schemas/index.ts --- src/cli/pack.ts | 5 +++- src/node/validate.ts | 5 +++- src/schemas.ts | 6 +++++ src/schemas/0.1.ts | 5 +++- src/schemas/0.2.ts | 55 ++++++++++++++++++++------------------ src/schemas/index.ts | 6 +++-- src/schemas_loose/0.1.ts | 5 +++- src/schemas_loose/0.2.ts | 5 +++- src/schemas_loose/index.ts | 2 +- src/shared/constants.ts | 6 +++-- test/config.test.ts | 4 +-- test/schemas.test.ts | 4 +-- test/valid-manifest.json | 2 +- 13 files changed, 69 insertions(+), 41 deletions(-) create mode 100644 src/schemas.ts diff --git a/src/cli/pack.ts b/src/cli/pack.ts index 5b9dc6b..0e51d9b 100644 --- a/src/cli/pack.ts +++ b/src/cli/pack.ts @@ -13,7 +13,10 @@ import { basename, join, relative, resolve, sep } from "path"; import { getAllFilesWithCount, readMcpbIgnorePatterns } from "../node/files.js"; import { validateManifest } from "../node/validate.js"; -import { CURRENT_MANIFEST_VERSION, CURRENT_MANIFEST_SCHEMA } from "../shared/constants.js"; +import { + CURRENT_MANIFEST_SCHEMA, + CURRENT_MANIFEST_VERSION, +} from "../shared/constants.js"; import { getLogger } from "../shared/log.js"; import { initExtension } from "./init.js"; diff --git a/src/node/validate.ts b/src/node/validate.ts index 3be269e..5b44189 100644 --- a/src/node/validate.ts +++ b/src/node/validate.ts @@ -6,7 +6,10 @@ import { join, resolve } from "path"; import prettyBytes from "pretty-bytes"; import { unpackExtension } from "../cli/unpack.js"; -import { CURRENT_MANIFEST_SCHEMA, CURRENT_MANIFEST_SCHEMA_LOOSE } from "../shared/constants.js"; +import { + CURRENT_MANIFEST_SCHEMA, + CURRENT_MANIFEST_SCHEMA_LOOSE, +} from "../shared/constants.js"; export function validateManifest(inputPath: string): boolean { try { diff --git a/src/schemas.ts b/src/schemas.ts new file mode 100644 index 0000000..4bf0ea8 --- /dev/null +++ b/src/schemas.ts @@ -0,0 +1,6 @@ +export { + CURRENT_MANIFEST_VERSION, + McpbManifestSchema, + v0_1, + v0_2, +} from "./schemas/index.js"; diff --git a/src/schemas/0.1.ts b/src/schemas/0.1.ts index ef54ce3..9bfa788 100644 --- a/src/schemas/0.1.ts +++ b/src/schemas/0.1.ts @@ -79,7 +79,10 @@ export const McpbUserConfigValuesSchema = z.record( export const McpbManifestSchema = z .strictObject({ $schema: z.string().optional(), - dxt_version: z.literal(MANIFEST_VERSION).optional().describe("@deprecated Use manifest_version instead"), + dxt_version: z + .literal(MANIFEST_VERSION) + .optional() + .describe("@deprecated Use manifest_version instead"), manifest_version: z.literal(MANIFEST_VERSION).optional(), name: z.string(), display_name: z.string().optional(), diff --git a/src/schemas/0.2.ts b/src/schemas/0.2.ts index 844efe8..f5d4d03 100644 --- a/src/schemas/0.2.ts +++ b/src/schemas/0.2.ts @@ -79,33 +79,36 @@ export const McpbUserConfigValuesSchema = z.record( export const McpbManifestSchema = z .strictObject({ $schema: z.string().optional(), - dxt_version: z.literal(MANIFEST_VERSION).optional().describe("@deprecated Use manifest_version instead"), + dxt_version: z + .literal(MANIFEST_VERSION) + .optional() + .describe("@deprecated Use manifest_version instead"), manifest_version: z.literal(MANIFEST_VERSION).optional(), - name: z.string(), - display_name: z.string().optional(), - version: z.string(), - description: z.string(), - long_description: z.string().optional(), - author: McpbManifestAuthorSchema, - repository: McpbManifestRepositorySchema.optional(), - homepage: z.string().url().optional(), - documentation: z.string().url().optional(), - support: z.string().url().optional(), - icon: z.string().optional(), - screenshots: z.array(z.string()).optional(), - server: McpbManifestServerSchema, - tools: z.array(McpbManifestToolSchema).optional(), - tools_generated: z.boolean().optional(), - prompts: z.array(McpbManifestPromptSchema).optional(), - prompts_generated: z.boolean().optional(), - keywords: z.array(z.string()).optional(), - license: z.string().optional(), - privacy_policies: z.array(z.string().url()).optional(), - compatibility: McpbManifestCompatibilitySchema.optional(), - user_config: z - .record(z.string(), McpbUserConfigurationOptionSchema) - .optional(), -}) + name: z.string(), + display_name: z.string().optional(), + version: z.string(), + description: z.string(), + long_description: z.string().optional(), + author: McpbManifestAuthorSchema, + repository: McpbManifestRepositorySchema.optional(), + homepage: z.string().url().optional(), + documentation: z.string().url().optional(), + support: z.string().url().optional(), + icon: z.string().optional(), + screenshots: z.array(z.string()).optional(), + server: McpbManifestServerSchema, + tools: z.array(McpbManifestToolSchema).optional(), + tools_generated: z.boolean().optional(), + prompts: z.array(McpbManifestPromptSchema).optional(), + prompts_generated: z.boolean().optional(), + keywords: z.array(z.string()).optional(), + license: z.string().optional(), + privacy_policies: z.array(z.string().url()).optional(), + compatibility: McpbManifestCompatibilitySchema.optional(), + user_config: z + .record(z.string(), McpbUserConfigurationOptionSchema) + .optional(), + }) .refine((data) => !!(data.dxt_version || data.manifest_version), { message: "Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", diff --git a/src/schemas/index.ts b/src/schemas/index.ts index beb8b97..d8599cd 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -1,4 +1,6 @@ export * as v0_1 from "./0.1.js"; export * as v0_2 from "./0.2.js"; - -export { MANIFEST_VERSION as CURRENT_MANIFEST_VERSION } from "./0.2.js"; \ No newline at end of file +export { + MANIFEST_VERSION as CURRENT_MANIFEST_VERSION, + McpbManifestSchema, +} from "./0.2.js"; diff --git a/src/schemas_loose/0.1.ts b/src/schemas_loose/0.1.ts index 9b37647..fbba24c 100644 --- a/src/schemas_loose/0.1.ts +++ b/src/schemas_loose/0.1.ts @@ -81,7 +81,10 @@ export const McpbUserConfigValuesSchema = z.record( export const McpbManifestSchema = z .object({ $schema: z.string().optional(), - dxt_version: z.literal(MANIFEST_VERSION).optional().describe("@deprecated Use manifest_version instead"), + dxt_version: z + .literal(MANIFEST_VERSION) + .optional() + .describe("@deprecated Use manifest_version instead"), manifest_version: z.literal(MANIFEST_VERSION).optional(), name: z.string(), display_name: z.string().optional(), diff --git a/src/schemas_loose/0.2.ts b/src/schemas_loose/0.2.ts index 062b0e6..7cdbc1a 100644 --- a/src/schemas_loose/0.2.ts +++ b/src/schemas_loose/0.2.ts @@ -81,7 +81,10 @@ export const McpbUserConfigValuesSchema = z.record( export const McpbManifestSchema = z .object({ $schema: z.string().optional(), - dxt_version: z.literal(MANIFEST_VERSION).optional().describe("@deprecated Use manifest_version instead"), + dxt_version: z + .literal(MANIFEST_VERSION) + .optional() + .describe("@deprecated Use manifest_version instead"), manifest_version: z.literal(MANIFEST_VERSION).optional(), name: z.string(), display_name: z.string().optional(), diff --git a/src/schemas_loose/index.ts b/src/schemas_loose/index.ts index 16bf78f..168c457 100644 --- a/src/schemas_loose/index.ts +++ b/src/schemas_loose/index.ts @@ -1,2 +1,2 @@ export * as v0_1 from "./0.1.js"; -export * as v0_2 from "./0.2.js"; \ No newline at end of file +export * as v0_2 from "./0.2.js"; diff --git a/src/shared/constants.ts b/src/shared/constants.ts index f1c1359..8cf0606 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -27,9 +27,11 @@ export const MANIFEST_SCHEMAS_LOOSE = { /** * Get the current manifest schema based on CURRENT_MANIFEST_VERSION */ -export const CURRENT_MANIFEST_SCHEMA = MANIFEST_SCHEMAS[CURRENT_MANIFEST_VERSION]; +export const CURRENT_MANIFEST_SCHEMA = + MANIFEST_SCHEMAS[CURRENT_MANIFEST_VERSION]; /** * Get the current loose manifest schema based on CURRENT_MANIFEST_VERSION */ -export const CURRENT_MANIFEST_SCHEMA_LOOSE = MANIFEST_SCHEMAS_LOOSE[CURRENT_MANIFEST_VERSION]; +export const CURRENT_MANIFEST_SCHEMA_LOOSE = + MANIFEST_SCHEMAS_LOOSE[CURRENT_MANIFEST_VERSION]; diff --git a/test/config.test.ts b/test/config.test.ts index 6461c5a..062c66e 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -90,7 +90,7 @@ describe("getMcpConfigForManifest", () => { }; const baseManifest: McpbManifest = { - manifest_version: "1.0.0", + manifest_version: "0.2", name: "test-extension", version: "1.0.0", description: "Test extension", @@ -305,7 +305,7 @@ describe("getMcpConfigForManifest", () => { describe("hasRequiredConfigMissing", () => { const baseManifest: McpbManifest = { - manifest_version: "1.0.0", + manifest_version: "0.2", name: "test-extension", version: "1.0.0", description: "Test extension", diff --git a/test/schemas.test.ts b/test/schemas.test.ts index a9297d8..71773f0 100644 --- a/test/schemas.test.ts +++ b/test/schemas.test.ts @@ -37,7 +37,7 @@ describe("McpbManifestSchema", () => { it("should validate manifest with all optional fields", () => { const fullManifest = { - manifest_version: "1.0", + manifest_version: "0.2", name: "full-extension", display_name: "Full Featured Extension", version: "2.0.0", @@ -117,7 +117,7 @@ describe("McpbManifestSchema", () => { serverTypes.forEach((type) => { const manifest = { - manifest_version: "1.0", + manifest_version: "0.2", name: "test", version: "1.0.0", description: "Test", diff --git a/test/valid-manifest.json b/test/valid-manifest.json index a91e78f..c2d121d 100644 --- a/test/valid-manifest.json +++ b/test/valid-manifest.json @@ -1,5 +1,5 @@ { - "manifest_version": "1.0", + "manifest_version": "0.2", "name": "test-extension", "display_name": "Test Extension", "version": "1.0.0",