Skip to content

Commit 77ca23c

Browse files
committed
fix(continuous-learning-v2): reconfigure stdout to UTF-8 on Windows
`instinct-cli.py status` prints a confidence bar using the box-drawing characters █ and ░. On Windows the default console codec is cp1250 / cp1252, and Python's stdout inherits it, so the print statement crashes with: UnicodeEncodeError: 'charmap' codec can't encode characters in position 4-13: character maps to <undefined> This affects any Windows user whose console is not manually set to `chcp 65001`, even after #353 (file I/O UTF-8) and #216 (.md glob) — those fixes cover reading instinct files, but the crash happens on the *output* side when rendering the status table. Fix: reconfigure `sys.stdout` / `sys.stderr` to UTF-8 at startup, guarded by `sys.platform == "win32"`. The reconfigure call is wrapped in `try/except` because a caller may pipe into something that doesn't support reconfigure (e.g., a captured buffer in tests). No-op on Linux/macOS. Verified locally on Windows 11 / Python 3.14 / cp1250 console: `instinct-cli.py status` now prints all 155 instincts from `~/.claude/homunculus/instincts/` without crashing.
1 parent 9d766af commit 77ca23c

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

skills/continuous-learning-v2/scripts/instinct-cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@
2828
from collections import defaultdict
2929
from typing import Optional
3030

31+
# Force UTF-8 stdout/stderr on Windows so the confidence bar (█░) and any
32+
# non-ASCII instinct metadata don't crash `status` under cp1250/cp1252.
33+
# No-op on Linux/macOS, where stdout is already UTF-8 by default.
34+
if sys.platform == "win32":
35+
try:
36+
sys.stdout.reconfigure(encoding="utf-8")
37+
sys.stderr.reconfigure(encoding="utf-8")
38+
except Exception:
39+
pass
40+
3141
try:
3242
import fcntl
3343
_HAS_FCNTL = True

0 commit comments

Comments
 (0)