AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Bill Splitter in the alexandrai-tools project.
Project overview
This guide covers src/tools/bill-splitter. splitEvenly calculates bill plus percentage tip and divides it across a person count, while splitByShares calculates the same tipped total and distributes it by each share over the sum of all shares. Both helpers return the total and a per-person array.
Primary source files
- src/tools/bill-splitter/index.ts defines meta, SplitResult, splitEvenly, and splitByShares.
- src/tools/bill-splitter/index.test.ts covers even splitting with tip, zero count, zero tip, proportional shares, share sums, and tipped share totals.
- src/tools/bill-splitter/Body.astro owns bill, tip, currency, people, share inputs, and result display.
- src/tools/bill-splitter/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
- Return an empty perPerson array and zero total when even split count is not positive.
- Calculate tipped total as bill times one plus tip percentage divided by one hundred.
- For custom shares, divide each share by the sum of all shares.
- When share sum is not positive, return zero per-person amounts but keep the tipped total.
- Preserve one per-person output for each custom share input.
- Keep currency formatting in UI code, not in pure split helpers.
- Add tests before changing rounding or settlement behavior.
Testing
Test even splits, custom shares, zero counts, zero and high tips, zero share sum, negative UI input handling, currency display, total consistency, and per-person rounding policy.
PR checklist
- npm test passes for bill-splitter.
- Calculator formulas, units, and rounding expectations are documented.
- Currency and display formatting remain outside pure helpers.
- Invalid-input behavior is covered by tests and UI validation.