/**
 * Runner para GitSyncAgent.commitByDay().
 * Uso: npm run agent:git:commit [-- --dry-run]
 */

import { GitSyncAgent } from '../agents/GitSyncAgent.js';

const dryRun = process.argv.includes('--dry-run');
const agent = new GitSyncAgent();

const result = await agent.commitByDay({ dryRun });

if (result.userMessage) console.log('\n⚠️ ' + result.userMessage);
if (result.retryPrompt) console.log('➡️ ' + result.retryPrompt);
if (result.commits?.length) {
  console.log('\n📦 Commits:', result.commits.length);
  result.commits.forEach((c) => console.log(`   ${c.date}: ${c.message}`));
}
if (result.errors?.length) console.error('\n❌ Erros:', result.errors);

process.exit(result.passed ? 0 : 1);
