@ppdocs/mcp 3.0.5 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/hooks/hook.py +18 -4
package/package.json
CHANGED
package/templates/hooks/hook.py
CHANGED
|
@@ -11,6 +11,7 @@ from __future__ import print_function, unicode_literals
|
|
|
11
11
|
import io
|
|
12
12
|
import json
|
|
13
13
|
import os
|
|
14
|
+
import re
|
|
14
15
|
import sys
|
|
15
16
|
|
|
16
17
|
# HTTP 库兼容
|
|
@@ -38,6 +39,21 @@ BYPASS = [
|
|
|
38
39
|
"ok", "yes", "hi", "hello", "你好",
|
|
39
40
|
]
|
|
40
41
|
|
|
42
|
+
# 英文绕过词用单词边界匹配,避免 "hooks" 中的 "ok" 误触发
|
|
43
|
+
_EN_BYPASS = [w for w in BYPASS if w.isascii()]
|
|
44
|
+
_CN_BYPASS = [w for w in BYPASS if not w.isascii()]
|
|
45
|
+
_EN_BYPASS_RE = re.compile(r'\b(' + '|'.join(re.escape(w) for w in _EN_BYPASS) + r')\b', re.IGNORECASE) if _EN_BYPASS else None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def is_bypass(text):
|
|
49
|
+
"""检查短输入是否为绕过词 (英文用单词边界,中文用子串)"""
|
|
50
|
+
for w in _CN_BYPASS:
|
|
51
|
+
if w in text:
|
|
52
|
+
return True
|
|
53
|
+
if _EN_BYPASS_RE and _EN_BYPASS_RE.search(text):
|
|
54
|
+
return True
|
|
55
|
+
return False
|
|
56
|
+
|
|
41
57
|
|
|
42
58
|
# ╔══════════════════════════════════════════════════════════════╗
|
|
43
59
|
# ║ API 请求 ║
|
|
@@ -168,10 +184,8 @@ def main():
|
|
|
168
184
|
user_input_lower = user_input.lower()
|
|
169
185
|
|
|
170
186
|
# 短输入包含绕过词 → 跳过
|
|
171
|
-
if len(user_input) <= 15:
|
|
172
|
-
|
|
173
|
-
if word.lower() in user_input_lower:
|
|
174
|
-
return
|
|
187
|
+
if len(user_input) <= 15 and is_bypass(user_input_lower):
|
|
188
|
+
return
|
|
175
189
|
|
|
176
190
|
# 读取配置
|
|
177
191
|
config = load_ppdocs_config()
|