An AI agent built to do Ralph loops - plan mode for planning and ralph mode for implementing.
at main 62 lines 1.9 kB view raw
1use chrono::Utc; 2use rustagent::config::{ 3 AnthropicConfig, Config, LlmConfig, LlmProvider, RustagentConfig, SecurityConfig, 4}; 5use rustagent::spec::{Spec, Task, TaskStatus}; 6use tempfile::TempDir; 7 8#[test] 9fn test_full_workflow() { 10 let temp = TempDir::new().unwrap(); 11 12 // Create config 13 let config = Config { 14 llm: LlmConfig { 15 provider: LlmProvider::Anthropic, 16 model: "claude-sonnet-4-20250514".to_string(), 17 max_tokens: 8192, 18 }, 19 anthropic: Some(AnthropicConfig { 20 api_key: "test-key".to_string(), 21 }), 22 openai: None, 23 ollama: None, 24 planning: None, 25 ralph: None, 26 rustagent: RustagentConfig { 27 spec_dir: "specs".to_string(), 28 max_iterations: Some(10), 29 }, 30 security: SecurityConfig::default(), 31 }; 32 33 // Create spec 34 let spec = Spec { 35 name: "test-feature".to_string(), 36 description: "A test feature".to_string(), 37 branch_name: "feature/test".to_string(), 38 created_at: Utc::now(), 39 tasks: vec![Task { 40 id: "task-1".to_string(), 41 title: "First task".to_string(), 42 description: "Do the first thing".to_string(), 43 acceptance_criteria: vec!["Must work".to_string()], 44 status: TaskStatus::Pending, 45 blocked_reason: None, 46 completed_at: None, 47 }], 48 learnings: vec![], 49 }; 50 51 let spec_path = temp.path().join("test.json"); 52 spec.save(&spec_path).unwrap(); 53 54 // Verify spec was saved 55 let loaded_spec = Spec::load(&spec_path).unwrap(); 56 assert_eq!(loaded_spec.name, "test-feature"); 57 assert_eq!(loaded_spec.tasks.len(), 1); 58 59 // Verify config structure 60 assert_eq!(config.llm.provider, LlmProvider::Anthropic); 61 assert!(config.anthropic.is_some()); 62}