AGENTS.md
Guidance for coding agents working on AlexandrAI Tools GPA Calculator in the alexandrai-tools project.
Project overview
This guide covers src/tools/gpa-calculator. GRADE_POINTS maps letter grades to a 4.0 scale, GRADE_OPTIONS derives choices from the map, and calculateGpa filters rows to valid grades with positive credits before computing total points, total credits, and weighted GPA.
Primary source files
- src/tools/gpa-calculator/index.ts defines meta, GRADE_POINTS, GRADE_OPTIONS, CourseRow, GpaResult, and calculateGpa.
- src/tools/gpa-calculator/index.test.ts covers straight A rows, weighted average math, A+ and A mapping, F mapping, zero-credit filtering, invalid-grade filtering, empty-row errors, and A-minus mapping.
- src/tools/gpa-calculator/Body.astro owns course rows, add and remove controls, and result rendering.
- src/tools/gpa-calculator/i18n.ts owns localized labels.
- 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
- Filter out rows with non-positive credits.
- Filter out rows whose grade is not in GRADE_POINTS.
- Return ok false with an error when no valid rows remain.
- Compute total points as grade points times credits.
- Compute GPA as total points divided by total credits.
- Keep GRADE_OPTIONS derived from GRADE_POINTS.
- Add tests when grade mappings or grading scales change.
Testing
Test grade mapping, weighted averages, zero credits, invalid grades, empty rows, fractional credits if UI permits them, row add/remove behavior, error text, and displayed rounding.
PR checklist
- npm test passes for gpa-calculator.
- Calculator formulas, units, and rounding rules are documented.
- Health and fitness outputs keep informational safety scope.
- UI labels, validation, and pure helper tests stay aligned.