namespace ClaudeDo.Worker.Prime;

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 IReadOnlyList<string> BuildArgs(int maxTurns) =>
    [
        "-p", "--output-format", "stream-json", "--verbose",
        "--permission-mode", "acceptEdits",
        "--max-turns", maxTurns.ToString(),
        "--allowedTools", CandidatesTool, SetMyDayTool,
    ];

    public static string BuildPrompt(int maxTasks, DateOnly today, string? promptOverride = null)
    {
        var prompt = ClaudeDo.Data.PromptFiles.Render(
            ClaudeDo.Data.PromptKind.DailyPrep,
            new Dictionary<string, string>
            {
                ["date"] = today.ToString("yyyy-MM-dd"),
                ["maxTasks"] = maxTasks.ToString(),
            });

        // Additive by design: a schedule's override is appended, never substituted, so a user
        // can't accidentally break the mcp__claudedo__get_daily_prep_candidates/set_my_day flow.
        return string.IsNullOrWhiteSpace(promptOverride) ? prompt : $"{prompt}\n\n{promptOverride}";
    }
}
