fix(run_command): decode subprocess output as UTF-8 on Windows

GBK default decoding failed on curl/wttr.in UTF-8 output, leaving stdout empty
with exit 0; use utf-8 + replace.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-10 12:08:42 +08:00
parent 95dfa7020a
commit 75a3038f33

View file

@ -108,11 +108,15 @@ class LocalAdapter:
# It only uses explicit cwd; otherwise defaults to data/workspace.
workdir = str(resolve_workspace_path(cwd or "data/workspace"))
Path(workdir).mkdir(parents=True, exist_ok=True)
# Use UTF-8 for decoded streams: Windows defaults (e.g. GBK) break on UTF-8-only bytes from
# curl/wttr.in, git, ripgrep, etc.; subprocess may leave stdout None after UnicodeDecodeError.
run_kwargs: dict[str, Any] = {
"cwd": workdir,
"shell": True,
"capture_output": True,
"text": True,
"encoding": "utf-8",
"errors": "replace",
"timeout": float(timeout_s),
}
if os.name == "nt":