Extract global rules into markdown file

This commit is contained in:
2026-06-02 00:53:16 +07:00
parent eb5af7c62c
commit 3f9fe30cf0
4 changed files with 101 additions and 95 deletions

View File

@@ -5,6 +5,7 @@
set -euo pipefail
SCRIPT="$(cd "$(dirname "$0")/.." && pwd)/ai-setup.sh"
GLOBAL_RULES_SOURCE="$(cd "$(dirname "$0")/.." && pwd)/GLOBAL_RULES.md"
PASS=0; FAIL=0
ok() { echo "[PASS] $1"; PASS=$((PASS+1)); }
@@ -75,16 +76,18 @@ test_gemini_native_launcher() {
# ── global rules: Karpathy-style guidelines and native rule files ───────────
test_global_rules_include_quality_guidelines() {
karpathy_line=$(grep -n '^## 1\. Think Before Coding$' "$SCRIPT" | head -1 | cut -d: -f1)
global_line=$(grep -n '^# Global Rules for All AI Agents$' "$SCRIPT" | head -1 | cut -d: -f1)
karpathy_line=$(grep -n '^## 1\. Think Before Coding$' "$GLOBAL_RULES_SOURCE" | head -1 | cut -d: -f1)
global_line=$(grep -n '^# Global Rules for All AI Agents$' "$GLOBAL_RULES_SOURCE" | head -1 | cut -d: -f1)
if [ -n "$karpathy_line" ] \
&& [ -n "$global_line" ] \
&& [ "$karpathy_line" -lt "$global_line" ] \
&& grep -q 'Always reply in Russian' "$SCRIPT" \
&& grep -q 'Plain git diff visibility' "$SCRIPT"; then
ok "global rules: include English Karpathy guidelines before translated user rules"
&& grep -q 'Always reply in Russian' "$GLOBAL_RULES_SOURCE" \
&& grep -q 'Plain git diff visibility' "$GLOBAL_RULES_SOURCE" \
&& grep -q 'GLOBAL_RULES_SOURCE=' "$SCRIPT" \
&& grep -q 'cp "$GLOBAL_RULES_SOURCE" "$CONFIG_DIR/global_rules.md"' "$SCRIPT"; then
ok "global rules: source file includes English Karpathy guidelines before translated user rules"
else
fail "global rules: missing English Karpathy guidelines or translated user rules"
fail "global rules: missing source file, English Karpathy guidelines, or translated user rules"
fi
}