Skip to content

Commit 56697f1

Browse files
committed
Add winpty support for Windows pseudo-TTY
Detect and use winpty on Windows (comes with Git for Windows) to create pseudo-TTY for Claude. Falls back to direct execution if winpty not found. This provides cross-platform PTY support for fixing CI failures.
1 parent dcd55d1 commit 56697f1

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

scripts/claude.mjs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,10 +3317,20 @@ Fix all CI failures now by making the necessary changes.`
33173317

33183318
// Use script command to create pseudo-TTY for Ink compatibility
33193319
// Platform-specific script command syntax
3320-
// Windows doesn't have script, fall back to direct command
3321-
const scriptCmd = WIN32
3322-
? claudeCommand
3323-
: `script -q /dev/null ${claudeCommand} < "${tmpFile}"`
3320+
let scriptCmd
3321+
if (WIN32) {
3322+
// Try winpty (comes with Git for Windows)
3323+
const winptyCheck = await runCommandWithOutput('where', ['winpty'])
3324+
if (winptyCheck.exitCode === 0) {
3325+
scriptCmd = `winpty ${claudeCommand} < "${tmpFile}"`
3326+
} else {
3327+
// No winpty, try direct (may fail with raw mode error)
3328+
scriptCmd = `${claudeCommand} < "${tmpFile}"`
3329+
}
3330+
} else {
3331+
// Unix/macOS: use script command
3332+
scriptCmd = `script -q /dev/null ${claudeCommand} < "${tmpFile}"`
3333+
}
33243334

33253335
const exitCode = await new Promise((resolve, _reject) => {
33263336
const child = spawn(scriptCmd, [], {
@@ -3535,10 +3545,20 @@ Fix the failure now by making the necessary changes.`
35353545

35363546
// Use script command to create pseudo-TTY for Ink compatibility
35373547
// Platform-specific script command syntax
3538-
// Windows doesn't have script, fall back to direct command
3539-
const scriptCmd = WIN32
3540-
? claudeCommand
3541-
: `script -q /dev/null ${claudeCommand} < "${tmpFile}"`
3548+
let scriptCmd
3549+
if (WIN32) {
3550+
// Try winpty (comes with Git for Windows)
3551+
const winptyCheck = await runCommandWithOutput('where', ['winpty'])
3552+
if (winptyCheck.exitCode === 0) {
3553+
scriptCmd = `winpty ${claudeCommand} < "${tmpFile}"`
3554+
} else {
3555+
// No winpty, try direct (may fail with raw mode error)
3556+
scriptCmd = `${claudeCommand} < "${tmpFile}"`
3557+
}
3558+
} else {
3559+
// Unix/macOS: use script command
3560+
scriptCmd = `script -q /dev/null ${claudeCommand} < "${tmpFile}"`
3561+
}
35423562

35433563
const exitCode = await new Promise((resolve, _reject) => {
35443564
const child = spawn(scriptCmd, [], {

0 commit comments

Comments
 (0)