Skip to content

Commit 50daa99

Browse files
committed
Reorder agent-config a bit, update tools.d.ts, tweak changes-reviewer
1 parent 7bdeea2 commit 50daa99

File tree

3 files changed

+115
-101
lines changed

3 files changed

+115
-101
lines changed

.agents/changes-reviewer.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ const config: AgentConfig = {
55
version: '0.0.1',
66
displayName: 'Changes Reviewer',
77
model: 'x-ai/grok-4',
8+
includeMessageHistory: false,
9+
10+
inputSchema: {
11+
prompt: {
12+
type: 'string',
13+
description:
14+
'Please provide a short description of the changes you want to review',
15+
},
16+
},
17+
outputMode: 'last_message',
18+
19+
toolNames: ['read_files', 'run_terminal_command', 'end_turn'],
820

921
parentPrompt: 'Spawn when you need to review code changes',
1022

@@ -13,21 +25,16 @@ const config: AgentConfig = {
1325

1426
instructionsPrompt: `
1527
Use the following guidelines to review the changes and suggest improvements:
16-
1. Find ways to simplify the code
17-
2. Reuse existing code as much as possible instead of writing new code
18-
3. Preserve as much behavior as possible in the existing code
19-
4. Prefer to change as few lines of code as possible
20-
5. Look for logical errors in the code
21-
6. Look for missed cases in the code
22-
7. Look for any other bugs
23-
8. Look for opportunities to improve the code's readability
28+
- Find ways to simplify the code
29+
- Reuse existing code as much as possible instead of writing new code
30+
- Preserve as much behavior as possible in the existing code
31+
- Prefer changing as few lines of code as possible
32+
- Look for opportunities to improve the code's readability
33+
- Look for logical errors in the code
34+
- Look for missed cases in the code
35+
- Look for any other bugs
2436
`.trim(),
2537

26-
includeMessageHistory: true,
27-
outputMode: 'last_message',
28-
29-
toolNames: ['read_files', 'run_terminal_command', 'end_turn'],
30-
3138
handleSteps: function* ({ agentState, prompt, params }: AgentStepContext) {
3239
// Step 1: Get list of changed files from git diff
3340
const { toolResult: gitDiffResult } = yield {
@@ -59,14 +66,13 @@ Use the following guidelines to review the changes and suggest improvements:
5966
},
6067
}
6168

62-
// Step 4: Extract file paths from git diff output
69+
// Step 4: Extract file paths from git diff and status output
6370
const gitDiffOutput = gitDiffResult?.result || ''
6471
const changedFiles = gitDiffOutput
6572
.split('\n')
6673
.map((line) => line.trim())
6774
.filter((line) => line && !line.startsWith('??') && !line.includes('OSC'))
6875

69-
// Step 5: Extract untracked files from git status output
7076
const gitStatusOutput = gitStatusResult?.result || ''
7177
const untrackedFiles = gitStatusOutput
7278
.split('\n')
@@ -75,11 +81,11 @@ Use the following guidelines to review the changes and suggest improvements:
7581
.map((line) => line.substring(3).trim()) // Remove '?? ' prefix
7682
.filter((file) => file)
7783

78-
// Step 6: Combine all files to read
7984
const allFilesToRead = [...changedFiles, ...untrackedFiles].filter(
8085
(file) => file,
8186
)
8287

88+
// Step 5: Read the files
8389
if (allFilesToRead.length > 0) {
8490
yield {
8591
toolName: 'read_files',
@@ -89,9 +95,7 @@ Use the following guidelines to review the changes and suggest improvements:
8995
}
9096
}
9197

92-
// Step 7: Let AI review the changes
98+
// Step 7: Let AI review the changes (and take as many steps as needed)
9399
yield 'STEP_ALL'
94100
},
95101
}
96-
97-
export default config

