feat(notes): add_note MCP tool with a per-day agent cap
Agents can write into the user's daily notes, but only within limits: max 10 agent notes a day, max 500 characters, add only — no edit, no delete. A new from_agent column separates their lines from the user's so the cap counts the right ones and the UI can mark them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
cf093e3178
commit
ae0c7d3771
@@ -22,7 +22,13 @@ public sealed class DailyNoteRepository
|
||||
.OrderBy(n => n.Date).ThenBy(n => n.SortOrder)
|
||||
.ToListAsync(ct);
|
||||
|
||||
public async Task<DailyNoteEntity> AddAsync(DateOnly day, string text, CancellationToken ct = default)
|
||||
/// <summary>Notes an agent wrote on <paramref name="day"/> — the number the MCP cap counts against.</summary>
|
||||
public async Task<int> CountAgentNotesAsync(DateOnly day, CancellationToken ct = default) =>
|
||||
await _context.DailyNotes.AsNoTracking()
|
||||
.CountAsync(n => n.Date == day && n.FromAgent, ct);
|
||||
|
||||
public async Task<DailyNoteEntity> AddAsync(
|
||||
DateOnly day, string text, bool fromAgent = false, CancellationToken ct = default)
|
||||
{
|
||||
var nextOrder = await _context.DailyNotes
|
||||
.Where(n => n.Date == day)
|
||||
@@ -34,6 +40,7 @@ public sealed class DailyNoteRepository
|
||||
Date = day,
|
||||
Text = text,
|
||||
SortOrder = nextOrder + 1,
|
||||
FromAgent = fromAgent,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
};
|
||||
_context.DailyNotes.Add(note);
|
||||
|
||||
Reference in New Issue
Block a user