Skip to content

Commit 02ef7c0

Browse files
committed
Move agent-definition and examples to .agents. Have client bundle them and write them directly. Make agent-builder pure llm.
1 parent ab4819b commit 02ef7c0

File tree

22 files changed

+169
-1391
lines changed

22 files changed

+169
-1391
lines changed

.agents/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Codebuff Agents
2+
3+
This directory contains your custom Codebuff agents. Each agent is a TypeScript file that defines an AI agent with specific capabilities and behavior.
4+
5+
## Getting Started
6+
7+
1. **Edit an existing agent**: Start with `my-custom-agent.ts` and modify it for your needs
8+
2. **Check out the examples and types**: See the examples and types directories to draw inspiration and learn what's possible.
9+
3. **Test your agent**: Run `codebuff --agent your-agent-name`
10+
4. **Publish your agent**: Run `codebuff publish your-agent-name`
11+
12+
## File Structure
13+
14+
- `types/` - TypeScript type definitions
15+
- `examples/` - Example agents for reference
16+
- `my-custom-agent.ts` - Your first custom agent (edit this!)
17+
- Add any new agents you wish to the .agents directory
18+
19+
## Agent Basics
20+
21+
Each agent file exports an `AgentDefinition` object with:
22+
23+
- `id`: Unique identifier (lowercase, hyphens only)
24+
- `displayName`: Human-readable name
25+
- `model`: AI model to use (see OpenRouter for options)
26+
- `toolNames`: Tools the agent can use
27+
- `instructionsPrompt`: Instructions for the agent's behavior
28+
- `spawnPurposePrompt`: When other agents should spawn this one
29+
- `spawnableAgents`: Which agents *this* agent can spawn
30+
31+
## Common Tools
32+
33+
- `read_files` - Read file contents
34+
- `write_file` - Create or modify files
35+
- `str_replace` - Make targeted edits
36+
- `run_terminal_command` - Execute shell commands
37+
- `code_search` - Search for code patterns
38+
- `spawn_agents` - Delegate to other agents
39+
- `end_turn` - Finish the response
40+
41+
See `types/tools.ts` for more information on each tool!
42+
43+
## Need Help?
44+
45+
- Check the type definitions in `types/agent-definition.ts`
46+
- Look at examples in the `examples/` directory
47+
- Join the Codebuff Discord community (https://discord.com/invite/mcWTGjgTj3)
48+
49+
Happy agent building! 🤖

.agents/examples/diff-reviewer-1.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import type { AgentDefinition } from '../types/agent-definition'
22

33
const definition: AgentDefinition = {
44
id: 'diff-reviewer-1',
5-
65
displayName: 'Diff Reviewer (Level 1)',
7-
model: 'openai/gpt-5',
6+
model: 'anthropic/claude-4-sonnet-20250522',
87
toolNames: ['read_files', 'run_terminal_command'],
98

109
spawnPurposePrompt:

.agents/examples/diff-reviewer-2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
const definition: AgentDefinition = {
77
id: 'diff-reviewer-2',
88
displayName: 'Diff Reviewer (Level 2)',
9-
model: 'openai/gpt-5',
9+
model: 'anthropic/claude-4-sonnet-20250522',
1010

1111
inputSchema: {
1212
prompt: {

.agents/examples/diff-reviewer-3.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import type {
55

66
const definition: AgentDefinition = {
77
id: 'diff-reviewer-3',
8-
98
displayName: 'Diff Reviewer (Level 3)',
10-
model: 'openai/gpt-5',
9+
model: 'anthropic/claude-4-sonnet-20250522',
1110
inputSchema: {
1211
prompt: {
1312
type: 'string',
@@ -18,7 +17,7 @@ const definition: AgentDefinition = {
1817
outputMode: 'last_message',
1918

2019
toolNames: ['read_files', 'run_terminal_command', 'spawn_agents'],
21-
spawnableAgents: ['james/file-explorer@0.1.3'],
20+
spawnableAgents: ['codebuff/file-explorer@0.0.1'],
2221

2322
spawnPurposePrompt:
2423
'Spawn when you need to review code changes in the git diff',
@@ -77,23 +76,11 @@ Use the following guidelines while reviewing the changes:
7776
args: {
7877
role: 'assistant',
7978
content:
80-
'Now I will spawn a file explorer to find any missing codebase context.',
81-
},
82-
}
83-
84-
yield 'STEP'
85-
86-
// Step 5: Put words in the AI's mouth to review the changes.
87-
yield {
88-
toolName: 'add_message',
89-
args: {
90-
role: 'assistant',
91-
content: 'Here is my comprehensive review of the changes.',
79+
'Now I will spawn a file explorer to find any missing codebase context, and then review the changes.',
9280
},
9381
}
9482

95-
// Step 6: Let AI review the changes in a final step. (The last message is also the agent's output.)
96-
yield 'STEP'
83+
yield 'STEP_ALL'
9784
},
9885
}
9986

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@
77
* > codebuff --agent git-committer
88
*
99
* Or, run codebuff normally, and use the '@' menu to mention your agent, and codebuff will spawn it for you.
10-
*
11-
* Finally, you can publish your agent with 'codebuff publish your-custom-agent'.
10+
*
11+
* Finally, you can publish your agent with 'codebuff publish your-custom-agent' so users from around the world can run it.
1212
*/
1313

1414
import type { AgentDefinition } from './types/agent-definition'
1515

1616
const definition: AgentDefinition = {
17-
id: 'git-committer',
17+
id: 'my-custom-agent',
1818
displayName: 'Git Committer',
1919

2020
model: 'anthropic/claude-4-sonnet-20250522',
21-
toolNames: ['read_files', 'run_terminal_command', 'spawn_agents'],
2221
spawnableAgents: ['codebuff/file-explorer@0.0.1'],
2322

23+
// Check out .agents/types/tools.ts for more information on the tools you can include.
24+
toolNames: ['read_files', 'run_terminal_command', 'spawn_agents'],
25+
2426
spawnPurposePrompt:
2527
'Spawn when you need to commit changes to the git repository',
2628

.agents/types/tools.d.ts

Lines changed: 0 additions & 194 deletions
This file was deleted.

0 commit comments

Comments
 (0)