registry/scripts/lint-agent-names.sh
blink-so[bot] 492b38cc81 feat: Add linting script for coder_agent naming conventions
Add a simple bash script that validates module documentation uses
coder_agent.main consistently. This can be integrated into CI to
prevent future inconsistencies.

The script checks:
- Module README files use coder_agent.main
- Example templates use coder_agent.main
- Root documentation uses coder_agent.main

Usage: ./scripts/lint-agent-names.sh
2025-11-26 19:09:38 +00:00

63 lines
2.1 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
# Script to validate coder_agent naming conventions across the registry
# This ensures consistency between templates and module documentation
ERRORS=0
echo "🔍 Linting coder_agent naming conventions..."
echo ""
# Check 1: Module README files should use coder_agent.main
echo "📝 Checking module README files..."
if grep -r 'coder_agent\.' registry/*/modules/*/README.md 2> /dev/null | grep -v 'coder_agent\.main' | grep -v 'agent_id' | grep -v 'coder_agent\.id' | grep -v '# ' | grep -E 'coder_agent\.[a-z_]+'; then
echo "❌ ERROR: Module READMEs should reference 'coder_agent.main' in examples"
echo " Found references to other agent names above."
ERRORS=$((ERRORS + 1))
else
echo "✅ All module READMEs use 'coder_agent.main'"
fi
echo ""
# Check 2: Examples should use coder_agent.main
echo "📝 Checking example files..."
if [ -f "examples/templates/main.tf" ]; then
if grep -q 'coder_agent\.' examples/templates/main.tf | grep -v 'coder_agent\.main' 2> /dev/null; then
echo "❌ ERROR: examples/templates/main.tf should use 'coder_agent.main'"
ERRORS=$((ERRORS + 1))
else
echo "✅ Example template uses 'coder_agent.main'"
fi
fi
echo ""
# Check 3: Root documentation should use coder_agent.main
echo "📝 Checking root documentation..."
FILES_TO_CHECK=("README.md" "CONTRIBUTING.md")
for file in "${FILES_TO_CHECK[@]}"; do
if [ -f "$file" ]; then
if grep 'coder_agent\.' "$file" 2> /dev/null | grep -v 'coder_agent\.main' | grep -v '# ' | grep -v 'agent_id' | grep -v 'coder_agent\.id' | grep -E 'coder_agent\.[a-z_]+' > /dev/null 2>&1; then
echo "❌ ERROR: $file should use 'coder_agent.main' in examples"
ERRORS=$((ERRORS + 1))
fi
fi
done
if [ $ERRORS -eq 0 ]; then
echo "✅ All documentation uses 'coder_agent.main'"
fi
echo ""
# Summary
if [ $ERRORS -eq 0 ]; then
echo "✅ All linting checks passed!"
exit 0
else
echo "❌ Found $ERRORS linting error(s)"
echo ""
echo " Module documentation should use 'coder_agent.main' in examples"
echo " to match the most common template convention (78% of templates)."
exit 1
fi