|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## What This Is |
| 6 | + |
| 7 | +Hackertuah is a Rust TUI application for browsing Hacker News. It uses ratatui/crossterm for the terminal UI, tokio/reqwest for async HTTP, and integrates with the Claude API for story summarization. The app features vim-style navigation, a command palette, search/filter, and section switching (Top, Ask, Show, Jobs). |
| 8 | + |
| 9 | +## Build & Run |
| 10 | + |
| 11 | +```bash |
| 12 | +make build # cargo build |
| 13 | +make run # cargo run |
| 14 | +make test # cargo test |
| 15 | +make lint # cargo clippy -- -D warnings |
| 16 | +make format # cargo fmt |
| 17 | +make verify # format + lint + build + test (run after any change) |
| 18 | +make clean # cargo clean |
| 19 | +make install # release build + copy binary to ~/bin |
| 20 | +make bump # cog bump --auto (cocogitto versioning) |
| 21 | +``` |
| 22 | + |
| 23 | +## Architecture |
| 24 | + |
| 25 | +The `src/` directory is split by concern: |
| 26 | + |
| 27 | +- **`types.rs`** — Data types: `Story`, `Section`, `Mode`, `ClaudeRequest`, `Message`. No dependencies on other local modules. |
| 28 | +- **`hn_api.rs`** — HTTP layer: `fetch_stories` (HN Firebase API) and `get_claude_summary` (Anthropic API). Depends on `types`. |
| 29 | +- **`ui.rs`** — All rendering: `draw_ui`, `draw_menu`, `draw_summary`, `draw_command_palette`, `centered_rect`. Depends on `types` and `app`. |
| 30 | +- **`loading_screen.rs`** — `MatrixRain` struct for the Matrix-style loading animation. |
| 31 | +- **`main.rs`** — `App` struct (all application state), `Command`/`CommandPalette`, terminal setup/teardown, and the main event loop. `App` is exposed via `pub mod app` so `ui.rs` can reference it. |
| 32 | + |
| 33 | +The app uses a single-threaded tokio runtime. Story fetching spawns tokio tasks per section that run concurrently. The `App` struct holds all state: stories, UI mode, cached stories per section, command palette state, and search state. |
| 34 | + |
| 35 | +## Key Details |
| 36 | + |
| 37 | +- HN API: Firebase REST API at `hacker-news.firebaseio.com/v0/`. Fetches up to 100 stories per section. |
| 38 | +- Claude API: Requires `CLAUDE_API_KEY` env var. Currently hardcoded to `claude-3-opus-20240229` model. |
| 39 | +- Versioning: Uses cocogitto (`cog.toml`) with conventional commits. Changelog at `CHANGELOG.md`. |
| 40 | +- CI: GitHub Actions runs `cargo build` and `cargo test` on push/PR to main. |
| 41 | +- Cargo.toml lists edition 2021; version is `0.1.0` (behind the `0.2.0` tag from cog). |
0 commit comments