1use agentlint_core::{Diagnostic, Validator};
2use std::path::Path;
3
4pub struct CodexValidator;
5
6impl Validator for CodexValidator {
7 fn patterns(&self) -> &[&str] {
8 &["AGENTS.md"]
9 }
10
11 fn validate(&self, path: &Path, src: &str) -> Vec<Diagnostic> {
12 if src.trim().is_empty() {
13 vec![Diagnostic::error(path, 1, 1, "AGENTS.md is empty")]
14 } else {
15 vec![]
16 }
17 }
18}
19
20#[cfg(test)]
21mod tests {
22 use super::*;
23 use std::path::Path;
24
25 #[test]
26 fn non_empty_is_clean() {
27 let v = CodexValidator;
28 let diags = v.validate(Path::new("AGENTS.md"), "# Agents\n\nSome content.");
29 assert!(diags.is_empty());
30 }
31
32 #[test]
33 fn empty_file_is_error() {
34 let v = CodexValidator;
35 let diags = v.validate(Path::new("AGENTS.md"), "");
36 assert!(!diags.is_empty());
37 assert!(diags[0].message.contains("empty"));
38 }
39
40 #[test]
41 fn whitespace_only_is_error() {
42 let v = CodexValidator;
43 let diags = v.validate(Path::new("AGENTS.md"), " \n\t\n ");
44 assert!(!diags.is_empty());
45 assert!(diags[0].message.contains("empty"));
46 }
47}