11/**
22 * Script to generate JSON Schema from Zod schema
3- * Run with: pnpm tsx scripts/generate-schema.ts
3+ * Run with: pnpm tsx packages/skills-package-manager/ scripts/generate-schema.ts
44 */
55import { writeFile } from 'node:fs/promises'
6- import { createRequire } from 'node:module'
76import path from 'node:path'
87import { fileURLToPath } from 'node:url'
9- import { skillsManifestSchema } from '../packages/skills-package-manager/src/config/schema'
8+ import { z } from 'zod'
9+ import { skillsManifestSchema } from '../src/config/schema'
1010
1111const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
1212const rootDir = path . join ( __dirname , '..' )
1313
14- // Use createRequire to import from the workspace package
15- const requireFromPackage = createRequire (
16- new URL ( '../packages/skills-package-manager/package.json' , import . meta. url ) ,
17- )
18- const { zodToJsonSchema } = requireFromPackage ( 'zod-to-json-schema' ) as {
19- zodToJsonSchema : typeof import ( 'zod-to-json-schema' ) . zodToJsonSchema
20- }
21-
2214async function main ( ) {
23- const jsonSchema = zodToJsonSchema ( skillsManifestSchema , {
15+ // Use Zod v4 native JSON Schema generation
16+ const jsonSchema = z . toJSONSchema ( skillsManifestSchema , {
2417 name : 'skillsManifest' ,
25- $refStrategy : 'none' ,
2618 } )
2719
2820 // Add $schema field for JSON Schema draft
@@ -32,7 +24,7 @@ async function main() {
3224 }
3325
3426 // Generate in package directory (for npm publishing)
35- const pkgOutputPath = path . join ( rootDir , 'packages/skills-package-manager/ skills.schema.json' )
27+ const pkgOutputPath = path . join ( rootDir , 'skills.schema.json' )
3628 await writeFile ( pkgOutputPath , JSON . stringify ( output , null , 2 ) + '\n' )
3729 console . log ( `✅ Generated JSON Schema (package): ${ pkgOutputPath } ` )
3830}
0 commit comments