@@ -4,6 +4,7 @@ import fs from "node:fs/promises";
44import path from "node:path" ;
55import type { ServerResponse } from "node:http" ;
66import type { OperationDispatcher , OperationRequestContext } from "../operation-dispatcher.js" ;
7+ import { getShellPath } from "../shell-path.js" ;
78import { DirectoryNotAllowedError } from "../security.js" ;
89import { ENGINEER_CHAT_TOOLS , withMcpTools } from "./chat-tools.js" ;
910import { loadJsonFile , saveJsonFile } from "./chat-history-store.js" ;
@@ -1158,7 +1159,7 @@ export function registerCodexRoutes(
11581159 stdio : [ "pipe" , "pipe" , "pipe" ] ,
11591160 env : {
11601161 ...process . env ,
1161- PATH : ` ${ process . env . PATH } :/opt/homebrew/bin:/usr/local/bin`
1162+ PATH : await getShellPath ( )
11621163 }
11631164 } ) ;
11641165
@@ -1549,7 +1550,8 @@ function similarityScore(messageA: string, messageB: string, fileA: string, file
15491550 return Math . min ( score , 1 ) ;
15501551}
15511552
1552- function spawnClaudeReview ( cwd : string , model : string ) : ChildProcess {
1553+ async function spawnClaudeReview ( cwd : string , model : string ) : Promise < ChildProcess > {
1554+ const shellPath = await getShellPath ( ) ;
15531555 return spawn (
15541556 "claude" ,
15551557 [
@@ -1570,7 +1572,7 @@ function spawnClaudeReview(cwd: string, model: string): ChildProcess {
15701572 stdio : [ "pipe" , "pipe" , "pipe" ] ,
15711573 env : {
15721574 ...process . env ,
1573- PATH : ` ${ process . env . PATH } :/opt/homebrew/bin:/usr/local/bin`
1575+ PATH : shellPath
15741576 }
15751577 }
15761578 ) ;
@@ -1587,7 +1589,7 @@ async function resolveClaudeReviewProcess(
15871589 prNum : string ,
15881590 logPath : string
15891591) : Promise < ChildProcess > {
1590- const first = spawnClaudeReview ( cwd , model ) ;
1592+ const first = await spawnClaudeReview ( cwd , model ) ;
15911593 first . stdin ?. write ( "/code-review:start" ) ;
15921594 first . stdin ?. end ( ) ;
15931595
@@ -1659,7 +1661,7 @@ async function resolveClaudeReviewProcess(
16591661 // Skill exited without producing review content — fall back to /review <prNum>
16601662 await fs . writeFile ( logPath , "" , "utf-8" ) ;
16611663
1662- const fallback = spawnClaudeReview ( cwd , model ) ;
1664+ const fallback = await spawnClaudeReview ( cwd , model ) ;
16631665 fallback . stdin ?. write ( `/review ${ prNum } ` ) ;
16641666 fallback . stdin ?. end ( ) ;
16651667 return fallback ;
@@ -2085,12 +2087,13 @@ async function waitForExit(child: ChildProcess): Promise<number> {
20852087}
20862088
20872089async function runCommand ( command : string , args : string [ ] ) : Promise < string > {
2090+ const shellPath = await getShellPath ( ) ;
20882091 return await new Promise ( ( resolve , reject ) => {
20892092 const child = spawn ( command , args , {
20902093 stdio : [ "ignore" , "pipe" , "pipe" ] ,
20912094 env : {
20922095 ...process . env ,
2093- PATH : ` ${ process . env . PATH } :/opt/homebrew/bin:/usr/local/bin`
2096+ PATH : shellPath
20942097 }
20952098 } ) ;
20962099
@@ -2369,11 +2372,12 @@ function runCodexVerdict(worktreeDir: string, sessionId: string): Promise<string
23692372 ) ;
23702373}
23712374
2372- function runClaudeVerdict ( worktreeDir : string , sessionId : string ) : Promise < string > {
2375+ async function runClaudeVerdict ( worktreeDir : string , sessionId : string ) : Promise < string > {
2376+ const shellPath = await getShellPath ( ) ;
23732377 return runVerdictProcess (
23742378 "claude" ,
23752379 [ "-p" , "--resume" , sessionId , "--output-format" , "stream-json" , "--model" , "sonnet" , "--allowedTools" , "Read,Glob,Grep" ] ,
2376- { cwd : worktreeDir , stdin : VERDICT_PROMPT , env : { PATH : ` ${ process . env . PATH } :/opt/homebrew/bin:/usr/local/bin` } } ,
2380+ { cwd : worktreeDir , stdin : VERDICT_PROMPT , env : { PATH : shellPath } } ,
23772381 extractClaudeVerdictLine
23782382 ) ;
23792383}
0 commit comments