AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Mirror Text in the alexandrai-tools project.
Project overview
This guide covers src/tools/mirror-text/index.ts. The tool defines a small mirror character map, reverses strings with code-point spread syntax, mirrors by reversing then substituting mapped characters, reverses word order by captured whitespace, and routes processText through reverse, mirror, or reverseWords mode.
Primary source files
- src/tools/mirror-text/index.ts defines meta, MirrorMode, MIRROR_MAP, reverse, mirror, reverseWords, and processText.
- src/tools/mirror-text/index.test.ts covers reverse behavior, Unicode safety, mirror substitutions, empty input, reverseWords, processText routing, and map entries.
- src/tools/mirror-text/Body.astro owns browser controls.
- src/tools/mirror-text/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
- Use code-point spread for reverse and mirror.
- Apply mirror substitutions after reversing.
- Keep MIRROR_MAP explicit and small.
- Reverse word order with captured whitespace tokens.
- Return empty input unchanged from processText.
- Route processText directly to the matching helper.
- If broader mirrored Unicode output is added, preserve current ASCII map tests.
Testing
Test reverse, mirror, reverseWords, empty input, Unicode code points, mapped punctuation, mapped letters, unmapped characters, processText routing, whitespace preservation, and map expansion.
PR checklist
- npm test passes for mirror-text.
- Encoding, decoding, and failure behavior remain documented.
- Browser-local processing and security limits stay clear in UI copy.
- UI labels, metadata, and tests update together for behavior changes.