feat: add correct JSON schema for .roomodes configuration files#11791
feat: add correct JSON schema for .roomodes configuration files#11791roomote[bot] wants to merge 4 commits intomainfrom
Conversation
Adds schemas/roomodes.json that accurately reflects the actual .roomodes
format as defined in packages/types/src/mode.ts. The schema supports:
- All CustomMode properties including optional description and source
- Tuple-style group entries like ["edit", { fileRegex, description }]
- All five tool groups: read, edit, command, mcp, modes
Also adds comprehensive tests validating the schema against valid and
invalid configurations.
Closes #11790
|
@roomote There are things missing from the proposed schema:
|
schemas/roomodes.json
Outdated
| "definitions": { | ||
| "ToolGroup": { | ||
| "type": "string", | ||
| "enum": ["read", "edit", "command", "mcp", "modes"], |
There was a problem hiding this comment.
| "enum": ["read", "edit", "command", "mcp", "modes"], | |
| "enum": ["read", "edit", "command", "mcp", "modes", "browser"], |
|
@roomote are you able to implement my suggestions? |
Fixed the reported issues: added |
- Add "browser" to ToolGroup enum (deprecated but accepted for backward compat) - Add RuleFile definition with relativePath and content properties - Add optional rulesFiles array property to CustomMode - Add 6 new tests covering browser groups and rulesFiles validation
schemas/roomodes.json
Outdated
| "RuleFile": { | ||
| "type": "object", | ||
| "description": "A rules file associated with a mode, used during import/export.", | ||
| "required": ["relativePath", "content"], |
The content property in RuleFile is now optional, matching the defensive runtime check in CustomModesManager that handles missing content. Only relativePath remains required.
|
@roomote LGTM |
All 25 tests pass locally. Marked PR as ready for review. |
|
@roomote should the JSON schema be dynamically generated in case the typescript types change? |
Converted the static JSON schema to be dynamically generated from the Zod types via |
Replace the hand-crafted schemas/roomodes.json with one generated from the Zod schemas in packages/types/src/mode.ts using zod-to-json-schema. This ensures the schema stays in sync when TypeScript types change. - Add zod-to-json-schema dev dependency to packages/types - Create packages/types/scripts/generate-roomodes-schema.ts - Add generate:schema npm script to packages/types - Add drift-detection test in packages/types to catch schema/type mismatches - Update existing AJV validation tests with documentation comment
|
@mrubens @cte @jr @hannesrudolph @daniel-lxs Any thoughts on this? Concerns? Personally I prefer the structure in the currently published JSON schema (always been tough for me to wrap my head around "array of arrays" in YAML), but didn't want to introduce any breaking changes by proposing modifications to the typescript types/interfaces |
Related GitHub Issue
Closes: #11790
Description
This PR attempts to address Issue #11790 by adding a correct JSON Schema (draft-07) for
.roomodesconfiguration files that accurately reflects the actual internal types defined inpackages/types/src/mode.ts.The existing SchemaStore schema at
https://www.schemastore.org/roomodes.jsonhas several discrepancies with the actual format Roo Code uses:descriptionandsourceonCustomMode{ type: "edit", allowedPaths: [...] }but Roo Code uses tuple format["edit", { fileRegex: "...", description: "..." }]allowedPaths/disallowedPathsvsfileRegex/descriptionKey implementation details:
schemas/roomodes.jsonwith draft-07 syntax (usingitemsarray +additionalItems: falsefor tuple validation)CustomModeproperties are represented:slug,name,roleDefinition,whenToUse,description,customInstructions,groups,sourceGroupEntryis modeled asoneOf: either a simple tool group string enum or a[ToolGroup, GroupOptions]tupleread,edit,command,mcp,modesA follow-up PR to SchemaStore to update their copy would be a natural next step.
Feedback and guidance are welcome.
Test Procedure
src/utils/__tests__/roomodes-schema.spec.tsusingajvto validate the schemacd src && npx vitest run utils/__tests__/roomodes-schema.spec.tsPre-Submission Checklist
Documentation Updates
Additional Notes
ajvas a dev dependency insrc/package.jsonfor schema validation in tests.Interactively review PR in Roo Code Cloud