Skip to content

Commit dcd55d1

Browse files
committed
Use script command to create pseudo-TTY for Claude fixes
Replace shell redirection with script command wrapper to create a proper pseudo-TTY. This prevents Ink raw mode errors while still allowing Claude to use file editing tools when fixing CI failures.
1 parent a20d784 commit dcd55d1

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

scripts/claude.mjs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,15 +3308,22 @@ Fix all CI failures now by making the necessary changes.`
33083308
}, 10_000)
33093309

33103310
try {
3311-
// Write prompt to temp file to avoid stdin raw mode issues
3311+
// Write prompt to temp file
33123312
const tmpFile = path.join(rootPath, `.claude-fix-${Date.now()}.txt`)
33133313
await fs.writeFile(tmpFile, fixPrompt, 'utf8')
33143314

33153315
const fixArgs = prepareClaudeArgs([], opts)
3316-
// Use shell input redirection to pass prompt without stdin pipe
3317-
const shellCmd = `${claudeCmd} ${fixArgs.join(' ')} < "${tmpFile}"`
3316+
const claudeCommand = `${claudeCmd} ${fixArgs.join(' ')}`
3317+
3318+
// Use script command to create pseudo-TTY for Ink compatibility
3319+
// 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}"`
3324+
33183325
const exitCode = await new Promise((resolve, _reject) => {
3319-
const child = spawn(shellCmd, [], {
3326+
const child = spawn(scriptCmd, [], {
33203327
stdio: 'inherit',
33213328
cwd: rootPath,
33223329
shell: true,
@@ -3519,15 +3526,22 @@ Fix the failure now by making the necessary changes.`
35193526
}, 10_000)
35203527

35213528
try {
3522-
// Write prompt to temp file to avoid stdin raw mode issues
3529+
// Write prompt to temp file
35233530
const tmpFile = path.join(rootPath, `.claude-fix-${Date.now()}.txt`)
35243531
await fs.writeFile(tmpFile, fixPrompt, 'utf8')
35253532

35263533
const fixArgs = prepareClaudeArgs([], opts)
3527-
// Use shell input redirection to pass prompt without stdin pipe
3528-
const shellCmd = `${claudeCmd} ${fixArgs.join(' ')} < "${tmpFile}"`
3534+
const claudeCommand = `${claudeCmd} ${fixArgs.join(' ')}`
3535+
3536+
// Use script command to create pseudo-TTY for Ink compatibility
3537+
// 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}"`
3542+
35293543
const exitCode = await new Promise((resolve, _reject) => {
3530-
const child = spawn(shellCmd, [], {
3544+
const child = spawn(scriptCmd, [], {
35313545
stdio: 'inherit',
35323546
cwd: rootPath,
35333547
shell: true,

0 commit comments

Comments
 (0)