AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Download Time Calculator in the alexandrai-tools project.
Project overview
This guide covers src/tools/download-time-calculator. calculateDownloadTime validates positive finite file size and speed, converts decimal file units to bytes, converts bit or byte speed units to bits per second, calculates seconds from bits divided by bps, and formats duration as h:mm:ss with fractional seconds truncated.
Primary source files
- src/tools/download-time-calculator/index.ts defines meta, FileSizeUnit, SpeedUnit, DownloadResult, unit converters, formatDuration, and calculateDownloadTime.
- src/tools/download-time-calculator/index.test.ts covers MB at Mbps, GB at Gbps, MBps conversion, Kbps, GBps, zero size, zero speed, negative size, duration formatting, and fractional-second truncation.
- src/tools/download-time-calculator/Body.astro owns file-size inputs, speed inputs, unit selectors, and result display.
- src/tools/download-time-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
- Reject non-finite file sizes.
- Reject file sizes less than or equal to zero.
- Reject non-finite speeds.
- Reject speeds less than or equal to zero.
- Use decimal unit powers, not binary unit powers.
- Convert byte-per-second units to bits per second by multiplying by eight.
- Format duration by flooring total seconds.
Testing
Test every file unit, every speed unit, zero and negative values, fractional seconds, long durations, exact h:mm:ss formatting, displayed errors, and unit label copy.
PR checklist
- npm test passes for download-time-calculator.
- 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.