Skip to main content

pawan/
lib.rs

1//! # Pawan (पवन) - Self-Healing CLI Coding Agent
2//!
3//! Core library for the Pawan coding agent. Provides:
4//!
5//! - **Agent**: Tool-calling loop engine with multi-provider LLM support
6//! - **Tools**: File operations, bash execution, git, search
7//! - **Healing**: Automatic detection and repair of compilation errors, test failures, warnings
8//! - **Config**: TOML-based configuration with provider/model management
9//!
10//! ## Architecture
11//!
12//! - `pawan-core` (this crate): Library with zero dirmacs dependencies
13//! - `pawan-cli`: Binary with TUI and CLI interface
14//!
15//! ## Quick Start
16//!
17//! ```bash
18//! pawan                    # Interactive TUI mode
19//! pawan heal               # Auto-fix compilation issues
20//! pawan task "description" # Execute a coding task
21//! pawan run "prompt"       # Headless single-prompt execution
22//! ```
23
24pub mod agent;
25pub mod config;
26pub mod eruka_bridge;
27pub mod healing;
28pub mod tasks;
29pub mod tools;
30
31pub use agent::PawanAgent;
32pub use config::PawanConfig;
33
34/// Error types for Pawan
35#[derive(Debug, thiserror::Error)]
36pub enum PawanError {
37    #[error("IO error: {0}")]
38    Io(#[from] std::io::Error),
39
40    #[error("Configuration error: {0}")]
41    Config(String),
42
43    #[error("Tool execution error: {0}")]
44    Tool(String),
45
46    #[error("Agent error: {0}")]
47    Agent(String),
48
49    #[error("LLM error: {0}")]
50    Llm(String),
51
52    #[error("Git error: {0}")]
53    Git(String),
54
55    #[error("Parse error: {0}")]
56    Parse(String),
57
58    #[error("Timeout: {0}")]
59    Timeout(String),
60
61    #[error("Not found: {0}")]
62    NotFound(String),
63}
64
65/// Result type alias for Pawan operations
66pub type Result<T> = std::result::Result<T, PawanError>;
67
68/// Version information
69pub const VERSION: &str = env!("CARGO_PKG_VERSION");
70
71/// Default model for coding tasks (StepFun Step 3.5 Flash via NVIDIA NIM)
72/// Note: deepseek-v3.2 hangs on tool-use — do not use as default.
73pub const DEFAULT_MODEL: &str = "stepfun-ai/step-3.5-flash";
74
75/// Default NVIDIA API URL
76pub const DEFAULT_NVIDIA_API_URL: &str = "https://integrate.api.nvidia.com/v1";
77
78/// Maximum iterations for tool calling loops
79pub const MAX_TOOL_ITERATIONS: usize = 50;
80
81/// Default timeout for bash commands (in seconds)
82pub const DEFAULT_BASH_TIMEOUT: u64 = 120;