INNER CODE UNIT · Python
main
simonlin1212/Vibe-Research · backtest/cli.py:157
def main() -> None:
# 🔴 **必须在打任何 JSON 之前**:中文 Windows 的管道默认 GBK,
# 含 \xa0 会当场崩、其余中文会变成 Node 按 UTF-8 读不懂的字节(上游 issue #27)。
force_utf8_stdio()
raw = sys.stdin.read()
try:
req: dict[str, Any] = json.loads(raw or "{}")
except json.JSONDecodeError as exc:
print(json.dumps({"ok": False, "error": f"入参不是合法 JSON:{exc}"}, ensure_ascii=False))
return
if not isinstance(req, dict):
print(json.dumps({"ok": False, "error": "入参必须是 JSON 对象"}, ensure_ascii=False))
return
if req.get("action") == "catalog":
print(json.dumps({"ok": True, "catalog": _catalog()}, ensure_ascii=False))
return