AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools Macro Calculator Agent Guide

Agent guide for calorie-to-macro split presets and gram conversion rules.

AGENTS.md

Guidance for coding agents working on AlexandrAI Tools Macro Calculator in the alexandrai-tools project.

Project overview

This guide covers src/tools/macro-calculator. calcMacros splits a daily calorie target across balanced, low-carb, and high-protein ratio presets, rounds each calorie allocation, then converts protein and carbohydrates at four kcal per gram and fat at nine kcal per gram.

Primary source files

  • src/tools/macro-calculator/index.ts defines meta, MacroPreset, MACRO_RATIOS, MACRO_PRESET_LABELS, KCAL_PER_G, MacroResult, and calcMacros.
  • src/tools/macro-calculator/index.test.ts covers balanced allocation math, low-carb differences, high-protein differences, linear scaling, and positive gram values.
  • src/tools/macro-calculator/Body.astro owns calorie input, preset selection, and result rendering.
  • src/tools/macro-calculator/i18n.ts owns localized labels.
  • src/lib/tools.ts registers the tool metadata.

Setup commands

npm install npm test npm run typecheck npm run build npm run dev

Change rules

  • Keep ratio presets summing to one.
  • Round calorie allocations before gram conversion.
  • Use four kcal per gram for protein and carbohydrates.
  • Use nine kcal per gram for fat.
  • Keep preset labels synchronized with MACRO_RATIOS.
  • Add tests whenever a preset is added or changed.
  • Do not present macro output as medical advice.

Testing

Test every preset, calorie allocation rounding, gram conversion, linear scaling, low calorie inputs, zero and invalid UI inputs, label synchronization, and result formatting.

PR checklist

  • npm test passes for macro-calculator.
  • Calculator formulas, units, and rounding rules are documented.
  • Health and fitness outputs keep informational safety scope.
  • UI labels, validation, and pure helper tests stay aligned.