feat(report): write weekly report as short bullets with haiku

This commit is contained in:
mika kuns
2026-09-30 10:05:24 +02:00
parent f2ff865dca
commit 8a31a67c74
3 changed files with 17 additions and 20 deletions
@@ -40,14 +40,12 @@ public sealed class WeekReportService
public async Task<string> GenerateAsync(DateOnly start, DateOnly end, CancellationToken ct = default)
{
string[] excludes;
string model;
IReadOnlyList<Data.Models.DailyNoteEntity> noteRows;
await using (var ctx = await _dbFactory.CreateDbContextAsync(ct))
{
var settings = await new AppSettingsRepository(ctx).GetAsync(ct);
excludes = ParseExcludes(settings.ReportExcludedPaths);
model = string.IsNullOrWhiteSpace(settings.DefaultModel) ? "sonnet" : settings.DefaultModel;
noteRows = await new DailyNoteRepository(ctx).ListBetweenAsync(start, end, ct);
}
@@ -65,15 +63,13 @@ public sealed class WeekReportService
else
{
var prompt = WeekReportPromptBuilder.Build(start, end, activity, notesByDay);
// Guard against argument injection via the model setting: model aliases/ids are
// alphanumerics, dashes and dots only.
var safeModel = new string(model.Where(c => char.IsLetterOrDigit(c) || c is '-' or '.').ToArray());
if (safeModel.Length == 0) safeModel = "sonnet";
// Summarising notes into bullets doesn't need the user's default model.
const string model = "haiku";
IReadOnlyList<string> args =
[
"-p", "--output-format", "stream-json", "--verbose",
"--permission-mode", PermissionModeResolver.Resolve(safeModel, "auto"),
"--model", safeModel,
"--permission-mode", PermissionModeResolver.Resolve(model, "auto"),
"--model", model,
];
var result = await _claude.RunAsync(args, prompt, Path.GetTempPath(), _ => Task.CompletedTask, ct);
if (!result.IsSuccess)