feat(prime): add PrimeActionKind to the schedule entity

This commit is contained in:
mika kuns
2026-08-25 08:29:40 +02:00
parent 3003cfa561
commit 022eaf385c
5 changed files with 69 additions and 56 deletions
@@ -1,11 +1,27 @@
using ClaudeDo.Data.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ClaudeDo.Data.Configuration;
public class PrimeScheduleEntityConfiguration : IEntityTypeConfiguration<PrimeScheduleEntity>
{
private static string KindToString(PrimeActionKind v)
=> v == PrimeActionKind.Ping ? "ping"
: v == PrimeActionKind.FillMyDay ? "fill_my_day"
: v == PrimeActionKind.Custom ? "custom"
: throw new ArgumentOutOfRangeException(nameof(v));
private static PrimeActionKind KindFromString(string v)
=> v == "ping" ? PrimeActionKind.Ping
: v == "fill_my_day" ? PrimeActionKind.FillMyDay
: v == "custom" ? PrimeActionKind.Custom
: throw new ArgumentOutOfRangeException(nameof(v));
private static readonly ValueConverter<PrimeActionKind, string> KindConverter =
new(v => KindToString(v), v => KindFromString(v));
public void Configure(EntityTypeBuilder<PrimeScheduleEntity> builder)
{
builder.ToTable("prime_schedules");
@@ -15,6 +31,9 @@ public class PrimeScheduleEntityConfiguration : IEntityTypeConfiguration<PrimeSc
builder.Property(s => s.Days).HasColumnName("days_of_week")
.IsRequired().HasDefaultValue(PrimeDays.Weekdays);
builder.Property(s => s.Kind).HasColumnName("action_kind")
.IsRequired().HasDefaultValue(PrimeActionKind.Ping)
.HasConversion(KindConverter);
builder.Property(s => s.TimeOfDay).HasColumnName("time_of_day").IsRequired();
builder.Property(s => s.Enabled).HasColumnName("enabled").IsRequired().HasDefaultValue(true);
builder.Property(s => s.LastRunAt).HasColumnName("last_run_at");
@@ -0,0 +1,12 @@
namespace ClaudeDo.Data.Models;
/// <summary>What a Prime schedule actually does when it fires.</summary>
public enum PrimeActionKind
{
/// <summary>One throwaway turn that only opens the usage window. Default for new schedules.</summary>
Ping,
/// <summary>Run the daily prep prompt and let Claude fill MyDay.</summary>
FillMyDay,
/// <summary>Run the schedule's own prompt with the ClaudeDo MCP tools available.</summary>
Custom
}
@@ -4,6 +4,7 @@ public sealed class PrimeScheduleEntity
{
public Guid Id { get; set; } = Guid.NewGuid();
public PrimeDays Days { get; set; } = PrimeDays.Weekdays;
public PrimeActionKind Kind { get; set; } = PrimeActionKind.Ping;
public TimeSpan TimeOfDay { get; set; }
public bool Enabled { get; set; } = true;
public DateTimeOffset? LastRunAt { get; set; }
@@ -32,6 +32,7 @@ public sealed class PrimeScheduleRepository
existing.TimeOfDay = entity.TimeOfDay;
existing.Enabled = entity.Enabled;
existing.PromptOverride = entity.PromptOverride;
existing.Kind = entity.Kind;
}
await _context.SaveChangesAsync(ct);
}