1pub mod agent;
2pub mod analyzer;
3pub mod bedrock; pub mod cli;
5pub mod common;
6pub mod config;
7pub mod error;
8pub mod generator;
9pub mod handlers;
10pub mod telemetry; pub use analyzer::{ProjectAnalysis, analyze_project};
14use cli::Commands;
15pub use error::{IaCGeneratorError, Result};
16pub use generator::{generate_compose, generate_dockerfile, generate_terraform};
17pub use handlers::*;
18pub use telemetry::{TelemetryClient, TelemetryConfig, UserId}; pub const VERSION: &str = env!("CARGO_PKG_VERSION");
22
23pub async fn run_command(command: Commands) -> Result<()> {
24 match command {
25 Commands::Analyze {
26 path,
27 json,
28 detailed,
29 display,
30 only,
31 color_scheme,
32 } => {
33 match handlers::handle_analyze(path, json, detailed, display, only, color_scheme) {
34 Ok(_output) => Ok(()), Err(e) => Err(e),
36 }
37 }
38 Commands::Generate {
39 path,
40 output,
41 dockerfile,
42 compose,
43 terraform,
44 all,
45 dry_run,
46 force,
47 } => handlers::handle_generate(
48 path, output, dockerfile, compose, terraform, all, dry_run, force,
49 ),
50 Commands::Validate { path, types, fix } => handlers::handle_validate(path, types, fix),
51 Commands::Support {
52 languages,
53 frameworks,
54 detailed,
55 } => handlers::handle_support(languages, frameworks, detailed),
56 Commands::Dependencies {
57 path,
58 licenses,
59 vulnerabilities,
60 prod_only,
61 dev_only,
62 format,
63 } => handlers::handle_dependencies(
64 path,
65 licenses,
66 vulnerabilities,
67 prod_only,
68 dev_only,
69 format,
70 )
71 .await
72 .map(|_| ()),
73 Commands::Vulnerabilities {
74 path,
75 severity,
76 format,
77 output,
78 } => handlers::handle_vulnerabilities(path, severity, format, output).await,
79 Commands::Security {
80 path,
81 mode,
82 include_low,
83 no_secrets,
84 no_code_patterns,
85 no_infrastructure,
86 no_compliance,
87 frameworks,
88 format,
89 output,
90 fail_on_findings,
91 } => {
92 handlers::handle_security(
93 path,
94 mode,
95 include_low,
96 no_secrets,
97 no_code_patterns,
98 no_infrastructure,
99 no_compliance,
100 frameworks,
101 format,
102 output,
103 fail_on_findings,
104 )
105 .map(|_| ()) }
107 Commands::Tools { command } => handlers::handle_tools(command).await,
108 Commands::Chat {
109 path,
110 provider,
111 model,
112 query,
113 } => {
114 use agent::ProviderType;
115 use cli::ChatProvider;
116 use config::load_agent_config;
117
118 let project_path = path.canonicalize().unwrap_or(path);
119
120 let agent_config = load_agent_config();
122
123 let (provider_type, effective_model) = match provider {
125 ChatProvider::Openai => (ProviderType::OpenAI, model),
126 ChatProvider::Anthropic => (ProviderType::Anthropic, model),
127 ChatProvider::Bedrock => (ProviderType::Bedrock, model),
128 ChatProvider::Ollama => {
129 eprintln!("Ollama support coming soon. Using OpenAI as fallback.");
130 (ProviderType::OpenAI, model)
131 }
132 ChatProvider::Auto => {
133 let saved_provider = match agent_config.default_provider.as_str() {
135 "openai" => ProviderType::OpenAI,
136 "anthropic" => ProviderType::Anthropic,
137 "bedrock" => ProviderType::Bedrock,
138 _ => ProviderType::OpenAI, };
140 let saved_model = if model.is_some() {
142 model
143 } else {
144 agent_config.default_model.clone()
145 };
146 (saved_provider, saved_model)
147 }
148 };
149
150 agent::session::ChatSession::load_api_key_to_env(provider_type);
153
154 if let Some(q) = query {
155 let response =
156 agent::run_query(&project_path, &q, provider_type, effective_model).await?;
157 println!("{}", response);
158 Ok(())
159 } else {
160 agent::run_interactive(&project_path, provider_type, effective_model).await?;
161 Ok(())
162 }
163 }
164 }
165}