Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { isSea } from "node:sea";
import { argv, exit } from "node:process";
import { runAgentCommand } from "./run-agent.js";
Expand Down Expand Up @@ -159,7 +160,24 @@ function userArgsFromArgv(): string[] {
return argv.slice(2);
}

/**
* Windows console defaults to CP866 for Cyrillic, which makes Russian input,
* output and copy/paste turn into mojibake because Node speaks UTF-8. Switch
* the console code page to UTF-8 (65001) at startup. This only changes the
* console's code page тАФ it does NOT touch stdout/stderr streams, so ink and
* readline rendering are unaffected.
*/
function ensureUtf8Console(): void {
if (process.platform !== "win32") return;
try {
execSync("chcp 65001 >nul", { stdio: "ignore" });
} catch {
// Non-fatal: some hosts disallow changing the code page.
}
}

async function main(): Promise<number> {
ensureUtf8Console();
const [command, ...rest] = userArgsFromArgv();
if (command === "-h" || command === "--help") {
printHelp();
Expand Down