贡献指南
欢迎为 NeoMind 贡献代码!本文覆盖开发环境、代码规范、提交约定、CI 流水线和 PR 流程。
推荐用 AI 辅助:贡献前先读 AI 辅助开发指南,用 Claude Code 探索代码、生成实现、跑测试,效率翻倍。
开发环境
# 1. Fork & clone
git clone https://github.com/<your-username>/NeoMind.git
cd NeoMind
# 2. 安装依赖
cargo build # Rust 后端
cd web && npm install # 前端
# 3. 启动开发环境
cargo run -p neomind-cli -- serve # 后端(端口 9375)
npm run dev # 前端(端口 5173)
工具链要求:
- Rust 1.92.0+(edition 2021)
- Node.js 18+
- 系统依赖:protobuf 编译器(
protoc)
代码规范
Rust
项目使用默认 rustfmt 和 clippy 配置(无自定义 .rustfmt.toml)。
# 提交前必跑
cargo fmt --all # 格式化
cargo clippy --all-targets # 代码检查(必须无 warning)
cargo test # 单元测试
关键约定:
- 公开类型必须有文档注释(
///) - 错误处理用
Result<T, E>,不要unwrap()/expect()(测试代码除外) - 异步代码用 Tokio runtime
- 重新导出(
pub use)只保留实际被外部使用的——项目定期清理 dead re-exports
前端
cd web
npm run lint # ESLint + TypeScript 检查
npm run build:check # 类型检查 + 循环依赖检测
npm run test # Vitest 单元测试
关键约定(详见 web/DESIGN_SPEC.md):
- 颜色:只用 design token 类名(
text-success、bg-error-light),