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

Function main

agents/librarian/librarian.test.ts:214–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

212}
213
214async function main() {
215 fs.mkdirSync(TRACE_DIR, { recursive: true })
216
217 const taskIndexArg = process.argv[2]
218 const tasksToRun =
219 taskIndexArg !== undefined
220 ? [
221 {
222 task: TASKS[parseInt(taskIndexArg, 10)],
223 index: parseInt(taskIndexArg, 10),
224 },
225 ]
226 : TASKS.map((task, index) => ({ task, index }))
227
228 if (tasksToRun.some((t) => !t.task)) {
229 console.error(
230 `Invalid task index: ${taskIndexArg}. Available: 0-${TASKS.length - 1}`,
231 )
232 process.exit(1)
233 }
234
235 const agents = await loadLocalAgents({
236 agentsPath: path.join(process.cwd(), 'agents'),
237 verbose: true,
238 })
239 const agentDefinitions = Object.values(agents) as AgentDefinition[]
240
241 const librarianAgent = agentDefinitions.find((a) => a.id === 'librarian')
242 if (!librarianAgent) {
243 console.error('librarian agent not found in agents/ directory')
244 process.exit(1)
245 }
246 console.log(`Loaded librarian agent (model: ${librarianAgent.model})`)
247
248 const client = new CodebuffClient({
249 apiKey: process.env.CODEBUFF_API_KEY,
250 cwd: process.cwd(),
251 })
252
253 const results: Array<{
254 name: string
255 success: boolean
256 traceFile: string
257 validationErrors: string[]
258 }> = []
259
260 for (const { task, index } of tasksToRun) {
261 const result = await runTask(client, task, agentDefinitions, index)
262 results.push({
263 name: task.name,
264 success: result.success,
265 traceFile: result.traceFile,
266 validationErrors: result.validationErrors,
267 })
268 }
269
270 console.log(`\n${'='.repeat(60)}`)
271 console.log('SUMMARY')

Callers 1

librarian.test.tsFile · 0.70

Calls 2

loadLocalAgentsFunction · 0.90
runTaskFunction · 0.70

Tested by

no test coverage detected