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
This commit is contained in:
Joan Xie 2025-09-24 14:12:10 -07:00
commit fefd9e1d21
No known key found for this signature in database
13 changed files with 69 additions and 41 deletions

View file

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

View file

@ -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 {

6
src/schemas.ts Normal file
View file

@ -0,0 +1,6 @@
export {
CURRENT_MANIFEST_VERSION,
McpbManifestSchema,
v0_1,
v0_2,
} from "./schemas/index.js";

View file

@ -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(),

View file

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

View file

@ -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";
export {
MANIFEST_VERSION as CURRENT_MANIFEST_VERSION,
McpbManifestSchema,
} from "./0.2.js";

View file

@ -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(),

View file

@ -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(),

View file

@ -1,2 +1,2 @@
export * as v0_1 from "./0.1.js";
export * as v0_2 from "./0.2.js";
export * as v0_2 from "./0.2.js";

View file

@ -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];

View file

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

View file

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

View file

@ -1,5 +1,5 @@
{
"manifest_version": "1.0",
"manifest_version": "0.2",
"name": "test-extension",
"display_name": "Test Extension",
"version": "1.0.0",