@@ -104,6 +104,35 @@ function getCommitMessage(repoPath: string, commitSha: string): string {
104104 } ) . trim ( )
105105}
106106
107+ function printTaskResult ( taskResult : {
108+ id : string
109+ reasoning : string
110+ spec : string
111+ prompt : string
112+ supplementalFiles : string [ ]
113+ } ) {
114+ console . log ( '\n' + '=' . repeat ( 80 ) )
115+ console . log ( '📋 GENERATED TASK' )
116+ console . log ( '=' . repeat ( 80 ) )
117+ console . log ( `\n🏷️ Task ID: ${ taskResult . id } \n` )
118+ console . log ( `💭 Reasoning:\n${ taskResult . reasoning } \n` )
119+ console . log ( `📝 Spec:\n${ taskResult . spec } \n` )
120+ console . log ( `💬 Prompt:\n${ taskResult . prompt } \n` )
121+ console . log ( `📁 Supplemental Files (${ taskResult . supplementalFiles . length } ):` )
122+ taskResult . supplementalFiles . forEach ( ( file , idx ) => {
123+ console . log ( ` ${ idx + 1 } . ${ file } ` )
124+ } )
125+ console . log ( '=' . repeat ( 80 ) + '\n' )
126+ }
127+
128+ function savePartialResults (
129+ partialPath : string ,
130+ evalData : EvalDataV2 ,
131+ ) : void {
132+ fs . writeFileSync ( partialPath , JSON . stringify ( evalData , null , 2 ) )
133+ console . log ( `💾 Saved partial results to ${ partialPath } ` )
134+ }
135+
107136export async function generateEvalFileV2 ( {
108137 repoUrl,
109138 commitShas,
@@ -119,7 +148,13 @@ export async function generateEvalFileV2({
119148 apiKey : process . env [ API_KEY_ENV_VAR ] || getUserCredentials ( ) ?. authToken ,
120149 } )
121150
151+ const finalOutputPath =
152+ outputPath || path . join ( __dirname , `eval-${ actualRepoName } -v2.json` )
153+ const partialOutputPath = finalOutputPath . replace ( / \. j s o n $ / , '.partial.json' )
154+
122155 console . log ( `Processing ${ commitShas . length } commits in parallel...` )
156+ console . log ( `Partial results will be saved to: ${ partialOutputPath } ` )
157+ console . log ( `Final results will be saved to: ${ finalOutputPath } \n` )
123158
124159 const BATCH_SIZE = 5
125160 const evalCommits : EvalCommitV2 [ ] = [ ]
@@ -159,16 +194,9 @@ export async function generateEvalFileV2({
159194 } ,
160195 } )
161196
162- console . log ( `Task ID: ${ taskResult . id } ` )
163- console . log ( `Generated spec: ${ taskResult . spec . substring ( 0 , 100 ) } ...` )
164- console . log (
165- `Generated prompt: ${ taskResult . prompt . substring ( 0 , 100 ) } ...` ,
166- )
167- console . log (
168- `Supplemental files: ${ taskResult . supplementalFiles . length } files` ,
169- )
197+ printTaskResult ( taskResult )
170198
171- return {
199+ const evalCommit : EvalCommitV2 = {
172200 id : taskResult . id ,
173201 sha : commitSha ,
174202 parentSha,
@@ -177,24 +205,44 @@ export async function generateEvalFileV2({
177205 supplementalFiles : taskResult . supplementalFiles ,
178206 fileDiffs,
179207 }
208+
209+ return evalCommit
180210 } ,
181211 )
182212 }
183213
184- const batchResults = await mapLimit ( commitShas , BATCH_SIZE , processCommit )
185- evalCommits . push ( ...( batchResults . filter ( Boolean ) as EvalCommitV2 [ ] ) )
214+ const batchResults = await mapLimit (
215+ commitShas ,
216+ BATCH_SIZE ,
217+ async ( commitSha : string ) => {
218+ const result = await processCommit ( commitSha )
219+ if ( result ) {
220+ evalCommits . push ( result )
221+
222+ const partialEvalData : EvalDataV2 = {
223+ repoUrl,
224+ generationDate : new Date ( ) . toISOString ( ) ,
225+ evalCommits : [ ...evalCommits ] ,
226+ }
227+ savePartialResults ( partialOutputPath , partialEvalData )
228+ }
229+ return result
230+ } ,
231+ )
186232
187233 const evalData : EvalDataV2 = {
188234 repoUrl,
189235 generationDate : new Date ( ) . toISOString ( ) ,
190236 evalCommits,
191237 }
192238
193- const generatedOutputPath =
194- outputPath || path . join ( __dirname , `eval- ${ actualRepoName } -v2.json `)
239+ fs . writeFileSync ( finalOutputPath , JSON . stringify ( evalData , null , 2 ) )
240+ console . log ( `\n✅ Eval data written to ${ finalOutputPath } `)
195241
196- fs . writeFileSync ( generatedOutputPath , JSON . stringify ( evalData , null , 2 ) )
197- console . log ( `Eval data written to ${ generatedOutputPath } ` )
242+ if ( fs . existsSync ( partialOutputPath ) ) {
243+ fs . unlinkSync ( partialOutputPath )
244+ console . log ( `🗑️ Removed partial file: ${ partialOutputPath } ` )
245+ }
198246}
199247
200248if ( require . main === module ) {
0 commit comments