@@ -97,7 +97,7 @@ function validateCollectionItems(items) {
9797 if ( ! [ "prompt" , "instruction" , "chat-mode" ] . includes ( item . kind ) ) {
9898 return `Item ${ i + 1 } kind must be one of: prompt, instruction, chat-mode` ;
9999 }
100-
100+
101101 // Validate file path exists
102102 const filePath = path . join ( __dirname , item . path ) ;
103103 if ( ! fs . existsSync ( filePath ) ) {
@@ -123,11 +123,39 @@ function validateCollectionDisplay(display) {
123123 return "Display must be an object" ;
124124 }
125125 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+ }
128146 }
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+ }
131159 }
132160 }
133161 return null ;
@@ -160,7 +188,7 @@ function validateCollectionManifest(collection, filePath) {
160188// Main validation function
161189function validateCollections ( ) {
162190 const collectionsDir = path . join ( __dirname , "collections" ) ;
163-
191+
164192 if ( ! fs . existsSync ( collectionsDir ) ) {
165193 console . log ( "No collections directory found - validation skipped" ) ;
166194 return true ;
@@ -183,7 +211,7 @@ function validateCollections() {
183211 for ( const file of collectionFiles ) {
184212 const filePath = path . join ( collectionsDir , file ) ;
185213 console . log ( `\nValidating ${ file } ...` ) ;
186-
214+
187215 const collection = parseCollectionYaml ( filePath ) ;
188216 if ( ! collection ) {
189217 console . error ( `❌ Failed to parse ${ file } ` ) ;
@@ -193,7 +221,7 @@ function validateCollections() {
193221
194222 // Validate the collection structure
195223 const errors = validateCollectionManifest ( collection , filePath ) ;
196-
224+
197225 if ( errors . length > 0 ) {
198226 console . error ( `❌ Validation errors in ${ file } :` ) ;
199227 errors . forEach ( error => console . error ( ` - ${ error } ` ) ) ;
@@ -231,4 +259,4 @@ try {
231259} catch ( error ) {
232260 console . error ( `Error during validation: ${ error . message } ` ) ;
233261 process . exit ( 1 ) ;
234- }
262+ }
0 commit comments