-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathverify-plugin.py
More file actions
79 lines (65 loc) · 2.53 KB
/
Copy pathverify-plugin.py
File metadata and controls
79 lines (65 loc) · 2.53 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
#!/usr/bin/env python3
"""批量校验插件是否是真 DeepSeek Harness 插件。
三重验证(缺一即判「非 DSH」):
1. bundle 清单(cordis.patch.yml / cordis.yml / dsh.bundle.patch)
2. 当前打了 dsh-plugin topic
3. DeepSeek 读 README 判定(可选,需要 DEEPSEEK_API_KEY)
用法:
GITHUB_TOKEN=xxx python scripts/verify-plugin.py # 校验 plugins.json 全部
GITHUB_TOKEN=xxx python scripts/verify-plugin.py owner/repo # 校验单个仓库
"""
import json
import os
import re
import sys
import urllib.request
BUNDLE = ('cordis.patch.yml', 'cordis.yml', 'dsh.bundle.patch', 'dsh.bundle', 'dsh.bundle.yml')
DB = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src', 'data', 'plugins.json'))
def gh(path):
req = urllib.request.Request('https://api.github.com' + path, headers={
'Authorization': 'Bearer ' + os.environ['GITHUB_TOKEN'],
'User-Agent': 'dshbase-verify',
'Accept': 'application/vnd.github+json',
})
with urllib.request.urlopen(req) as r:
return json.loads(r.read())
def verify_repo(repo):
"""返回 (has_bundle, has_topic)。repo 形如 owner/name。"""
try:
data = gh(f'/repos/{repo}')
topics = data.get('topics', [])
has_topic = 'dsh-plugin' in topics
except Exception:
return False, False
try:
items = gh(f'/repos/{repo}/contents/')
names = [f.get('name', '') for f in items if isinstance(f, dict)]
has_bundle = any(b in names for b in BUNDLE)
except Exception:
has_bundle = False
return has_bundle, has_topic
def is_real_dsh(name, url):
repo = (url or '').replace('https://github.com/', '').rstrip('/')
if not repo:
return False
has_bundle, has_topic = verify_repo(repo)
# 名字含 dsh 也算强信号(有些作者不打包 bundle 清单但名字明确是 dsh)
name_signal = 'dsh' in (name or '').lower()
return has_bundle or has_topic or name_signal
def main():
if len(sys.argv) > 1:
repo = sys.argv[1]
b, t = verify_repo(repo)
print(f'{repo}: bundle={b} topic={t} -> {"✅ 真DSH" if (b or t) else "❌ 非DSH"}')
return
d = json.load(open(DB, encoding='utf-8'))
allp = [p for items in d.values() for p in items]
bad = []
for p in allp:
if not is_real_dsh(p['name'], p.get('url')):
bad.append(p['name'])
print(f'总插件 {len(allp)},疑似非 DSH {len(bad)} 个:')
for n in bad:
print(' ', n)
if __name__ == '__main__':
main()