(
commit: CommitInfo,
index: number,
)
| 346 | |
| 347 | // Process each commit individually |
| 348 | async function processCommit( |
| 349 | commit: CommitInfo, |
| 350 | index: number, |
| 351 | ): Promise<FilteredCommit | null> { |
| 352 | console.log( |
| 353 | `Screening commit ${index + 1}/${commits.length}: ${commit.sha.substring(0, 8)}...`, |
| 354 | ) |
| 355 | |
| 356 | // Get detailed commit information including diffs |
| 357 | let diffs: CommitDiff[] = [] |
| 358 | try { |
| 359 | diffs = await generateDiffFromCommit(repoPath, commit.sha) |
| 360 | } catch (error) { |
| 361 | console.warn(`Failed to get diffs for commit ${commit.sha}:`, error) |
| 362 | } |
| 363 | |
| 364 | let commitInfo = |
| 365 | `${commit.sha.substring(0, 8)}: ${commit.message}\n` + |
| 366 | `Author: ${commit.author}, Date: ${commit.date}\n` + |
| 367 | `Stats: ${commit.stats.filesChanged} files changed, +${commit.stats.insertions} -${commit.stats.deletions}\n` |
| 368 | |
| 369 | if (diffs.length > 0) { |
| 370 | commitInfo += `\nFile Changes:\n` |
| 371 | for (const diff of diffs) { |
| 372 | commitInfo += `\n--- ${diff.path} ---\n` |
| 373 | |
| 374 | if (diff.preContent === '[NEW FILE]') { |
| 375 | commitInfo += `New file:\n${diff.postContent}\n` |
| 376 | } else if (diff.postContent === '[DELETED]') { |
| 377 | commitInfo += `File deleted\n` |
| 378 | } else { |
| 379 | // Show a simplified diff for existing files |
| 380 | const preLines = diff.preContent.split('\n') |
| 381 | const postLines = diff.postContent.split('\n') |
| 382 | |
| 383 | let hasChanges = false |
| 384 | for (let i = 0; i < preLines.length; i++) { |
| 385 | if (preLines[i] !== postLines[i]) { |
| 386 | commitInfo += `Line ${i + 1}:\n- ${preLines[i]}\n+ ${postLines[i]}\n` |
| 387 | hasChanges = true |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | if (!hasChanges && preLines.length !== postLines.length) { |
| 392 | commitInfo += `File length changed from ${preLines.length} to ${postLines.length} lines\n` |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | const prompt = `${COMMIT_SCREENING_PROMPT}\n\nCommit to evaluate:\n\n${commitInfo}` |
| 399 | |
| 400 | try { |
| 401 | const result = await promptAiSdkStructured({ |
| 402 | messages: [userMessage(prompt)], |
| 403 | schema: CommitSelectionSchema, |
| 404 | model: models.openrouter_gpt5, |
| 405 | clientSessionId, |
no test coverage detected