()
| 377 | |
| 378 | // 主函数 |
| 379 | async function main() { |
| 380 | // 获取两个仓库的提交 |
| 381 | const teleboxCommits = CHECKOUT_SUCCESS ? getCommitsForDate('TeleBox', 'TeleBox', TARGET_DATE) : []; |
| 382 | const pluginsCommits = getCommitsForDate('TeleBox-Plugins', 'TeleBox-Plugins', TARGET_DATE); |
| 383 | |
| 384 | if (!CHECKOUT_SUCCESS) { |
| 385 | console.warn('⚠️ TeleBox 仓库访问失败,仅统计 TeleBox-Plugins 提交'); |
| 386 | } |
| 387 | |
| 388 | const dedupedTeleboxCommits = deduplicateCommits(teleboxCommits); |
| 389 | const dedupedPluginsCommits = deduplicateCommits(pluginsCommits); |
| 390 | const allCommits = [...dedupedTeleboxCommits, ...dedupedPluginsCommits]; |
| 391 | |
| 392 | if (allCommits.length === 0) { |
| 393 | console.log('📭 今日无提交记录,跳过发布'); |
| 394 | return; |
| 395 | } |
| 396 | |
| 397 | // 按仓库分组提交 |
| 398 | const commitsByRepo = { |
| 399 | 'TeleBox': dedupedTeleboxCommits, |
| 400 | 'TeleBox-Plugins': dedupedPluginsCommits |
| 401 | }; |
| 402 | |
| 403 | // 尝试使用 Gemini AI 生成智能摘要 |
| 404 | console.log('\n' + '='.repeat(50)); |
| 405 | console.log('🚀 开始生成更新日志'); |
| 406 | console.log('='.repeat(50)); |
| 407 | |
| 408 | const geminiSummary = await summarizeWithGemini(allCommits); |
| 409 | |
| 410 | // 生成摘要消息 |
| 411 | let message = `📅 TeleBox 日报 - ${TARGET_DATE}\n\n`; |
| 412 | message += `📊 今日提交统计\n`; |
| 413 | message += `• 总提交数: ${allCommits.length}\n`; |
| 414 | message += `• TeleBox: ${dedupedTeleboxCommits.length} 次提交\n`; |
| 415 | message += `• TeleBox-Plugins: ${dedupedPluginsCommits.length} 次提交\n\n`; |
| 416 | |
| 417 | // 如果有 Gemini 摘要,使用 AI 生成的内容 |
| 418 | if (geminiSummary) { |
| 419 | console.log('\n✅ 使用 Gemini AI 生成的智能摘要'); |
| 420 | console.log('📊 摘要长度:', geminiSummary.length, '字符'); |
| 421 | // 清理输出,移除多余的提示和重复标题 |
| 422 | const cleanedSummary = geminiSummary |
| 423 | .replace(/好的,根据您提供的提交记录,我将生成以下更新日志:\n+/g, '') |
| 424 | .replace(/^#\s+/gm, '') // 移除markdown标题符号 |
| 425 | .replace(/📢\s*TeleBox\s*更新\s*\|[^\n]*\n+/g, '') // 移除重复的标题行 |
| 426 | .replace(/🗓\s*\[[^\]]*\]\s*--[^\n]*\n+/g, '') // 移除重复的版本行 |
| 427 | .trim(); |
| 428 | message += `${cleanedSummary}\n\n`; |
| 429 | } else { |
| 430 | console.log('\n📝 使用基础分组摘要(Fallback 模式)'); |
| 431 | console.log(' 原因: Gemini AI 不可用或返回空结果'); |
| 432 | // 按功能分组提交信息(作为 fallback) |
| 433 | message += generateBasicSummary(commitsByRepo); |
| 434 | } |
| 435 | |
| 436 | // 贡献者统计已移除(精简输出) |
no test coverage detected