AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools Unit Converter Agent Guide

Agent guide for combined length, weight, temperature, and volume conversion with six significant figures.

AGENTS.md

Guidance for coding agents working on AlexandrAI Tools Unit Converter in the alexandrai-tools project.

Project overview

This guide covers src/tools/unit-converter/index.ts. The tool groups units by length, weight, temperature, and volume. Non-temperature categories use meter, gram, or liter base factors and temperature uses Celsius as an intermediate. Converted values are rounded to six significant figures.

Primary source files

  • src/tools/unit-converter/index.ts defines meta, UNITS, LENGTH_TO_M, WEIGHT_TO_G, VOLUME_TO_L, sigFig, and convert.
  • src/tools/unit-converter/index.test.ts covers km to m, mi to km, kg to lb, Celsius to Fahrenheit, Celsius to Kelvin, liters to milliliters, Fahrenheit to Celsius, cm to mm, lb to oz, and identity conversion.
  • src/tools/unit-converter/Body.astro owns browser controls.
  • src/tools/unit-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 categories aligned with UNITS: length, weight, temperature, and volume.
  • Use meter as length base, gram as weight base, and liter as volume base.
  • Use Celsius as the temperature intermediate.
  • Round converted non-identity results to six significant figures.
  • Return same-unit values unchanged.
  • Do not silently mix units across categories in UI code.
  • If missing factors are encountered, current pure logic falls back to one; add validation before relying on that behavior.

Testing

Test length, weight, temperature, and volume representative conversions, identity, six significant figure rounding, missing-factor validation if added, metric and imperial units, zero, negative temperature, and category-switching UI behavior.

PR checklist

  • npm test passes for unit-converter.
  • Conversion constants remain traceable and tested.
  • Identity conversions and rounding behavior remain documented.
  • UI labels, unit arrays, and pure conversion logic stay in sync.