AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Reverse Text in the alexandrai-tools project.
Project overview
This guide covers src/tools/reverse-text/index.ts. The tool returns empty input unchanged, reverses characters with code-point spread syntax, reverses words within each line while preserving whitespace tokens, and reverses line order by splitting on newline characters.
Primary source files
- src/tools/reverse-text/index.ts defines meta, ReverseMode, and reverseText.
- src/tools/reverse-text/index.test.ts covers character reversal, Unicode code points, word reversal, spacing preservation, line reversal, and empty input.
- src/tools/reverse-text/Body.astro owns browser controls.
- src/tools/reverse-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
- Return falsy empty text unchanged.
- Use code-point spread for character reversal.
- Reverse words per line, not across the whole text.
- Split word mode on captured whitespace so spacing tokens remain.
- Reverse lines by newline splitting only.
- Do not mutate or normalize input text outside the selected mode.
- If grapheme cluster support is added, test emoji sequences and combining marks.
Testing
Test chars, words, lines, empty input, Unicode code points, combining marks if supported, multiple spaces, tabs, multiple lines, trailing newline behavior, and unsupported mode exhaustiveness.
PR checklist
- npm test passes for reverse-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.