Skip to content

fix(cli): switch Windows console to UTF-8 on startup - #236

Open
savvadesogle wants to merge 1 commit into
AtomicBot-ai:mainfrom
savvadesogle:fix/windows-console-utf8
Open

fix(cli): switch Windows console to UTF-8 on startup#236
savvadesogle wants to merge 1 commit into
AtomicBot-ai:mainfrom
savvadesogle:fix/windows-console-utf8

Conversation

@savvadesogle

Copy link
Copy Markdown

Summary

On Windows, switch the console code page to UTF-8 (65001) at CLI startup so Cyrillic (and other non-ASCII) input, output and copy/paste no longer turn into mojibake.

Motivation

The Windows console defaults to the CP866 OEM code page, while Node and atomic-agent emit/consume UTF-8. The mismatch corrupts Russian text in three places at once:

  • Input — what the user types is misread by readline;
  • Output — what the agent prints (reply/status lines) displays garbled;
  • Copy/paste — text copied from the terminal is pasted as mojibake (╨Я╤А╨╕╨▓╨╡╤В for "Привет").

Changes

  • src/cli/index.ts — add ensureUtf8Console(), called at the top of main(). On Windows only it runs chcp 65001 >nul (via execSync) and swallows failures (some hosts disallow changing the code page).

Design constraint honored here: the fix does not touch process.stdout / process.stderr. An earlier attempt that overrode write to emit raw UTF-8 bytes broke the interactive TUI (ink/readline frame rendering) — output lines "jumped" and the screen corrupted. Changing only the console code page fixes all three symptoms while leaving the stream mechanics untouched.

Verification

  • npm run lint — clean.
  • npm test — full suite: 20 failed / 5939 passed, identical to the pre-existing main baseline (same 20 environment-specific Windows failures; none introduced by this change).
  • Manual (Windows): after launch chcp reports 65001; Russian input, output and copy/paste are correct.

Notes

  • Orthogonal to the --use-env-proxy flag (documented separately); this change affects only the console code page.
  • The execSync is wrapped in try/catch because chcp can fail on hosts that forbid changing the code page (non-interactive sessions, some terminals).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant