aca/
lib.rs

1//! # Automatic Coding Agent
2//!
3//! A Rust-based agentic tool that automates coding tasks using multiple LLM providers.
4//! The system operates with dynamic task trees, comprehensive session persistence,
5//! and full resumability for long-running automated coding sessions.
6//!
7//! ## Architecture Overview
8//!
9//! The system consists of several key components organized into modules:
10//!
11//! - **[`cli`]**: Command-line interface with intelligent task parsing and simple task loading
12//! - **[`llm`]**: Provider-agnostic LLM interface supporting multiple providers (Claude Code CLI/API, OpenAI Codex CLI, etc.)
13//! - **[`claude`]**: Claude Code integration with rate limiting and error recovery
14//! - **[`task`]**: Hierarchical task management with intelligent scheduling
15//! - **[`session`]**: Complete session lifecycle management with atomic persistence
16//! - **[`integration`]**: High-level system orchestration and agent coordination
17//!
18//! ## Features
19//!
20//! ### 🤖 Intelligent Task Parsing
21//! - **LLM-based decomposition**: Analyzes complex tasks and breaks them into structured hierarchies
22//! - **Markdown file resolution**: Automatically follows and includes referenced files
23//! - **Detail preservation**: Expands 6 high-level tasks into 42+ detailed subtasks
24//! - **Dependency mapping**: Automatic TaskId generation and dependency graph construction
25//!
26//! ### 🔌 LLM Provider System
27//! - **Multi-Provider Support**: Claude Code CLI (default), Claude API, OpenAI Codex CLI, local models (Ollama)
28//! - **CLI Mode (default)**: Uses `claude` command, no API key required
29//! - **API Mode**: Direct Anthropic API access with API key
30//! - **Provider-Agnostic Interface**: Unified API across all LLM providers
31//! - **Rate Limiting**: Provider-specific rate limiting and cost optimization
32//!
33//! ### 🎯 Task Management
34//! - **Dynamic Task Tree**: Hierarchical task organization with parent-child relationships
35//! - **Intelligent Scheduling**: Multi-factor scoring system with resource-aware prioritization
36//! - **Dependency Resolution**: Complex dependency tracking with circular dependency detection
37//! - **Progress Tracking**: Real-time statistics and completion estimation
38//!
39//! ### 💾 Session Persistence
40//! - **Atomic Operations**: Thread-safe persistence with transaction support and rollback
41//! - **Checkpoint System**: UUID-based checkpoint creation with automatic cleanup
42//! - **Recovery Manager**: Intelligent recovery from corruption and failures
43//! - **State Validation**: Comprehensive integrity checking with auto-correction
44//!
45//! ## Quick Start
46//!
47//! ```rust,no_run
48//! use aca::{AgentSystem, AgentConfig};
49//!
50//! #[tokio::main]
51//! async fn main() -> anyhow::Result<()> {
52//!     // Initialize the agent system
53//!     let config = AgentConfig::default();
54//!     let agent = AgentSystem::new(config).await?;
55//!
56//!     // Create and process a task
57//!     let task_id = agent.create_and_process_task(
58//!         "Implement feature",
59//!         "Add new functionality to the codebase"
60//!     ).await?;
61//!
62//!     println!("Task completed: {}", task_id);
63//!     Ok(())
64//! }
65//! ```
66
67/// Session management and persistence functionality.
68///
69/// This module provides comprehensive session lifecycle management including
70/// atomic persistence, checkpoint creation, and intelligent recovery capabilities.
71pub mod session;
72
73/// Hierarchical task management system.
74///
75/// Provides dynamic task trees, intelligent scheduling, dependency resolution,
76/// and progress tracking for complex coding automation workflows.
77pub mod task;
78
79/// Claude Code integration layer.
80///
81/// Handles direct integration with Claude Code including rate limiting,
82/// error recovery, context management, and usage tracking.
83pub mod claude;
84
85/// OpenAI Codex integration layer.
86///
87/// Executes the Codex CLI headlessly with session logging and rate limiting.
88pub mod openai;
89
90/// Provider-agnostic LLM interface.
91///
92/// Abstraction layer supporting multiple LLM providers (Claude, OpenAI, local models)
93/// with unified API, automatic fallback, and provider-specific optimizations.
94pub mod llm;
95
96/// High-level system integration and orchestration.
97///
98/// Combines all subsystems into a cohesive agent architecture with
99/// coordinated task processing and system-wide status monitoring.
100pub mod integration;
101
102/// Environment constants and path utilities.
103///
104/// Centralizes all hardcoded paths and directory names used throughout
105/// the application for easier maintenance and consistency.
106pub mod env;
107
108// Re-export main session types
109pub use session::{SessionInitOptions, SessionManager, SessionManagerConfig, SessionMetadata};
110
111// Re-export main task types
112pub use task::{Task, TaskManager, TaskManagerConfig, TaskPriority, TaskSpec, TaskStatus};
113
114// Re-export main Claude types
115pub use claude::{ClaudeCodeInterface, ClaudeConfig};
116
117// Re-export OpenAI types
118pub use openai::{OpenAICodexInterface, OpenAIConfig};
119
120// Re-export LLM abstraction types
121pub use llm::{LLMProvider, LLMRequest, LLMResponse, ProviderConfig, ProviderType};
122
123// Re-export integration types
124pub use integration::{AgentConfig, AgentSystem, SystemStatus};
125
126// CLI module for command-line interface
127pub mod cli;
128
129/// Prints "Hello, World!" to stdout.
130///
131/// # Examples
132///
133/// ```
134/// use aca::hello_world;
135///
136/// hello_world();
137/// ```
138#[allow(dead_code)]
139pub fn hello_world() {
140    println!("Hello, World!");
141}