|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Test that AGENTS.md symlink works for Cursor and other AI tools |
| 4 | +# This validates that: |
| 5 | +# 1. AGENTS.md exists and is a valid symlink |
| 6 | +# 2. It points to CLAUDE.md |
| 7 | +# 3. Content is readable and identical to CLAUDE.md |
| 8 | +# 4. File is tracked by git correctly |
| 9 | + |
| 10 | +set -e |
| 11 | + |
| 12 | +echo "Testing AGENTS.md symlink..." |
| 13 | + |
| 14 | +# Test 1: Check that AGENTS.md exists |
| 15 | +echo -n "✓ Checking AGENTS.md exists... " |
| 16 | +if [ ! -e AGENTS.md ]; then |
| 17 | + echo "FAILED" |
| 18 | + echo "Error: AGENTS.md does not exist" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | +echo "OK" |
| 22 | + |
| 23 | +# Test 2: Check that AGENTS.md is a symlink |
| 24 | +echo -n "✓ Checking AGENTS.md is a symlink... " |
| 25 | +if [ ! -L AGENTS.md ]; then |
| 26 | + echo "FAILED" |
| 27 | + echo "Error: AGENTS.md is not a symlink" |
| 28 | + exit 1 |
| 29 | +fi |
| 30 | +echo "OK" |
| 31 | + |
| 32 | +# Test 3: Check that symlink points to CLAUDE.md |
| 33 | +echo -n "✓ Checking symlink target is CLAUDE.md... " |
| 34 | +TARGET=$(readlink AGENTS.md) |
| 35 | +if [ "$TARGET" != "CLAUDE.md" ]; then |
| 36 | + echo "FAILED" |
| 37 | + echo "Error: AGENTS.md points to '$TARGET', expected 'CLAUDE.md'" |
| 38 | + exit 1 |
| 39 | +fi |
| 40 | +echo "OK" |
| 41 | + |
| 42 | +# Test 4: Check that CLAUDE.md exists (symlink target) |
| 43 | +echo -n "✓ Checking CLAUDE.md exists... " |
| 44 | +if [ ! -f CLAUDE.md ]; then |
| 45 | + echo "FAILED" |
| 46 | + echo "Error: CLAUDE.md (symlink target) does not exist" |
| 47 | + exit 1 |
| 48 | +fi |
| 49 | +echo "OK" |
| 50 | + |
| 51 | +# Test 5: Check that content is readable through symlink |
| 52 | +echo -n "✓ Checking AGENTS.md content is readable... " |
| 53 | +if ! cat AGENTS.md > /dev/null 2>&1; then |
| 54 | + echo "FAILED" |
| 55 | + echo "Error: Cannot read content through AGENTS.md symlink" |
| 56 | + exit 1 |
| 57 | +fi |
| 58 | +echo "OK" |
| 59 | + |
| 60 | +# Test 6: Check that content is identical to CLAUDE.md |
| 61 | +echo -n "✓ Checking AGENTS.md content matches CLAUDE.md... " |
| 62 | +if ! diff -q AGENTS.md CLAUDE.md > /dev/null 2>&1; then |
| 63 | + echo "FAILED" |
| 64 | + echo "Error: AGENTS.md content does not match CLAUDE.md" |
| 65 | + exit 1 |
| 66 | +fi |
| 67 | +echo "OK" |
| 68 | + |
| 69 | +# Test 7: Check that file is tracked by git |
| 70 | +echo -n "✓ Checking AGENTS.md is tracked by git... " |
| 71 | +if ! git ls-files --error-unmatch AGENTS.md > /dev/null 2>&1; then |
| 72 | + echo "WARNING" |
| 73 | + echo "Warning: AGENTS.md is not tracked by git (will be added in commit)" |
| 74 | +else |
| 75 | + echo "OK" |
| 76 | +fi |
| 77 | + |
| 78 | +# Test 8: Validate that symlink contains expected project context |
| 79 | +echo -n "✓ Checking AGENTS.md contains project context... " |
| 80 | +if ! grep -q "Ambient Code Platform" AGENTS.md; then |
| 81 | + echo "FAILED" |
| 82 | + echo "Error: AGENTS.md does not contain expected project context" |
| 83 | + exit 1 |
| 84 | +fi |
| 85 | +echo "OK" |
| 86 | + |
| 87 | +# Test 9: Validate key sections exist |
| 88 | +echo -n "✓ Checking key sections exist... " |
| 89 | +REQUIRED_SECTIONS=( |
| 90 | + "Project Overview" |
| 91 | + "Development Commands" |
| 92 | + "Key Architecture Patterns" |
| 93 | + "Backend and Operator Development Standards" |
| 94 | + "Frontend Development Standards" |
| 95 | +) |
| 96 | + |
| 97 | +for section in "${REQUIRED_SECTIONS[@]}"; do |
| 98 | + if ! grep -q "$section" AGENTS.md; then |
| 99 | + echo "FAILED" |
| 100 | + echo "Error: Section '$section' not found in AGENTS.md" |
| 101 | + exit 1 |
| 102 | + fi |
| 103 | +done |
| 104 | +echo "OK" |
| 105 | + |
| 106 | +# Test 10: Check file size is reasonable (should match CLAUDE.md) |
| 107 | +echo -n "✓ Checking file size is reasonable... " |
| 108 | +SIZE=$(wc -c < AGENTS.md) |
| 109 | +if [ "$SIZE" -lt 1000 ]; then |
| 110 | + echo "FAILED" |
| 111 | + echo "Error: AGENTS.md content is too small ($SIZE bytes), symlink may be broken" |
| 112 | + exit 1 |
| 113 | +fi |
| 114 | +echo "OK (${SIZE} bytes)" |
| 115 | + |
| 116 | +echo "" |
| 117 | +echo "✅ All tests passed! AGENTS.md symlink is working correctly." |
| 118 | +echo " - Symlink: AGENTS.md -> CLAUDE.md" |
| 119 | +echo " - Content size: ${SIZE} bytes" |
| 120 | +echo " - Cursor and other AI tools can use AGENTS.md" |
| 121 | +echo "" |
0 commit comments