#![cfg_attr(coverage_nightly, coverage(off))]
pub mod bridge;
pub mod discovery;
pub mod executor;
pub mod generator;
pub mod manifest;
pub mod parser;
pub mod quality;
pub mod router;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct AgentsMdDocument {
pub metadata: DocumentMetadata,
pub sections: Vec<Section>,
pub commands: Vec<Command>,
pub guidelines: Vec<Guideline>,
pub quality_rules: Option<QualityRules>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct DocumentMetadata {
pub path: PathBuf,
pub modified: std::time::SystemTime,
pub version: Option<String>,
pub project: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Section {
pub section_type: SectionType,
pub title: String,
pub content: String,
pub subsections: Vec<Section>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub enum SectionType {
Overview,
DevEnvironment,
Testing,
CodeStyle,
PRGuidelines,
Security,
Custom(String),
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Command {
pub name: String,
pub command: String,
pub working_dir: Option<PathBuf>,
pub env: Vec<(String, String)>,
pub timeout: Option<u64>,
pub safe: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Guideline {
pub category: String,
pub text: String,
pub priority: Priority,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum Priority {
Low,
Medium,
High,
Critical,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct QualityRules {
pub max_complexity: Option<u32>,
pub min_coverage: Option<f64>,
pub satd_allowed: bool,
pub custom_checks: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentCapabilities {
pub operations: Vec<Operation>,
pub tools: Vec<Tool>,
pub quality_requirements: QualityRequirements,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Operation {
pub name: String,
pub description: String,
pub input_schema: serde_json::Value,
pub output_schema: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tool {
pub name: String,
pub tool_type: ToolType,
pub config: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ToolType {
Command,
Analysis,
Generator,
Validator,
Custom(String),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QualityRequirements {
pub enforce_gates: bool,
pub max_complexity: u32,
pub min_coverage: f64,
pub auto_fix: bool,
}
impl Default for QualityRequirements {
fn default() -> Self {
Self {
enforce_gates: true,
max_complexity: 10,
min_coverage: 80.0,
auto_fix: true,
}
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_quality_requirements_default() {
let req = QualityRequirements::default();
assert!(req.enforce_gates);
assert_eq!(req.max_complexity, 10);
assert_eq!(req.min_coverage, 80.0);
assert!(req.auto_fix);
}
#[test]
fn test_priority_ordering() {
assert!(Priority::Critical > Priority::High);
assert!(Priority::High > Priority::Medium);
assert!(Priority::Medium > Priority::Low);
}
#[test]
fn test_section_type_equality() {
assert_eq!(SectionType::Testing, SectionType::Testing);
assert_ne!(SectionType::Testing, SectionType::Security);
assert_eq!(
SectionType::Custom("foo".to_string()),
SectionType::Custom("foo".to_string())
);
}
}