@@ -509,16 +509,18 @@ describe("paths.mjs exports", () => {
509509 } )
510510
511511 describe ( "parseFrontmatter" , ( ) => {
512- it ( "should return found: false when content does not start with ---" , ( ) => {
512+ it ( "should return found: false with reason 'missing' when content does not start with ---" , ( ) => {
513513 const result = parseFrontmatter ( "# No frontmatter" )
514514 expect ( result . found ) . toBe ( false )
515+ expect ( result . reason ) . toBe ( "missing" )
515516 expect ( result . fields ) . toEqual ( { } )
516517 expect ( result . endIndex ) . toBe ( 0 )
517518 } )
518519
519- it ( "should return found: false when closing --- is missing" , ( ) => {
520+ it ( "should return found: false with reason 'unclosed' when closing --- is missing" , ( ) => {
520521 const result = parseFrontmatter ( "---\nversion: 1.0\nno closing delimiter" )
521522 expect ( result . found ) . toBe ( false )
523+ expect ( result . reason ) . toBe ( "unclosed" )
522524 expect ( result . fields ) . toEqual ( { } )
523525 expect ( result . endIndex ) . toBe ( 0 )
524526 } )
@@ -531,6 +533,7 @@ requires: opencode
531533# Content`
532534 const result = parseFrontmatter ( content )
533535 expect ( result . found ) . toBe ( true )
536+ expect ( result . reason ) . toBeUndefined ( )
534537 expect ( result . fields . version ) . toBe ( "1.0" )
535538 expect ( result . fields . requires ) . toBe ( "opencode" )
536539 } )
@@ -641,15 +644,28 @@ The agent can process multiple items efficiently.
641644 expect ( result . error ) . toContain ( `minimum ${ MIN_CONTENT_LENGTH } ` )
642645 } )
643646
644- it ( "should return valid: false when frontmatter is missing" , ( ) => {
647+ it ( "should return valid: false with specific error when frontmatter is missing" , ( ) => {
645648 const content =
646649 "# No Frontmatter Agent\n\nThis agent has no frontmatter but is an agent for tasks." . padEnd (
647650 MIN_CONTENT_LENGTH + 10 ,
648651 " " ,
649652 )
650653 const result = validateAgentContent ( content )
651654 expect ( result . valid ) . toBe ( false )
652- expect ( result . error ) . toContain ( "YAML frontmatter" )
655+ expect ( result . error ) . toBe ( "File missing YAML frontmatter (must start with ---)" )
656+ } )
657+
658+ it ( "should return valid: false with specific error when frontmatter is unclosed" , ( ) => {
659+ const content = `---
660+ version: 1.0
661+ requires: opencode
662+ This file has no closing frontmatter delimiter.
663+ # Test Agent
664+ This is a test agent that handles various tasks.
665+ ` . padEnd ( MIN_CONTENT_LENGTH + 50 , " " )
666+ const result = validateAgentContent ( content )
667+ expect ( result . valid ) . toBe ( false )
668+ expect ( result . error ) . toBe ( "Unclosed YAML frontmatter (missing closing ---)" )
653669 } )
654670
655671 it ( "should return valid: false when version field is missing" , ( ) => {
0 commit comments