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 description(&self) -> &'static str {
24 "Anthropic-hosted agents perform best with explicit XML tags (e.g. <conventions>)."
25 }
26
27 fn fix_hint(&self) -> &'static str {
28 "Wrap sections in <conventions>...</conventions> or similar XML tags."
29 }
30
31 fn applies_to(&self, file_type: FileType) -> bool {
32 matches!(file_type, FileType::ClaudeMd | FileType::ClineRules)
33 }
34
35 fn run(&self, doc: &ParsedDocument, ctx: &RuleContext<'_>) -> Vec<Violation> {
36 if !doc.raw.contains("<conventions>")
37 && !doc.raw.contains("<rules>")
38 && !doc.raw.contains("</")
39 {
40 let v = Violation::new(AIL105, ctx.severity, doc.path.clone(), "no XML tags found");
41 vec![v]
42 } else {
43 Vec::new()
44 }
45 }
46}