AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools JSON Formatter Agent Guide

Project-specific AGENTS.md guidance for the AlexandrAI Tools JSON formatter, pure processJson logic, friendly syntax errors, formatter and minifier modes, and Vitest coverage.

AGENTS.md

Guidance for coding agents working on the AlexandrAI Tools JSON formatter.

Project Overview

The JSON formatter is a representative developer utility. Its index.ts keeps parsing, formatting, minifying, and friendly error reporting as pure logic. The UI layer should only pass input, mode, and indent choices into processJson() and render the result.

Project Map

  • src/tools/json-formatter/index.ts defines meta, JsonMode, JsonResult, processJson(), friendlyError(), and lineCol().
  • src/tools/json-formatter/index.test.ts covers two-space formatting, four-space formatting, minify mode, invalid JSON, blank input, and Unicode preservation.
  • src/tools/json-formatter/i18n.ts provides localized copy.
  • src/tools/json-formatter/Body.astro wires browser input and output.
  • src/lib/dom.ts provides shared client helpers such as element lookup, debounce, and copy feedback.

Setup Commands

bashnpm test -- src/tools/json-formatter/index.test.ts
npm run typecheck
npm run build

Change Rules For Agents

  • Keep JSON parsing and serialization in processJson().
  • Treat blank input as a valid no-op.
  • Preserve Unicode through format and minify operations.
  • Keep error messages friendly and include line and column when available.
  • Do not put DOM access in index.ts.
  • Add tests before changing parser behavior.
  • Keep meta keywords focused on actual JSON formatter use cases.
  • Keep output deterministic for stable tests.

Verification

bashnpm test -- src/tools/json-formatter/index.test.ts
npm run typecheck

Manual UI checks should cover invalid JSON, large nested JSON, minify mode, indent switching, copy output, and blank input.

Security Notes

JSON content must stay in the browser. Do not add upload, server logging, analytics payloads containing input, or remote formatting services.

PR Checklist

  • Pure logic remains DOM-free.
  • Existing formatter tests pass.
  • New edge cases have tests.
  • UI copy still says nothing is uploaded.
  • Typecheck passes.