AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools Factorial Calculator Agent Guide

Agent guide for exact BigInt factorials with whole-number, negative, and maximum-size guards.

AGENTS.md

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

Project overview

This guide covers src/tools/factorial-calculator/index.ts. The tool returns a structured FactorialResult, rejects non-integers, rejects negative numbers, caps n above ten thousand to protect the browser, computes factorial with BigInt multiplication, and returns the decimal string form.

Primary source files

  • src/tools/factorial-calculator/index.ts defines meta, FactorialResult, and factorial.
  • src/tools/factorial-calculator/index.test.ts covers zero, one, small factorials, exact 20 factorial, 100 factorial shape, negative input, non-integer input, over-limit input, and n equal to ten thousand.
  • src/tools/factorial-calculator/Body.astro owns browser controls.
  • src/tools/factorial-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

  • Reject non-integer input with ok false.
  • Reject negative input with ok false.
  • Reject n greater than 10000 with ok false.
  • Accept n equal to 10000.
  • Use BigInt for exact multiplication.
  • Return value as a string.
  • Keep error messages stable enough for UI expectations.

Testing

Test 0, 1, small factorials, exact large values, trailing zeros, maximum accepted n, over-limit n, negative n, non-integer n, non-finite inputs, and UI progress or blocking behavior if added.

PR checklist

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