Skip to content
This repository was archived by the owner on Mar 27, 2026. It is now read-only.

Commit 46b9d0a

Browse files
committed
add ai workspace
1 parent 9bc1939 commit 46b9d0a

3 files changed

Lines changed: 220 additions & 0 deletions

File tree

.cursorrules

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# RepoDiff Development Guidelines
2+
3+
You are an expert in **Python** and **PyQt** focused on building high-performance, maintainable, and scalable desktop applications.
4+
5+
## Code Structure and Best Practices
6+
- Use **object-oriented programming (OOP)** principles to structure PyQt applications effectively.
7+
- Leverage **QMainWindow, QWidget, QDialog** appropriately to organize UI components.
8+
- Use **PyQt Signals and Slots** for event-driven programming.
9+
- Prefer **composition over inheritance** for better modularity and reusability.
10+
- Store UI layouts in **.ui XML files** and load them dynamically with **PyQt’s uic module**.
11+
- Keep UI definitions (`.ui` files) separate from logic to improve team collaboration.
12+
13+
## Performance and Optimization
14+
- Minimize **UI redraw events** to avoid unnecessary processing.
15+
- Use **QThread or QThreadPool** for background tasks to keep the UI responsive.
16+
- Optimize large table views with **QAbstractTableModel** instead of default models.
17+
18+
## GUI Styling and Responsiveness
19+
- Use **Qt Style Sheets (QSS)** for flexible UI customization.
20+
- Implement **adaptive layouts (QVBoxLayout, QHBoxLayout, QGridLayout)** to support different screen sizes.
21+
- Avoid hardcoded dimensions; use **size policies** instead.
22+
23+
## Code Quality and Maintainability
24+
- Follow **PEP 8** guidelines for code readability.
25+
- Use **descriptive method names** that reflect UI behavior (e.g., `on_button_click`, `load_settings`).
26+
- Implement **logging** using Python’s `logging` module instead of `print` statements.
27+
- Modularize code into **separate files (e.g., models, views, controllers)**.
28+
29+
## Debugging and Testing
30+
- Use **QDebug** and **Qt’s logging mechanisms** to track issues.
31+
- Write **unit tests** with `pytest` and **mock PyQt objects** where necessary.
32+
- Use **pytest-qt** for UI testing.
33+
34+
## Deployment and Packaging
35+
- Use **PyInstaller** to bundle the application into an executable.
36+
- Ensure all **Qt dependencies** are included in the packaging process.
37+
- Create an **installer** using tools like NSIS or Inno Setup for Windows distributions.

ai-workspace/core/prd.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Product Requirements Document (PRD) for RepoDiff: Single-Pass Diff + Post-Processing
2+
3+
## 1. Overview
4+
The goal is to **simplify** RepoDiff by performing a **single** `git diff` command that captures all changed files. Post-processing will then apply user-defined rules (like ignoring bodies of methods far from the changed lines). This approach eliminates the need for multiple Git calls or complex exclude patterns.
5+
6+
## 2. Key Objectives
7+
1. Generate one **unified diff** that covers all changed files in a **single pass**.
8+
2. **Post-process** that diff in Python to apply user-defined patterns, such as:
9+
- Number of context lines around changes.
10+
- Inclusion of entire files with method body removal outside a specified threshold.
11+
3. Provide **user-friendly** output. For instance, when removing method bodies, either keep the braces or replace them with a comment so that an LLM or human reviewer knows code is intentionally omitted.
12+
13+
## 3. Example Configuration
14+
```json
15+
{
16+
"tiktoken_model": "gpt-4o",
17+
"filters": [
18+
{
19+
"file_pattern": "*.cs",
20+
"include_entire_file_with_signatures": true,
21+
"method_body_threshold": 10
22+
},
23+
{
24+
"file_pattern": "*.py",
25+
"context_lines": 5
26+
}
27+
]
28+
}
29+
```
30+
31+
## 4. Single-Pass Approach
32+
1. **Collect All Changes**: Perform one `git diff` for the relevant commits or branches, capturing all changed files (e.g., `git diff commit1 commit2 --unified=999999`).
33+
2. **Parse the Unified Diff**: Use Python to parse each file’s changed lines, hunks, and contextual lines.
34+
3. **Apply Filters**: For each file, determine which config pattern applies and apply the appropriate rule.
35+
4. **Finalize Output**: Reconstruct a single unified diff in memory or produce a custom output where method bodies are replaced with `{ ... }`.
36+
37+
## 5. Handling Method Body Removal in C#
38+
When **`include_entire_file_with_signatures`** is true for a `.cs` file:
39+
1. **Preserve** the **method signature** (e.g., `public void Foo(int x) { ... }`).
40+
2. Keep an **opening** and **closing** brace for that method, replacing the body with `{ ... }`.
41+
42+
```csharp
43+
public void Foo(int x)
44+
{
45+
{ ... }
46+
}
47+
```
48+
49+
The `{ ... }` placeholder is defined in an **instructional header** at the beginning of the diff output to explain that method bodies were intentionally omitted.
50+
51+
## 6. Additional Instructions in Output
52+
Include a **header** in the final diff explaining placeholders:
53+
54+
```
55+
NOTE: Some method bodies have been replaced with "{ ... }" to improve clarity for code reviews and LLM analysis.
56+
```
57+
58+
## 7. Pseudocode
59+
```python
60+
def generate_single_pass_diff(commit1, commit2):
61+
cmd = ["git", "diff", commit1, commit2, "--unified=999999", "--ignore-all-space"]
62+
return run_command(cmd)
63+
64+
def parse_unified_diff(diff_output):
65+
return parse_patch(diff_output)
66+
67+
def post_process_files(patch_dict, config):
68+
for filename, hunks in patch_dict.items():
69+
rule = find_matching_rule(filename, config['filters'])
70+
if rule.get('include_entire_file_with_signatures'):
71+
threshold = rule.get('method_body_threshold', 10)
72+
patch_dict[filename] = apply_signature_removal(hunks, threshold)
73+
else:
74+
c = rule.get('context_lines', 3)
75+
patch_dict[filename] = apply_context_filter(hunks, c)
76+
77+
def main():
78+
config = load_config('config.json')
79+
raw_diff = generate_single_pass_diff("commit1", "commit2")
80+
patch_dict = parse_unified_diff(raw_diff)
81+
post_process_files(patch_dict, config)
82+
final_output = reconstruct_patch(patch_dict)
83+
add_explanatory_comments(final_output)
84+
print(final_output)
85+
```
86+
87+
## 8. Performance
88+
- **Single Git Command**: Works efficiently for 20-100 changed files.
89+
- **In-Memory Post-Processing**: Minimal overhead, simple to maintain.
90+
91+
## 9. Summary
92+
By **capturing all changes in one pass** and then **applying** user-defined rules in Python, RepoDiff remains simple, fast, and predictable. Including an **instructional header** helps both humans and LLMs understand the placeholders used for omitted code sections.

