WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 2fa55b9

Browse files
committed
Setup for agents to help build
1 parent eb75087 commit 2fa55b9

File tree

2 files changed

+105
-6
lines changed

2 files changed

+105
-6
lines changed

CLAUDE.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
ghciwatch is a GHCi-based file watcher and recompiler for Haskell projects written in Rust. It loads a GHCi session and automatically reloads it when source files change, providing fast feedback during Haskell development.
8+
9+
## Common Development Commands
10+
11+
### Build
12+
```bash
13+
cargo build # Build debug version
14+
cargo build --release # Build optimized release version
15+
```
16+
17+
### Test
18+
```bash
19+
cargo nextest run # Run tests with nextest (preferred, faster)
20+
cargo test # Alternative test runner
21+
cargo llvm-cov nextest # Run tests with coverage
22+
```
23+
24+
### Lint & Format
25+
```bash
26+
cargo clippy # Run linter
27+
cargo fmt # Format code
28+
cargo check # Check compilation without building
29+
```
30+
31+
### Documentation
32+
```bash
33+
cargo doc --document-private-items --no-deps --workspace # Generate API docs
34+
cargo run --features clap-markdown -- --generate-markdown-help > docs/cli.md # Update CLI docs
35+
mdbook build docs # Build user manual
36+
```
37+
38+
## High-Level Architecture
39+
40+
The codebase follows a modular architecture with clear separation of concerns:
41+
42+
### Core Components
43+
44+
1. **Main Entry Point** (`src/main.rs`, `src/lib.rs`): Initializes the application, parses CLI arguments, and orchestrates the three main subsystems below.
45+
46+
2. **GHCi Management** (`src/ghci/`):
47+
- `manager.rs`: Handles lifecycle of the GHCi process including startup, shutdown, and reload coordination
48+
- `process.rs`: Manages the actual GHCi subprocess
49+
- `stdin.rs`, `stdout.rs`, `stderr.rs`: Handle I/O streams from GHCi
50+
- `parse/`: Contains parsers for GHCi output including error messages, module information, and evaluation comments
51+
- `warning_tracker.rs`: Tracks and manages GHC warnings across reloads
52+
53+
3. **File Watching** (`src/watcher.rs`): Monitors filesystem changes and triggers reload events. Uses the `notify` crate for cross-platform file watching.
54+
55+
4. **TUI (Terminal UI)** (`src/tui/`): Optional terminal interface for displaying compilation results in a structured format using ratatui.
56+
57+
### Key Architectural Patterns
58+
59+
- **Async/Await**: Uses Tokio for concurrent operations, allowing GHCi process management, file watching, and UI updates to run simultaneously
60+
- **Channel-based Communication**: Components communicate via mpsc channels (e.g., `WatcherEvent` sent from watcher to GHCi manager)
61+
- **Graceful Shutdown**: `ShutdownManager` coordinates clean shutdown across all subsystems
62+
- **Hook System** (`src/hooks.rs`): Extensible lifecycle hooks allow running custom commands at various points (startup, before/after reload, etc.)
63+
64+
### Data Flow
65+
66+
1. File watcher detects changes → sends `WatcherEvent` to GHCi manager
67+
2. GHCi manager processes event → sends reload command to GHCi process
68+
3. GHCi output is parsed → compilation results displayed to user
69+
4. Lifecycle hooks execute at appropriate points
70+
5. TUI (if enabled) continuously updates display with latest compilation state
71+
72+
## Development Notes
73+
74+
- The project uses Nix for development environment setup (`nix develop`)
75+
- Integration tests in `tests/` require a Haskell toolchain (GHC, cabal, hpack)
76+
- Test harness is in `test-harness/` workspace member
77+
- Minimum supported Rust version appears to be 1.72 based on dependency constraints

CONTRIBUTING.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,43 @@ Covenant Code of Conduct][contributor-covenant].
1313

1414
**TL;DR:** Use `nix develop`, but you may be able to scrape by with `cargo`.
1515

16+
### Quick Start Commands
17+
18+
You can use either `cargo` commands directly or use the provided `justfile` recipes (requires [just](https://github.com/casey/just)):
19+
20+
```bash
21+
# Build the project
22+
just build # Or: cargo build
23+
cargo build --release # Build optimized release version
24+
25+
# Run tests
26+
just test # Or: cargo nextest run (preferred, faster)
27+
cargo test # Alternative: Run tests with standard cargo test
28+
29+
# Code quality
30+
just lint # Or: cargo clippy
31+
just format # Or: cargo fmt
32+
cargo check # Check compilation without building
33+
34+
# Documentation
35+
just api-docs # Or: cargo doc --document-private-items --no-deps --workspace
36+
just docs # Build user manual (requires mdbook)
37+
just serve-docs # Serve user manual on http://localhost:3000
38+
```
39+
40+
### Setup Requirements
41+
1642
A standard [Rust installation][rustup] with `cargo` is sufficient to build
1743
ghciwatch. If you're new to Rust, check out [Rust for
1844
Haskellers][rust-for-haskellers].
1945

2046
[rust-for-haskellers]: https://becca.ooo/blog/rust-for-haskellers/
2147

22-
To run tests, you'll need [Nix/Lix][lix] installed. Run `nix
48+
To run the full test suite (including integration tests), you'll need [Nix/Lix][lix] installed. Run `nix
2349
develop` to enter a [development shell][dev-env] with all the dependencies
24-
available and then use `cargo nextest run` to run the tests (including the
25-
integration tests) with [`cargo-nextest`][nextest]. (`cargo test` will work,
50+
available and then use `cargo nextest run` to run the tests with [`cargo-nextest`][nextest]. (`cargo test` will work,
2651
too, but slower.)
2752

28-
You can run the tests with coverage output with `cargo llvm-cov nextest`.
29-
it is [possible to display coverage][coverage-vscode] information in VSCode, with `cargo llvm-cov --lcov --output-path lcov.info`.
30-
3153
[rustup]: https://rustup.rs/
3254
[lix]: https://lix.systems/
3355
[dev-env]: https://zero-to-nix.com/concepts/dev-env

0 commit comments

Comments
 (0)