@@ -8,9 +8,11 @@ import { spawn } from 'node:child_process'
88import { existsSync , promises as fs } from 'node:fs'
99import path from 'node:path'
1010import { fileURLToPath } from 'node:url'
11- import { parseArgs } from '@socketsecurity/lib/argv/parse'
11+
1212import colors from 'yoctocolors-cjs'
1313
14+ import { parseArgs } from '@socketsecurity/lib/argv/parse'
15+
1416const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
1517const rootPath = path . join ( __dirname , '..' )
1618const parentPath = path . join ( rootPath , '..' )
@@ -3306,15 +3308,22 @@ Fix all CI failures now by making the necessary changes.`
33063308 } , 10_000 )
33073309
33083310 try {
3309- // Write prompt to temp file to avoid stdin raw mode issues
3311+ // Write prompt to temp file
33103312 const tmpFile = path . join ( rootPath , `.claude-fix-${ Date . now ( ) } .txt` )
33113313 await fs . writeFile ( tmpFile , fixPrompt , 'utf8' )
33123314
33133315 const fixArgs = prepareClaudeArgs ( [ ] , opts )
3314- // Use shell input redirection to pass prompt without stdin pipe
3315- 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+
33163325 const exitCode = await new Promise ( ( resolve , _reject ) => {
3317- const child = spawn ( shellCmd , [ ] , {
3326+ const child = spawn ( scriptCmd , [ ] , {
33183327 stdio : 'inherit' ,
33193328 cwd : rootPath ,
33203329 shell : true ,
@@ -3438,8 +3447,7 @@ Fix all CI failures now by making the necessary changes.`
34383447
34393448 // Check for any failed or cancelled jobs
34403449 const failedJobs = jobs . filter (
3441- job =>
3442- job . conclusion === 'failure' || job . conclusion === 'cancelled' ,
3450+ job => job . conclusion === 'failure' || job . conclusion === 'cancelled'
34433451 )
34443452
34453453 // Find new failures we haven't fixed yet
@@ -3518,18 +3526,22 @@ Fix the failure now by making the necessary changes.`
35183526 } , 10_000 )
35193527
35203528 try {
3521- // Write prompt to temp file to avoid stdin raw mode issues
3522- const tmpFile = path . join (
3523- rootPath ,
3524- `.claude-fix-${ Date . now ( ) } .txt` ,
3525- )
3529+ // Write prompt to temp file
3530+ const tmpFile = path . join ( rootPath , `.claude-fix-${ Date . now ( ) } .txt` )
35263531 await fs . writeFile ( tmpFile , fixPrompt , 'utf8' )
35273532
35283533 const fixArgs = prepareClaudeArgs ( [ ] , opts )
3529- // Use shell input redirection to pass prompt without stdin pipe
3530- 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+
35313543 const exitCode = await new Promise ( ( resolve , _reject ) => {
3532- const child = spawn ( shellCmd , [ ] , {
3544+ const child = spawn ( scriptCmd , [ ] , {
35333545 stdio : 'inherit' ,
35343546 cwd : rootPath ,
35353547 shell : true ,
@@ -3614,9 +3626,7 @@ Fix the failure now by making the necessary changes.`
36143626
36153627 // Show current status
36163628 if ( fixedJobs . size > 0 ) {
3617- log . substep (
3618- `Fixed ${ fixedJobs . size } job(s) so far (commits pending push)` ,
3619- )
3629+ log . substep ( `Fixed ${ fixedJobs . size } job(s) so far (commits pending push)` )
36203630 }
36213631 } catch ( e ) {
36223632 log . warn ( `Failed to parse job data: ${ e . message } ` )
0 commit comments