AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Word Counter in the alexandrai-tools project.
Project overview
This guide covers src/tools/word-counter/index.ts. The tool computes word count from trimmed whitespace tokens, counts characters by code point, counts non-whitespace characters, detects sentence terminators, counts paragraphs separated by blank lines, counts lines, and estimates reading time at two hundred words per minute rounded up.
Primary source files
- src/tools/word-counter/index.ts defines meta, TextStats, and analyze.
- src/tools/word-counter/index.test.ts covers empty input, simple words and sentences, emoji code point counting, characters without spaces, paragraphs, lines, reading time, multiple terminators, and whitespace-only input.
- src/tools/word-counter/Body.astro owns browser controls.
- src/tools/word-counter/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 zeros for empty input.
- Count words from trimmed whitespace-separated tokens.
- Count characters by iterating code points.
- Exclude all whitespace from charactersNoSpaces.
- Count sentences only when terminators appear.
- Count paragraphs by blank-line separation.
- Round reading time up from two hundred words per minute.
Testing
Test empty and whitespace-only input, words, characters, emoji, no-space characters, sentence terminators, no-terminator text, paragraph boundaries, line counts, and reading time thresholds at 199, 200, and 201 words.
PR checklist
- npm test passes for word-counter.
- Browser-local text processing remains browser-local.
- Existing option defaults and edge-case semantics stay documented.
- UI copy, metadata, and tests are updated together for behavior changes.