verify_skills.py
2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python3
"""VERIFY phase: Skills page smoketest + frontend checks."""
import subprocess, sys
BASE = "http://127.0.0.1:5001"
errors = []
def curl(path):
cmd = ["curl", "-s", f"{BASE}{path}"]
r = subprocess.run(cmd, capture_output=True, text=True, timeout=15)
return r.stdout, r.returncode
def http_code(path):
cmd = ["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}", f"{BASE}{path}"]
r = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
return r.stdout.strip()
# 1. Skills menu entry check
print("=== 1. Skills menu entry ===")
html, _ = curl("/")
if '/skills' in html and 'Skills' in html:
print(" PASS: Skills link in menu")
else:
print(" FAIL: Skills link missing")
errors.append("menu")
# 2. JS/Jinja2 escape checks (simple grep)
print("=== 2. Frontend JS checks ===")
html, _ = curl("/")
# Check for common escape bugs
escaped_quote = chr(92) + chr(92) + chr(92) + '"'
if escaped_quote in html:
print(f" FAIL: triple-escaped quotes found")
errors.append("js-escape")
else:
print(" PASS: JS CLEAN")
# Check for jinja2 literal escaping
jinja_esc = 'data-action=' + chr(92) + '"'
if jinja_esc in html:
print(f" FAIL: jinja2 escaped quotes in template literal")
errors.append("jinja2-escape")
else:
print(" PASS: JINJA2 CLEAN")
# 3. Smoketest - all key pages
print("=== 3. Smoketest ===")
pages = ["/", "/skills", "/skill/feishu-todo-sync", "/articles", "/learn", "/reports", "/chat", "/cron", "/jobs", "/dashboard"]
for p in pages:
code = http_code(p)
if code == "200":
print(f" {code} {p}")
else:
print(f" FAIL {code} {p}")
errors.append(p)
# 4. Skills page content
print("=== 4. Skills page content ===")
html, _ = curl("/skills")
checks = ['skill-name', 'use-count', 'skill-item', 'skill-list', 'SKILL']
found_any = any(c.lower() in html.lower() for c in checks)
if found_any:
# Count skills
count = html.count('skill-name') or html.count('skill-item') or 'N/A'
print(f" PASS: skills list content found (skill-name x{count})")
else:
print(" FAIL: no skill list content")
errors.append("skills-content")
# 5. Skill detail page
print("=== 5. Skill detail page ===")
html, _ = curl("/skill/feishu-todo-sync")
if 'feishu-todo-sync' in html.lower():
print(" PASS: skill detail page shows skill name")
else:
print(" FAIL: skill detail page")
errors.append("skill-detail")
# Summary
if not errors:
print("\n=== ALL VERIFY CHECKS PASSED ===")
sys.exit(0)
else:
print(f"\n=== FAILURES: {', '.join(errors)} ===")
sys.exit(1)