URL: /community/contributing

---
title: 贡献指南
description: 如何为 Zapmyco 项目做出贡献
---

感谢您考虑为 Zapmyco 做贡献！

## 行为准则

本项目采用贡献者公约作为行为准则。参与本项目即表示您同意遵守其条款。

## 如何贡献

### 报告 Bug

如果您发现了 Bug，请通过 [GitHub Issues](https://github.com/shenjingnan/zapmyco/issues) 报告。

报告 Bug 时，请包含：

1. **清晰的标题** — 简要描述问题
2. **复现步骤** — 详细说明如何复现
3. **预期行为** — 您期望发生什么
4. **实际行为** — 实际发生了什么
5. **环境信息** — 操作系统、Rust 版本 (`rustc --version`) 等

### 建议新功能

我们欢迎新功能建议！请在 Issue 中描述：

1. **功能描述** — 您希望添加什么功能
2. **使用场景** — 为什么需要这个功能
3. **替代方案** — 您考虑过的其他方案

### 提交代码

#### 开发环境设置

需要安装 [Rust 工具链](https://rustup.rs)：

```bash
# 克隆仓库
git clone https://github.com/shenjingnan/zapmyco.git
cd zapmyco

# 验证
cargo build
```

#### 分支策略

- `main` — 主分支，保持稳定
- `feature/*` — 新功能分支
- `fix/*` — Bug 修复分支
- `docs/*` — 文档更新分支

#### 提交规范

遵循 [Conventional Commits](https://www.conventionalcommits.org/)：

```
<type>(<scope>): <description>
```

**类型**：

- `feat` — 新功能
- `fix` — Bug 修复
- `docs` — 文档
- `style` — 代码格式
- `refactor` — 重构
- `perf` — 性能优化
- `test` — 测试
- `chore` — 构建/工具

**示例**：

```
feat: add new CLI command
fix(agent): handle empty input
docs: update API reference
```

#### Pull Request 流程

1. Fork 仓库
2. 创建功能分支（`git checkout -b feature/my-feature`）
3. 进行更改
4. 确保检查通过：`cargo fmt --check && cargo clippy -- -D warnings && cargo test -- --test-threads=1`
5. 提交更改
6. 推送分支（`git push origin feature/my-feature`）
7. 创建 Pull Request

#### PR 检查清单

- [ ] 代码通过所有测试
- [ ] 代码通过 clippy 检查
- [ ] 代码通过格式化检查
- [ ] 新功能有对应测试
- [ ] 文档已更新（如需要）
- [ ] Commit 消息遵循规范

## 开发指南

### 代码风格

由 `cargo fmt` 强制执行（Rust Edition 2024）：

- 2 空格缩进
- 单引号
- 必须有分号
- 行宽 100 字符

### 质量检查

```bash
# 运行所有检查
cargo fmt --check && cargo clippy -- -D warnings && cargo test -- --test-threads=1

# 或逐步执行
cargo fmt --check             # 格式检查
cargo clippy -- -D warnings   # Lint 检查
cargo test -- --test-threads=1 # 测试
```

### 测试规范

- 单元测试：`src/*.rs` 中的 `#[cfg(test)] mod tests`
- 集成测试：`tests/*.rs`
- 运行测试：`cargo test`
- 运行测试（单线程避免环境变量竞争）：`cargo test -- --test-threads=1`

### 技术栈

| 技术 | 用途 |
|------|------|
| Rust 1.95+ | 编程语言 |
| clap 4.x | CLI 参数解析 |
| anthropic-ai-sdk | Anthropic Messages API 客户端 |
| inquire | 交互式终端提示 |
| tokio | 异步运行时 |
| serde / serde_json | JSON 序列化 |

## 获取帮助

如果您有任何问题，可以：

- 查看[文档站点](https://zapmyco-docs.vercel.app)
- 在 [Discussions](https://github.com/shenjingnan/zapmyco/discussions) 提问
- 创建 [Issue](https://github.com/shenjingnan/zapmyco/issues)

## 许可证

通过贡献代码，您同意您的代码将在 MIT 许可证下发布。
