From 0f4a59fdfcae26b15c3dd70254eb9f4ce0cff605 Mon Sep 17 00:00:00 2001 From: Panniantong Date: Wed, 25 Feb 2026 02:41:14 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20Windows=20=E6=8E=A7=E5=88=B6=E5=8F=B0=20?= =?UTF-8?q?emoji=20=E7=BC=96=E7=A0=81=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows 默认控制台编码是 cp936(中文)或 cp1252(西文), print() 输出 emoji 字符时直接 UnicodeEncodeError 崩溃。 在 cli.py 入口处添加 UTF-8 encoding wrapper, 用 errors='replace' 确保不会因为编码问题导致整个程序崩溃。 --- agent_reach/cli.py | 8 ++++++++ config/mcporter.json | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 config/mcporter.json diff --git a/agent_reach/cli.py b/agent_reach/cli.py index 5598815..d94d411 100644 --- a/agent_reach/cli.py +++ b/agent_reach/cli.py @@ -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__ diff --git a/config/mcporter.json b/config/mcporter.json new file mode 100644 index 0000000..82a7b98 --- /dev/null +++ b/config/mcporter.json @@ -0,0 +1,11 @@ +{ + "mcpServers": { + "exa": { + "baseUrl": "https://mcp.exa.ai/mcp" + }, + "xiaohongshu": { + "baseUrl": "http://localhost:18060/mcp" + } + }, + "imports": [] +}