11---
2- description:
2+ description: general
33globs:
44alwaysApply: false
55---
66# RepoDiff Development Guidelines
77
8- You are an expert in **Python ** focused on building high-performance, maintainable, and scalable command-line applications.
8+ You are an expert in **Rust ** focused on building high-performance, maintainable, and scalable command-line applications.
99
1010## Project Structure
1111```
1212RepoDiff/
13- ├── repodiff/ # Main package
14- │ ├── __init__.py # Package initialization
15- │ ├── __main__.py # Entry point for python -m repodiff
16- │ ├── main.py # Main application logic
17- │ ├── utils.py # Utility functions
18- │ ├── diff/ # Diff parsing and processing
19- │ │ ├── __init__.py
20- │ │ ├── parser.py # Diff parsing
21- │ │ └── processor.py # Diff processing
22- │ ├── filters/ # Filter implementations
23- │ │ ├── __init__.py
24- │ │ ├── base.py # Base filter class and registry
25- │ │ ├── context_filter.py # Context filter implementation
26- │ │ └── signature_filter.py # Signature filter implementation
27- │ └── git/ # Git operations
28- │ ├── __init__.py
29- │ └── operations.py # Git command wrappers
30- ├── tests/ # Unit tests
31- │ ├── __init__.py
32- │ ├── test_utils.py
33- │ ├── test_git_operations.py
34- │ ├── test_diff_parser.py
35- │ ├── test_processor.py
36- │ └── test_filters.py
37- ├── setup.py # Package setup script
38- ├── config.json # Configuration file
39- └── README.md # User documentation
13+ ├── src/ # Main source code
14+ │ ├── main.rs # Entry point
15+ │ ├── lib.rs # Library interface
16+ │ ├── error.rs # Error types
17+ │ ├── repodiff.rs # Core application logic
18+ │ └── utils/ # Utility modules
19+ │ ├── mod.rs # Module declarations
20+ │ ├── diff_parser.rs # Diff parsing
21+ │ ├── token_counter.rs # Token counting
22+ │ └── git_operations.rs # Git operations
23+ ├── tests/ # Integration tests
24+ │ ├── diff_parser_test.rs
25+ │ └── git_operations_test.rs
26+ ├── Cargo.toml # Package manifest
27+ ├── config.json # Configuration file
28+ └── README.md # User documentation
4029```
4130
4231## Code Structure and Best Practices
43- - Use **object-oriented programming (OOP) ** principles to structure the application effectively.
44- - Follow **PEP 8 ** guidelines for code readability.
45- - Use **descriptive function and method names ** that reflect their behavior.
46- - Implement **logging ** using Python's `logging` module instead of `print` statements.
47- - Modularize code into **separate files ** based on functionality.
32+ - Use **Rust's ownership and borrowing ** rules effectively
33+ - Follow **Rust's naming conventions ** (snake_case for functions, PascalCase for types)
34+ - Implement proper **error handling ** using `Result` and custom error types
35+ - Use **structs and traits ** to organize code effectively
36+ - Leverage Rust's **type system ** for safety and correctness
4837
49- ## Extending with Custom Filters
50- You can create custom filters by extending the `DiffFilter` base class and registering them with the `FilterRegistry` :
38+ ## Current Issues to Address
39+ The following unused fields have been identified and should be addressed :
5140
52- ```python
53- from repodiff.filters.base import DiffFilter, FilterRegistry
41+ 1. In `TokenCounter`:
42+ ```rust
43+ pub struct TokenCounter {
44+ model: String, // Currently unused
45+ }
46+ ```
47+ - Either implement functionality using this field or remove it
5448
55- @FilterRegistry.register("my_custom_filter")
56- class MyCustomFilter(DiffFilter):
57- def apply(self, hunks, rule):
58- # Custom filter implementation
59- return processed_hunks
60- ```
49+ 2. In `RepoDiff`:
50+ ```rust
51+ pub struct RepoDiff {
52+ config_manager: ConfigManager, // Currently unused
53+ }
54+ ```
55+ - Implement configuration management or remove if not needed
56+
57+ 3. In `RepoDiffError`:
58+ ```rust
59+ pub enum RepoDiffError {
60+ GeneralError(String), // Never constructed
61+ }
62+ ```
63+ - Remove if not needed or implement where appropriate
64+
65+ 4. In `Hunk`:
66+ ```rust
67+ pub struct Hunk {
68+ pub header: String,
69+ pub old_start: usize,
70+ pub old_count: usize,
71+ pub new_start: usize,
72+ pub new_count: usize,
73+ }
74+ ```
75+ - Implement functionality using these fields or remove if not needed
6176
6277## Testing Guidelines
63- - Write **unit tests** with `pytest` for all new functionality.
64- - Use **mock objects** to isolate tests from external dependencies.
65- - Aim for high test coverage, especially for core functionality.
66- - Run tests with coverage to identify untested code:
78+ - Write **unit tests** within source files using `#[cfg(test)]`
79+ - Create **integration tests** in the `tests/` directory
80+ - Use `cargo test` to run the test suite
81+ - Aim for high test coverage, especially for core functionality
82+ - Run tests with:
6783 ```bash
68- pytest --cov=repodiff tests/
84+ cargo test
6985 ```
7086
7187## Performance Considerations
72- - Optimize for large diffs by processing files incrementally.
73- - Consider memory usage when handling large repositories.
74- - Use efficient data structures for storing and processing diffs.
88+ - Leverage Rust's **zero-cost abstractions**
89+ - Use efficient data structures from the standard library
90+ - Consider memory usage when handling large repositories
91+ - Profile code using Rust's built-in tools when needed
7592
7693## Documentation
77- - Document all public functions, classes, and methods.
78- - Keep the README.md focused on end-user documentation.
79- - Use this file (.cursorrules) for developer-specific documentation.
80- - Update documentation when making significant changes.
94+ - Use **rustdoc** comments (`///`) for public items
95+ - Keep the README.md focused on end-user documentation
96+ - Use this file for developer-specific documentation
97+ - Run `cargo doc` to generate documentation
98+
99+ ## Building and Packaging
100+ - Use **Cargo** for package management
101+ - Ensure all dependencies are properly specified in Cargo.toml
102+ - Test the package in release mode before deployment:
103+ ```bash
104+ cargo build --release
105+ ```
106+
107+ ## Dependency Management
108+ Current dependencies (as of v0.3.0):
109+ ```toml
110+ clap = { version = "4.5.1", features = ["derive"] }
111+ serde = { version = "1.0.197", features = ["derive"] }
112+ serde_json = "1.0.114"
113+ regex = "1.10.3"
114+ tempfile = "3.10.0"
115+ tiktoken-rs = "0.5.8"
116+ fnmatch-regex = "0.2.0"
117+ thiserror = "1.0.57"
118+ ```
81119
82- ## Deployment and Packaging
83- - Use **setuptools** for package management.
84- - Ensure all dependencies are properly specified in setup.py.
85- - Test the package installation in a clean environment before release.
120+ Keep dependencies up to date and review for security updates regularly.
0 commit comments