AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Slope Calculator in the alexandrai-tools project.
Project overview
This guide covers src/tools/slope-calculator/index.ts. The tool validates NaN inputs, computes point distance and angle for all valid inputs, returns slope and y-intercept for non-vertical lines, and returns null slope and null intercept with vertical true when x coordinates match.
Primary source files
- src/tools/slope-calculator/index.ts defines meta, SlopeResult, and calcSlope.
- src/tools/slope-calculator/index.test.ts covers slope and intercept, vertical lines, 3-4-5 distance, negative slope, horizontal angle, and NaN errors.
- src/tools/slope-calculator/Body.astro owns browser controls.
- src/tools/slope-calculator/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
- Return ok false when any coordinate is NaN.
- Compute distance for valid coordinates before vertical handling.
- Compute angle with Math.atan2 in degrees.
- Return slope null and intercept null for vertical lines.
- Set vertical true only when x1 equals x2.
- Compute slope as delta y divided by delta x for non-vertical lines.
- Compute intercept as y1 minus slope times x1.
Testing
Test positive, negative, zero, and undefined slopes, vertical lines, horizontal lines, point equality, distance, angle quadrants, NaN inputs, Infinity behavior if validation changes, and UI equation formatting.
PR checklist
- npm test passes for slope-calculator.
- Validation, formatting, and numeric precision behavior remain documented.
- Pure helpers stay browser-local and side-effect free.
- UI labels, metadata, and tests update together for behavior changes.