generate-roomodes-schema.ts 936 B

12345678910111213141516171819202122232425
  1. /**
  2. * Generates the JSON Schema for .roomodes configuration files from the Zod
  3. * schemas defined in packages/types/src/mode.ts.
  4. *
  5. * This ensures the schema stays in sync with the TypeScript types. Run via:
  6. * pnpm --filter @roo-code/types generate:schema
  7. *
  8. * The output is written to schemas/roomodes.json at the repository root.
  9. */
  10. import * as fs from "fs"
  11. import * as path from "path"
  12. import { fileURLToPath } from "url"
  13. import { generateRoomodesJsonSchema } from "../src/roomodes-schema.js"
  14. const jsonSchema = generateRoomodesJsonSchema()
  15. const __dirname = path.dirname(fileURLToPath(import.meta.url))
  16. const repoRoot = path.resolve(__dirname, "../../..")
  17. const outPath = path.join(repoRoot, "schemas", "roomodes.json")
  18. fs.mkdirSync(path.dirname(outPath), { recursive: true })
  19. fs.writeFileSync(outPath, JSON.stringify(jsonSchema, null, "\t") + "\n", "utf-8")
  20. console.log(`Generated ${path.relative(repoRoot, outPath)}`)