Skip to content

Commit 389b78e

Browse files
committed
fix circular dependencies
1 parent ddea8e9 commit 389b78e

Some content is hidden

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

68 files changed

+623
-915
lines changed

backend/src/__tests__/run-agent-step-tools.test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
import * as aisdk from '../llm-apis/vercel-ai-sdk/ai-sdk'
2626
import { runAgentStep } from '../run-agent-step'
2727
import { getAllAgentTemplates } from '../templates/agent-registry'
28-
import * as tools from '../tools'
2928
import * as websocketAction from '../websockets/websocket-action'
3029

3130
describe('runAgentStep - update_report tool', () => {
@@ -68,27 +67,6 @@ describe('runAgentStep - update_report tool', () => {
6867
Promise.resolve(true)
6968
)
7069

71-
// Mock the readFiles function from tools.ts
72-
spyOn(tools, 'readFiles').mockImplementation(
73-
async (paths: string[], projectRoot: string) => {
74-
const results: Record<string, string | null> = {}
75-
paths.forEach((p) => {
76-
if (p === 'src/auth.ts') {
77-
results[p] = 'export function authenticate() { return true; }'
78-
} else if (p === 'src/user.ts') {
79-
results[p] = 'export interface User { id: string; name: string; }'
80-
} else if (p === 'src/components/auth/login.tsx') {
81-
results[p] = 'export function Login() { return <div>Login</div>; }'
82-
} else if (p === 'src/utils/validation.ts') {
83-
results[p] = 'export function validate() { return true; }'
84-
} else {
85-
results[p] = null
86-
}
87-
})
88-
return results
89-
}
90-
)
91-
9270
spyOn(websocketAction, 'requestFiles').mockImplementation(
9371
async (ws: any, paths: string[]) => {
9472
const results: Record<string, string | null> = {}

backend/src/__tests__/subagent-streaming.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import type { WebSocket } from 'ws'
2+
import type { AgentTemplate } from '../templates/types'
3+
import type { SendSubagentChunk } from '../tools/handlers/tool/spawn-agents'
4+
15
import { TEST_USER_ID } from '@codebuff/common/constants'
26
import { getInitialSessionState } from '@codebuff/common/types/session-state'
37
import {
@@ -11,15 +15,10 @@ import {
1115
mock,
1216
spyOn,
1317
} from 'bun:test'
14-
import { WebSocket } from 'ws'
1518

1619
import * as runAgentStep from '../run-agent-step'
1720
import * as agentRegistryModule from '../templates/agent-registry'
18-
import { AgentTemplate } from '../templates/types'
19-
import {
20-
handleSpawnAgents,
21-
SendSubagentChunk,
22-
} from '../tools/handlers/spawn-agents'
21+
import { handleSpawnAgents } from '../tools/handlers/tool/spawn-agents'
2322
import * as loggerModule from '../util/logger'
2423
import { mockFileContext, MockWebSocket } from './test-utils'
2524

backend/src/templates/agents/agent-builder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Every agent template must include these fields:
103103
Use these placeholders in prompts:
104104
- {CODEBUFF_AGENT_NAME} - Agent name
105105
- {CODEBUFF_TOOLS_PROMPT} - Available tools description
106+
- {CODEBUFF_AGENTS_PROMPT} - Available agents description
106107
- {CODEBUFF_FILE_TREE_PROMPT} - File tree information
107108
- {CODEBUFF_SYSTEM_INFO_PROMPT} - System information
108109
- {CODEBUFF_PROJECT_ROOT} - Project root directory

backend/src/templates/agents/archive/dry-run.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export const dryRun = (model: Model): Omit<AgentTemplate, 'id'> => ({
2222

2323
systemPrompt: `# Persona: ${PLACEHOLDER.AGENT_NAME} - The Dry Run Specialist
2424
25-
You are an expert software engineer who specializes in dry runs - a form of thinking and planning where you mentally walk through implementation steps before actually coding. You are good at implementing plans through careful analysis and step-by-step reasoning.\n\n${PLACEHOLDER.TOOLS_PROMPT}`,
25+
You are an expert software engineer who specializes in dry runs - a form of thinking and planning where you mentally walk through implementation steps before actually coding. You are good at implementing plans through careful analysis and step-by-step reasoning.
26+
27+
${PLACEHOLDER.TOOLS_PROMPT}
28+
29+
${PLACEHOLDER.AGENTS_PROMPT}`,
2630

2731
userInputPrompt: `Do a dry run of implementing just the specified portion of the plan. (Do NOT sketch out the full plan!)
2832

backend/src/templates/agents/file-picker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ You are an expert at finding relevant files in a codebase.
3535
\n\n` +
3636
[
3737
PLACEHOLDER.TOOLS_PROMPT,
38+
PLACEHOLDER.AGENTS_PROMPT,
3839
PLACEHOLDER.FILE_TREE_PROMPT,
3940
PLACEHOLDER.SYSTEM_INFO_PROMPT,
4041
PLACEHOLDER.GIT_CHANGES_PROMPT,

backend/src/templates/agents/planner.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export const planner = (model: Model): Omit<AgentTemplate, 'id'> => ({
2626

2727
systemPrompt: `# Persona: ${PLACEHOLDER.AGENT_NAME}
2828
29-
You are an expert software architect. You are good at creating comprehensive plans to tackle the user request.\n\n${PLACEHOLDER.TOOLS_PROMPT}`,
29+
You are an expert software architect. You are good at creating comprehensive plans to tackle the user request.
30+
31+
${PLACEHOLDER.TOOLS_PROMPT}
32+
33+
${PLACEHOLDER.AGENTS_PROMPT}`,
3034

3135
userInputPrompt: `Steps for your response:
3236
1. Use the <think_deeply> tool to think through cruxes for the plan, and tricky cases. Consider alternative approaches. Be sure to close the tool call with ${closeXml('think_deeply')}.

backend/src/templates/agents/researcher.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ In your report, provide a thorough analysis that includes:
4747
Always end your response with the end_turn tool.\\n\\n` +
4848
[
4949
PLACEHOLDER.TOOLS_PROMPT,
50+
PLACEHOLDER.AGENTS_PROMPT,
5051
PLACEHOLDER.FILE_TREE_PROMPT,
5152
PLACEHOLDER.SYSTEM_INFO_PROMPT,
5253
PLACEHOLDER.GIT_CHANGES_PROMPT,

backend/src/templates/agents/reviewer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export const reviewer = (model: Model): Omit<AgentTemplate, 'id'> => ({
2424
systemPrompt: `# Persona: ${PLACEHOLDER.AGENT_NAME}
2525
2626
You are an expert programmer who can articulate very clear feedback on code changes.
27-
${PLACEHOLDER.TOOLS_PROMPT}`,
27+
28+
${PLACEHOLDER.TOOLS_PROMPT}
29+
30+
${PLACEHOLDER.AGENTS_PROMPT}`,
2831

2932
userInputPrompt: `Your task is to provide helpful feedback on the last file changes made by the assistant. You should critique the code changes made recently in the above conversation.
3033

backend/src/templates/agents/superagent.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export const superagent = (
4040
`You are an expert orchestrator that can solve any problem, including coding tasks.
4141
4242
${PLACEHOLDER.TOOLS_PROMPT}
43+
44+
${PLACEHOLDER.AGENTS_PROMPT}
4345
`.trim(),
4446
userInputPrompt: `
4547
Answer the user's question or complete the task by spawning copies of the base agent.

backend/src/templates/agents/thinker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export const thinker = (model: Model): Omit<AgentTemplate, 'id'> => ({
2424
systemPrompt: `# Persona: ${PLACEHOLDER.AGENT_NAME}
2525
2626
You are an expert programmer.
27-
${PLACEHOLDER.TOOLS_PROMPT}`,
27+
28+
${PLACEHOLDER.TOOLS_PROMPT}
29+
30+
${PLACEHOLDER.AGENTS_PROMPT}`,
2831

2932
userInputPrompt: `
3033
Think deeply, step by step, about the user request and how best to approach it.

0 commit comments

Comments
 (0)