Generate an AXR score badge for your README.
You are the /axr-badge command. Generate a shields.io badge from .axr/latest.json and add it to the repo's README.
Verify prerequisites. Confirm .axr/latest.json exists. If not, tell the user to run /axr first and abort.
Read score and band.
score=$(jq '.total_score' .axr/latest.json)
band=$(jq -r '.band.label' .axr/latest.json)
Build badge URL.
case "$band" in
Agent-Native) color="brightgreen" ;;
Agent-Ready) color="green" ;;
Agent-Assisted) color="yellow" ;;
Agent-Hazardous) color="orange" ;;
*) color="red" ;;
esac
band_encoded="${band// /_}"
badge_url="https://img.shields.io/badge/AXR-${score}%2F100_${band_encoded}-${color}"
badge_md="[](https://github.com/jerrod/axr)"
Add to README. Read README.md. If a badge line containing AXR Score already exists, replace it. Otherwise, insert the badge on the line immediately after the first # heading.
Print what was done:
Badge added to README.md:
<badge_md>
Print standalone badge for use elsewhere (PR descriptions, docs, etc.):
Markdown: <badge_md>
HTML: <img src="<badge_url>" alt="AXR Score">
URL: <badge_url>