AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Smoking Cost Calculator in the alexandrai-tools project.
Project overview
This guide covers src/tools/smoking-cost-calculator. calcSmokingCost divides cigarettes per day by pack size, multiplies by price per pack, then derives monthly cost with 30.4375 days, yearly cost with 365 days, and ten-year cost from yearly cost.
Primary source files
- src/tools/smoking-cost-calculator/index.ts defines meta, SmokingCost, and calcSmokingCost.
- src/tools/smoking-cost-calculator/index.test.ts covers one-pack-per-day cost, half-pack cost, ten-year derivation, monthly multiplier, and zero pack size.
- src/tools/smoking-cost-calculator/Body.astro owns cigarette, pack, price, currency, and result display.
- src/tools/smoking-cost-calculator/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 zeros when pack size is not positive.
- Calculate daily cost from cigarettes per day divided by pack size times price per pack.
- Use 30.4375 days for monthly cost.
- Use 365 days for yearly cost.
- Calculate ten-year cost as yearly cost times ten.
- Keep currency formatting in UI code.
- Do not present cost output as cessation medical advice.
Testing
Test daily, monthly, yearly, and ten-year values, zero pack size, zero cigarettes, zero price, high usage, negative UI input handling, currency display, and health-scope copy.
PR checklist
- npm test passes for smoking-cost-calculator.
- 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.