feat(ai): zod due_date field + prompt {{TODAY_KST}} injection

AiResponse extends with dueDate: string|null. zod regex
^\d{4}-\d{2}-\d{2}$, follow-up roundtrip check coerces invalid
dates (2026-13-99 etc.) to null. PROMPT_VERSION → 2: prompt now
takes todayKst arg, asks model to extract due_date as ISO or null.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
altair823
2026-04-26 11:12:45 +09:00
parent 95ba1653d7
commit 4ee135dcd6
3 changed files with 65 additions and 4 deletions

View File

@@ -52,4 +52,49 @@ describe('parseAiResponse', () => {
it('rejects non-object input', () => {
expect(() => parseAiResponse('nope')).toThrow();
});
it('parses note with valid due_date', () => {
const r = parseAiResponse({
title: '내일 회의',
summary: 'a\nb\nc',
tags: [],
due_date: '2026-04-27'
});
expect(r.dueDate).toBe('2026-04-27');
});
it('null due_date passes through', () => {
const r = parseAiResponse({
title: '내일 회의',
summary: 'a\nb\nc',
tags: []
});
expect(r.dueDate).toBeNull();
});
it('explicit null due_date passes through', () => {
const r = parseAiResponse({
title: '내일 회의',
summary: 'a\nb\nc',
tags: [],
due_date: null
});
expect(r.dueDate).toBeNull();
});
it('rejects malformed due_date string', () => {
expect(() =>
parseAiResponse({ title: '내일', summary: 'a\nb\nc', tags: [], due_date: 'tomorrow' })
).toThrow();
});
it('coerces invalid date that passes regex (e.g. 2026-13-99) to null', () => {
const r = parseAiResponse({
title: '내일 회의',
summary: 'a\nb\nc',
tags: [],
due_date: '2026-13-99'
});
expect(r.dueDate).toBeNull();
});
});