ailint_core/rules/semantic/
vendor_optimization.rs1use crate::file_type::FileType;
6use crate::parser::ParsedDocument;
7use crate::rules::semantic::AIL105;
8use crate::rules::{Rule, RuleContext, RuleId, Severity, Violation};
9
10#[derive(Debug, Default)]
12pub struct VendorOptimizationSyntaxRule;
13
14impl Rule for VendorOptimizationSyntaxRule {
15 fn id(&self) -> RuleId {
16 AIL105
17 }
18
19 fn default_severity(&self) -> Severity {
20 Severity::Warning
21 }
22
23 fn applies_to(&self, file_type: FileType) -> bool {
24 matches!(file_type, FileType::ClaudeMd | FileType::ClineRules)
25 }
26
27 fn run(&self, doc: &ParsedDocument, ctx: &RuleContext<'_>) -> Vec<Violation> {
28 if !doc.raw.contains("<conventions>")
29 && !doc.raw.contains("<rules>")
30 && !doc.raw.contains("</")
31 {
32 let mut v = Violation::new(
33 AIL105,
34 ctx.severity,
35 doc.path.clone(),
36 "Anthropic-hosted agents perform best with explicit XML tags (like <conventions>). No XML tags found.",
37 );
38 v.fix_hint = Some("Wrap your rules in <conventions>...</conventions> or similar XML tags based on Anthropic best practices.".to_string());
39 vec![v]
40 } else {
41 Vec::new()
42 }
43 }
44}