AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Color Converter in the alexandrai-tools project.
Project overview
This guide covers src/tools/color-converter/index.ts. The tool parses hex shorthand and full hex, converts RGB to lowercase hex, converts RGB to rounded HSL, converts HSL back to RGB, and accepts hex, rgb, or hsl input through parseColor.
Primary source files
- src/tools/color-converter/index.ts defines meta, hexToRgb, rgbToHex, rgbToHsl, hslToRgb, and parseColor.
- src/tools/color-converter/index.test.ts covers hex parsing, invalid input, lowercase hex output, RGB-HSL conversions, and parseColor variants.
- src/tools/color-converter/Body.astro owns browser inputs and result display.
- src/tools/color-converter/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
- Accept three-digit and six-digit hex and reject other lengths.
- Return lowercase six-digit hex from rgbToHex.
- Keep RGB channels in the zero through 255 range when parsing rgb input.
- Keep HSL saturation and lightness in the zero through one hundred range when parsing hsl input.
- Return null for unparseable or empty input rather than throwing.
- Keep conversion helpers pure and browser-independent.
- When adding alpha support, update all output formats and tests together.
Testing
Test shorthand hex, full hex, mixed case, invalid values, RGB to hex, RGB to HSL, HSL to RGB, parseColor for each input family, boundary values, and alpha behavior if introduced.
PR checklist
- npm test passes for color-converter.
- Pure string or color logic stays independent from DOM preview code.
- Generated CSS remains copy-ready.
- Browser-local behavior is preserved.