ai-workspace/ui/prd.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
**Product Requirements Document (PRD) for RepoDiff UI (PyQt)**
2+
3+
### 1. Overview
4+
This PRD outlines the requirements for a **modern, dark-mode enabled UI** for RepoDiff, built using **PyQt**. The UI should provide an intuitive interface for users to configure diff settings, select commits, and generate a structured diff file for LLM consumption.
5+
6+
### 2. Key Objectives
7+
1. **Provide an intuitive UI** for configuring file filters, diff settings, and context rules.
8+
2. **Support dark mode** with modern aesthetics.
9+
3. **Enable commit selection** from a dropdown or interactive selection.
10+
4. **Allow easy export** of the processed diff to a file.
11+
5. **Ensure responsiveness** and usability across different screen sizes.
12+
6. **Keep UI simple** without embedding a diff viewer, as users will edit the output in their own text editor.
13+
14+
### 3. UI Design
15+
#### **3.1. Main Window Components**
16+
1. **Commit Selection Panel**
17+
- Dropdowns to select `commit1` and `commit2`.
18+
2. **Configuration Panel**
19+
- File pattern selector (`*.cs`, `*.py`, etc.).
20+
- Toggle for `include_entire_file_with_signatures`.
21+
- Input field for `method_body_threshold`.
22+
- Context lines selection (`-U` value).
23+
3. **Export Options**
24+
- Output path.
25+
- “Pack” button to trigger diff generation and export output as `.md` file.
26+
4. **Dark Mode Toggle**
27+
- Integrated style switcher for light/dark themes.
28+
29+
### 4. Dark Mode Implementation
30+
- Use **Qt’s Fusion theme** with a dark stylesheet.
31+
- Custom stylesheets for buttons, dropdowns, and text areas to ensure consistency.
32+
- Automatic detection of system theme (if possible).
33+
34+
### 5. Interaction Flow
35+
1. **User selects two commits** from dropdowns.
36+
2. **User configures filters and options** (e.g., method body removal, context lines).
37+
3. **User clicks “Pack”** to generate the diff file.
38+
4. **File is automatically saved/exported**, ready for upload to an LLM.
39+
40+
### 6. Sample Pseudocode
41+
```python
42+
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QFileDialog
43+
from PyQt6.QtGui import QPalette, QColor
44+
45+
class RepoDiffUI(QMainWindow):
46+
def __init__(self):
47+
super().__init__()
48+
self.initUI()
49+
50+
def initUI(self):
51+
self.setWindowTitle("RepoDiff")
52+
self.setGeometry(100, 100, 600, 400)
53+
54+
# Dark mode setup
55+
palette = QPalette()
56+
palette.setColor(QPalette.ColorRole.Window, QColor(53, 53, 53))
57+
palette.setColor(QPalette.ColorRole.WindowText, QColor(255, 255, 255))
58+
self.setPalette(palette)
59+
60+
# Main Layout
61+
layout = QVBoxLayout()
62+
63+
# Pack Button
64+
self.pack_button = QPushButton("Pack")
65+
self.pack_button.clicked.connect(self.generate_diff)
66+
layout.addWidget(self.pack_button)
67+
68+
self.setLayout(layout)
69+
70+
def generate_diff(self):
71+
file_path, _ = QFileDialog.getSaveFileName(self, "Save Diff File", "", "Markdown Files (*.md);;All Files (*)")
72+
if file_path:
73+
with open(file_path, 'w') as f:
74+
f.write("Generated diff output...")
75+
76+
app = QApplication([])
77+
window = RepoDiffUI()
78+
window.show()
79+
app.exec()
80+
```
81+
82+
### 7. Expected Outcome
83+
- A modern UI with a **clean, structured layout**.
84+
- **Dark mode support** with clear text visibility.
85+
- **No embedded diff viewer**, only file export.
86+
- **Seamless interaction** for configuring and generating diffs.
87+
- **Optimized for LLMs and manual editing.**
88+
89+
### 8. Summary
90+
RepoDiff’s UI will be developed in **PyQt**, providing a **modern, user-friendly interface** with dark mode support. The UI will enable easy configuration, commit selection, and diff generation, making RepoDiff an accessible and efficient tool for code review workflows.
91+

0 commit comments

Comments
 (0)