AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Fraction Decimal in the alexandrai-tools project.
Project overview
This guide covers src/tools/fraction-decimal. fractionToDecimal validates finite numerator and denominator, rejects denominator zero, rounds numerator and denominator before reducing with Euclidean GCD, normalizes sign, and returns decimal plus reduced display string. decimalToFraction rejects non-finite values, returns integer decimals as n/1, and otherwise uses precision up to 1e8 before reducing.
Primary source files
- src/tools/fraction-decimal/index.ts defines meta, gcd, FractionResult, fractionToDecimal, and decimalToFraction.
- src/tools/fraction-decimal/index.test.ts covers simple fractions, reduction, whole number results, zero denominator, negative fractions, decimal conversion, integer conversion, tenths, Infinity, and NaN.
- src/tools/fraction-decimal/Body.astro owns conversion mode, numeric inputs, and result display.
- src/tools/fraction-decimal/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
- Reject non-finite fraction inputs.
- Reject zero denominator.
- Round fraction numerator and denominator before reduction.
- Keep denominator positive and carry sign on numerator.
- Use Euclidean GCD to reduce terms.
- Return integer decimal inputs as n/1.
- Use 1e8 precision for non-integer decimal conversion.
Testing
Test reduction, negative numerator and denominator combinations, zero denominator, finite checks, integers, recurring decimals as finite approximations, precision boundaries, display strings, and UI validation.
PR checklist
- npm test passes for fraction-decimal.
- Randomness, math, lookup tables, or Unicode behavior is documented exactly.
- Browser-local behavior and copy/output paths remain private.
- Invalid inputs and edge cases are covered by tests.