(filePath string, frontmatter map[string]any, isAgentFile bool)
| 231 | } |
| 232 | |
| 233 | func applyRelaxedIncludedFrontmatterValidation(filePath string, frontmatter map[string]any, isAgentFile bool) { |
| 234 | if len(frontmatter) == 0 { |
| 235 | return |
| 236 | } |
| 237 | unexpectedFields := collectUnexpectedIncludedFrontmatterFields(frontmatter) |
| 238 | if len(unexpectedFields) > 0 { |
| 239 | fmt.Fprintf(os.Stderr, "%s\n", console.FormatWarningMessage( |
| 240 | fmt.Sprintf("Ignoring unexpected frontmatter fields in %s: %s", |
| 241 | filePath, strings.Join(unexpectedFields, ", ")))) |
| 242 | } |
| 243 | |
| 244 | filteredFrontmatter := filterIncludedFrontmatterForRelaxedValidation(frontmatter, isAgentFile) |
| 245 | if len(filteredFrontmatter) > 0 { |
| 246 | if err := ValidateIncludedFileFrontmatterWithSchemaAndLocation(filteredFrontmatter, filePath); err != nil { |
| 247 | fmt.Fprintf(os.Stderr, "%s\n", console.FormatWarningMessage( |
| 248 | fmt.Sprintf("Invalid configuration in %s: %v", filePath, err))) |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | func collectUnexpectedIncludedFrontmatterFields(frontmatter map[string]any) []string { |
| 254 | validFields := map[string]struct { |
no test coverage detected