fix: Windows 控制台 emoji 编码崩溃
Windows 默认控制台编码是 cp936(中文)或 cp1252(西文), print() 输出 emoji 字符时直接 UnicodeEncodeError 崩溃。 在 cli.py 入口处添加 UTF-8 encoding wrapper, 用 errors='replace' 确保不会因为编码问题导致整个程序崩溃。
This commit is contained in:
parent
a860873237
commit
0f4a59fdfc
2 changed files with 19 additions and 0 deletions
|
|
@ -19,6 +19,14 @@ import argparse
|
|||
import json
|
||||
import os
|
||||
|
||||
# Fix Windows console encoding — emoji/CJK characters crash on cp936/cp1252
|
||||
if sys.platform == 'win32':
|
||||
import io
|
||||
if hasattr(sys.stdout, 'buffer'):
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
||||
if hasattr(sys.stderr, 'buffer'):
|
||||
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
||||
|
||||
from agent_reach import __version__
|
||||
|
||||
|
||||
|
|
|
|||
11
config/mcporter.json
Normal file
11
config/mcporter.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"mcpServers": {
|
||||
"exa": {
|
||||
"baseUrl": "https://mcp.exa.ai/mcp"
|
||||
},
|
||||
"xiaohongshu": {
|
||||
"baseUrl": "http://localhost:18060/mcp"
|
||||
}
|
||||
},
|
||||
"imports": []
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue