@@ -957,6 +957,12 @@ function prepareClaudeArgs(args = [], options = {}) {
957957 _opts . _selectedMode = mode
958958 _opts . _selectedModel = model
959959
960+ // Add --dangerously-skip-permissions unless --no-darkwing is specified
961+ // "Let's get dangerous!" mode for automated CI fixes
962+ if ( ! _opts [ 'no-darkwing' ] ) {
963+ claudeArgs . push ( '--dangerously-skip-permissions' )
964+ }
965+
960966 return claudeArgs
961967}
962968
@@ -3185,6 +3191,13 @@ Let's work through this together to get CI passing.`
31853191
31863192 log . substep ( `Workflow "${ run . name } " status: ${ run . status } ` )
31873193
3194+ // If workflow is queued, just wait for it to start
3195+ if ( run . status === 'queued' || run . status === 'waiting' ) {
3196+ log . substep ( 'Waiting for workflow to start...' )
3197+ await new Promise ( resolve => setTimeout ( resolve , 30_000 ) )
3198+ continue
3199+ }
3200+
31883201 if ( run . status === 'completed' ) {
31893202 if ( run . conclusion === 'success' ) {
31903203 log . done ( 'CI workflow passed! 🎉' )
@@ -3313,7 +3326,10 @@ Fix all CI failures now by making the necessary changes.`
33133326 await fs . writeFile ( tmpFile , fixPrompt , 'utf8' )
33143327
33153328 const fixArgs = prepareClaudeArgs ( [ ] , opts )
3316- const claudeCommand = `${ claudeCmd } ${ fixArgs . join ( ' ' ) } `
3329+ const claudeArgs = fixArgs . join ( ' ' )
3330+ const claudeCommand = claudeArgs
3331+ ? `${ claudeCmd } ${ claudeArgs } `
3332+ : claudeCmd
33173333
33183334 // Use script command to create pseudo-TTY for Ink compatibility
33193335 // Platform-specific script command syntax
@@ -3328,8 +3344,8 @@ Fix all CI failures now by making the necessary changes.`
33283344 scriptCmd = `${ claudeCommand } < "${ tmpFile } "`
33293345 }
33303346 } else {
3331- // Unix/macOS: use script command
3332- scriptCmd = `script -q /dev/null ${ claudeCommand } < "${ tmpFile } "`
3347+ // Unix/macOS: use script command with quoted command
3348+ scriptCmd = `script -q /dev/null sh -c ' ${ claudeCommand } < "${ tmpFile } "' `
33333349 }
33343350
33353351 const exitCode = await new Promise ( ( resolve , _reject ) => {
@@ -3470,17 +3486,18 @@ Fix all CI failures now by making the necessary changes.`
34703486 for ( const job of newFailures ) {
34713487 log . substep ( `❌ ${ job . name } : ${ job . conclusion } ` )
34723488
3473- // Fetch logs for this specific failed job
3489+ // Fetch logs for this specific failed job using job ID
34743490 log . progress ( `Fetching logs for ${ job . name } ` )
34753491 const logsResult = await runCommandWithOutput (
34763492 'gh' ,
34773493 [
34783494 'run' ,
34793495 'view' ,
3480- lastRunId . toString ( ) ,
3496+ '--job' ,
3497+ job . databaseId . toString ( ) ,
34813498 '--repo' ,
34823499 `${ owner } /${ repo } ` ,
3483- '--log-failed ' ,
3500+ '--log' ,
34843501 ] ,
34853502 {
34863503 cwd : rootPath ,
@@ -3541,7 +3558,10 @@ Fix the failure now by making the necessary changes.`
35413558 await fs . writeFile ( tmpFile , fixPrompt , 'utf8' )
35423559
35433560 const fixArgs = prepareClaudeArgs ( [ ] , opts )
3544- const claudeCommand = `${ claudeCmd } ${ fixArgs . join ( ' ' ) } `
3561+ const claudeArgs = fixArgs . join ( ' ' )
3562+ const claudeCommand = claudeArgs
3563+ ? `${ claudeCmd } ${ claudeArgs } `
3564+ : claudeCmd
35453565
35463566 // Use script command to create pseudo-TTY for Ink compatibility
35473567 // Platform-specific script command syntax
@@ -3556,8 +3576,8 @@ Fix the failure now by making the necessary changes.`
35563576 scriptCmd = `${ claudeCommand } < "${ tmpFile } "`
35573577 }
35583578 } else {
3559- // Unix/macOS: use script command
3560- scriptCmd = `script -q /dev/null ${ claudeCommand } < "${ tmpFile } "`
3579+ // Unix/macOS: use script command with quoted command
3580+ scriptCmd = `script -q /dev/null sh -c ' ${ claudeCommand } < "${ tmpFile } "' `
35613581 }
35623582
35633583 const exitCode = await new Promise ( ( resolve , _reject ) => {
@@ -4097,7 +4117,6 @@ async function main() {
40974117 process . exitCode = 1
40984118 return
40994119 }
4100- log . done ( `Found Claude Code CLI: ${ claudeCmd } ` )
41014120
41024121 // Ensure Claude is authenticated
41034122 const isClaudeAuthenticated = await ensureClaudeAuthenticated ( claudeCmd )
0 commit comments