Skip to content

[Refactor] Standardize type names across codebase #62

@oleander

Description

@oleander

Context

The codebase has inconsistent naming for similar concepts, making it confusing. This issue standardizes type names.

Priority

🟡 HIGH - Improves code clarity significantly

Steps

1. Rename App to AppConfig (Remove Settings alias)

In src/config.rs:

// BEFORE
pub struct App { ... }
pub static ref APP: App = ...;

// AFTER  
pub struct AppConfig { ... }
pub static ref APP_CONFIG: AppConfig = ...;

Update all references:

# Find all usages
rg "config::APP" src/
rg "App::new" src/
rg "Settings" src/

# Replace throughout:
# config::APP → config::APP_CONFIG
# App::new() → AppConfig::new()
# Settings → AppConfig (remove type alias)

2. Unify File-Related Types

Create src/generation/types.rs (new file):

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FileChange {
    pub path: String,
    pub operation: OperationType,
    pub diff_content: Option<String>,
    
    // Analysis fields (filled after analysis)
    pub lines_added: Option<u32>,
    pub lines_removed: Option<u32>,
    pub category: Option<FileCategory>,
    pub summary: Option<String>,
    pub impact_score: Option<f32>,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum OperationType {
    Added, Modified, Deleted, Renamed, Binary
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum FileCategory {
    Source, Test, Config, Docs, Binary, Build
}

Replace these types with FileChange:

  • FileAnalysisResult in multi_step_analysis.rs
  • FileWithScore in multi_step_analysis.rs
  • FileDataForScoring in multi_step_analysis.rs
  • ParsedFile in multi_step_integration.rs

3. Unify Response Types

In src/function_calling.rs or new src/generation/response.rs:

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommitResponse {
    pub message: String,
    pub reasoning: String,
    pub files: HashMap<String, FileChange>,
}

Replace:

  • openai::ResponseCommitResponse
  • CommitFunctionArgsCommitResponse (or keep as internal parsing type)

Verification Criteria

Pass:

  • No references to App remain (all are AppConfig)
  • No references to Settings remain
  • All file-related types consolidated to single FileChange struct
  • Response types unified to CommitResponse
  • cargo build succeeds
  • cargo test passes
  • cargo clippy shows no warnings
  • All imports updated correctly

Estimated Time

4-6 hours

Dependencies

Notes

  • Use IDE refactoring tools when possible for rename operations
  • Commit after each major rename (e.g., App→AppConfig, then file types, then responses)
  • This enables easier rollback if issues arise

Labels

  • refactor
  • naming
  • breaking-change

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions