use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use tracing::info;
pub mod shell_history;
pub mod git_config;
pub mod project_templates;
pub mod environment;
pub use shell_history::ShellHistoryAnalyzer;
pub use git_config::GitConfigAnalyzer;
pub use project_templates::TemplateManager;
pub use environment::EnvironmentAnalyzer;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DeveloperEnvironment {
pub shell_preferences: ShellPreferences,
pub git_configuration: GitConfiguration,
pub editor_settings: EditorSettings,
pub aliases: HashMap<String, String>,
pub environment_variables: HashMap<String, String>,
pub installed_tools: Vec<ToolInfo>,
pub project_templates: Vec<ProjectTemplate>,
pub workflow_patterns: WorkflowPatterns,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ShellPreferences {
pub shell_type: String,
pub shell_config_path: Option<String>,
pub prompt_style: Option<String>,
pub favorite_commands: Vec<CommandFrequency>,
pub command_history_stats: CommandHistoryStats,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommandFrequency {
pub command: String,
pub frequency: i64,
pub last_used: chrono::DateTime<chrono::Utc>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct CommandHistoryStats {
pub total_commands: i64,
pub unique_commands: i64,
pub most_used_commands: Vec<String>,
pub typical_working_hours: Vec<u8>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GitConfiguration {
pub user_name: Option<String>,
pub user_email: Option<String>,
pub default_branch: Option<String>,
pub preferred_merge_strategy: Option<String>,
pub aliases: HashMap<String, String>,
pub global_gitignore: Option<String>,
pub commit_template: Option<String>,
pub signing_key: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct EditorSettings {
pub editor_type: String,
pub config_path: Option<String>,
pub theme: Option<String>,
pub font: Option<String>,
pub extensions: Vec<String>,
pub keybindings: HashMap<String, String>,
pub snippets: Vec<CodeSnippet>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CodeSnippet {
pub name: String,
pub prefix: String,
pub body: String,
pub language: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolInfo {
pub name: String,
pub version: String,
pub install_source: String,
pub config_files: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectTemplate {
pub name: String,
pub description: String,
pub language: String,
pub framework: Option<String>,
pub structure: Vec<String>,
pub files: HashMap<String, String>,
pub setup_commands: Vec<String>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct WorkflowPatterns {
pub typical_branch_names: Vec<String>,
pub commit_message_patterns: Vec<String>,
pub code_review_checklist: Vec<String>,
pub deployment_commands: Vec<String>,
pub testing_commands: Vec<String>,
}
pub async fn capture_developer_environment() -> Result<DeveloperEnvironment> {
info!("Capturing developer environment...");
let mut env = DeveloperEnvironment::default();
let shell_analyzer = ShellHistoryAnalyzer::new();
env.shell_preferences = shell_analyzer.analyze().await?;
let git_analyzer = GitConfigAnalyzer::new();
env.git_configuration = git_analyzer.analyze().await?;
let editor_analyzer = EnvironmentAnalyzer::new();
env.editor_settings = editor_analyzer.capture_editor_settings().await?;
env.environment_variables = editor_analyzer.capture_env_vars().await?;
env.installed_tools = editor_analyzer.detect_installed_tools().await?;
let template_manager = TemplateManager::new();
env.project_templates = template_manager.discover_templates().await?;
env.workflow_patterns = shell_analyzer.extract_workflow_patterns().await?;
info!("Developer environment captured successfully");
Ok(env)
}