AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Sort Lines in the alexandrai-tools project.
Project overview
This guide covers src/tools/sort-lines/index.ts. The tool splits text on newline boundaries, optionally trims lines, optionally removes empty lines, optionally deduplicates with case-sensitive or case-insensitive keys, then sorts ascending, sorts descending, or reverses current order.
Primary source files
- src/tools/sort-lines/index.ts defines meta, SortOptions, and processLines.
- src/tools/sort-lines/index.test.ts covers ascending sort, descending sort, dedupe, numeric sort, case-insensitive sort, reverse, and empty-line removal.
- src/tools/sort-lines/Body.astro owns browser controls.
- src/tools/sort-lines/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
- Split input on LF and CRLF boundaries.
- Apply trimLines before empty-line removal and dedupe.
- Dedupe by first occurrence after preprocessing.
- Use lowercase dedupe keys only when caseInsensitive is true.
- When numeric is true, compare numerically only if both parsed values are numbers.
- Reverse mode reverses the current line order without sorting.
- Keep output joined with LF characters.
Testing
Test ascending, descending, reverse, dedupe before sort, case-insensitive dedupe, trim before dedupe, empty-line removal, numeric fallback for mixed data, CRLF input, and stable first-occurrence expectations.
PR checklist
- npm test passes for sort-lines.
- 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.