|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +Search and resume past conversations from Claude Code and Codex CLI. |
| 6 | + |
| 7 | +## Principles |
| 8 | + |
| 9 | +- **Delightful** - Made with love, feels good to use |
| 10 | +- **Simple, uncluttered, focused** - Two panes, keyboard-driven, no chrome |
| 11 | +- **Responsive** - Instant startup via background indexing, sub-100ms search |
| 12 | +- **Match-recency matters** - Rank by most recent message containing the match (human memory anchors to recent context) |
| 13 | +- **Seamless resume** - Enter execs directly into the CLI, no intermediate steps |
| 14 | + |
| 15 | +## Development |
| 16 | + |
| 17 | +```bash |
| 18 | +cargo check # Fast compile check (no binary) |
| 19 | +cargo run # Build debug + run |
| 20 | +cargo test # Run tests |
| 21 | +cargo clippy # Lint |
| 22 | +``` |
| 23 | + |
| 24 | +To test the TUI end-to-end, use tmux: |
| 25 | +```bash |
| 26 | +cargo build && tmux new-session -d -s test './target/debug/recall' |
| 27 | +tmux send-keys -t test 'search query' |
| 28 | +tmux capture-pane -t test -p # See output |
| 29 | +tmux kill-session -t test # Cleanup |
| 30 | +``` |
| 31 | + |
| 32 | +## Install |
| 33 | + |
| 34 | +```bash |
| 35 | +cargo install --path . |
| 36 | +``` |
| 37 | + |
| 38 | +## Architecture |
| 39 | + |
| 40 | +Rust TUI for searching Claude Code and Codex CLI conversation history. |
| 41 | + |
| 42 | +- `src/main.rs` - Entry point, event loop, exec into CLI on resume |
| 43 | +- `src/app.rs` - Application state, search logic, background indexing thread |
| 44 | +- `src/ui.rs` - Two-pane ratatui rendering, match highlighting |
| 45 | +- `src/tui.rs` - Terminal setup/teardown |
| 46 | +- `src/theme.rs` - Light/dark theme with auto-detection |
| 47 | +- `src/session.rs` - Core types: Session, Message, SearchResult |
| 48 | +- `src/parser/` - JSONL parsers for Claude (`~/.claude/projects/`) and Codex (`~/.codex/sessions/`) |
| 49 | +- `src/index/` - Tantivy full-text search index, stored in `~/.cache/recall/` |
| 50 | + |
| 51 | +## Key Patterns |
| 52 | + |
| 53 | +- Background indexing: spawns thread on startup, indexes most recent files first, sends progress via mpsc channel |
| 54 | +- Unicode-safe string handling: use char indices not byte indices when slicing (see `highlight_matches`, `create_snippet`) |
| 55 | +- Search ranking: combines BM25 relevance with recency boost (exponential decay, 7-day half-life) |
| 56 | +- Theme detection: queries terminal bg color via crossterm, falls back to COLORFGBG env var |
| 57 | +- Event handling: drains all pending events each frame to prevent mouse event flooding |
| 58 | +- Contextual status bar: hints adapt to state (e.g., scroll hint only when preview is scrollable) |
0 commit comments