pmat 3.16.0

PMAT - Zero-config AI context generation and code quality toolkit (CLI, MCP, HTTP)
//! Interactive agent scaffolding example for course exercises
//!
//! This example shows how to use the interactive scaffolder to guide
//! students through creating their own deterministic agents.

use anyhow::Result;

fn main() -> Result<()> {
    println!("╔══════════════════════════════════════════════════════╗");
    println!("║   Deterministic MCP Agents - Interactive Exercise    ║");
    println!("╚══════════════════════════════════════════════════════╝");
    println!();
    println!("Welcome to the interactive agent scaffolding exercise!");
    println!("This tool will guide you through creating a deterministic agent.\n");

    // Note: In a real interactive session, this would prompt the user
    // For the example, we'll demonstrate the flow
    demonstrate_interactive_flow()?;

    println!("\n═══════════════════════════════════════════════════════");
    println!("To run the actual interactive scaffolder:");
    println!("  $ pmat scaffold agent --interactive");
    println!();
    println!("Or programmatically:");
    println!("  let mut scaffolder = InteractiveScaffolder::new();");
    println!("  let context = scaffolder.run()?;");
    println!("═══════════════════════════════════════════════════════");

    Ok(())
}

/// Demonstrates the interactive scaffolding flow
fn demonstrate_interactive_flow() -> Result<()> {
    println!("INTERACTIVE FLOW DEMONSTRATION:");
    println!("───────────────────────────────");

    // Step 1: Agent Name
    println!("\n📝 Step 1: Agent Name");
    println!("   Prompt: 'Agent name'");
    println!("   Example Input: code_quality_analyzer");
    println!("   Validation:");
    println!("     • Must be alphanumeric with underscores");
    println!("     • Cannot start with a number");
    println!("     • Should be descriptive and follow snake_case");

    // Step 2: Template Selection
    println!("\n📋 Step 2: Template Selection");
    println!("   Options:");
    println!("     1. MCP Tool Server");
    println!("        → Standard MCP server with async handlers");
    println!("     2. State Machine Workflow");
    println!("        → Agent with state transitions and invariants");
    println!("     3. Deterministic Calculator");
    println!("        → Pure deterministic computation agent");
    println!("     4. Hybrid Analyzer");
    println!("        → Deterministic core with AI wrapper");
    println!("   Recommendation: Start with option 3 for course basics");

    // Step 3: Feature Selection
    println!("\n⚙️  Step 3: Feature Selection");
    println!("   Available features depend on template:");
    println!("   For MCP Server:");
    println!("     □ Tool Composition");
    println!("     □ Async Handlers");
    println!("     □ Resource Subscriptions");
    println!("     □ Monitoring (Prometheus/OpenTelemetry)");
    println!("     □ Tracing (Jaeger/Zipkin/OTLP)");
    println!("     □ Health Checks");

    // Step 4: Quality Level
    println!("\n🏆 Step 4: Quality Level");
    println!("   Options:");
    println!("     1. Standard");
    println!("        • Basic quality checks");
    println!("        • Max complexity: 20");
    println!("        • Min coverage: 70%");
    println!("     2. Strict");
    println!("        • Zero warnings");
    println!("        • Max complexity: 15");
    println!("        • Min coverage: 80%");
    println!("     3. Extreme (Toyota Way) [RECOMMENDED]");
    println!("        • Zero SATD");
    println!("        • Max complexity: 10");
    println!("        • Min coverage: 90%");

    // Step 5: Hybrid Configuration (if applicable)
    println!("\n🔀 Step 5: Hybrid Configuration (if Hybrid template selected)");
    println!("   Deterministic Core:");
    println!("     • Verification: Property Tests / Formal Proof / Model Checking");
    println!("     • Max Complexity: 10 (recommended)");
    println!("   Probabilistic Wrapper:");
    println!("     • Model: GPT-4 / Claude / Local");
    println!("     • Fallback: Deterministic / Default / Error");
    println!("     • Confidence Threshold: 0.95 (recommended)");

    // Step 6: Confirmation
    println!("\n✅ Step 6: Review and Generate");
    println!("   The scaffolder will show a summary:");
    println!("   ┌─────────────────────────────────┐");
    println!("   │ Agent Configuration Summary     │");
    println!("   ├─────────────────────────────────┤");
    println!("   │ Name:     code_quality_analyzer│");
    println!("   │ Template: MCP Tool Server      │");
    println!("   │ Quality:  Extreme               │");
    println!("   │ Features: 6 enabled             │");
    println!("   └─────────────────────────────────┘");

    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_interactive_flow_runs() {
        // Verify the demonstration doesn't panic
        assert!(demonstrate_interactive_flow().is_ok());
    }
}