From bee429192fb107b3457744ec1077873ea17180fd Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sun, 15 Mar 2026 20:09:06 +0100 Subject: [PATCH] chore: update .gitignore and enhance README with compositor setup instructions --- .gitignore | 1 + CLAUDE.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 4 ++-- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 CLAUDE.md diff --git a/.gitignore b/.gitignore index 2f7896d..873c9dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target/ +.worktrees/ diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..ca751a8 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,58 @@ +## 1. Core Philosophy + +- **Test-Driven Development (TDD):** No functional code is written without a failing test first. Red-Green-Refactor is the mandatory cycle. +- **Clean Architecture:** Maintain strict separation between Domain, Application, and Infrastructure layers. +- **Newtype Pattern:** Use the "Newtype" pattern for all domain primitives (e.g., `struct UserId(Uuid)`) to ensure type safety and prevent primitive obsession. + +--- + +## 2. Structural Rules + +### Dependency Management + +- **Strict Unidirectionality:** Dependencies must only point inwards (towards the Domain). +- **No Cyclic Dependencies:** Use traits and Dependency Injection (DI) to break cycles. If two modules need each other, abstract the shared behavior into a trait or move common data to a lower-level module. +- **Feature Gating:** Organize the project into logical crates or modules that can be compiled independently. + +### Traits and Decoupling + +- **Swappable Infrastructure:** Define all external interactions (Database, API, File System) as traits in the Application layer. +- **Small Traits:** Adhere to the Interface Segregation Principle. Favor many specific traits over one "God" trait. +- **Mocking:** Use traits to allow easy mocking in unit tests without requiring a real database or network. + +--- + +## 3. Rust Specifics & Clean Code + +### Type Safety + +- Avoid `String` or `i32` for domain concepts. Wrap them in structs. +- Use `Result` and `Option` explicitly. Minimize `unwrap()` and `expect()`—handle errors gracefully at the boundaries. + +### Formatting & Style + +- Follow standard `rustfmt` and `clippy` suggestions. +- Function names should be descriptive (e.g., `process_valid_order` instead of `handle_data`). +- Keep functions small (typically under 20-30 lines). + +--- + +## 4. Layer Definitions + +| Layer | Responsibility | Allowed Dependencies | +| ------------------ | --------------------------------------------- | -------------------- | +| **Domain** | Pure Business Logic, Entities, Value Objects. | None (Pure Rust) | +| **Application** | Use Cases, Orchestration, Trait definitions. | Domain | +| **Infrastructure** | Trait implementations (DB, HTTP clients). | Domain, Application | +| **Main/API** | Entry point, Wire-up/DI, Routing. | All of the above | + +--- + +## 5. TDD Workflow Requirement + +1. **Write a Test:** Create a test in `src/lib.rs` or a `tests/` directory. +2. **Define the Interface:** Use a trait or function signature to make the test compile (but fail). +3. **Minimum Implementation:** Write just enough code to pass the test. +4. **Refactor:** Clean up the logic, ensure no duplication, and check for "Newtype" opportunities. + +> **Note on Cyclic Dependencies:** If an AI agent suggests a change that introduces a cycle, it must be rejected. Use **Inversion of Control** by defining a trait in the higher-level module that the lower-level module implements. diff --git a/README.md b/README.md index e28e8c4..df4aebb 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ A lightweight, GPU-accelerated command palette for Linux (Wayland/X11). Zero Electron — every pixel rendered via WGPU. Async search that never blocks the UI. -![k-launcher](docs/screenshot.png) - ## Quick Start ```bash @@ -27,6 +25,7 @@ cargo build --release k-launcher uses a normal window; configure your compositor to float it. **Hyprland** (`~/.config/hypr/hyprland.conf`): + ``` windowrule = float, ^(k-launcher)$ windowrule = center, ^(k-launcher)$ @@ -34,6 +33,7 @@ bind = SUPER, Space, exec, k-launcher ``` **Sway** (`~/.config/sway/config`): + ``` for_window [app_id="k-launcher"] floating enable, move position center bindsym Mod4+space exec k-launcher