From 54f6dd2c7da85bcf3ac8b8b6ddee8fa888640539 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Thu, 22 Jan 2026 13:32:09 -0600 Subject: [PATCH 1/2] Add Claude.md & CONTRIBUTING.md Used /init in claude code to make initial structure than added some notes myself. --- CLAUDE.md | 19 ++++++++++++ CONTRIBUTING.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 4 +++ 3 files changed, 103 insertions(+) create mode 100644 CLAUDE.md create mode 100644 CONTRIBUTING.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..aa1da645 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,19 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +See [CONTRIBUTING.md](CONTRIBUTING.md) for build commands, testing, code style, and development workflow. + +## Workspace Structure + +- **ldk-server** - Main daemon server (entry point: `src/main.rs`) +- **ldk-server-cli** - CLI client using clap +- **ldk-server-client** - Reqwest-based client library +- **ldk-server-protos** - Protocol buffer definitions and generated Rust code + +## Development Rules + +- Always ensure tests pass and lints are fixed before committing +- Run `cargo fmt --all` after every code change +- Never add new dependencies unless explicitly requested +- Please always disclose the use of any AI tools in commit messages and PR descriptions diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..f5df1066 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,80 @@ +# Contributing to LDK Server + +Contributions are welcome and encouraged! Whether you're fixing bugs, adding features, improving documentation, or +helping with testing, we appreciate your help! + +## Building + +```bash +cargo build # Build all crates +cargo build --release # Production build (LTO enabled) +``` + +## Running + +```bash +cargo run --bin ldk-server ./ldk-server/ldk-server-config.toml +``` + +## Testing + +```bash +cargo test # Run all tests +cargo test --all-features # Run tests with all features +``` + +## Code Quality + +```bash +cargo fmt --all # Format code +cargo fmt --all -- --check # Check formatting +cargo clippy --all-features -- -D warnings -A clippy::drop_non_drop # Lint (CI uses this on MSRV) +``` + +## Code Style + +- MSRV: Rust 1.85.0 +- Hard tabs, max width 100 chars +- Imports grouped: std, external crates, local crates + +## Protocol Buffer Generation + +```bash +RUSTFLAGS="--cfg genproto" cargo build -p ldk-server-protos +``` + +After regenerating, you must manually readd the copyright header to each generated file in `ldk-server-protos/src/` ( +`api.rs`, `types.rs`, `events.rs`, `error.rs`): + +``` +// This file is Copyright its original authors, visible in version control +// history. +// +// This file is licensed under the Apache License, Version 2.0 or the MIT license +// , at your option. +// You may not use this file except in accordance with one or both of these +// licenses. +``` + +Then run `cargo fmt --all` to format the generated code. + +## Adding a New API Endpoint + +1. Define request/response messages in `ldk-server-protos/src/proto/api.proto` +2. Regenerate protos (see above) +3. Create handler in `ldk-server/src/api/` (follow existing patterns) +4. Add route in `ldk-server/src/service.rs` +5. Add CLI command in `ldk-server-cli/src/main.rs` + +## Configuration + +- Config template with all options: `ldk-server/ldk-server-config.toml` +- When updating config options, also update the tests in `ldk-server/src/util/config.rs` + +## Before Submitting + +- Ensure all tests pass +- Ensure all lints are fixed +- Run `cargo fmt --all` +- Please disclose the use of any AI tools in commit messages and PR descriptions diff --git a/README.md b/README.md index 8497da57..10f0c609 100644 --- a/README.md +++ b/README.md @@ -70,3 +70,7 @@ eval "$(ldk-server-cli completions zsh)" # Fish (add to ~/.config/fish/config.fish) ldk-server-cli completions fish | source ``` + +## Contributing + +Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on building, testing, code style, and development workflow. From 3824b8653f6ec085d89cf3c2cd677981f155f394 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Mon, 26 Jan 2026 05:56:08 -0600 Subject: [PATCH 2/2] Automatically include copyright headers in generated files --- CONTRIBUTING.md | 17 +---------------- ldk-server-protos/build.rs | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5df1066..9a783dfb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,24 +41,9 @@ cargo clippy --all-features -- -D warnings -A clippy::drop_non_drop # Lint (CI ```bash RUSTFLAGS="--cfg genproto" cargo build -p ldk-server-protos +cargo fmt --all ``` -After regenerating, you must manually readd the copyright header to each generated file in `ldk-server-protos/src/` ( -`api.rs`, `types.rs`, `events.rs`, `error.rs`): - -``` -// This file is Copyright its original authors, visible in version control -// history. -// -// This file is licensed under the Apache License, Version 2.0 or the MIT license -// , at your option. -// You may not use this file except in accordance with one or both of these -// licenses. -``` - -Then run `cargo fmt --all` to format the generated code. - ## Adding a New API Endpoint 1. Define request/response messages in `ldk-server-protos/src/proto/api.proto` diff --git a/ldk-server-protos/build.rs b/ldk-server-protos/build.rs index 32b9f6b0..a3d94017 100644 --- a/ldk-server-protos/build.rs +++ b/ldk-server-protos/build.rs @@ -13,6 +13,19 @@ extern crate prost_build; #[cfg(genproto)] use std::{env, fs, path::Path}; +#[cfg(genproto)] +const COPYRIGHT_HEADER: &str = + "// This file is Copyright its original authors, visible in version control +// history. +// +// This file is licensed under the Apache License, Version 2.0 or the MIT license +// , at your option. +// You may not use this file except in accordance with one or both of these +// licenses. + +"; + /// To generate updated proto objects, run `RUSTFLAGS="--cfg genproto" cargo build` fn main() { #[cfg(genproto)] @@ -38,13 +51,12 @@ fn generate_protos() { &["src/proto/"], ) .expect("protobuf compilation failed"); - println!("OUT_DIR: {}", &env::var("OUT_DIR").unwrap()); - let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("api.rs"); - fs::copy(from_path, "src/api.rs").unwrap(); - let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("types.rs"); - fs::copy(from_path, "src/types.rs").unwrap(); - let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("events.rs"); - fs::copy(from_path, "src/events.rs").unwrap(); - let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("error.rs"); - fs::copy(from_path, "src/error.rs").unwrap(); + let out_dir = env::var("OUT_DIR").unwrap(); + println!("OUT_DIR: {}", &out_dir); + for file in &["api.rs", "types.rs", "events.rs", "error.rs"] { + let from_path = Path::new(&out_dir).join(file); + let content = fs::read_to_string(&from_path).unwrap(); + let with_header = format!("{}{}", COPYRIGHT_HEADER, content); + fs::write(Path::new("src").join(file), with_header).unwrap(); + } }