Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
64 lines
2.3 KiB
Markdown
64 lines
2.3 KiB
Markdown
# Code Optimization Plan - Status Update
|
|
|
|
This document outlines optimizations to reduce boilerplate code and improve maintainability through the use of derive macros and utility crates.
|
|
|
|
## ✅ 1. Add Utility Crates to Cargo.toml - COMPLETED
|
|
|
|
**Files affected:**
|
|
- `Cargo.toml` - `thiserror` and `derive_more` are already present
|
|
|
|
## ✅ 2. Replace Manual Debug Implementations with Derives - MOSTLY COMPLETED
|
|
|
|
**Files affected:**
|
|
- Most structs now use `#[derive(Debug)]` instead of manual implementations
|
|
- Remaining manual implementations appear intentional for specific formatting
|
|
|
|
## ✅ 3. Replace Manual Default Implementations with Derives - PARTIALLY COMPLETED
|
|
|
|
**Files affected:**
|
|
- Many plugins use `#[derive(Default)]` or `#[derive(SmartDefault)]`
|
|
- Some still have manual implementations that could potentially be simplified
|
|
|
|
## ✅ 4. Use thiserror for Error Types - PARTIALLY COMPLETED
|
|
|
|
**Files affected:**
|
|
- `src/services/error.rs` - CoreError enum uses thiserror ✅
|
|
- `src/modes/server/mcp/tools.rs` - ToolError enum could be updated
|
|
|
|
## 🔄 5. Use derive_more for Common Trait Implementations - PENDING
|
|
|
|
**Files affected:**
|
|
- Wrapper types throughout the codebase could benefit from derive_more
|
|
- This would further reduce boilerplate code
|
|
|
|
## ✅ 6. Enhance Serde Usage - MOSTLY COMPLETED
|
|
|
|
**Files affected:**
|
|
- Most response and configuration types use `#[derive(Serialize, Deserialize)]`
|
|
- Field naming appears consistent
|
|
|
|
## ✅ 7. Improve Strum Usage for Enums - COMPLETED
|
|
|
|
**Files affected:**
|
|
- `src/compression_engine.rs` - CompressionType uses strum ✅
|
|
- `src/meta_plugin/mod.rs` - MetaPluginType uses strum ✅
|
|
|
|
## 🔄 8. Code Organization Improvements - ONGOING
|
|
|
|
**Files affected:**
|
|
- All source files could benefit from consistent derive ordering and import organization
|
|
|
|
## Implementation Status
|
|
|
|
1. **✅ High Priority**: Crates are already in Cargo.toml
|
|
2. **✅ Medium Priority**: Error handling mostly uses thiserror
|
|
3. **✅ Medium Priority**: Debug and Default derives mostly implemented
|
|
4. **🔄 Low Priority**: derive_more usage could be expanded
|
|
|
|
## Remaining Opportunities
|
|
|
|
- Apply `#[derive(thiserror::Error)]` to `ToolError` in `src/modes/server/mcp/tools.rs`
|
|
- Use `derive_more` for wrapper types to reduce boilerplate
|
|
- Ensure consistent import ordering across all files
|
|
- Standardize derive attribute ordering
|