|  | 
|  | 1 | +use std::collections::HashMap; | 
|  | 2 | + | 
|  | 3 | +use serde::{Deserialize, Serialize}; | 
|  | 4 | + | 
|  | 5 | +#[derive(Debug, Clone, Serialize, Deserialize)] | 
|  | 6 | +pub struct FileChange { | 
|  | 7 | +  pub file_path:      String, | 
|  | 8 | +  pub operation_type: OperationType, | 
|  | 9 | +  pub diff_content:   Option<String>, | 
|  | 10 | +  pub lines_added:    u32, | 
|  | 11 | +  pub lines_removed:  u32, | 
|  | 12 | +  pub file_category:  FileCategory, | 
|  | 13 | +  pub summary:        String, | 
|  | 14 | +  pub impact_score:   f32 | 
|  | 15 | +} | 
|  | 16 | + | 
|  | 17 | +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] | 
|  | 18 | +pub enum OperationType { | 
|  | 19 | +  Added, | 
|  | 20 | +  Modified, | 
|  | 21 | +  Deleted, | 
|  | 22 | +  Renamed, | 
|  | 23 | +  Binary | 
|  | 24 | +} | 
|  | 25 | + | 
|  | 26 | +impl OperationType { | 
|  | 27 | +  pub fn as_str(&self) -> &'static str { | 
|  | 28 | +    match self { | 
|  | 29 | +      OperationType::Added => "added", | 
|  | 30 | +      OperationType::Modified => "modified", | 
|  | 31 | +      OperationType::Deleted => "deleted", | 
|  | 32 | +      OperationType::Renamed => "renamed", | 
|  | 33 | +      OperationType::Binary => "binary" | 
|  | 34 | +    } | 
|  | 35 | +  } | 
|  | 36 | +} | 
|  | 37 | + | 
|  | 38 | +impl From<&str> for OperationType { | 
|  | 39 | +  fn from(s: &str) -> Self { | 
|  | 40 | +    match s { | 
|  | 41 | +      "added" => OperationType::Added, | 
|  | 42 | +      "modified" => OperationType::Modified, | 
|  | 43 | +      "deleted" => OperationType::Deleted, | 
|  | 44 | +      "renamed" => OperationType::Renamed, | 
|  | 45 | +      "binary" => OperationType::Binary, | 
|  | 46 | +      _ => OperationType::Modified // default fallback | 
|  | 47 | +    } | 
|  | 48 | +  } | 
|  | 49 | +} | 
|  | 50 | + | 
|  | 51 | +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] | 
|  | 52 | +pub enum FileCategory { | 
|  | 53 | +  Source, | 
|  | 54 | +  Test, | 
|  | 55 | +  Config, | 
|  | 56 | +  Docs, | 
|  | 57 | +  Binary, | 
|  | 58 | +  Build | 
|  | 59 | +} | 
|  | 60 | + | 
|  | 61 | +impl FileCategory { | 
|  | 62 | +  pub fn as_str(&self) -> &'static str { | 
|  | 63 | +    match self { | 
|  | 64 | +      FileCategory::Source => "source", | 
|  | 65 | +      FileCategory::Test => "test", | 
|  | 66 | +      FileCategory::Config => "config", | 
|  | 67 | +      FileCategory::Docs => "docs", | 
|  | 68 | +      FileCategory::Binary => "binary", | 
|  | 69 | +      FileCategory::Build => "build" | 
|  | 70 | +    } | 
|  | 71 | +  } | 
|  | 72 | +} | 
|  | 73 | + | 
|  | 74 | +impl From<&str> for FileCategory { | 
|  | 75 | +  fn from(s: &str) -> Self { | 
|  | 76 | +    match s { | 
|  | 77 | +      "source" => FileCategory::Source, | 
|  | 78 | +      "test" => FileCategory::Test, | 
|  | 79 | +      "config" => FileCategory::Config, | 
|  | 80 | +      "docs" => FileCategory::Docs, | 
|  | 81 | +      "binary" => FileCategory::Binary, | 
|  | 82 | +      "build" => FileCategory::Build, | 
|  | 83 | +      _ => FileCategory::Source // default fallback | 
|  | 84 | +    } | 
|  | 85 | +  } | 
|  | 86 | +} | 
|  | 87 | + | 
|  | 88 | +/// Unified response type for commit message generation | 
|  | 89 | +#[derive(Debug, Clone, Serialize, Deserialize)] | 
|  | 90 | +pub struct CommitResponse { | 
|  | 91 | +  pub message:   String, | 
|  | 92 | +  pub reasoning: String, | 
|  | 93 | +  pub files:     HashMap<String, FileChange> | 
|  | 94 | +} | 
0 commit comments