Skip to content

Commit f8345b7

Browse files
authored
Merge pull request #112 from benthecarman/claude.md
Add Claude.md
2 parents 6a43848 + 749e2ff commit f8345b7

4 files changed

Lines changed: 111 additions & 10 deletions

File tree

CLAUDE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
See [CONTRIBUTING.md](CONTRIBUTING.md) for build commands, testing, code style, and development workflow.
6+
7+
## Workspace Structure
8+
9+
- **ldk-server** - Main daemon server (entry point: `src/main.rs`)
10+
- **ldk-server-cli** - CLI client using clap
11+
- **ldk-server-client** - Reqwest-based client library
12+
- **ldk-server-protos** - Protocol buffer definitions and generated Rust code
13+
14+
## Development Rules
15+
16+
- Always ensure tests pass and lints are fixed before committing
17+
- Run `cargo fmt --all` after every code change
18+
- Never add new dependencies unless explicitly requested
19+
- Please always disclose the use of any AI tools in commit messages and PR descriptions

CONTRIBUTING.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Contributing to LDK Server
2+
3+
Contributions are welcome and encouraged! Whether you're fixing bugs, adding features, improving documentation, or
4+
helping with testing, we appreciate your help!
5+
6+
## Building
7+
8+
```bash
9+
cargo build # Build all crates
10+
cargo build --release # Production build (LTO enabled)
11+
```
12+
13+
## Running
14+
15+
```bash
16+
cargo run --bin ldk-server ./ldk-server/ldk-server-config.toml
17+
```
18+
19+
## Testing
20+
21+
```bash
22+
cargo test # Run all tests
23+
cargo test --all-features # Run tests with all features
24+
```
25+
26+
## Code Quality
27+
28+
```bash
29+
cargo fmt --all # Format code
30+
cargo fmt --all -- --check # Check formatting
31+
cargo clippy --all-features -- -D warnings -A clippy::drop_non_drop # Lint (CI uses this on MSRV)
32+
```
33+
34+
## Code Style
35+
36+
- MSRV: Rust 1.85.0
37+
- Hard tabs, max width 100 chars
38+
- Imports grouped: std, external crates, local crates
39+
40+
## Protocol Buffer Generation
41+
42+
```bash
43+
RUSTFLAGS="--cfg genproto" cargo build -p ldk-server-protos
44+
cargo fmt --all
45+
```
46+
47+
## Adding a New API Endpoint
48+
49+
1. Define request/response messages in `ldk-server-protos/src/proto/api.proto`
50+
2. Regenerate protos (see above)
51+
3. Create handler in `ldk-server/src/api/` (follow existing patterns)
52+
4. Add route in `ldk-server/src/service.rs`
53+
5. Add CLI command in `ldk-server-cli/src/main.rs`
54+
55+
## Configuration
56+
57+
- Config template with all options: `ldk-server/ldk-server-config.toml`
58+
- When updating config options, also update the tests in `ldk-server/src/util/config.rs`
59+
60+
## Before Submitting
61+
62+
- Ensure all tests pass
63+
- Ensure all lints are fixed
64+
- Run `cargo fmt --all`
65+
- Please disclose the use of any AI tools in commit messages and PR descriptions

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ eval "$(ldk-server-cli completions zsh)"
7070
# Fish (add to ~/.config/fish/config.fish)
7171
ldk-server-cli completions fish | source
7272
```
73+
74+
## Contributing
75+
76+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on building, testing, code style, and development workflow.

ldk-server-protos/build.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@
1111
extern crate prost_build;
1212

1313
#[cfg(genproto)]
14-
use std::{env, fs, path::Path};
14+
use std::{env, fs, io::Write, path::Path};
15+
16+
#[cfg(genproto)]
17+
const COPYRIGHT_HEADER: &str =
18+
"// This file is Copyright its original authors, visible in version control
19+
// history.
20+
//
21+
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
22+
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
23+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
24+
// You may not use this file except in accordance with one or both of these
25+
// licenses.
26+
27+
";
1528

1629
/// To generate updated proto objects, run `RUSTFLAGS="--cfg genproto" cargo build`
1730
fn main() {
@@ -38,13 +51,13 @@ fn generate_protos() {
3851
&["src/proto/"],
3952
)
4053
.expect("protobuf compilation failed");
41-
println!("OUT_DIR: {}", &env::var("OUT_DIR").unwrap());
42-
let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("api.rs");
43-
fs::copy(from_path, "src/api.rs").unwrap();
44-
let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("types.rs");
45-
fs::copy(from_path, "src/types.rs").unwrap();
46-
let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("events.rs");
47-
fs::copy(from_path, "src/events.rs").unwrap();
48-
let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("error.rs");
49-
fs::copy(from_path, "src/error.rs").unwrap();
54+
let out_dir = env::var("OUT_DIR").unwrap();
55+
println!("OUT_DIR: {}", &out_dir);
56+
for file in &["api.rs", "types.rs", "events.rs", "error.rs"] {
57+
let from_path = Path::new(&out_dir).join(file);
58+
let content = fs::read(&from_path).unwrap();
59+
let mut dest = fs::File::create(Path::new("src").join(file)).unwrap();
60+
dest.write_all(COPYRIGHT_HEADER.as_bytes()).unwrap();
61+
dest.write_all(&content).unwrap();
62+
}
5063
}

0 commit comments

Comments
 (0)