AGENTS.md
Guidance for coding agents working on AlexandrAI Tools YAML to JSON in the alexandrai-tools project.
Project overview
This guide covers src/tools/yaml-to-json/index.ts. The tool trims input, treats blank input as a valid empty result, parses YAML through js-yaml, and serializes the parsed value with JSON.stringify using a configurable indentation value.
Primary source files
- src/tools/yaml-to-json/index.ts defines meta, ConvertResult, and toJson.
- src/tools/yaml-to-json/index.test.ts covers simple YAML, invalid YAML, and empty input.
- src/tools/yaml-to-json/Body.astro owns browser input and output.
- src/tools/yaml-to-json/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
- Keep blank input as ok true with empty output.
- Return ok false with an Invalid YAML prefix when js-yaml throws.
- Keep indentation explicit and tested when the UI exposes it.
- Do not execute tags or custom schemas without a security review.
- Do not upload pasted YAML.
- Preserve ConvertResult shape for the UI.
- When changing parser options, add tests for aliases, null values, and nested structures.
Testing
Test mappings, arrays, nested values, nulls, booleans, invalid syntax, empty input, whitespace-only input, indentation variants, and parser option changes.
PR checklist
- npm test passes for yaml-to-json.
- Invalid YAML returns a structured error.
- JSON output is formatted consistently.
- No remote parsing is introduced.