this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add date/week filtering and regenerate command to CLI

- Add -d/--date flag for single day filtering (supports 'today', 'yesterday')
- Add -w/--week flag for week filtering (supports 'thisweek', 'lastweek')
- Add 'regenerate' command to regenerate daily summaries
- Use --force with regenerate to redo all summaries

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

alice e4f6fd7b a1107d10

+59 -6
+59 -6
src/cli/index.ts
··· 2 2 import { parseArgs } from 'util'; 3 3 import { processCommand } from './process'; 4 4 import { getSessionStats } from '../core/session-detector'; 5 - import { getStats } from '../core/db'; 5 + import { getStats, getDatesWithoutBragSummary, getSessionsForDate, saveDailySummary } from '../core/db'; 6 + import { generateDailyBragSummary } from '../core/summarizer'; 6 7 7 8 const { values, positionals } = parseArgs({ 8 9 args: Bun.argv.slice(2), ··· 11 12 verbose: { type: 'boolean', short: 'v' }, 12 13 force: { type: 'boolean', short: 'f' }, 13 14 date: { type: 'string', short: 'd' }, 15 + week: { type: 'string', short: 'w' }, 14 16 }, 15 17 allowPositionals: true, 16 18 }); ··· 29 31 force: values.force ?? false, 30 32 verbose: values.verbose ?? false, 31 33 date: values.date, 34 + week: values.week, 32 35 }); 33 36 break; 34 37 ··· 38 41 39 42 case 'serve': 40 43 await serveCommand(); 44 + break; 45 + 46 + case 'regenerate': 47 + await regenerateCommand(values.force ?? false); 41 48 break; 42 49 43 50 default: ··· 58 65 process Process new/unprocessed sessions 59 66 status Show processing stats 60 67 serve Start web UI server 68 + regenerate Regenerate daily summaries (use --force to redo all) 61 69 62 70 Options: 63 71 -h, --help Show help 64 72 -v, --verbose Verbose output 65 73 -f, --force Reprocess all sessions 66 74 -d, --date Process only sessions from specific date (YYYY-MM-DD) 75 + -w, --week Process only sessions from specific week (YYYY-MM-DD, uses that week) 67 76 68 77 Examples: 69 - bun cli process # Process new sessions 70 - bun cli process --force # Reprocess all 71 - bun cli process -d 2025-12-18 # Process specific date 72 - bun cli status # Show stats 73 - bun cli serve # Start web UI on port 3456 78 + bun cli process # Process new sessions 79 + bun cli process --force # Reprocess all 80 + bun cli process -d 2025-12-18 # Process specific date only 81 + bun cli process -w 2025-12-16 # Process week containing Dec 16 82 + bun cli process -d today # Process today's sessions 83 + bun cli process -w thisweek # Process this week's sessions 84 + bun cli status # Show stats 85 + bun cli serve # Start web UI on port 3456 74 86 `); 75 87 } 76 88 ··· 94 106 // Dynamic import to avoid loading web server code unless needed 95 107 const { startServer } = await import('../web/server'); 96 108 await startServer(); 109 + } 110 + 111 + async function regenerateCommand(force: boolean) { 112 + const { getDb } = await import('../core/db'); 113 + const db = getDb(); 114 + 115 + if (force) { 116 + // Clear all daily summaries to regenerate everything 117 + db.run('DELETE FROM daily_summaries'); 118 + console.log('\n🗑️ Cleared all daily summaries\n'); 119 + } 120 + 121 + const dates = getDatesWithoutBragSummary(); 122 + 123 + if (dates.length === 0) { 124 + console.log('\n✅ All daily summaries are up to date.\n'); 125 + console.log('Use --force to regenerate all summaries.\n'); 126 + return; 127 + } 128 + 129 + console.log(`\n📝 Regenerating ${dates.length} daily summaries...\n`); 130 + 131 + for (const date of dates) { 132 + const sessions = getSessionsForDate(date); 133 + if (sessions.length === 0) continue; 134 + 135 + try { 136 + const summary = await generateDailyBragSummary(date, sessions); 137 + const projectNames = [...new Set(sessions.map(s => s.project_name))]; 138 + saveDailySummary(date, summary, projectNames, sessions.length); 139 + 140 + // Parse and show preview 141 + const parsed = JSON.parse(summary); 142 + const preview = parsed.projects.map((p: any) => p.name).join(', '); 143 + console.log(` ✓ ${date}: ${preview}`); 144 + } catch (error) { 145 + console.error(` ✗ ${date}: ${error}`); 146 + } 147 + } 148 + 149 + console.log('\n✅ Done!\n'); 97 150 } 98 151 99 152 main().catch((error) => {