.agents/types/tools.d.ts

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
1+
/**
2+
* Union type of all available tool names
3+
*/
4+
export type ToolName =
5+
| 'add_message'
6+
| 'add_subgoal'
7+
| 'browser_logs'
8+
| 'code_search'
9+
| 'create_plan'
10+
| 'end_turn'
11+
| 'find_files'
12+
| 'read_docs'
13+
| 'read_files'
14+
| 'run_file_change_hooks'
15+
| 'run_terminal_command'
16+
| 'send_agent_message'
17+
| 'set_messages'
18+
| 'set_output'
19+
| 'spawn_agents'
20+
| 'spawn_agents_async'
21+
| 'str_replace'
22+
| 'think_deeply'
23+
| 'update_subgoal'
24+
| 'web_search'
25+
| 'write_file'
26+
27+
/**
28+
* Map of tool names to their parameter types
29+
*/
30+
export interface ToolParamsMap {
31+
add_message: AddMessageParams
32+
add_subgoal: AddSubgoalParams
33+
browser_logs: BrowserLogsParams
34+
code_search: CodeSearchParams
35+
create_plan: CreatePlanParams
36+
end_turn: EndTurnParams
37+
find_files: FindFilesParams
38+
read_docs: ReadDocsParams
39+
read_files: ReadFilesParams
40+
run_file_change_hooks: RunFileChangeHooksParams
41+
run_terminal_command: RunTerminalCommandParams
42+
send_agent_message: SendAgentMessageParams
43+
set_messages: SetMessagesParams
44+
set_output: SetOutputParams
45+
spawn_agents: SpawnAgentsParams
46+
spawn_agents_async: SpawnAgentsAsyncParams
47+
str_replace: StrReplaceParams
48+
think_deeply: ThinkDeeplyParams
49+
update_subgoal: UpdateSubgoalParams
50+
web_search: WebSearchParams
51+
write_file: WriteFileParams
52+
}
53+
154
/**
255
* Add a new message to the conversation history. To be used for complex requests that can't be solved in a single step, as you may forget what happened!
356
*/
@@ -225,59 +278,6 @@ export interface WriteFileParams {
225278
content: string
226279
}
227280

228-
/**
229-
* Union type of all available tool names
230-
*/
231-
export type ToolName =
232-
| 'add_message'
233-
| 'add_subgoal'
234-
| 'browser_logs'
235-
| 'code_search'
236-
| 'create_plan'
237-
| 'end_turn'
238-
| 'find_files'
239-
| 'read_docs'
240-
| 'read_files'
241-
| 'run_file_change_hooks'
242-
| 'run_terminal_command'
243-
| 'send_agent_message'
244-
| 'set_messages'
245-
| 'set_output'
246-
| 'spawn_agents'
247-
| 'spawn_agents_async'
248-
| 'str_replace'
249-
| 'think_deeply'
250-
| 'update_subgoal'
251-
| 'web_search'
252-
| 'write_file'
253-
254-
/**
255-
* Map of tool names to their parameter types
256-
*/
257-
export interface ToolParamsMap {
258-
add_message: AddMessageParams
259-
add_subgoal: AddSubgoalParams
260-
browser_logs: BrowserLogsParams
261-
code_search: CodeSearchParams
262-
create_plan: CreatePlanParams
263-
end_turn: EndTurnParams
264-
find_files: FindFilesParams
265-
read_docs: ReadDocsParams
266-
read_files: ReadFilesParams
267-
run_file_change_hooks: RunFileChangeHooksParams
268-
run_terminal_command: RunTerminalCommandParams
269-
send_agent_message: SendAgentMessageParams
270-
set_messages: SetMessagesParams
271-
set_output: SetOutputParams
272-
spawn_agents: SpawnAgentsParams
273-
spawn_agents_async: SpawnAgentsAsyncParams
274-
str_replace: StrReplaceParams
275-
think_deeply: ThinkDeeplyParams
276-
update_subgoal: UpdateSubgoalParams
277-
web_search: WebSearchParams
278-
write_file: WriteFileParams
279-
}
280-
281281
/**
282282
* Get parameters type for a specific tool
283283
*/

common/src/util/agent-config.d.ts

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
* This file provides TypeScript type definitions for creating custom Codebuff agents.
55
* Import these types in your agent files to get full type safety and IntelliSense.
66
*
7-
* Usage:
8-
* import { AgentConfig, ToolName, ModelName } from './agent-config'
7+
* Usage in .agents/your-agent.ts:
8+
* import { AgentConfig, ToolName, ModelName } from './types/agent-config'
99
*
1010
* const config: AgentConfig = {
11-
* // Your agent configuration with full type safety
11+
* // ... your agent configuration with full type safety ...
1212
* }
13+
*
14+
* export default config
1315
*/
1416

