Skip to content

Commit 5e2dfa4

Browse files
committed
Add anti-AI style guard for fractovision
1 parent ea2b02a commit 5e2dfa4

3 files changed

Lines changed: 91 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"scripts": {
66
"setup": "python3 scripts/setup.py",
77
"doctor": "python3 scripts/doctor.py",
8+
"style-guard": "python3 scripts/anti_ai_style_guard.py",
89
"smoke": "python3 scripts/smoke.py",
9-
"check:syntax": "python3 -m py_compile scripts/setup.py scripts/doctor.py scripts/smoke.py",
10+
"check:syntax": "python3 -m py_compile scripts/setup.py scripts/doctor.py scripts/smoke.py scripts/anti_ai_style_guard.py",
1011
"test": "python3 -m pytest tests/test_one_click_open_box.py -q"
1112
}
1213
}

scripts/anti_ai_style_guard.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env python3
2+
"""Anti-AI style/static quality guard for Fractovision.
3+
4+
Focus: artifact naming/style risk, overly synthetic language markers,
5+
and aggressive visual/branding defaults that often indicate template-heavy slop.
6+
"""
7+
from __future__ import annotations
8+
9+
import re
10+
from pathlib import Path
11+
from typing import Any, Dict
12+
13+
ROOT = Path(__file__).resolve().parents[1]
14+
15+
RULES = [
16+
{
17+
"name": "文本 emoji 过密(可能偏机器默认语体)",
18+
"pattern": re.compile(r"[\U0001F300-\U0001FAFF\u2600-\u27BF]"),
19+
"limit": 30,
20+
},
21+
{
22+
"name": "过多动效/幻觉模板符号(CSS/JS 滥用迹象)",
23+
"pattern": re.compile(r"linear-gradient\(|radial-gradient\(|box-shadow|filter:\s*blur\(|backdrop-filter", re.IGNORECASE),
24+
"limit": 40,
25+
},
26+
{
27+
"name": "过量全大写词(口号化倾向)",
28+
"pattern": re.compile(r"\b[A-Z]{5,}\b"),
29+
"limit": 26,
30+
},
31+
]
32+
33+
TARGET_EXTENSIONS = {".md", ".txt", ".py", ".json", ".yml", ".yaml", ".js", ".ts", ".tsx", ".css", ".html", ".mdx"}
34+
35+
36+
37+
def collect_style_guard_report(root: Path | None = None) -> Dict[str, Any]:
38+
root = root or ROOT
39+
checks = []
40+
41+
for rule in RULES:
42+
total = 0
43+
samples = []
44+
for p in root.rglob('*'):
45+
if not p.is_file() or '.git' in p.parts or p.name == 'anti_ai_style_guard.py':
46+
continue
47+
if p.suffix.lower() not in TARGET_EXTENSIONS:
48+
continue
49+
try:
50+
text = p.read_text(encoding='utf-8', errors='ignore')
51+
except Exception:
52+
continue
53+
hits = rule['pattern'].findall(text)
54+
if hits:
55+
total += len(hits)
56+
if len(samples) < 2:
57+
samples.append(str(p.relative_to(root)))
58+
59+
checks.append(
60+
{
61+
"name": rule['name'],
62+
"ok": total <= rule['limit'],
63+
"count": total,
64+
"limit": rule['limit'],
65+
"sample_files": samples,
66+
"fix": "降低模板化视觉指纹,结合 kill-ai-slop 风格清洗策略重新组织配色与动效节奏",
67+
}
68+
)
69+
70+
anti_doc = root / 'references' / 'content-guidelines.md'
71+
checks.append(
72+
{
73+
"name": "反AI风格执行文档",
74+
"ok": anti_doc.exists(),
75+
"fix": "补齐反AI风格文档(content-guidelines)并绑定 doctor 闭环",
76+
"sample_files": [str(anti_doc.relative_to(root))] if anti_doc.exists() else [],
77+
}
78+
)
79+
80+
return {
81+
"checks": checks,
82+
"passed": all(c['ok'] for c in checks),
83+
}

scripts/doctor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Human-readable environment doctor for one-click users."""
33
from __future__ import annotations
44
import json, shutil, subprocess, sys
5+
from anti_ai_style_guard import collect_style_guard_report
56
from pathlib import Path
67

78
ROOT = Path(__file__).resolve().parents[1]
@@ -32,6 +33,11 @@ def main() -> int:
3233
ok &= check(f'npm script {script}', script in scripts, f'在 package.json scripts 中补充 {script}')
3334
else:
3435
print('[INFO] package.json absent; shell/python one-click path is primary')
36+
slop = collect_style_guard_report(ROOT)
37+
for item in slop.get('checks', []):
38+
if not item.get('ok', False):
39+
print(f"[WARN] {item.get('name')}{item.get('fix', '')}")
40+
3541
gate = ROOT/'scripts/product_convergence_gate.py'
3642
if gate.exists():
3743
try:

0 commit comments

Comments
 (0)