Thank you for your interest in contributing to this project! 感谢你对本项目的关注!
- Prerequisites | 前置要求
- Development Setup | 开发环境配置
- Code Style | 代码风格
- Testing | 测试
- Pull Request Process | PR 流程
Before you begin, ensure you have the following tools installed:
开始之前,请确保已安装以下工具:
- C++ Compiler: g++ 9+ or clang++ 10+ (with C++17 support)
- Go: 1.19 or later
- Rust: 1.70 or later (with rustfmt and clippy)
- Python: 3.8 or later (for benchmark scripts)
- Make: For simplified build commands
- Docker: For consistent build environment
Ubuntu/Debian:
sudo apt update
sudo apt install g++ golang rustc python3macOS (with Homebrew):
brew install gcc go rust python3Windows:
- Fork and clone the repository | Fork 并克隆仓库
git clone https://github.com/LessUp/compress-kit.git
cd compress-kit- Verify your environment | 验证环境
# Check C++ compiler
g++ --version
# Check Go
go version
# Check Rust
rustc --version
cargo --version
# Check Python
python3 --version- Build all implementations | 构建所有实现
# C++ (example: Huffman)
cd algorithms/huffman/cpp && g++ -std=c++17 -O2 main.cpp -o huffman_cpp && cd ../..
# Go (example: Huffman)
cd algorithms/huffman/go && go build -o huffman_go . && cd ../..
# Rust (example: Huffman)
cd algorithms/huffman/rust && rustc -O main.rs -o huffman_rust && cd ../..- Follow Google C++ Style Guide
- Use 4 spaces for indentation
- Use
snake_casefor functions and variables - Use
PascalCasefor classes and structs
# Format check (if clang-format is available)
clang-format --dry-run --Werror *.cpp- Use
gofmtfor formatting (mandatory) - Use
go vetfor static analysis - Follow Effective Go
# Format code
gofmt -w .
# Check for issues
go vet ./...- Use
rustfmtfor formatting (mandatory) - Use
clippyfor linting - Follow Rust API Guidelines
# Format code
cargo fmt
# Lint code
cargo clippy -- -D warnings- Follow PEP 8
- Use 4 spaces for indentation
# Generate test data
python3 tests/gen_testdata.py
# Run all benchmarks
python3 scripts/run_all_bench.py
# Run specific algorithm benchmark
cd algorithms/huffman/benchmark && python3 bench.py
cd algorithms/rle/benchmark && python3 bench.pyEach implementation should pass the encode-decode round-trip test:
每个实现都应通过编码-解码往返测试:
# Example: Huffman C++
./huffman_cpp encode input.bin encoded.huf
./huffman_cpp decode encoded.huf decoded.bin
diff input.bin decoded.bin # Should produce no outputFiles encoded by one language implementation should be decodable by others:
一种语言编码的文件应能被其他语言正确解码:
# Encode with C++, decode with Go
./huffman_cpp encode input.bin encoded.huf
./huffman_go decode encoded.huf decoded.bin
diff input.bin decoded.binThis project follows Spec-Driven Development (SDD). All code implementations must be based on the specification documents in /specs/.
本项目遵循规范驱动开发(SDD)。所有代码实现必须以 /specs/ 目录下的规范文档为依据。
-
Review Specs First | 先审查规范: Before writing any code, read the relevant documents in
/specs/product/,/specs/rfc/, or/specs/testing/.编写代码前,请先阅读
/specs/product/、/specs/rfc/或/specs/testing/中的相关文档。 -
Update Specs First | 先更新规范: For new features or interface changes, propose spec changes first. Wait for confirmation before coding.
对于新功能或接口变更,请先提议更新规范文档,确认后再编写代码。
-
Implement to Spec | 按规范实现: Code must 100% adhere to spec definitions (naming, API paths, data types, etc.).
代码必须 100% 遵守规范定义(命名、API 路径、数据类型等)。
-
Test Against Spec | 按规范测试: Write tests based on the acceptance criteria in
/specs/.根据
/specs/中的验收标准编写测试。
See AGENTS.md for the complete AI workflow instructions.
完整的 AI 工作流指令,请参阅 AGENTS.md。
- Create a feature branch | 创建功能分支
git checkout -b feature/your-feature-name- Make your changes | 进行修改
- Write clean, readable code
- Add comments for complex logic
- Update documentation if needed
- Test your changes | 测试修改
# Build and test
# Run benchmarks to verify correctness- Commit with clear messages | 提交清晰的 commit 信息
git commit -m "feat: add XXX feature"
# or
git commit -m "fix: resolve XXX issue"Commit message format | 提交信息格式:
feat:New feature | 新功能fix:Bug fix | 修复 bugdocs:Documentation | 文档style:Code style | 代码风格refactor:Refactoring | 重构test:Tests | 测试chore:Maintenance | 维护
- Push and create PR | 推送并创建 PR
git push origin feature/your-feature-nameThen create a Pull Request on GitHub.
- PR Checklist | PR 检查清单
Before submitting, ensure:
提交前请确保:
- Code compiles without errors | 代码编译无错误
- All tests pass | 所有测试通过
- Code follows the style guide | 代码符合风格指南
- Documentation is updated | 文档已更新
- CHANGELOG.md is updated (if applicable) | CHANGELOG 已更新(如适用)
Feel free to open an issue if you have any questions or suggestions!
如有任何问题或建议,欢迎提交 Issue!