AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Hash Generator in the alexandrai-tools project.
Project overview
This guide covers src/tools/hash-generator/index.ts. The tool exposes a fixed list of SHA algorithms and hashes text through globalThis.crypto.subtle.digest, returning lowercase hexadecimal output. Empty input is valid and must continue to produce the standard digest for an empty byte array.
Primary source files
- src/tools/hash-generator/index.ts defines meta, ALGOS, and hashHex.
- src/tools/hash-generator/index.test.ts covers known vectors, output lengths, lowercase hex, and algorithm list coverage.
- src/tools/hash-generator/Body.astro owns browser input, algorithm selection, and result display.
- src/tools/hash-generator/i18n.ts owns localized page copy.
- src/lib/tools.ts auto-discovers tool metadata.
Setup commands
npm install npm test npm run typecheck npm run build npm run dev
Change rules
- Keep ALGOS as the source of truth for selectable algorithms.
- Use TextEncoder before hashing so Unicode input is encoded consistently as UTF-8.
- Return lowercase hex with two characters per byte.
- Treat empty strings as valid input rather than an error.
- Do not label unsalted hashes as password storage guidance.
- Do not add remote hashing services; this utility should remain browser-local.
- When adding algorithms, confirm browser Web Crypto support and add vector or length tests.
Testing
Test known digest vectors, empty string digest, output length for each algorithm, lowercase hex characters, algorithm list rendering, and error handling if unsupported algorithms become user-configurable.
PR checklist
- npm test passes for hash-generator.
- Output stays lowercase hex.
- Empty input remains valid.
- UI copy does not imply password-storage safety.