Skip to content

Commit eedf761

Browse files
committed
Merge branch 'main' of github.com:CodebuffAI/codebuff into billing-di-refactor
# Conflicts: # bun.lock # packages/internal/package.json
2 parents a21bb3d + 20b9080 commit eedf761

File tree

149 files changed

+2312
-3878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+2312
-3878
lines changed

.agents/base/ask.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,7 @@ Messages from the system are surrounded by <system>${closeXml('system')} or <sys
9999
100100
## Verifying Your Changes at the End of Your Response
101101
102-
### User has a \`codebuff.json\`
103-
104-
If the user has a \`codebuff.json\` with the appropriate \`fileChangeHooks\`, there is no need to run any commands.
105-
106-
If the \`fileChangeHooks\` are not configured, inform the user about the \`fileChangeHooks\` parameter.
107-
108-
### User has no \`codebuff.json\`
109-
110-
If this is the case, inform the user know about the \`/init\` command (within Codebuff, not a terminal command).
111-
112-
Check the knowledge files to see if the user has specified a further protocol for what terminal commands should be run to verify edits. For example, a \`knowledge.md\` file could specify that after every change you should run the tests or linting or run the type checker. If there are multiple commands to run, you should run them all using '&&' to concatenate them into one commands, e.g. \`npm run lint && npm run test\`.
102+
Check the knowledge files to see if the user has specified a protocol for what commands should be run to verify edits. If so, follow it. Otherwise, suggest the most relevant checks for the change.
113103
114104
## Example Response (Simplified - Demonstrating Rules)
115105
@@ -152,18 +142,6 @@ What is included in knowledge files:
152142
153143
If the user sends you the url to a page that is helpful now or could be helpful in the future (e.g. documentation for a library or api), you should always save the url in a knowledge file for future reference. Any links included in knowledge files are automatically scraped and the web page content is added to the knowledge file.
154144
155-
# Codebuff Configuration (codebuff.json)
156-
157-
## Schema
158-
159-
The following describes the structure of the \`./codebuff.json\` configuration file that users might have in their project root. You can use this to understand user settings if they mention them.
160-
161-
${PLACEHOLDER.CONFIG_SCHEMA}
162-
163-
## Background Processes
164-
165-
The user does not have access to these outputs. Please display any pertinent information to the user before referring to it.
166-
167145
${PLACEHOLDER.FILE_TREE_PROMPT}
168146
169147
${PLACEHOLDER.SYSTEM_INFO_PROMPT}

.agents/base/base-prompts.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,6 @@ ${
104104
105105
## Verifying Your Changes at the End of Your Response
106106
107-
### User has a \`codebuff.json\`
108-
109-
If the user has a \`codebuff.json\` with the appropriate \`fileChangeHooks\`, there is no need to run any commands.
110-
111-
If the \`fileChangeHooks\` are not configured, inform the user about the \`fileChangeHooks\` parameter.
112-
113-
### User has no \`codebuff.json\`
114-
115-
If this is the case, inform the user know about the \`/init\` command (within Codebuff, not a terminal command).
116-
117107
Check the knowledge files to see if the user has specified a further protocol for what terminal commands should be run to verify edits. For example, a \`knowledge.md\` file could specify that after every change you should run the tests or linting or run the type checker. If there are multiple commands to run, you should run them all using '&&' to concatenate them into one commands, e.g. \`npm run lint && npm run test\`.
118108
119109
## Example Response (Simplified - Demonstrating Rules)
@@ -202,15 +192,7 @@ Once again: BE CONCISE!
202192
203193
If the user sends you the url to a page that is helpful now or could be helpful in the future (e.g. documentation for a library or api), you should always save the url in a knowledge file for future reference. Any links included in knowledge files are automatically scraped and the web page content is added to the knowledge file.
204194
205-
# Codebuff Configuration (codebuff.json)
206-
207-
## Schema
208-
209-
The following describes the structure of the \`./codebuff.json\` configuration file that users might have in their project root. You can use this to understand user settings if they mention them.
210-
211-
${PLACEHOLDER.CONFIG_SCHEMA}
212-
213-
## Background Processes
195+
# Background Processes
214196
215197
The user does not have access to these outputs. Please display any pertinent information to the user before referring to it.
216198

.agents/base2/base2-evals.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createBase2 } from './base2'
2+
3+
const definition = {
4+
...createBase2('default', { noAskUser: true }),
5+
id: 'base2-evals',
6+
displayName: 'Buffy the Evals Orchestrator',
7+
}
8+
export default definition

.agents/base2/base2.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function createBase2(
7575
isDefault && 'thinker',
7676
isLite && 'editor-gpt-5',
7777
isDefault && 'editor',
78-
isMax && 'editor-multi-prompt2',
78+
isMax && 'editor-multi-prompt',
7979
isMax && 'thinker-best-of-n-opus',
8080
!isLite && 'code-reviewer',
8181
'context-pruner',
@@ -138,7 +138,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
138138
(isDefault || isMax) &&
139139
`- Spawn the ${isDefault ? 'thinker' : 'thinker-best-of-n-opus'} after gathering context to solve complex problems or when the user asks you to think about a problem.`,
140140
isMax &&
141-
`- IMPORTANT: You must spawn the editor-multi-prompt2 agent to implement the changes after you have gathered all the context you need. You must spawn this agent for non-trivial changes, since it writes much better code than you would with the str_replace or write_file tools. Don't spawn the editor in parallel with context-gathering agents.`,
141+
`- IMPORTANT: You must spawn the editor-multi-prompt agent to implement the changes after you have gathered all the context you need. You must spawn this agent for non-trivial changes, since it writes much better code than you would with the str_replace or write_file tools. Don't spawn the editor in parallel with context-gathering agents.`,
142142
'- Spawn commanders sequentially if the second command depends on the the first.',
143143
!isFast &&
144144
!isLite &&
@@ -165,6 +165,7 @@ ${buildArray(
165165
isFast &&
166166
'- Prioritize speed: quickly getting the user request done is your first priority. Do not call any unnecessary tools. Spawn more agents in parallel to speed up the process. Be extremely concise in your responses. Use 2 words where you would have used 2 sentences.',
167167
'- If a tool fails, try again, or try a different tool or approach.',
168+
'- **Use <think></think> tags for moderate reasoning:** When you need to work through something moderately complex (e.g., understanding code flow, planning a small refactor, reasoning about edge cases, planning which agents to spawn), wrap your thinking in <think></think> tags. Spawn the thinker agent for anything more complex.',
168169
'- Context is managed for you. The context-pruner agent will automatically run as needed. Gather as much context as you need without worrying about it.',
169170
isSonnet &&
170171
`- **Don't create a summary markdown file:** The user doesn't want markdown files they didn't ask for. Don't create them.`,
@@ -192,7 +193,7 @@ ${
192193
? '[ You implement the changes using the str_replace or write_file tools ]'
193194
: isLite
194195
? '[ You implement the changes using the editor-gpt-5 agent ]'
195-
: '[ You implement the changes using the editor-multi-prompt2 agent ]'
196+
: '[ You implement the changes using the editor-multi-prompt agent ]'
196197
}
197198
198199
${
@@ -311,14 +312,16 @@ ${buildArray(
311312
'If needed, use the ask_user tool to ask the user for clarification on their request or alternate implementation strategies. It is good to get context on the codebase before asking questions so you can ask informed questions.',
312313
(isDefault || isMax) &&
313314
`- For any task requiring 3+ steps, use the write_todos tool to write out your step-by-step implementation plan. Include ALL of the applicable tasks in the list.${isFast ? '' : ' You should include a step to review the changes after you have implemented the changes.'}:${hasNoValidation ? '' : ' You should include at least one step to validate/test your changes: be specific about whether to typecheck, run tests, run lints, etc.'} You may be able to do reviewing and validation in parallel in the same step. Skip write_todos for simple tasks like quick edits or answering questions.`,
314-
isDefault &&
315-
`- For complex problems, spawn the thinker agent to help find the best solution, or when the user asks you to think about a problem.`,
315+
(isDefault || isMax) &&
316+
`- For quick problems, use <think></think> tags to think through the problem. For anything more complex, spawn the thinker agent to help find the best solution.`,
317+
isMax &&
318+
'You should use <think></think> tags all the time to help arrive at the best solution!',
316319
isLite &&
317320
'- IMPORTANT: You must spawn the editor-gpt-5 agent to implement the changes after you have gathered all the context you need. This agent will do the best job of implementing the changes so you must spawn it for all changes. Do not pass any prompt or params to the editor agent when spawning it. It will make its own best choices of what to do.',
318321
isDefault &&
319322
'- IMPORTANT: You must spawn the editor agent to implement the changes after you have gathered all the context you need. This agent will do the best job of implementing the changes so you must spawn it for all non-trivial changes. Do not pass any prompt or params to the editor agent when spawning it. It will make its own best choices of what to do.',
320323
isMax &&
321-
`- IMPORTANT: You must spawn the editor-multi-prompt2 agent to implement non-trivial code changes, since it will generate the best code changes from multiple implementation proposals. This is the best way to make high quality code changes -- strongly prefer using this agent over the str_replace or write_file tools, unless the change is very straightforward and obvious.`,
324+
`- IMPORTANT: You must spawn the editor-multi-prompt agent to implement non-trivial code changes, since it will generate the best code changes from multiple implementation proposals. This is the best way to make high quality code changes -- strongly prefer using this agent over the str_replace or write_file tools, unless the change is very straightforward and obvious.`,
322325
isFast &&
323326
'- Implement the changes using the str_replace or write_file tools. Implement all the changes in one go.',
324327
isFast &&
@@ -355,7 +358,7 @@ function buildImplementationStepPrompt({
355358
isMax &&
356359
`Keep working until the user's request is completely satisfied${!hasNoValidation ? ' and validated' : ''}, or until you require more information from the user.`,
357360
isMax &&
358-
`You must spawn the 'editor-multi-prompt2' agent to implement code changes, since it will generate the best code changes.`,
361+
`You must spawn the 'editor-multi-prompt' agent to implement code changes, since it will generate the best code changes.`,
359362
(isDefault || isMax) &&
360363
'Spawn code-reviewer to review the changes after you have implemented the changes and in parallel with typechecking or testing.',
361364
`After completing the user request, summarize your changes in a sentence${isFast ? '' : ' or a few short bullet points'}.${isSonnet ? " Don't create any summary markdown files or example documentation files, unless asked by the user." : ''} Don't repeat yourself, especially if you have already concluded and summarized the changes in a previous step -- just end your turn.`,

.agents/commander.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const commander: AgentDefinition = {
1010
model: 'anthropic/claude-haiku-4.5',
1111
displayName: 'Commander',
1212
spawnerPrompt:
13-
'Runs a single terminal command and describes its output based on what information is requested.',
13+
'Runs a single terminal command and describes its output using an LLM based on what information is requested.',
14+
1415
inputSchema: {
1516
prompt: {
1617
type: 'string',
@@ -28,6 +29,11 @@ const commander: AgentDefinition = {
2829
type: 'number',
2930
description: 'Set to -1 for no timeout. Default 30',
3031
},
32+
rawOutput: {
33+
type: 'boolean',
34+
description:
35+
'If true, returns the full command output without summarization. Defaults to false.',
36+
},
3137
},
3238
required: ['command'],
3339
},
@@ -60,16 +66,29 @@ Do not use any tools! Only analyze the output of the command.`,
6066
}
6167

6268
const timeout_seconds = params?.timeout_seconds as number | undefined
69+
const rawOutput = params?.rawOutput as boolean | undefined
6370

6471
// Run the command
65-
yield {
72+
const { toolResult } = yield {
6673
toolName: 'run_terminal_command',
6774
input: {
6875
command,
6976
...(timeout_seconds !== undefined && { timeout_seconds }),
7077
},
7178
}
7279

80+
if (rawOutput) {
81+
// Return the raw command output without summarization
82+
const result = toolResult?.[0]
83+
const output = result?.type === 'json' ? result.value : ''
84+
yield {
85+
toolName: 'set_output',
86+
input: { output },
87+
includeToolCall: false,
88+
}
89+
return
90+
}
91+
7392
// Let the model analyze and describe the output
7493
yield 'STEP'
7594
},

.agents/editor/best-of-n/editor-implementor.ts

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,27 @@ export const createBestOfNImplementor = (options: {
1919
? 'anthropic/claude-opus-4.5'
2020
: isGemini
2121
? 'google/gemini-3-pro-preview'
22-
: 'openai/gpt-5.2',
22+
: 'openai/gpt-5.1',
2323
displayName: 'Implementation Generator',
2424
spawnerPrompt:
25-
'Generates a complete implementation plan with all code changes',
25+
'Generates a complete implementation using propose_* tools that draft changes without applying them',
2626

2727
includeMessageHistory: true,
2828
inheritParentSystemPrompt: true,
2929

30-
toolNames: [],
30+
toolNames: ['propose_write_file', 'propose_str_replace'],
3131
spawnableAgents: [],
3232

3333
inputSchema: {},
34-
outputMode: 'last_message',
34+
outputMode: 'structured_output',
3535

3636
instructionsPrompt: `You are an expert code editor with deep understanding of software engineering principles. You were spawned to generate an implementation for the user's request.
3737
38-
Your task is to write out ALL the code changes needed to complete the user's request in a single comprehensive response.
38+
Your task is to write out ALL the code changes needed to complete the user's request.
3939
40-
Important: You can not make any other tool calls besides editing files. You cannot read more files, write todos, spawn agents, or set output. Do not call any of these tools!
41-
42-
Write out what changes you would make using the tool call format below. Use this exact format for each file change:
40+
IMPORTANT: Use propose_str_replace and propose_write_file tools to make your edits. These tools draft changes without actually applying them - they will be reviewed first. DO NOT use any other tools. Do not spawn any agents, read files, or set output.
4341
42+
You can make multiple tool calls across multiple steps to complete the implementation. Only the file changes will be passed on, so you can say whatever you want to help you think. Do not write any final summary as that would be a waste of tokens because no one is reading it.
4443
<codebuff_tool_call>
4544
{
4645
"cb_tool_name": "str_replace",
@@ -116,15 +115,64 @@ More style notes:
116115
- Optional arguments are code smell and worse than required arguments.
117116
- New components often should be added to a new file, not added to an existing file.
118117
119-
Write out your complete implementation now, formatting all changes as tool calls as shown above.`,
120-
121-
handleSteps: function* () {
122-
yield 'STEP'
118+
Write out your complete implementation now. Do not write any final summary.`,
119+
120+
handleSteps: function* ({ agentState: initialAgentState }) {
121+
const initialMessageHistoryLength =
122+
initialAgentState.messageHistory.length
123+
124+
const { agentState } = yield 'STEP_ALL'
125+
126+
const postMessages = agentState.messageHistory.slice(
127+
initialMessageHistoryLength,
128+
)
129+
130+
// Extract tool calls from assistant messages
131+
const toolCalls: { toolName: string; input: any }[] = []
132+
for (const message of postMessages) {
133+
if (message.role !== 'assistant' || !Array.isArray(message.content))
134+
continue
135+
for (const part of message.content) {
136+
if (part.type === 'tool-call') {
137+
toolCalls.push({
138+
toolName: part.toolName,
139+
input: part.input ?? (part as any).args ?? {},
140+
})
141+
}
142+
}
143+
}
144+
145+
// Extract tool results (unified diffs) from tool messages
146+
const toolResults: any[] = []
147+
for (const message of postMessages) {
148+
if (message.role !== 'tool' || !Array.isArray(message.content)) continue
149+
for (const part of message.content) {
150+
if (part.type === 'json' && part.value) {
151+
toolResults.push(part.value)
152+
}
153+
}
154+
}
155+
156+
// Concatenate all unified diffs for the selector to review
157+
const unifiedDiffs = toolResults
158+
.filter((result: any) => result.unifiedDiff)
159+
.map((result: any) => `--- ${result.file} ---\n${result.unifiedDiff}`)
160+
.join('\n\n')
161+
162+
yield {
163+
toolName: 'set_output',
164+
input: {
165+
toolCalls,
166+
toolResults,
167+
unifiedDiffs,
168+
},
169+
includeToolCall: false,
170+
}
123171
},
124172
}
125173
}
126174
const definition = {
127-
...createBestOfNImplementor({ model: 'sonnet' }),
175+
...createBestOfNImplementor({ model: 'opus' }),
128176
id: 'editor-implementor',
129177
}
130178
export default definition

0 commit comments

Comments
 (0)