#![cfg_attr(coverage_nightly, coverage(off))]
pub mod context;
pub mod error;
pub mod features;
pub mod generator;
pub mod hybrid;
pub mod invariants;
pub mod registry;
pub mod subagents;
pub mod templates;
pub use context::{AgentContext, AgentContextBuilder};
pub use error::ScaffoldError;
pub use features::{AgentFeature, MonitoringBackend, QualityLevel, TraceExporter};
pub use generator::{FileContent, GeneratedFiles, TemplateGenerator};
pub use hybrid::{
BoundarySpec, CoreSpec, ErrorPropagation, FallbackStrategy, HybridAgentSpec, ModelType,
SerializationFormat, ValidationStrategy, VerificationMethod, WrapperSpec,
};
pub use invariants::{
AgentContext as InvariantAgentContext, AgentEvent, AgentState, AgentStateMachine, Invariant,
InvariantChecker, InvariantViolation, ViolationAction, ViolationHandler,
};
pub use registry::TemplateRegistry;
pub use subagents::{PmatSubAgent, SubAgentGenerator};
pub use templates::{AgentTemplate, MCPServerTemplate, StateMachineTemplate};
use anyhow::Result;
use std::path::Path;
pub async fn scaffold_agent(context: &AgentContext, output: &Path) -> Result<()> {
let registry = TemplateRegistry::new();
let generator = registry.get(&context.template_type)?;
generator.validate_context(context)?;
let files = generator.generate(context)?;
files.write_to_disk(output).await?;
generator.post_generation_hooks(output)?;
Ok(())
}
#[must_use]
pub fn list_templates() -> Vec<String> {
let registry = TemplateRegistry::new();
registry.list_available()
}
pub fn validate_template(path: &Path) -> Result<()> {
let registry = TemplateRegistry::new();
registry.validate_template_file(path)
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod coverage_tests {
use super::*;
#[test]
fn test_list_templates_returns_vec() {
let templates = list_templates();
assert!(templates.is_empty() || !templates.is_empty());
}
#[test]
fn test_validate_template_nonexistent() {
let result = validate_template(Path::new("/nonexistent/template.toml"));
assert!(result.is_err());
}
#[test]
fn test_agent_context_builder_exists() {
let _builder: Option<AgentContextBuilder> = None;
}
#[test]
fn test_template_generator_trait() {
let _files: Option<GeneratedFiles> = None;
}
#[test]
fn test_agent_template_export() {
let template = AgentTemplate::MCPToolServer;
let debug_str = format!("{:?}", template);
assert!(debug_str.contains("MCPToolServer"));
}
#[test]
fn test_quality_level_export() {
let level = QualityLevel::Extreme;
let debug_str = format!("{:?}", level);
assert!(debug_str.contains("Extreme"));
}
#[test]
fn test_agent_feature_export() {
let _feature: Option<AgentFeature> = None;
}
#[test]
fn test_monitoring_backend_export() {
let _backend: Option<MonitoringBackend> = None;
}
#[test]
fn test_trace_exporter_export() {
let _exporter: Option<TraceExporter> = None;
}
#[test]
fn test_hybrid_agent_spec_export() {
let _spec: Option<HybridAgentSpec> = None;
}
#[test]
fn test_core_spec_export() {
let _spec: Option<CoreSpec> = None;
}
#[test]
fn test_wrapper_spec_export() {
let _spec: Option<WrapperSpec> = None;
}
#[test]
fn test_boundary_spec_export() {
let _spec: Option<BoundarySpec> = None;
}
#[test]
fn test_model_type_export() {
let _model: Option<ModelType> = None;
}
#[test]
fn test_fallback_strategy_export() {
let _strategy: Option<FallbackStrategy> = None;
}
#[test]
fn test_validation_strategy_export() {
let _strategy: Option<ValidationStrategy> = None;
}
#[test]
fn test_serialization_format_export() {
let _format: Option<SerializationFormat> = None;
}
#[test]
fn test_verification_method_export() {
let _method: Option<VerificationMethod> = None;
}
#[test]
fn test_error_propagation_export() {
let _propagation: Option<ErrorPropagation> = None;
}
#[test]
fn test_agent_state_machine_trait_exists() {
fn _ensure_trait_exists<T: AgentStateMachine>() {}
}
#[test]
fn test_agent_state_trait_exists() {
fn _ensure_trait_exists<T: AgentState>() {}
}
#[test]
fn test_agent_event_trait_exists() {
fn _ensure_trait_exists<T: AgentEvent>() {}
}
#[test]
fn test_invariant_trait_exists() {
fn _ensure_trait_exists<S, C, T: Invariant<S, C>>() {}
}
#[test]
fn test_invariant_checker_struct_exists() {
#[derive(Clone, Debug)]
struct TestState;
impl AgentState for TestState {}
#[derive(Clone)]
struct TestCtx;
impl super::InvariantAgentContext for TestCtx {}
let _checker: Option<InvariantChecker<TestState, TestCtx>> = None;
}
#[test]
fn test_invariant_violation_export() {
let _violation: Option<InvariantViolation> = None;
}
#[test]
fn test_violation_action_export() {
let _action: Option<ViolationAction> = None;
}
#[test]
fn test_violation_handler_export() {
let _handler: Option<ViolationHandler> = None;
}
#[test]
fn test_template_registry_export() {
let registry = TemplateRegistry::new();
let _ = registry.list_available();
}
#[test]
fn test_pmat_sub_agent_export() {
let _agent: Option<PmatSubAgent> = None;
}
#[test]
fn test_sub_agent_generator_export() {
let _generator: Option<SubAgentGenerator> = None;
}
#[test]
fn test_mcp_server_template_export() {
let _template: Option<MCPServerTemplate> = None;
}
#[test]
fn test_state_machine_template_export() {
let _template: Option<StateMachineTemplate> = None;
}
#[test]
fn test_file_content_export() {
let _content: Option<FileContent> = None;
}
#[test]
fn test_scaffold_error_export() {
let err = ScaffoldError::UserCancelled;
assert_eq!(err.to_string(), "Operation cancelled by user");
}
#[test]
fn test_invariant_agent_context_export() {
fn _ensure_trait_exists<T: InvariantAgentContext>() {}
}
}