@@ -20,9 +20,7 @@ export async function runGitEvals2(
2020) : Promise < GitEvals2Result > {
2121 const { evalDataPath, agents, outputPath, limit, onProgress } = options
2222
23- const evalData : EvalData = JSON . parse (
24- fs . readFileSync ( evalDataPath , 'utf-8' ) ,
25- )
23+ const evalData : EvalData = JSON . parse ( fs . readFileSync ( evalDataPath , 'utf-8' ) )
2624 const commitsToRun = limit
2725 ? evalData . evalCommits . slice ( 0 , limit )
2826 : evalData . evalCommits
@@ -36,6 +34,16 @@ export async function runGitEvals2(
3634 const startTime = Date . now ( )
3735 const results = new Map < string , AgentEvalResults > ( )
3836
37+ // Create logs directory with current date and time
38+ const date = new Date ( ) . toISOString ( ) . replace ( / : / g, '-' ) . slice ( 0 , 16 ) // YYYY-MM-DDTHH-MM
39+ const outputDir = outputPath
40+ ? path . dirname ( outputPath )
41+ : 'evals/git-evals2/results'
42+ const logsDir = path . join ( outputDir , 'logs' , date )
43+ if ( ! fs . existsSync ( logsDir ) ) {
44+ fs . mkdirSync ( logsDir , { recursive : true } )
45+ }
46+
3947 for ( const agentId of agents ) {
4048 results . set ( agentId , {
4149 agentId,
@@ -85,6 +93,28 @@ export async function runGitEvals2(
8593 error : agentResult . error ,
8694 }
8795
96+ // Save trace to logs directory
97+ const safeAgentId = agentId . replace ( / [ ^ a - z A - Z 0 - 9 - ] / g, '_' )
98+ const safeCommitShort = commit . sha . slice ( 0 , 7 )
99+ const traceFilename = `${ safeAgentId } -${ safeCommitShort } .json`
100+ const tracePath = path . join ( logsDir , traceFilename )
101+
102+ const traceData = {
103+ agentId,
104+ commitSha : commit . sha ,
105+ spec : commit . spec ,
106+ trace : agentResult . trace ,
107+ diff : agentResult . diff ,
108+ judgeResult,
109+ cost : agentResult . cost ,
110+ durationMs : agentResult . durationMs ,
111+ error : agentResult . error ,
112+ timestamp : new Date ( ) . toISOString ( ) ,
113+ }
114+
115+ fs . writeFileSync ( tracePath , JSON . stringify ( traceData , null , 2 ) )
116+ console . log ( `Trace saved to ${ tracePath } ` )
117+
88118 onProgress ?.( {
89119 type : 'agent_complete' ,
90120 agent : agentId ,
@@ -172,6 +202,7 @@ export async function runGitEvals2(
172202 console . log ( `\nResults written to ${ outputPath } ` )
173203 }
174204
205+ console . log ( `\nTraces saved to ${ logsDir } ` )
175206 console . log ( '\n=== Summary ===' )
176207 for ( const [ agentId , data ] of results ) {
177208 console . log ( `\n${ agentId } :` )
0 commit comments