15-
import type * as Tools from './tools'
16-
export type { Tools }
17-
type ToolName = Tools.ToolName
18-
1917
// ============================================================================
2018
// Core Agent Configuration Types
2119
// ============================================================================
@@ -43,26 +41,6 @@ export interface AgentConfig {
4341
/** Other agents this agent can spawn. */
4442
subagents?: SubagentName[]
4543

46-
// ============================================================================
47-
// Prompts
48-
// ============================================================================
49-
50-
/** Prompt for when to spawn this agent as a subagent. Include the main purpose and use cases.
51-
* This field is key if the agent is a subagent and intended to be spawned. */
52-
parentPrompt?: string
53-
54-
/** Background information for the agent. Fairly optional. Prefer using instructionsPrompt for agent instructions. */
55-
systemPrompt?: string
56-
57-
/** Instructions for the agent.
58-
* IMPORTANT: Updating this prompt is the best way to shape the agent's behavior.
59-
* This prompt is inserted after each user input. */
60-
instructionsPrompt?: string
61-
62-
/** Prompt inserted at each agent step. Powerful for changing the agent's behavior,
63-
* but usually not necessary for smart models. Prefer instructionsPrompt for most instructions. */
64-
stepPrompt?: string
65-
6644
// ============================================================================
6745
// Input and Output
6846
// ============================================================================
@@ -78,21 +56,50 @@ export interface AgentConfig {
7856
params?: JsonSchema
7957
}
8058

81-
/** Whether to include conversation history. Defaults to false.
59+
/** Whether to include conversation history from the parent agent in context.
60+
*
61+
* Defaults to false.
8262
* Use this if the agent needs to know all the previous messages in the conversation.
8363
*/
8464
includeMessageHistory?: boolean
8565

8666
/** How the agent should output a response to its parent (defaults to 'last_message')
67+
*
8768
* last_message: The last message from the agent, typcically after using tools.
69+
*
8870
* all_messages: All messages from the agent, including tool calls and results.
71+
*
8972
* json: Make the agent output a JSON object. Can be used with outputSchema or without if you want freeform json output.
9073
*/
9174
outputMode?: 'last_message' | 'all_messages' | 'json'
9275

9376
/** JSON schema for structured output (when outputMode is 'json') */
9477
outputSchema?: JsonSchema
9578

79+
// ============================================================================
80+
// Prompts
81+
// ============================================================================
82+
83+
/** Prompt for when to spawn this agent as a subagent. Include the main purpose and use cases.
84+
*
85+
* This field is key if the agent is a subagent and intended to be spawned. */
86+
parentPrompt?: string
87+
88+
/** Background information for the agent. Fairly optional. Prefer using instructionsPrompt for agent instructions. */
89+
systemPrompt?: string
90+
91+
/** Instructions for the agent.
92+
*
93+
* IMPORTANT: Updating this prompt is the best way to shape the agent's behavior.
94+
* This prompt is inserted after each user input. */
95+
instructionsPrompt?: string
96+
97+
/** Prompt inserted at each agent step.
98+
*
99+
* Powerful for changing the agent's behavior, but usually not necessary for smart models.
100+
* Prefer instructionsPrompt for most instructions. */
101+
stepPrompt?: string
102+
96103
// ============================================================================
97104
// Handle Steps
98105
// ============================================================================
@@ -190,7 +197,6 @@ export interface ToolResult {
190197
result: string
191198
}
192199

193-
194200
/**
195201
* JSON Schema definition (for prompt schema or output schema)
196202
*/
@@ -299,3 +305,7 @@ export type SubagentName =
299305
| 'thinker'
300306
| 'reviewer'
301307
| (string & {})
308+
309+
import type * as Tools from './tools'
310+
export type { Tools }
311+
type ToolName = Tools.ToolName

0 commit comments

Comments
 (0)