Skip to content

feat: add heuristic cleanup for common project directories (#328)#332

Open
rh42-ic wants to merge 9 commits into
Byron:mainfrom
rh42-ic:heuristics
Open

feat: add heuristic cleanup for common project directories (#328)#332
rh42-ic wants to merge 9 commits into
Byron:mainfrom
rh42-ic:heuristics

Conversation

@rh42-ic
Copy link
Copy Markdown

@rh42-ic rh42-ic commented May 31, 2026

Description

This PR implements an initial prototype of the declarative heuristic engine discussed in #328.

This code is currently a draft and serves as a proof of concept. It requires further discussion, thorough code review, and extensive testing before merging. I am opening this PR now to gather early feedback on the implementation and architectural direction.

Key Changes

  • Add declarative TOML-based heuristic engine in etc/heuristics/
  • Support common languages: Rust, Node.js, Python, Java, PHP, Dart, Elixir, Zig, macOS
  • Integrate with TUI: auto-detect project type on directory navigation
  • Highlight matched build/cache directories in yellow
  • Add dynamic bottom-right help text (e.g., clean-rust = X)
  • Press X to quickly mark matched directories for deletion

rh42-ic added 9 commits May 31, 2026 18:23
- Add declarative TOML-based heuristic engine in `etc/heuristics/`
- Support common languages: Rust, Node.js, Python, Java, PHP, Dart, Elixir, Zig, macOS
- Integrate with TUI: auto-detect project type on directory navigation
- Highlight matched build/cache directories in yellow
- Add dynamic bottom-right help text (e.g., `clean-rust = X`)
- Press `X` to quickly mark matched directories for deletion
- Use `OnceLock` to parse heuristic TOML files only once instead of on every directory change
- Avoid blocking the UI thread with filesystem I/O by matching heuristics against the already-loaded in-memory entries
- Eliminate string allocations in the render loop by using `OsStr` comparisons instead of `to_string_lossy()`
- Support glob patterns in heuristic `patterns` (e.g., `*.log`)
- Make heuristic matching case-insensitive on Windows and macOS
- Auto-discover and include TOML files in `etc/heuristics/` via `build.rs`
- Re-evaluate heuristics immediately after deleting marked entries
- Centralize matching logic in `Heuristic::is_match`
- Fix directory matching flaw for patterns ending with `/`
- Use `&'static Heuristic` to avoid unnecessary cloning
- Panic on invalid built-in TOML heuristic configs
- Simplify UI color logic and remove redundant functions
- Move `prev_view_root` capture before ESC key handling to correctly detect directory changes and trigger `update_heuristics`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant