AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Pregnancy Due Date in the alexandrai-tools project.
Project overview
This guide covers src/tools/pregnancy-due-date. calcDueDate parses LMP and reference dates as UTC epoch days, estimates due date as LMP plus 280 days, rejects malformed date strings and reference dates before LMP, and reports gestational weeks plus days from elapsed days.
Primary source files
- src/tools/pregnancy-due-date/index.ts defines meta, DueDateResult, isoToEpochDay, addDays, and calcDueDate.
- src/tools/pregnancy-due-date/index.test.ts covers 280-day addition, leap year handling, two-week output, 10 weeks 3 days, invalid LMP, reference before LMP, and reference equal to LMP.
- src/tools/pregnancy-due-date/Body.astro owns LMP/reference inputs and result display.
- src/tools/pregnancy-due-date/i18n.ts owns localized labels and health-scope copy.
- src/lib/tools.ts registers the tool metadata.
Setup commands
npm install npm test npm run typecheck npm run build npm run dev
Change rules
- Estimate due date as LMP plus 280 days.
- Use UTC date arithmetic for due-date addition.
- Default blank reference date to the LMP day in the pure helper.
- Reject malformed LMP strings.
- Reject malformed reference-date strings.
- Reject reference dates before LMP.
- Keep due-date output framed as an estimate.
Testing
Test Naegele date addition, leap years, reference equal to LMP, gestational weeks and days, reference before LMP, malformed inputs, blank reference behavior, and health disclaimer copy.
PR checklist
- npm test passes for pregnancy-due-date.
- Date, random, or hash behavior is documented exactly as implemented.
- Health outputs remain framed as estimates, not medical decisions.
- UI labels, validation, and pure helper tests stay aligned.