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

Function runOnce

agents/e2e/base2-free-summary-format.e2e.test.ts:291–378  ·  view source on GitHub ↗
(
        runIndex: number,
      )

Source from the content-addressed store, hash-verified

289 const tmpDirs: string[] = []
290
291 const runOnce = async (
292 runIndex: number,
293 ): Promise<{
294 runIndex: number
295 imitationMatches: string[]
296 hadToolCalls: boolean
297 textOutput: string
298 error?: string
299 }> => {
300 const events: PrintModeEvent[] = []
301
302 const tmpDir = await fs.promises.mkdtemp(
303 path.join(os.tmpdir(), 'base2-free-summary-test-'),
304 )
305 tmpDirs.push(tmpDir)
306
307 // Write project files to disk so tools can read them
308 for (const [filePath, content] of Object.entries(PROJECT_FILES)) {
309 const fullPath = path.join(tmpDir, filePath)
310 await fs.promises.mkdir(path.dirname(fullPath), { recursive: true })
311 await fs.promises.writeFile(fullPath, content, 'utf-8')
312 }
313
314 const client = new CodebuffClient({
315 apiKey,
316 cwd: tmpDir,
317 projectFiles: PROJECT_FILES,
318 agentDefinitions: [base2Free as AgentDefinition, contextPruner],
319 })
320
321 const sessionState = await initialSessionState({
322 cwd: tmpDir,
323 projectFiles: PROJECT_FILES,
324 })
325 const runStateWithMessages = withMessageHistory({
326 runState: {
327 traceSessionId: 'test-trace-session',
328 sessionState,
329 output: { type: 'error', message: '' },
330 },
331 messages: [summarizedMessage],
332 })
333
334 try {
335 const run = await client.run({
336 agent: base2Free.id,
337 prompt: userPrompt,
338 previousRun: runStateWithMessages,
339 maxAgentSteps: 5,
340 handleEvent: (event) => {
341 events.push(event)
342 },
343 })
344
345 if (run.output.type === 'error') {
346 return {
347 runIndex,
348 imitationMatches: [],

Calls 5

runMethod · 0.95
initialSessionStateFunction · 0.90
withMessageHistoryFunction · 0.90
detectSummaryImitationFunction · 0.85
writeFileMethod · 0.80

Tested by

no test coverage detected