AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Exponent Calculator in the alexandrai-tools project.
Project overview
This guide covers src/tools/exponent-calculator/index.ts. The tool delegates powers to Math.pow, computes nth roots as x raised to one divided by n, returns NaN for zero root degree, returns NaN for even roots of negative values, and handles odd roots of negative values by applying the sign manually.
Primary source files
- src/tools/exponent-calculator/index.ts defines meta, power, and nthRoot.
- src/tools/exponent-calculator/index.test.ts covers positive powers, negative exponents, zero exponents, square roots, cube roots, fourth roots, odd roots of negative values, even roots of negative values, and zero-degree roots.
- src/tools/exponent-calculator/Body.astro owns browser controls.
- src/tools/exponent-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
- Keep power as Math.pow(base, exp).
- Return NaN for nthRoot when n is zero.
- Return NaN for even roots of negative x.
- Return the negative root for odd roots of negative x.
- Do not round in pure helpers.
- Let JavaScript numeric behavior surface for overflow unless UI validates it.
- If complex roots are added, expose a separate result type rather than changing nthRoot.
Testing
Test positive powers, zero exponent, negative exponent, fractional exponents, square and cube roots, odd roots of negative numbers, even roots of negative numbers, n equals zero, large exponents, and non-finite input behavior.
PR checklist
- npm test passes for exponent-calculator.
- Return types, edge cases, and numeric limits remain documented.
- Pure math helpers stay browser-local and side-effect free.
- UI labels, metadata, and tests update together for behavior changes.