Skip to content

Commit 37d0892

Browse files
authored
docs: add Simplified Chinese README (#677)
1 parent 97ec216 commit 37d0892

2 files changed

Lines changed: 253 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Codebuff & Freebuff
22

3+
English | [简体中文](./README.zh-CN.md)
4+
35
**[Codebuff](https://codebuff.com)** is an open-source AI coding assistant that edits your codebase through natural language instructions. **[Freebuff](https://www.npmjs.com/package/freebuff)** is the free, ad-supported version — no subscription, no credits, no configuration.
46

57
Instead of using one model for everything, Codebuff coordinates specialized agents that work together to understand your project and make precise changes.

README.zh-CN.md

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
# Codebuff & Freebuff
2+
3+
[English](./README.md) | 简体中文
4+
5+
**[Codebuff](https://codebuff.com)** 是一款开源的 AI 编程助手,能根据自然语言指令直接修改你的代码库。**[Freebuff](https://www.npmjs.com/package/freebuff)** 是它的免费、广告支持版本——无需订阅、无需积分、零配置。
6+
7+
与那种"一个模型干所有事"的工具不同,Codebuff 会协调多个专业化的智能体(agent)协同工作,理解你的项目并做出精准的改动。
8+
9+
<div align="center">
10+
<img src="./assets/codebuff-vs-claude-code.png" alt="Codebuff vs Claude Code" width="400">
11+
</div>
12+
13+
在我们的[评测](evals/README.md)中,Codebuff 在 175+ 个真实开源仓库的编码任务上以 61% 对 53% 的成绩领先 Claude Code。
14+
15+
16+
## 工作原理
17+
18+
当你让 Codebuff "给我的 API 加上身份验证"时,它可能会调用:
19+
20+
1. **File Picker Agent** —— 扫描代码库、理解架构、找出相关文件
21+
2. **Planner Agent** —— 规划哪些文件需要改、按什么顺序改
22+
3. **Editor Agent** —— 执行精确的修改
23+
4. **Reviewer Agent** —— 校验改动是否正确
24+
25+
<div align="center">
26+
<img src="./assets/multi-agents.png" alt="Codebuff Multi-Agents" width="250">
27+
</div>
28+
29+
相比单模型工具,这种多智能体方案能带来更准的上下文理解、更精确的修改,以及更少的错误。
30+
31+
## CLI:装好就能写代码
32+
33+
安装:
34+
35+
```bash
36+
npm install -g codebuff
37+
```
38+
39+
运行:
40+
41+
```bash
42+
cd your-project
43+
codebuff
44+
```
45+
46+
然后直接告诉 Codebuff 你想做什么,剩下的它自己搞定:
47+
48+
- "修掉用户注册里的 SQL 注入漏洞"
49+
- "给所有 API 端点加上限流"
50+
- "重构数据库连接代码,提升性能"
51+
52+
Codebuff 会找到对应的文件,跨多个文件做改动,并跑测试确认没有破坏现有功能。
53+
54+
## 创建自定义智能体
55+
56+
要开始构建自己的智能体,先启动 Codebuff 然后执行 `/init`
57+
58+
```bash
59+
codebuff
60+
```
61+
62+
进入 CLI 后:
63+
64+
```
65+
/init
66+
```
67+
68+
这会生成:
69+
```
70+
knowledge.md # Codebuff 用的项目上下文
71+
.agents/
72+
└── types/ # TypeScript 类型定义
73+
├── agent-definition.ts
74+
├── tools.ts
75+
└── util-types.ts
76+
```
77+
78+
通过编写智能体定义文件,你可以最大程度地控制智能体的行为。
79+
80+
通过指定工具、可派生的子智能体和提示词来实现自己的工作流。我们还提供了 TypeScript 生成器,方便你以更程序化的方式控制流程。
81+
82+
下面是一个 `git-committer` 智能体的例子,它会基于当前的 git 状态生成提交。注意它先跑 `git diff``git log` 分析改动,然后再把决策权交给 LLM,让它撰写有意义的 commit message 并完成实际提交。
83+
84+
```typescript
85+
export default {
86+
id: 'git-committer',
87+
displayName: 'Git Committer',
88+
model: 'openai/gpt-5-nano',
89+
toolNames: ['read_files', 'run_terminal_command', 'end_turn'],
90+
91+
instructionsPrompt:
92+
'You create meaningful git commits by analyzing changes, reading relevant files for context, and crafting clear commit messages that explain the "why" behind changes.',
93+
94+
async *handleSteps() {
95+
// 分析改动
96+
yield { tool: 'run_terminal_command', command: 'git diff' }
97+
yield { tool: 'run_terminal_command', command: 'git log --oneline -5' }
98+
99+
// 暂存文件,并用合适的 message 生成提交
100+
yield 'STEP_ALL'
101+
},
102+
}
103+
```
104+
105+
## SDK:在生产环境里跑智能体
106+
107+
安装 [SDK 包](https://www.npmjs.com/package/@codebuff/sdk)——注意这跟 CLI 用的 codebuff 包是两个不同的包。
108+
109+
```bash
110+
npm install @codebuff/sdk
111+
```
112+
113+
引入 client,开始跑智能体:
114+
115+
```typescript
116+
import { CodebuffClient } from '@codebuff/sdk'
117+
118+
// 1. 初始化 client
119+
const client = new CodebuffClient({
120+
apiKey: 'your-api-key',
121+
cwd: '/path/to/your/project',
122+
onError: (error) => console.error('Codebuff error:', error.message),
123+
})
124+
125+
// 2. 跑一个编码任务……
126+
const result = await client.run({
127+
agent: 'base', // Codebuff 默认的基础编码智能体
128+
prompt: 'Add error handling to all API endpoints',
129+
handleEvent: (event) => {
130+
console.log('Progress', event)
131+
},
132+
})
133+
134+
// 3. 也可以跑自定义智能体!
135+
const myCustomAgent: AgentDefinition = {
136+
id: 'greeter',
137+
displayName: 'Greeter',
138+
model: 'openai/gpt-5.1',
139+
instructionsPrompt: 'Say hello!',
140+
}
141+
await client.run({
142+
agent: 'greeter',
143+
agentDefinitions: [myCustomAgent],
144+
prompt: 'My name is Bob.',
145+
customToolDefinitions: [], // 也可以加自定义工具!
146+
handleEvent: (event) => {
147+
console.log('Progress', event)
148+
},
149+
})
150+
```
151+
152+
更多 SDK 用法请看[这里](https://www.npmjs.com/package/@codebuff/sdk)
153+
154+
## Freebuff:免费的编程智能体
155+
156+
不想订阅?**[Freebuff](https://www.npmjs.com/package/freebuff)** 是 Codebuff 的免费版本——无需订阅、无需积分、零配置,装上就能用。
157+
158+
```bash
159+
npm install -g freebuff
160+
cd your-project
161+
freebuff
162+
```
163+
164+
Freebuff 由广告支持,使用经过优化、兼顾速度与质量的模型。内置网页检索、浏览器使用等能力。详情见 [Freebuff README](./freebuff/README.md)
165+
166+
## 为什么选 Codebuff
167+
168+
**自定义工作流**:用 TypeScript 生成器把 AI 生成和程序化控制混着用。智能体可以派生子智能体、按条件分支、跑多步流程。
169+
170+
**OpenRouter 上的任何模型**:Claude Code 把你锁死在 Anthropic 的模型上,Codebuff 不一样——它支持 [OpenRouter](https://openrouter.ai/models) 上的所有模型,从 Claude、GPT 到 Qwen、DeepSeek 这类专用模型都行。可以按任务切换模型,也能随时用上最新发布的模型,不必等平台跟进。
171+
172+
**复用已发布的智能体**:把社区[已发布的智能体](https://www.codebuff.com/store)拼起来用,少走弯路。Codebuff 智能体就是新一代的 MCP!
173+
174+
**SDK**:把 Codebuff 嵌进你自己的应用里。可以创建自定义工具、对接 CI/CD,或把编码能力内嵌进你的产品。
175+
176+
## 进阶用法
177+
178+
### 自定义智能体工作流
179+
180+
`/init` 命令创建带专门工作流的智能体:
181+
182+
```bash
183+
codebuff
184+
/init
185+
```
186+
187+
这会在 `.agents/` 下生成一套可自定义的智能体结构。
188+
189+
## 参与贡献
190+
191+
我们 ❤️ 来自社区的贡献——无论是修 bug、调整智能体、还是改进文档。
192+
193+
**想参与?** 看一眼[贡献指南](./CONTRIBUTING.md) 就能上手。
194+
195+
### 运行测试
196+
197+
跑测试套件:
198+
199+
```bash
200+
cd cli
201+
bun test
202+
```
203+
204+
**交互式端到端测试**需要 tmux:
205+
206+
```bash
207+
# macOS
208+
brew install tmux
209+
210+
# Ubuntu/Debian
211+
sudo apt-get install tmux
212+
213+
# Windows(通过 WSL)
214+
wsl --install
215+
sudo apt-get install tmux
216+
```
217+
218+
更完整的测试文档见 [cli/src/__tests__/README.md](cli/src/__tests__/README.md)
219+
220+
可以帮忙的方向:
221+
222+
- 🐛 **修 bug** 或新增功能
223+
- 🤖 **打造专用智能体**并发布到 Agent Store
224+
- 📚 **完善文档**或撰写教程
225+
- 💡 **分享想法**:在 [GitHub Issues](https://github.com/CodebuffAI/codebuff/issues) 留言
226+
227+
## 开始使用
228+
229+
### 安装
230+
231+
**CLI**`npm install -g codebuff`
232+
233+
**SDK**`npm install @codebuff/sdk`
234+
235+
**Freebuff(免费版)**`npm install -g freebuff`
236+
237+
### 资源
238+
239+
**文档**[codebuff.com/docs](https://codebuff.com/docs)
240+
241+
**社区**[Discord](https://codebuff.com/discord)
242+
243+
**Issue 与想法**[GitHub Issues](https://github.com/CodebuffAI/codebuff/issues)
244+
245+
**贡献指南**[CONTRIBUTING.md](./CONTRIBUTING.md) ——想贡献从这里开始!
246+
247+
**支持**[support@codebuff.com](mailto:support@codebuff.com)
248+
249+
## Star 历史
250+
251+
[![Star History Chart](https://api.star-history.com/svg?repos=CodebuffAI/codebuff&type=Date)](https://www.star-history.com/#CodebuffAI/codebuff&Date)

0 commit comments

Comments
 (0)