MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / evalPlannerAgent

Function evalPlannerAgent

evals/subagents/eval-planner.ts:16–158  ·  view source on GitHub ↗
(params: {
  client: CodebuffClient
  agentId: string
  agentDefinitions: Array<AgentDefinition>
  spec: string
  repoUrl: string
  parentSha: string
  initCommand?: string
  fileStates: Array<{
    path: string
    preContent: string
    postContent: string
  }>
})

Source from the content-addressed store, hash-verified

14import type { AgentDefinition } from '@codebuff/sdk'
15
16export const evalPlannerAgent = async (params: {
17 client: CodebuffClient
18 agentId: string
19 agentDefinitions: Array<AgentDefinition>
20 spec: string
21 repoUrl: string
22 parentSha: string
23 initCommand?: string
24 fileStates: Array<{
25 path: string
26 preContent: string
27 postContent: string
28 }>
29}) => {
30 const {
31 client,
32 agentId,
33 agentDefinitions,
34 spec,
35 repoUrl,
36 parentSha,
37 initCommand,
38 fileStates,
39 } = params
40 const plannerStartTime = Date.now()
41 const result = await withTestRepo(
42 { repoUrl, parentSha, initCommand },
43 async (cwd) => {
44 // Run the agent with the test repository as cwd
45 console.log(`Running agent ${agentId} with prompt: ${spec}...`)
46 return await client.run({
47 agent: agentId,
48 prompt: `Please plan a full implementation of the following spec: ${spec}`,
49 cwd,
50 agentDefinitions,
51 handleEvent: (event) => {
52 console.log(agentId, JSON.stringify(event, null, 2))
53 },
54 })
55 },
56 )
57 const plannerLatencyMs = Date.now() - plannerStartTime
58
59 const { output } = result
60
61 const outputString = JSON.stringify(
62 'value' in output ? output.value : output.message,
63 )
64
65 // Compute file changes and diffs
66 const fileChangesSection = fileStates
67 .map(({ path, preContent, postContent }) => {
68 return `\n### File: ${path}\n\n<pre_content>\n${preContent}\n</pre_content>\n\n<post_content>\n${postContent}\n</post_content>`
69 })
70 .join('\n')
71
72 const diffsSection = fileStates
73 .map(({ path, preContent, postContent }) => {

Callers 1

mainFunction · 0.85

Calls 2

withTestRepoFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected