AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools Distance Calculator Agent Guide

Agent guide for Euclidean distance and midpoint calculation between two 2D points.

AGENTS.md

Guidance for coding agents working on AlexandrAI Tools Distance Calculator in the alexandrai-tools project.

Project overview

This guide covers src/tools/distance-calculator/index.ts. The tool rejects NaN and non-finite coordinates, computes Euclidean distance from coordinate deltas, and returns midpoint x and y averages for valid inputs.

Primary source files

  • src/tools/distance-calculator/index.ts defines meta, DistanceResult, and calcDistance.
  • src/tools/distance-calculator/index.test.ts covers 3-4-5 distances, identical points, negative coordinates, offset points, NaN input, and non-finite input.
  • src/tools/distance-calculator/Body.astro owns browser controls.
  • src/tools/distance-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.
  • Return ok false when any coordinate is non-finite.
  • Compute distance with square root of squared deltas.
  • Compute midX as the average of x coordinates.
  • Compute midY as the average of y coordinates.
  • Return zero distance for identical points.
  • Do not round in pure logic.

Testing

Test origin and offset 3-4-5 cases, identical points, negative coordinates, fractional coordinates, NaN, Infinity, midpoint signs, zero distance, and UI formatting.

PR checklist

  • npm test passes for distance-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.