codebuff-cli 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -202
- package/http.js +176 -0
- package/index.js +592 -0
- package/package.json +31 -78
- package/postinstall.js +34 -0
- package/LICENSE +0 -202
- package/README.zh-CN.md +0 -251
- package/cli/README.md +0 -84
- package/cli/bin/codebuff.cjs +0 -165
- package/cli/scripts/download-binary.cjs +0 -164
package/README.md
CHANGED
|
@@ -1,251 +1,107 @@
|
|
|
1
|
-
#
|
|
1
|
+
# The most powerful coding agent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Codebuff is a CLI tool that writes code for you.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
1. Run `codebuff` from your project directory
|
|
6
|
+
2. Tell it what to do
|
|
7
|
+
3. It will read and write to files and run commands to produce the code you want
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
Note: Codebuff will run commands in your terminal as it deems necessary to fulfill your request.
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
<img src="./assets/codebuff-vs-claude-code.png" alt="Codebuff vs Claude Code" width="400">
|
|
11
|
-
</div>
|
|
11
|
+
## Installation
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## How it works
|
|
17
|
-
|
|
18
|
-
When you ask Codebuff to "add authentication to my API," it might invoke:
|
|
19
|
-
|
|
20
|
-
1. A **File Picker Agent** to scan your codebase to understand the architecture and find relevant files
|
|
21
|
-
2. A **Planner Agent** to plan which files need changes and in what order
|
|
22
|
-
3. An **Editor Agent** to make precise edits
|
|
23
|
-
4. A **Reviewer Agent** to validate changes
|
|
24
|
-
|
|
25
|
-
<div align="center">
|
|
26
|
-
<img src="./assets/multi-agents.png" alt="Codebuff Multi-Agents" width="250">
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
This multi-agent approach gives you better context understanding, more accurate edits, and fewer errors compared to single-model tools.
|
|
30
|
-
|
|
31
|
-
## CLI: Install and start coding
|
|
32
|
-
|
|
33
|
-
Install:
|
|
13
|
+
To install Codebuff, run:
|
|
34
14
|
|
|
35
15
|
```bash
|
|
36
16
|
npm install -g codebuff
|
|
37
17
|
```
|
|
38
18
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
cd your-project
|
|
43
|
-
codebuff
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Then just tell Codebuff what you want and it handles the rest:
|
|
47
|
-
|
|
48
|
-
- "Fix the SQL injection vulnerability in user registration"
|
|
49
|
-
- "Add rate limiting to all API endpoints"
|
|
50
|
-
- "Refactor the database connection code for better performance"
|
|
51
|
-
|
|
52
|
-
Codebuff will find the right files, makes changes across your codebase, and runs tests to make sure nothing breaks.
|
|
19
|
+
(Use `sudo` if you get a permission error.)
|
|
53
20
|
|
|
54
|
-
##
|
|
21
|
+
## Usage
|
|
55
22
|
|
|
56
|
-
|
|
23
|
+
After installation, you can start Codebuff by running:
|
|
57
24
|
|
|
58
25
|
```bash
|
|
59
|
-
codebuff
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Then inside the CLI:
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
/init
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
This creates:
|
|
69
|
-
```
|
|
70
|
-
knowledge.md # Project context for Codebuff
|
|
71
|
-
.agents/
|
|
72
|
-
└── types/ # TypeScript type definitions
|
|
73
|
-
├── agent-definition.ts
|
|
74
|
-
├── tools.ts
|
|
75
|
-
└── util-types.ts
|
|
26
|
+
codebuff [project-directory]
|
|
76
27
|
```
|
|
77
28
|
|
|
78
|
-
|
|
29
|
+
If no project directory is specified, Codebuff will use the current directory.
|
|
79
30
|
|
|
80
|
-
|
|
31
|
+
Once running, simply chat with Codebuff to say what coding task you want done.
|
|
81
32
|
|
|
82
|
-
|
|
33
|
+
## Features
|
|
83
34
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
model: 'openai/gpt-5-nano',
|
|
89
|
-
toolNames: ['read_files', 'run_terminal_command', 'end_turn'],
|
|
35
|
+
- Understands your whole codebase
|
|
36
|
+
- Creates and edits multiple files based on your request
|
|
37
|
+
- Can run your tests or type checker or linter; can install packages
|
|
38
|
+
- It's powerful: ask Codebuff to keep working until it reaches a condition and it will.
|
|
90
39
|
|
|
91
|
-
|
|
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.',
|
|
40
|
+
Our users regularly use Codebuff to implement new features, write unit tests, refactor code,write scripts, or give advice.
|
|
93
41
|
|
|
94
|
-
|
|
95
|
-
// Analyze what changed
|
|
96
|
-
yield { tool: 'run_terminal_command', command: 'git diff' }
|
|
97
|
-
yield { tool: 'run_terminal_command', command: 'git log --oneline -5' }
|
|
42
|
+
## Knowledge Files
|
|
98
43
|
|
|
99
|
-
|
|
100
|
-
yield 'STEP_ALL'
|
|
101
|
-
},
|
|
102
|
-
}
|
|
103
|
-
```
|
|
44
|
+
To unlock the full benefits of modern LLMs, we recommend storing knowledge alongside your code. Add a `knowledge.md` file anywhere in your project to provide helpful context, guidance, and tips for the LLM as it performs tasks for you.
|
|
104
45
|
|
|
105
|
-
|
|
46
|
+
Codebuff can fluently read and write files, so it will add knowledge as it goes. You don't need to write knowledge manually!
|
|
106
47
|
|
|
107
|
-
|
|
48
|
+
Some have said every change should be paired with a unit test. In 2024, every change should come with a knowledge update!
|
|
108
49
|
|
|
109
|
-
|
|
110
|
-
npm install @codebuff/sdk
|
|
111
|
-
```
|
|
50
|
+
## Tips
|
|
112
51
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// 1. Initialize the 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. Do a coding task...
|
|
126
|
-
const result = await client.run({
|
|
127
|
-
agent: 'base', // Codebuff's base coding agent
|
|
128
|
-
prompt: 'Add error handling to all API endpoints',
|
|
129
|
-
handleEvent: (event) => {
|
|
130
|
-
console.log('Progress', event)
|
|
131
|
-
},
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
// 3. Or, run a custom agent!
|
|
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: [], // Add custom tools too!
|
|
146
|
-
handleEvent: (event) => {
|
|
147
|
-
console.log('Progress', event)
|
|
148
|
-
},
|
|
149
|
-
})
|
|
150
|
-
```
|
|
52
|
+
1. Type '/help' or just '/' to see available commands.
|
|
53
|
+
2. Create a `knowledge.md` file and collect specific points of advice. The assistant will use this knowledge to improve its responses.
|
|
54
|
+
3. Type `undo` or `redo` to revert or reapply file changes from the conversation.
|
|
55
|
+
4. Press `Esc` or `Ctrl+C` while Codebuff is generating a response to stop it.
|
|
151
56
|
|
|
152
|
-
|
|
57
|
+
## Troubleshooting
|
|
153
58
|
|
|
154
|
-
|
|
59
|
+
### Permission Errors
|
|
155
60
|
|
|
156
|
-
|
|
61
|
+
If you are getting permission errors during installation, try using sudo:
|
|
157
62
|
|
|
158
|
-
```
|
|
159
|
-
npm install -g
|
|
160
|
-
cd your-project
|
|
161
|
-
freebuff
|
|
63
|
+
```
|
|
64
|
+
sudo npm install -g codebuff
|
|
162
65
|
```
|
|
163
66
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
## Why choose Codebuff
|
|
167
|
-
|
|
168
|
-
**Custom workflows**: TypeScript generators let you mix AI generation with programmatic control. Agents can spawn subagents, branch on conditions, and run multi-step processes.
|
|
169
|
-
|
|
170
|
-
**Any model on OpenRouter**: Unlike Claude Code which locks you into Anthropic's models, Codebuff supports any model available on [OpenRouter](https://openrouter.ai/models) - from Claude and GPT to specialized models like Qwen, DeepSeek, and others. Switch models for different tasks or use the latest releases without waiting for platform updates.
|
|
171
|
-
|
|
172
|
-
**Reuse any published agent**: Compose existing [published agents](https://www.codebuff.com/store) to get a leg up. Codebuff agents are the new MCP!
|
|
173
|
-
|
|
174
|
-
**SDK**: Build Codebuff into your applications. Create custom tools, integrate with CI/CD, or embed coding assistance into your products.
|
|
67
|
+
If you still have errors, it's a good idea to [reinstall Node](https://nodejs.org/en/download).
|
|
175
68
|
|
|
176
|
-
|
|
69
|
+
### Corporate Proxy / Firewall
|
|
177
70
|
|
|
178
|
-
|
|
71
|
+
If you see `Failed to download codebuff: Request timeout` or `Failed to determine latest version`, you may be behind a corporate proxy or firewall.
|
|
179
72
|
|
|
180
|
-
|
|
73
|
+
Codebuff respects standard proxy environment variables. Set `HTTPS_PROXY` to route traffic through your proxy:
|
|
181
74
|
|
|
75
|
+
**Linux / macOS (bash/zsh):**
|
|
182
76
|
```bash
|
|
77
|
+
export HTTPS_PROXY=http://your-proxy-server:port
|
|
183
78
|
codebuff
|
|
184
|
-
/init
|
|
185
79
|
```
|
|
186
80
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
We ❤️ contributions from the community - whether you're fixing bugs, tweaking our agents, or improving documentation.
|
|
192
|
-
|
|
193
|
-
**Want to contribute?** Check out our [Contributing Guide](./CONTRIBUTING.md) to get started.
|
|
194
|
-
|
|
195
|
-
### Running Tests
|
|
196
|
-
|
|
197
|
-
To run the test suite:
|
|
198
|
-
|
|
199
|
-
```bash
|
|
200
|
-
cd cli
|
|
201
|
-
bun test
|
|
81
|
+
**Windows (PowerShell):**
|
|
82
|
+
```powershell
|
|
83
|
+
$env:HTTPS_PROXY = "http://your-proxy-server:port"
|
|
84
|
+
codebuff
|
|
202
85
|
```
|
|
203
86
|
|
|
204
|
-
**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
brew install tmux
|
|
209
|
-
|
|
210
|
-
# Ubuntu/Debian
|
|
211
|
-
sudo apt-get install tmux
|
|
212
|
-
|
|
213
|
-
# Windows (via WSL)
|
|
214
|
-
wsl --install
|
|
215
|
-
sudo apt-get install tmux
|
|
87
|
+
**Windows (CMD):**
|
|
88
|
+
```cmd
|
|
89
|
+
set HTTPS_PROXY=http://your-proxy-server:port
|
|
90
|
+
codebuff
|
|
216
91
|
```
|
|
217
92
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
Some ways you can help:
|
|
221
|
-
|
|
222
|
-
- 🐛 **Fix bugs** or add features
|
|
223
|
-
- 🤖 **Create specialized agents** and publish them to the Agent Store
|
|
224
|
-
- 📚 **Improve documentation** or write tutorials
|
|
225
|
-
- 💡 **Share ideas** in our [GitHub Issues](https://github.com/CodebuffAI/codebuff/issues)
|
|
226
|
-
|
|
227
|
-
## Get started
|
|
228
|
-
|
|
229
|
-
### Install
|
|
230
|
-
|
|
231
|
-
**CLI**: `npm install -g codebuff`
|
|
232
|
-
|
|
233
|
-
**SDK**: `npm install @codebuff/sdk`
|
|
234
|
-
|
|
235
|
-
**Freebuff (free)**: `npm install -g freebuff`
|
|
236
|
-
|
|
237
|
-
### Resources
|
|
238
|
-
|
|
239
|
-
**Documentation**: [codebuff.com/docs](https://codebuff.com/docs)
|
|
240
|
-
|
|
241
|
-
**Community**: [Discord](https://codebuff.com/discord)
|
|
93
|
+
To make it permanent, add the `export` or `set` line to your shell profile (e.g. `~/.bashrc`, `~/.zshrc`, or Windows System Environment Variables).
|
|
242
94
|
|
|
243
|
-
**
|
|
95
|
+
**Supported environment variables:**
|
|
244
96
|
|
|
245
|
-
|
|
97
|
+
| Variable | Purpose |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `HTTPS_PROXY` / `https_proxy` | Proxy for HTTPS requests (recommended) |
|
|
100
|
+
| `HTTP_PROXY` / `http_proxy` | Fallback proxy for HTTP requests |
|
|
101
|
+
| `NO_PROXY` / `no_proxy` | Comma-separated list of hostnames to bypass the proxy (port suffixes are ignored) |
|
|
246
102
|
|
|
247
|
-
|
|
103
|
+
Both `http://` and `https://` proxy URLs are supported. Proxy authentication is supported via URL credentials (e.g. `http://user:password@proxy:port`).
|
|
248
104
|
|
|
249
|
-
##
|
|
105
|
+
## Feedback
|
|
250
106
|
|
|
251
|
-
|
|
107
|
+
We value your input! Please email your feedback to `founders@codebuff.com`. Thank you for using Codebuff!
|
package/http.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const http = require('http')
|
|
2
|
+
const https = require('https')
|
|
3
|
+
const tls = require('tls')
|
|
4
|
+
|
|
5
|
+
function createReleaseHttpClient({
|
|
6
|
+
env = process.env,
|
|
7
|
+
userAgent,
|
|
8
|
+
requestTimeout,
|
|
9
|
+
httpModule = http,
|
|
10
|
+
httpsModule = https,
|
|
11
|
+
tlsModule = tls,
|
|
12
|
+
}) {
|
|
13
|
+
function getProxyUrl() {
|
|
14
|
+
return (
|
|
15
|
+
env.HTTPS_PROXY ||
|
|
16
|
+
env.https_proxy ||
|
|
17
|
+
env.HTTP_PROXY ||
|
|
18
|
+
env.http_proxy ||
|
|
19
|
+
null
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function shouldBypassProxy(hostname) {
|
|
24
|
+
const noProxy = env.NO_PROXY || env.no_proxy || ''
|
|
25
|
+
if (!noProxy) return false
|
|
26
|
+
|
|
27
|
+
const domains = noProxy
|
|
28
|
+
.split(',')
|
|
29
|
+
.map((domain) => domain.trim().toLowerCase().replace(/:\d+$/, ''))
|
|
30
|
+
const host = hostname.toLowerCase()
|
|
31
|
+
|
|
32
|
+
return domains.some((domain) => {
|
|
33
|
+
if (domain === '*') return true
|
|
34
|
+
if (domain.startsWith('.')) {
|
|
35
|
+
return host.endsWith(domain) || host === domain.slice(1)
|
|
36
|
+
}
|
|
37
|
+
return host === domain || host.endsWith(`.${domain}`)
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function connectThroughProxy(proxyUrl, targetHost, targetPort) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const proxy = new URL(proxyUrl)
|
|
44
|
+
const isHttpsProxy = proxy.protocol === 'https:'
|
|
45
|
+
const connectOptions = {
|
|
46
|
+
hostname: proxy.hostname,
|
|
47
|
+
port: proxy.port || (isHttpsProxy ? 443 : 80),
|
|
48
|
+
method: 'CONNECT',
|
|
49
|
+
path: `${targetHost}:${targetPort}`,
|
|
50
|
+
headers: {
|
|
51
|
+
Host: `${targetHost}:${targetPort}`,
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (proxy.username || proxy.password) {
|
|
56
|
+
const auth = Buffer.from(
|
|
57
|
+
`${decodeURIComponent(proxy.username || '')}:${decodeURIComponent(
|
|
58
|
+
proxy.password || '',
|
|
59
|
+
)}`,
|
|
60
|
+
).toString('base64')
|
|
61
|
+
connectOptions.headers['Proxy-Authorization'] = `Basic ${auth}`
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const transport = isHttpsProxy ? httpsModule : httpModule
|
|
65
|
+
const req = transport.request(connectOptions)
|
|
66
|
+
|
|
67
|
+
req.on('connect', (res, socket) => {
|
|
68
|
+
if (res.statusCode === 200) {
|
|
69
|
+
resolve(socket)
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
socket.destroy()
|
|
74
|
+
reject(new Error(`Proxy CONNECT failed with status ${res.statusCode}`))
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
req.on('error', (error) => {
|
|
78
|
+
reject(new Error(`Proxy connection failed: ${error.message}`))
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
req.setTimeout(requestTimeout, () => {
|
|
82
|
+
req.destroy()
|
|
83
|
+
reject(new Error('Proxy connection timeout.'))
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
req.end()
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function buildRequestOptions(url, options = {}) {
|
|
91
|
+
const parsedUrl = new URL(url)
|
|
92
|
+
const reqOptions = {
|
|
93
|
+
hostname: parsedUrl.hostname,
|
|
94
|
+
port: parsedUrl.port || 443,
|
|
95
|
+
path: parsedUrl.pathname + parsedUrl.search,
|
|
96
|
+
headers: {
|
|
97
|
+
'User-Agent': userAgent,
|
|
98
|
+
...options.headers,
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const proxyUrl = getProxyUrl()
|
|
103
|
+
if (!proxyUrl || shouldBypassProxy(parsedUrl.hostname)) {
|
|
104
|
+
return reqOptions
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const tunnelSocket = await connectThroughProxy(
|
|
108
|
+
proxyUrl,
|
|
109
|
+
parsedUrl.hostname,
|
|
110
|
+
parsedUrl.port || 443,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
class TunnelAgent extends httpsModule.Agent {
|
|
114
|
+
createConnection(_options, callback) {
|
|
115
|
+
const secureSocket = tlsModule.connect({
|
|
116
|
+
socket: tunnelSocket,
|
|
117
|
+
servername: parsedUrl.hostname,
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
if (typeof callback === 'function') {
|
|
121
|
+
if (typeof secureSocket.once === 'function') {
|
|
122
|
+
let settled = false
|
|
123
|
+
const finish = (error) => {
|
|
124
|
+
if (settled) return
|
|
125
|
+
settled = true
|
|
126
|
+
callback(error || null, error ? undefined : secureSocket)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
secureSocket.once('secureConnect', () => finish(null))
|
|
130
|
+
secureSocket.once('error', (error) => finish(error))
|
|
131
|
+
} else {
|
|
132
|
+
callback(null, secureSocket)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return secureSocket
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
reqOptions.agent = new TunnelAgent({ keepAlive: false })
|
|
141
|
+
return reqOptions
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function httpGet(url, options = {}) {
|
|
145
|
+
const reqOptions = await buildRequestOptions(url, options)
|
|
146
|
+
|
|
147
|
+
return new Promise((resolve, reject) => {
|
|
148
|
+
const req = httpsModule.get(reqOptions, (res) => {
|
|
149
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
150
|
+
res.resume()
|
|
151
|
+
httpGet(new URL(res.headers.location, url).href, options)
|
|
152
|
+
.then(resolve)
|
|
153
|
+
.catch(reject)
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
resolve(res)
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
req.on('error', reject)
|
|
161
|
+
req.setTimeout(options.timeout || requestTimeout, () => {
|
|
162
|
+
req.destroy()
|
|
163
|
+
reject(new Error('Request timeout.'))
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
getProxyUrl,
|
|
170
|
+
httpGet,
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = {
|
|
175
|
+
createReleaseHttpClient,
|
|
176
|
+
}
|