feat(daily-prep): persist last prep run to a log file and serve it via GetLastPrepLog

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-06-04 09:39:11 +02:00
parent 3a40e39fc8
commit 4d82079cac
4 changed files with 48 additions and 1 deletions

View File

@@ -5,6 +5,9 @@ public static class DailyPrepPrompt
public const string CandidatesTool = "mcp__claudedo__get_daily_prep_candidates";
public const string SetMyDayTool = "mcp__claudedo__set_my_day";
public static string LogPath() =>
System.IO.Path.Combine(ClaudeDo.Data.Paths.AppDataRoot(), "logs", "daily-prep.log");
public static string BuildArgs(int maxTurns) =>
"-p --output-format stream-json --verbose --permission-mode acceptEdits " +
$"--max-turns {maxTurns} " +

View File

@@ -39,6 +39,10 @@ public sealed class PrimeRunner : IPrimeRunner
var success = false;
try
{
var logPath = DailyPrepPrompt.LogPath();
try { if (File.Exists(logPath)) File.Delete(logPath); } catch { /* best effort */ }
await using var logWriter = new LogWriter(logPath);
await _broadcaster.PrepStartedAsync();
var cwd = Paths.AppDataRoot();
@@ -62,7 +66,11 @@ public sealed class PrimeRunner : IPrimeRunner
arguments: args,
prompt: prompt,
workingDirectory: cwd,
onStdoutLine: line => _broadcaster.PrepLineAsync(line),
onStdoutLine: async line =>
{
await logWriter.WriteLineAsync(line);
await _broadcaster.PrepLineAsync(line);
},
ct: timeoutCts.Token);
success = result.IsSuccess;