@@ -97,7 +97,7 @@ function validateCollectionItems(items) {
97
97
if ( ! [ "prompt" , "instruction" , "chat-mode" ] . includes ( item . kind ) ) {
98
98
return `Item ${ i + 1 } kind must be one of: prompt, instruction, chat-mode` ;
99
99
}
100
-
100
+
101
101
// Validate file path exists
102
102
const filePath = path . join ( __dirname , item . path ) ;
103
103
if ( ! fs . existsSync ( filePath ) ) {
@@ -123,11 +123,39 @@ function validateCollectionDisplay(display) {
123
123
return "Display must be an object" ;
124
124
}
125
125
if ( display ) {
126
- if ( display . ordering && ! [ "manual" , "alpha" ] . includes ( display . ordering ) ) {
127
- return "Display ordering must be 'manual' or 'alpha'" ;
126
+ // Normalize ordering and show_badge in case the YAML parser left inline comments
127
+ const normalize = ( val ) => {
128
+ if ( typeof val !== 'string' ) return val ;
129
+ // Strip any inline comment starting with '#'
130
+ const hashIndex = val . indexOf ( '#' ) ;
131
+ if ( hashIndex !== - 1 ) {
132
+ val = val . substring ( 0 , hashIndex ) . trim ( ) ;
133
+ }
134
+ // Also strip surrounding quotes if present
135
+ if ( ( val . startsWith ( "\"" ) && val . endsWith ( "\"" ) ) || ( val . startsWith ( "'" ) && val . endsWith ( "'" ) ) ) {
136
+ val = val . substring ( 1 , val . length - 1 ) ;
137
+ }
138
+ return val . trim ( ) ;
139
+ } ;
140
+
141
+ if ( display . ordering ) {
142
+ const normalizedOrdering = normalize ( display . ordering ) ;
143
+ if ( ! [ "manual" , "alpha" ] . includes ( normalizedOrdering ) ) {
144
+ return "Display ordering must be 'manual' or 'alpha'" ;
145
+ }
128
146
}
129
- if ( display . show_badge && typeof display . show_badge !== "boolean" ) {
130
- return "Display show_badge must be boolean" ;
147
+
148
+ if ( display . show_badge !== undefined ) {
149
+ const raw = display . show_badge ;
150
+ const normalizedBadge = normalize ( raw ) ;
151
+ // Accept boolean or string boolean values
152
+ if ( typeof normalizedBadge === 'string' ) {
153
+ if ( ! [ 'true' , 'false' ] . includes ( normalizedBadge . toLowerCase ( ) ) ) {
154
+ return "Display show_badge must be boolean" ;
155
+ }
156
+ } else if ( typeof normalizedBadge !== 'boolean' ) {
157
+ return "Display show_badge must be boolean" ;
158
+ }
131
159
}
132
160
}
133
161
return null ;
@@ -160,7 +188,7 @@ function validateCollectionManifest(collection, filePath) {
160
188
// Main validation function
161
189
function validateCollections ( ) {
162
190
const collectionsDir = path . join ( __dirname , "collections" ) ;
163
-
191
+
164
192
if ( ! fs . existsSync ( collectionsDir ) ) {
165
193
console . log ( "No collections directory found - validation skipped" ) ;
166
194
return true ;
@@ -183,7 +211,7 @@ function validateCollections() {
183
211
for ( const file of collectionFiles ) {
184
212
const filePath = path . join ( collectionsDir , file ) ;
185
213
console . log ( `\nValidating ${ file } ...` ) ;
186
-
214
+
187
215
const collection = parseCollectionYaml ( filePath ) ;
188
216
if ( ! collection ) {
189
217
console . error ( `❌ Failed to parse ${ file } ` ) ;
@@ -193,7 +221,7 @@ function validateCollections() {
193
221
194
222
// Validate the collection structure
195
223
const errors = validateCollectionManifest ( collection , filePath ) ;
196
-
224
+
197
225
if ( errors . length > 0 ) {
198
226
console . error ( `❌ Validation errors in ${ file } :` ) ;
199
227
errors . forEach ( error => console . error ( ` - ${ error } ` ) ) ;
@@ -231,4 +259,4 @@ try {
231
259
} catch ( error ) {
232
260
console . error ( `Error during validation: ${ error . message } ` ) ;
233
261
process . exit ( 1 ) ;
234
- }
262
+ }
0 commit comments