AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Blood Sugar Converter in the alexandrai-tools project.
Project overview
This guide covers src/tools/blood-sugar-converter/index.ts. The tool uses a fixed factor of 18.0182 to convert mg/dL to mmol/L rounded to two decimals, and mmol/L to mg/dL rounded to the nearest integer. It is a unit conversion helper and does not provide medical interpretation.
Primary source files
- src/tools/blood-sugar-converter/index.ts defines meta, FACTOR, mgdlToMmol, and mmolToMgdl.
- src/tools/blood-sugar-converter/index.test.ts covers 100, 126, and 180 mg/dL conversions and 5.55, 7, and 10 mmol/L conversions.
- src/tools/blood-sugar-converter/Body.astro owns browser controls.
- src/tools/blood-sugar-converter/i18n.ts owns localized copy.
- src/lib/tools.ts registers metadata.
Setup commands
npm install npm test npm run typecheck npm run build npm run dev
Change rules
- Keep FACTOR as 18.0182 unless the product intentionally changes its glucose molecular weight assumption.
- Round mg/dL to mmol/L results to two decimal places.
- Round mmol/L to mg/dL results to the nearest integer.
- Do not add diagnosis or treatment interpretation to pure conversion logic.
- Keep UI copy clear that this is unit conversion only.
- If alternate rounding modes are added, keep current defaults stable.
- If input validation is added, define behavior for negative and non-finite values.
Testing
Test known glucose conversion anchors, round-trip tolerances, rounding boundaries, zero, decimal mmol/L input, negative input if supported, and any future validation or copy changes.
PR checklist
- npm test passes for blood-sugar-converter.
- Unit constants, lookup tables, and rounding rules are covered by tests.
- Same-unit and invalid-input behavior remain documented.
- UI labels, metadata, and pure conversion logic stay in sync.