@@ -1951,13 +1951,35 @@ program
19511951 emitCliProxyStatusLogs ( config , logger . info . bind ( logger ) , logger . warn . bind ( logger ) ) ;
19521952
19531953 // Warn if a classic PAT is combined with COPILOT_MODEL (Copilot CLI 1.0.21+ incompatibility)
1954- // Check if COPILOT_MODEL is set via --env/-e flags or host env (when --env-all is active)
1955- const copilotModelFromFlags = Object . prototype . hasOwnProperty . call ( additionalEnv , 'COPILOT_MODEL' ) ;
1956- const copilotModelInHostEnv =
1957- config . envAll && Object . prototype . hasOwnProperty . call ( process . env , 'COPILOT_MODEL' ) ;
1954+ const hasCopilotModelInEnvFiles = ( envFile : unknown ) : boolean => {
1955+ const envFiles = Array . isArray ( envFile ) ? envFile : envFile ? [ envFile ] : [ ] ;
1956+ for ( const candidate of envFiles ) {
1957+ if ( typeof candidate !== 'string' || candidate . trim ( ) === '' ) continue ;
1958+ try {
1959+ const envFilePath = path . isAbsolute ( candidate ) ? candidate : path . resolve ( process . cwd ( ) , candidate ) ;
1960+ const envFileContents = fs . readFileSync ( envFilePath , 'utf8' ) ;
1961+ for ( const line of envFileContents . split ( / \r ? \n / ) ) {
1962+ const trimmedLine = line . trim ( ) ;
1963+ if ( ! trimmedLine || trimmedLine . startsWith ( '#' ) ) continue ;
1964+ if ( / ^ (?: e x p o r t \s + ) ? C O P I L O T _ M O D E L \s * = / . test ( trimmedLine ) ) {
1965+ return true ;
1966+ }
1967+ }
1968+ } catch {
1969+ // Ignore unreadable env files here; this check is only for a pre-flight warning.
1970+ }
1971+ }
1972+ return false ;
1973+ } ;
1974+
1975+ // Warn if a classic PAT is combined with COPILOT_MODEL (Copilot CLI 1.0.21+ incompatibility)
1976+ // Check if COPILOT_MODEL is set via --env/-e flags, host env (when --env-all is active), or --env-file
1977+ const copilotModelFromFlags = ! ! ( additionalEnv [ 'COPILOT_MODEL' ] ) ;
1978+ const copilotModelInHostEnv = ! ! ( config . envAll && process . env . COPILOT_MODEL ) ;
1979+ const copilotModelInEnvFile = hasCopilotModelInEnvFiles ( ( config as { envFile ?: unknown } ) . envFile ) ;
19581980 warnClassicPATWithCopilotModel (
19591981 config . copilotGithubToken ?. startsWith ( 'ghp_' ) ?? false ,
1960- copilotModelFromFlags || copilotModelInHostEnv ,
1982+ copilotModelFromFlags || copilotModelInHostEnv || copilotModelInEnvFile ,
19611983 logger . warn . bind ( logger )
19621984 ) ;
19631985
0 commit comments